Adding Attributes


Contents:



How to Add Attributes

There are two categories of attributes, User-Defined and Pre-Defined. This tutorial only covers User-Defined attributes. There are specialized attribute routines for pre-defined attributes, which you can read about in the HDF User's Guide.

There are three types of User-Defined attributes:

The function you use to add attributes to an HDF file is: Depending on the type of attribute you are creating, you pass this function either the file identifier, SDS identifier, or dimension identifier.

Sample Program

The following sample program shows how to add attributes to an HDF file (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): If you have downloaded this program, then you can compile and run it. It adds a file attribute, an SDS attribute, and a dimension attribute to the sd.hdf file created previously. Following is a detailed review of what this program does: NOTE:

Contents of HDF File

To view the attributes, you can examine the contents of sd.hdf, using the hdp command, as follows:

To see the file attribute:
hdp list -a sd.hdf

To see the dataset attribute and dimension attribute:
hdp dumpsds sd.hdf
Take a look at the new dataset, as described in the NOTE: above.

Download Sample Program (optional)

Programs used in this tutorial: [Compiling a program]