Adding Attributes to a Vdata and its Fields


Contents:



How to Read/ Write Attributes

A feature new to HDF, as of HDF 4.1r1, is the ability to create and read attributes (auxiliary information) for Vdatas.

Following are the calls that you need to do this:


Sample Program to Write Attributes

In this tutorial, we will take example 4, vd_ex4 and modify it to create the following attributes: Basically, all you need to do is add the following two calls to vd_ex4 along with any variables that you need to define to make it compile.

C:

     istat = VSsetattr (vdata_id, _HDF_VDATA, "Fixed_type", DFNT_INT32, 
                        4, (VOIDP)values); 
     istat = VSsetattr (vdata_id, 2, "Symbol", DFNT_CHAR, 3, "MAX");
FORTRAN:
     retn = vsfsnat(vdata_id, -1, 'Fixed_type', DFNT_INT32, 4, values)
     retn = vsfscat(vdata_id, 2, 'Symbol', DFNT_CHAR8, 3, 'MAX')
Following is the vd_ex4 program in HTML that adds attributes. You can optionally download this program, and compile and run it. To see what the resulting HDF file looks like with attributes, see the next section, "Contents of HDF File with Attributes":

Contents of HDF File with Attributes

Following are the contents of the HDF files containing the attributes created in this tutorial example:


Download Sample Program (optional)

Programs used in this tutorial: