[Top] [Prev] [Next] [Bottom]
2.8 Fortran-77 and C Language Issues
In order to make the Fortran-77 and C versions of each routine as similar as possible, some compromises have been made in the process of simplifying the interface for both programming languages.
2.8.1 Fortran-77-to-C Translation
Nearly all of the HDF library code is written in C. The Fortran-77 HDF API routines translate all parameter data types to C data types, then call the C routine that performs the main function. For example, d8aimg is the Fortran-77 equivalent for DFR8addimage. Calls to either routine execute the same C code that adds an 8-bit raster image to an HDF file - see the following figure.
FIGURE 2e Use of a Function Call Converter to Route Fortran-77 HDF Calls to the C Library
2.8.2 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.
2.8.3 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.
2.8.4 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 your compiler include and preprocess header files. If this capability is not available, you may have to copy whatever declarations, definitions, or values you need from the "constants.f" file into your program code. If it is, include the header file named "hdf.inc" in your Fortran-77 code. The "constants.f" file is included in the "hdf.inc" header file.
2.8.5 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 Data Type Definitions
When using a Fortran-77 data type that is not supported, the general practice is to use another data type of the same size. For example, an 8-bit signed integer can be used to store an 8-bit unsigned integer variable unless the code relies on a sign-specific operation.
2.8.6 Array Specifications
In the declarations contained in the headers of Fortran-77 functions, the following conventions are followed:
2.8.7 Fortran-77, ANSI C and K&R C
As much as possible, we have conformed the HDF API routines to those implementations of Fortran and C that are in most common use today, namely Fortran-77, ANSI C and K&R C. Due to the increasing availability of ANSI C, future versions of HDF will no longer support K&R C.
As Fortran-90 is a superset of Fortran-77, HDF programs should compile and run correctly when using a Fortran-90 compiler.
[Top] [Prev] [Next] [Bottom]
hdfhelp@ncsa.uiuc.edu
HDF User's Guide - 06/04/97, NCSA HDF
Development Group.