/* This procedure opens and reads ACE MAG FFT data from a level 1 HDF file. Data records are read into a structure. This procedure was modified from its original source to be called from a Fortran main routine and pass back the data set contents as a structure array. Original source: MAG_FFT_RD.C - ACE Science Center Modifications: port to VMS platform - Sandy Kramer, NASA/GSFC 10/21/97 incorporate ASC updates - SBK 12/11/98 */ #include #include #include "mag_fft.h" #include "df.h" int rd_fft(name, fftdat, fftcnt) char *name; struct MagFFTSet *fftdat; int *fftcnt; { int32 hdf_fp,sd_id; struct MagFFTSet testdata; int ii,jj,kk,retval; printf("ACE MAG FFT read routine\n"); printf("File name is <%s>\n", name); if (name[0] == ' ') { printf("Usage: rd_hdf hdf_file\n"); return(1); } /* open hdf input file */ if ((hdf_fp=Hopen(name, DFACC_RDONLY, 0))==FAIL) { fprintf(stderr, "Hopen: could not open hdf file\n"); return(-1); } printf("File successfully opened.\n"); Vstart(hdf_fp); if ((sd_id=SDstart(name, DFACC_RDONLY))==FAIL) { fprintf(stderr, "SDstart: could not open hdf file\n"); return(-1); } if( init_rd_mag_fft(hdf_fp, sd_id, "r") <= 0) { fprintf(stderr,"RD_FFT: No mag fft data\n"); } ii=0; while((retval= read_mag_fft(&testdata,ii))!=-1) { fftdat[ii] = testdata; /* printf("%4d sc clock = %8d QAC=%3d\n", ii,testdata.sctime_readout,testdata.QAC); printf(" %4x %4x %4x %4x %4x\n", testdata.fft_statbits[0], testdata.fft_statbits[1], testdata.fft_statbits[2], testdata.fft_statbits[3], testdata.fft_statbits[4]); for(jj=0;jj