/* This procedure opens and reads ACE sunpulse 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 - sunpulse_rd.c Modifications: Sandy Kramer, NASA/GSFC, code 692 - 01/08/98 */ #include #include #include "sunpulsetime.h" #include "df.h" int rd_sunpulse(name, sunpulsedat, sunpulsecnt) char *name; struct ACEsunpulsetime *sunpulsedat; int *sunpulsecnt; { int32 hdf_fp,sd_id; struct ACEsunpulsetime testdata; int ii,jj,retval; float64 lastsptime; printf("ACE Sunpulse read routine\n"); printf("File name is <%s>\n", name); if (name[0] == ' ') { printf("Usage: rd_sunpulse 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); } 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_sunpulsetime(hdf_fp, sd_id, "r") <= 0) { fprintf(stderr,"RD_SUNPULSE: No sunpulsetime data\n"); } ii=0; while((retval= read_sunpulsetime(&testdata,ii))!=-1) { sunpulsedat[ii] = testdata; /* printf("%12.5f %12.5f\n", testdata.SPtime, testdata.SPtime-lastsptime); lastsptime=testdata.SPtime; */ ii++; } *sunpulsecnt = ii; /* all done, close HDF file */ close_rd_sunpulsetime(); fprintf(stderr,"VS detached \n"); Vend(hdf_fp); fprintf(stderr,"VS ended \n"); 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); } fprintf(stderr,"file closed \n"); return(0); }