/* This procedure opens and reads ACE MAG vector 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: ACE Science Center Modifications: Sandy Kramer, NASA/GSFC, code 692 - 09/08/97 */ #include #include #include "mag_vector.h" #include "df.h" #include "mfhdf.h" int rd_vec(name, vecdat, veccnt) char *name; struct MagVectorSet *vecdat; int *veccnt; { int32 hdf_fp, sd_id; struct MagVectorSet testdata; int ii,jj,retval; printf("ACE MAG Vector 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_ALL, 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_WRITE))==FAIL) { fprintf(stderr, "SDstart: could not open hdf file\n"); return(-1); } init_rd_mag_vec(hdf_fp, sd_id); ii=0; while((retval= read_mag_vec(&testdata,ii))!=-1) { vecdat[ii] = testdata; /* printf("%4d sc clock = %8d\n", ii,testdata.sctime_readout); for(jj=0;jj<18;jj++) printf(" %3x", testdata.vector[0][jj]); printf("\n"); */ ii++; } *veccnt = ii; /* all done, close HDF file */ close_rd_mag_vec(); Vend(hdf_fp); if (Hclose(hdf_fp)==FAIL) { fprintf(stderr, "Hclose: could not close hdf file\n"); return(-1); } if (SDend(sd_id)==FAIL) { fprintf(stderr, "SDend: could not close hdf file\n"); return(-1); } return(0); }