Simple Writing to a File
Contents:
Typical functions that you would use to write to a Vdata are as follows:
The vd_ex3.c (vd_ex3f.f) program is a sample program for
writing out a Simple Vdata. You can either download the C or FORTRAN program
at the end, or just take a look at the HTML version, with HDF calls highlighted:
If you have downloaded this program, then you can
compile and run it. It creates an HDF file
called VD_Ex3.hdf (VD_Ex3f.hdf). You can view the contents
of the HDF file that gets created by this program, in the next section
"Contents of HDF File Created".
Following is a detailed review of what this program does:
- Opens the HDF file, using Hopen (hopen).
[C]
[FORTRAN]
- Initializes the HDF Vgroup/Vdata Interface with Vstart
(vfstart).
[C]
[FORTRAN]
- Creates a new Vdata with VSattach (vsfatch).
[C]
[FORTRAN]
- Defines the field data name, type and order with VSfdefine
(vsffdef).
In this case one field called "Field Entries" gets created with 3
components of type DFNT_INT16.
[C]
[FORTRAN]
- Specifies the fields that will be written to with VSsetfields
(vsfsfld).
In this case, we just specify one field, "Field Entries".
[C]
[FORTRAN]
- Writes out ten records of data to the vdata with VSwrite
(vsfwrt), specifying FULL_INTERLACE to indicate that the data
should be written out by record rather than by field.
[C]
[FORTRAN]
- Gives the vdata a name of 'Example Vdata' with VSsetname
(vsfsnam).
[C]
[FORTRAN]
- Gives the vdata a class name of 'Example Vdata' with VSsetclass
(vsfscls).
[C]
[FORTRAN]
- Terminates access to the vdata with VSdetach
(vsfdtch).
[C]
[FORTRAN]
- Terminates access to the Vdata/Vgroup interface with Vend
(vfend).
[C]
[FORTRAN]
- Closes the file with Hclose (hclose).
[C]
[FORTRAN]
You can view the contents of the HDF file that gets created, VD_Ex3.hdf
(VD_Ex3f.hdf), using the hdp command. Following is the output you
would get by examining the file with hdp:
Programs used in this tutorial:
[Compiling a program]