Reading a Vdata
Contents:
Following are some of the functions you can use to obtain information
regarding a Vdata:
(The functions in bold are used in the program examples in this tutorial.)
The vd_ex5 program is a sample program for reading a Vdata.
This program reads the HDF file created in the previous tutorial,
"Writing Mixed Field Data Types". You can either download the C or
FORTRAN vd_ex5 program at the end, or just look at the HTML
version, with HDF functions highlighted:
If you have downloaded this program, then
compile and run it. To see the output
of this program, look in the next section entitled "Output of Program to
Read a Vdata".
Following is a detailed review of what the vd_ex5 program does:
- Opens the HDF files and initializes the Vset interface.
- Gets the reference number of the first Vdata using VSgetid
(vsfgid).
[C]
[FORTRAN]
- Attaches to the first Vdata in read mode.
- Gets information regarding a Vdata using VSinquire (vsfinq).
[C]
[FORTRAN]
- Gets the class name of the Vdata using VSgetclass (vsgcls).
[C]
[FORTRAN]
- Determines which fields to read using VSsetfields (vsfsfld).
- Reads the data into a buffer, using VSread (vsfread).
[C]
[FORTRAN]
- Unpacks the data using VSfpack (vsfnpak/vsfcpak)
and then prints out the data.
- Detaches from the Vdata and closes the interface and the file.
The output of the program is:
How would you use VSfind instead of VSgetid in this
example?
What would you do to read specific fields?
Programs used in this tutorial:
[Compiling a program]