/* This procedure opens and reads ACE MAG field browse 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_BR_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 "magframe_out_br.h" #include "df.h" #include "mfhdf.h" int rd_br(name, brdat, brcnt) char *name; struct MagFrm_out_br *brdat; int *brcnt; { int32 hdf_fp, sd_id; struct MagFrm_out_br testdata; int ii,jj,retval; printf("ACE MAG field averages 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); } if( init_rd_mag_br(hdf_fp, sd_id,"r") <=0) { fprintf(stderr,"No mag vector browse data\n"); } ii=0; while((retval= read_mag_br(&testdata,ii))!=-1) { brdat[ii] = testdata; /* printf("%4d bin_start = %f", ii,testdata.bin_start); printf("%4d ", testdata.iflag_out); printf("%e %e %e\n", testdata.b_out[0], testdata.b_out[1], testdata.b_out[2]); */ ii++; } *brcnt = ii; /* all done, close HDF file */ close_rd_mag_br(); Vend(hdf_fp); if (SDend(sd_id)==FAIL) { fprintf(stderr, "SDend: could not close hdf file\n"); return(-1); } if (Hclose(hdf_fp)==FAIL) { fprintf(stderr, "Hclose: could not close hdf file\n"); return(-1); } return(0); }