Adding an SDS to a Vgroup
Contents:
Following is what you need to do to add an SDS to a Vgroup.
- open the SD interface
- open the Vgroup interface
- create an SDS
- create a Vgroup
- get the tag and reference number for the object (DFTAG_NDG for an SDS)
- obtain the reference number of the SD object you created, by calling
SDidtoref/sfid2ref
- insert the object into the Vgroup using
Vaddtagref/vfadtr
- close the SD interface
- close the Vgroup interface
The program might look as follows (You can either download the
C or FORTRAN program at the end, or just take a
look at the HTML version with the HDF calls highlighted):
Run this program, and then look at the resulting HDF file using
hdp dumpsds addsdvg.hdf. The HDF file
contains an SDS named sd1 of type 32-bit signed integer, with 1 dimension
of size 10. There is no data in this object, and there are no attributes.
If you look at the resulting file using
hdp dumpvg addsdvg.hdf, you can see that
the SDS is included under the Vgroup with the name VG_Name_1. (This requires
some understanding of the underlying structure of an HDF file.)
Next, add data to the HDF file.
Your program will need to:
- Open the "addsdvg.hdf" file for Read/Write Access.
- Open the data set.
- Fill up a temporary buffer and write this to the HDF file, using
SDwritedata (sfwdata/sfwcdata).
- End access to the data array.
- Terminate access to the SD interface and close the file.
The resulting program might look as follows (You can either
download the C or FORTRAN program at the end, or just take a
look at the HTML version with the HDF calls highlighted):
Examine the resulting HDF file using hdp dumpsds
addsdvg.hdf. Notice that data is now included.
Programs used in this tutorial:
[Compiling a program]