From dean@phobos.cira.colostate.edu Thu Jun 22 09:18:51 1995 Path: solitaire.cv.nrao.edu!hearst.acc.Virginia.EDU!concert!gatech!news.mathworks.com!newshost.marcam.com!usc!elroy.jpl.nasa.gov!decwrl!purdue!yuma!DEAN@phobos.cira.colostate.edu From: dean@phobos.cira.colostate.edu Newsgroups: sci.data.formats Subject: HDF Scientific Data Date: 22 Jun 1995 04:39:06 GMT Organization: Colorado State Univ, CIRA Lines: 119 Message-ID: <3sas5a$2l5f@yuma.ACNS.ColoState.EDU> Reply-To: dean@sol.cira.colostate.edu NNTP-Posting-Host: sol.cira.colostate.edu I am attempting to read a HDF SDS file with a C program on a VAX/AXP with OpenVMS operating system. I can read this file with a FORTRAN routine and using HDF calls in IDL. However, I cannot get this C program to work. It comes up with an access violation while in the DFSDgetdata routine. Is there an example available somewhere that will allow me to read a HDF SDS file. I checked the NCSA site, but could not find an example. If someone knows a location where I can find a simple C program to assist me to read a HDF SDS file, please let me know. OR if you see an obvious error in the program below, let me know. Thanks in advance, Kelly Dean CSU/CIRA ============================sdstoppm.c===================================== #include "ppm.h" #include "df.h" #define TRUE 1 #define FALSE 0 #ifndef VMS void #endif main( argc, argv ) int argc; char* argv[]; { pixel* pixrow; register pixel* pP; int argn, headerskip, rowskip, rows, cols, row, i; register int col; int order; int val1, val2, val3; char* usage = "[-n] [HDFfile]"; char *bp; /* Byte pointer in image */ char hdf_file[80]; /* HDF input file name */ int err_ret; /* error number on DF call */ /* int16 *image; */ /* image array */ int16 image[2000][4000]; int inRank; /* ranking */ int32 Dims[2]; /* image dimnsions */ #ifdef VMS getredirection (&argc, &argv); #endif ppm_init( &argc, argv ); argn = 1; if ( argn != argc ) { strcpy(hdf_file,argv[argn]); err_ret = DFSDgetdims(hdf_file, &inRank, &Dims, 2); if (err_ret != 0 ) { fprintf( stderr, "\n Error Opening SDS file > %d\n", err_ret); exit (1); } else { fprintf( stderr, "\n Reading > %s \n", hdf_file ); fprintf( stderr, "\n Dimensions > %d x %d\n", Dims[0], Dims[1] ); ++argn; } err_ret = DFSDgetdata(hdf_file, inRank, Dims, &image ); if (err_ret != 0 ) { fprintf( stderr, "\n Error reading SDS file > %d\n", err_ret); exit (1); } else { fprintf( stderr,"\n Successfully read SDS image > %s \n",argv[argn] ); } cols = Dims[0]; rows = Dims[1]; } if ( argn != argc ) pm_usage( usage ); ppm_writeppminit( stdout, cols, rows, 255, 0 ); pixrow = ppm_allocrow( cols ); fprintf( stderr, "\n Converting to PPM \n"); for ( row = 0; row < rows; ++row) /* top to bottom */ /* for ( row = rows-1; row >= 0; row--) */ /* bottom to top */ { bp = ( char * ) &image[row*cols]; for ( col = 0, pP = pixrow; col < cols; ++col, ++pP ) { val1 = ( (*bp)*3 ) / 4; /* red */ if ( val1 == EOF ) pm_error( "EOF / read error - color red" ); val2 = ( (*bp)*3+1 ) / 4; /* green */ if ( val2 == EOF ) pm_error( "EOF / read error - color green" ); val3 = ( (*bp)*3+2 ) / 4; /* blue */ if ( val3 == EOF ) pm_error( "EOF / read error - color blue" ); PPM_ASSIGN( *pP, val1, val2, val3 ); bp++; } ppm_writeppmrow( stdout, pixrow, cols, 255, 0 ); } pm_close( stdout ); exit( 0 ); } From dilg@newsroom.hitc.com Fri Jun 23 13:02:37 1995 Path: solitaire.cv.nrao.edu!hearst.acc.Virginia.EDU!portal.gmu.edu!europa.chnt.gtegsc.com!news.mathworks.com!news.ultranet.com!news.sprintlink.net!howland.reston.ans.net!swrinde!elroy.jpl.nasa.gov!ames!newsfeed.gsfc.nasa.gov!newsroom.hitc.com!dilg From: dilg@newsroom.hitc.com (Doug Ilg) Newsgroups: sci.data.formats Subject: Re: HDF Scientific Data Date: 22 Jun 1995 15:41:42 GMT Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA Lines: 24 Distribution: world Message-ID: <3sc2vm$j0g@post.gsfc.nasa.gov> References: <3sas5a$2l5f@yuma.ACNS.ColoState.EDU> NNTP-Posting-Host: newsroom.gsfc.nasa.gov In article , ejh@larry.gsfc.nasa.gov (Edward Hartnett) writes: |> >>>>> "d" == dean writes: |> |> d> strcpy(hdf_file,argv[argn]); |> d> err_ret = DFSDgetdims(hdf_file, &inRank, &Dims, 2); |> d> fprintf( stderr, "\n Reading > %s \n", hdf_file ); |> d> fprintf( stderr, "\n Dimensions > %d x %d\n", Dims[0], Dims[1] ); |> d> err_ret = DFSDgetdata(hdf_file, inRank, Dims, &image ); |> |> I think you need to use a 1-based instead of a 0-based array for the |> dimensional sizes (i.e. the Dims array). No, HDF uses 0-based arrays. I haven't had a chance to look over the whole program yet, but it looks like you could do without the & before Dims in your call to DFSDgetdims. Since Dims is an array, it is equivalent to a pointer. There is a sample DFSD program in the HDF manual called "Getting Started With HDF." Also, I would urge you to use the newer "SD" interface to HDF SDSs. It's a bit more complicated, but it is much more capable. -Doug From ejh@larry.gsfc.nasa.gov Fri Jun 23 16:21:13 1995 Path: solitaire.cv.nrao.edu!hearst.acc.Virginia.EDU!concert!news-server.ncren.net!news.duke.edu!hookup!ames!newsfeed.gsfc.nasa.gov!gsfc.nasa.gov!ejh From: ejh@larry.gsfc.nasa.gov (Edward Hartnett) Newsgroups: sci.data.formats Subject: Re: HDF Scientific Data Date: 22 Jun 1995 15:05:39 GMT Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA Lines: 26 Message-ID: References: <3sas5a$2l5f@yuma.ACNS.ColoState.EDU> NNTP-Posting-Host: larry.gsfc.nasa.gov In-reply-to: dean@phobos.cira.colostate.edu's message of 22 Jun 1995 04:39:06 GMT >>>>> "d" == dean writes: d> I am attempting to read a HDF SDS file with a C program on a VAX/AXP d> with OpenVMS operating system. I can read this file with a FORTRAN routine d> and using HDF calls in IDL. However, I cannot get this C program to work. d> It comes up with an access violation while in the DFSDgetdata routine. d> Is there an example available somewhere that will allow me to read d> a HDF SDS file. I checked the NCSA site, but could not find an example. d> If someone knows a location where I can find a simple C program to d> assist me to read a HDF SDS file, please let me know. OR if you see an d> obvious error in the program below, let me know. d> strcpy(hdf_file,argv[argn]); d> err_ret = DFSDgetdims(hdf_file, &inRank, &Dims, 2); d> fprintf( stderr, "\n Reading > %s \n", hdf_file ); d> fprintf( stderr, "\n Dimensions > %d x %d\n", Dims[0], Dims[1] ); d> err_ret = DFSDgetdata(hdf_file, inRank, Dims, &image ); I think you need to use a 1-based instead of a 0-based array for the dimensional sizes (i.e. the Dims array). -- From ratel@mars.ireq-ccfm.hydro.qc.ca Sun Jun 25 11:53:50 1995 Newsgroups: sci.data.formats Path: solitaire.cv.nrao.edu!hearst.acc.Virginia.EDU!maui.cc.odu.edu!xanth.cs.odu.edu!lll-winken.llnl.gov!uwm.edu!hookup!news.mcgill.ca!newsflash.concordia.ca!sunqbc.risq.net!hobbit.ireq.hydro.qc.ca!mars.ireq-ccfm.hydro.qc.ca!ratel From: ratel@mars.ireq-ccfm.hydro.qc.ca (Gilles Ratel (8720)) Subject: Re: HDF scientific data, SD interface Message-ID: Sender: news@ireq.hydro.qc.ca (Netnews Admin) Organization: Centre Canadien de Fusion Magnetique Date: Sun, 25 Jun 1995 02:52:53 GMT Lines: 23 Doug Ilg writes: > Also, I would urge you to use the newer "SD" interface to HDF SDSs. > It's a bit more complicated, but it is much more capable. Yes! SD interface enhance DFSD. But, for 1D data HDF file double in size. Suppose I have a 1D data of 10,000 values. SD interface create a SDS (good!) [10,000] _AND_ a "fakedim" data [10,000] (?) also HDF content 20,000 values. I don't understand exact usage for "fakedim". For me: array "fakedim" is a _big_ problem. consequence: I use DFSD interface :-( Gilles Ratel Email: ratel@toka.ireq-ccfm.hydro.qc.ca From dilg@newsroom.hitc.com Mon Jun 26 15:42:54 1995 Path: solitaire.cv.nrao.edu!hearst.acc.Virginia.EDU!maui.cc.odu.edu!xanth.cs.odu.edu!lll-winken.llnl.gov!ames!newsfeed.gsfc.nasa.gov!newsroom.hitc.com!dilg From: dilg@newsroom.hitc.com (Doug Ilg) Newsgroups: sci.data.formats Subject: Re: HDF scientific data, SD interface Date: 26 Jun 1995 13:46:12 GMT Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA Lines: 28 Distribution: world Message-ID: <3smdn4$89l@post.gsfc.nasa.gov> References: NNTP-Posting-Host: newsroom.gsfc.nasa.gov ratel@mars.ireq-ccfm.hydro.qc.ca (Gilles Ratel (8720)) writes: |> |> Doug Ilg writes: |> |> > Also, I would urge you to use the newer "SD" interface to HDF SDSs. |> > It's a bit more complicated, but it is much more capable. |> |> |> Yes! SD interface enhance DFSD. |> But, for 1D data HDF file double in size. |> |> Suppose I have a 1D data of 10,000 values. |> SD interface create a SDS (good!) [10,000] _AND_ a "fakedim" data |> [10,000] (?) also HDF content 20,000 values. I don't understand |> exact usage for "fakedim". For me: array "fakedim" is |> a _big_ problem. |> consequence: I use DFSD interface :-( The 100% overhead on 1-D SDs is a problem that NCSA is looking into. It's an outgrowth of the merger of netCDF into HDF. I don't know why, but apparently it turned out to make sense in the netCDF context. For that reason, when I need 1-D data, I use a vdata. They are very efficient and convenient for putting many variables into one structure. The drawback with vdatas is the lack of nifty general purpose visualization tools like you get with SDSs (of either type). C'est le vie, eh? -Doug