Writing to a File


Contents:



How to Write to an SDS

Typical functions that you would use to write to an SDS are as follows:

Sample Program to Write an SDS

The sd_create program is a sample program for writing out an SDS. 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 creates an HDF file called sd.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:


Contents of HDF File Created

You can view the contents of sd.hdf, using the hdp command. Following is the output you would get by examining the file with hdp: hdp dumpsds sd.hdf

The hdp command allows you to view general information about a file. You can see that sd.hdf contains a two-dimensional array (rank = 2) of 16-bit signed integers, and has no attributes. Dimension 0, named fakeDim0, has a size of 10, and Dimension 1, named fakeDim1, has a size of 5. The index is the position of the data set relative to the beginning of the file, beginning with zero. There is only one dataset in this file, so its index is zero. The data is a series of increasing numbers.


Download Sample Program (optional)

Programs used in this tutorial: [Compiling a program]