hdf.h
must be included in every HDF application program written in C, except for programs that call routines in the SD interface. The header file mfhdf.h
must be included in all programs that call SD interface routines.Fortran programmers who use compilers that allow file inclusion can include the files
hdf.inc
and dffunc.inc
. If a Fortran compiler that does not support file inclusion is used, HDF library definitions must be explicitly defined in the Fortran program as they are included in the header files of the HDF library.
hdf.h
header file, and the data type flags are located in the hntdefs.h
header file. Both are also included in Table 2F on page 14, Table 2G on page 14, and Table 2H on page 15. HDF data types are used for portability in the declaration of variables, and data type flags are used as parameters in various HDF interface routines.
2.5.2.1 Standard HDF Data Types
The definitions of the fundamental data types are in Table 2F. Although DFNT_FLOAT
(or 5
), DFNT_UCHAR
(or 3
), and DFNT_CHAR
(or 4
) have not been added to this table, they are also supported by the HDF library for backward compatibility.
If the machine used is big-endian, using these data types will result in no byte-order conversion being performed. If the machine used is little-endian, the library will convert the byte-order of the variables to big-endian.
TABLE 2F - Standard HDF Data Types and Flags
2.5.2.2 Native Format Data Types
When a native format data type is specified, the corresponding numbers are stored in the HDF file exactly as they appear in memory, without conversion. For example, on a Cray Y-MP, 8 bytes of memory, or one Cray word, is used to store most integers. Therefore, an 8-bit signed integer, represented by the DFNT_INT32
flag, on a Cray Y-MP uses 8 bytes of memory. Consequently, when the data type DFNT_NATIVE | DFNT_INT32
(DFNT_NATIVE
bytewise-ORed with DFNT_INT32
) is used on a Cray Y-MP to specify the data type of an HDF SDS or vdata, each integer stored in the HDF file is 8 bytes. DFNT_NATIVE
flag is bitwise-ORed with the flag of the corresponding standard data type.
TABLE 2G - Native Format Data Type Definitions
The method for constructing the data type flag for each little-endian data type is similar to the method for constructing native format data type flags: the
DFNT_LITEND
flag is bitwise-ORed with the flag of the corresponding standard data type.If the user is on a little-endian machine, using these data types will result in no conversion. If the user is on a big-endian machine, the HDF library will perform big-to-little-endian conversion.
The definitions of the little-endian data types and the corresponding data type flags appear in Table 2H.
TABLE 2H - Little-Endian Format Data Type Definitions
2.5.2.5 Limit Definitions
These definitions declare the maximum size of specific data object parameters, such as the maximum length of a vdata field or the maximum number of objects in a vgroup. They are located in the header file hlimits.h
. A selection of the most-commonly-used limit definitions appears in Table 2I.
FIGURE 2e - Use of a Function Call Converter to Route FORTRAN-77 HDF Calls to the C Library
Case Sensitivity
FORTRAN-77 identifiers generally are not case sensitive, whereas C identifiers are. Although all of the FORTRAN-77 routines shown in this manual are written in lower case, FORTRAN-77 programs can generally call them using either upper- or lower-case letters without loss of meaning. Name Length
Because some FORTRAN-77 compilers only interpret identifier names with seven or fewer characters, the first seven characters of the FORTRAN-77 HDF routine names are unique. Header Files
The inclusion of header files is not generally permitted by FORTRAN-77 compilers. However, it is sometimes available as an option. On UNIX systems, for example, the macro processors m4
and cpp
let the compiler include and preprocess header files. If this capability is not available, the user may have to copy the declarations, definitions, or values needed from the files dffunc.inc
and hdf.inc
into the user application. If the capability is available, the files can be included in the Fortran code. These two files reside in the include directory after the library is installed on the user's system. Data Type Specifications
When mixing machines, compilers, and languages, it is difficult to maintain consistent data type definitions. For instance, on some machines an integer is a 32-bit quantity and on others, a 16-bit quantity. In addition, the differences between FORTRAN-77 and C lead to difficulties in describing the data types found in the argument lists of HDF routines. To maintain portability, the HDF library expects assigned names for all data types used in HDF routines. See Table 2J.
TABLE 2J - Correspondence Between Fortran and HDF C Data Types
character*(*)
defines a string of an indefinite number of characters. It is the responsibility of the calling program to allocate enough space to hold the data to be stored in the string.
real x(*)
means that x
refers to an array of reals of indefinite size and of indefinite rank. It is the responsibility of the calling program to allocate an actual array with the correct number of dimensions and dimension sizes.
<valid numeric data type> x
means that x
may have one of the numeric data types listed in the Description column of Table 2J above.
<valid data type> x
means that x
may have any of the data types listed in the Description column of Table 2J above.
FORTRAN-77 and ANSI C
As much as possible, we have ensured that the HDF interface routines conform to the implementations of Fortran and C that are in most common use today, namely FORTRAN-77 and ANSI C.