As every file is assigned its own identifier, the order in which files are accessed is very flexible. For example, it is valid to open a file and obtain an identifier for it, then open a second file without closing the first file or disposing of the first file identifier. The only requirement made by HDF is that all file identifiers be individually discarded before the termination of the calling program.
File identifiers created by the routine of one HDF interface can be used by the routines of any other interfaces, except SD's.
C: file_id = Hopen(filename, access_mode, num_dds_block);
FORTRAN: file_id = hopen(filename, access_mode, num_dds_block)The Hopen parameters are defined in Table 2A and the following discussion.
TABLE 2A - Hopen Parameter List
filename
is a character string representing the name of the HDF file to be accessed. The parameter
access_mode
specifies how the file should be accessed. All the access modes are listed in Table 2B. If the access mode is DFACC_CREATE
and the file already exists, the file will be replaced by the new one. If the access mode is DFACC_READ
and the file does not exist, Hopen will return FAIL
(or -1
). If the access mode is DFACC_WRITE
and the file does not exist, a new file will be created.
The parameter
num_dds_block
specifies the number of data descriptors in a block when the access mode specified is create. If the access mode is not create, the value of num_dds_block
is ignored. The default number of data descriptors in a block is 16 (defined as DEF_NDDS
) data descriptors. The user may specify 0
to keep the default or any non-negative integer to reset this limit when creating the HDF file.
TABLE 2B - File Access Code Flags
|
|
|
|
Read access
| |
|
Read and write access
| |
|
Create with read and write access
|
file_id
. The Hclose syntax is as follows:
C: status = Hclose(file_id);
FORTRAN: status = hclose(file_id)Hclose returns a value of
SUCCEED
(or 0
) if successful or FAIL
(or -1
) otherwise. The parameter name and type are listed in Table 2C. Refer also to the HDF Reference Manual for additional information regarding Hclose.Note that Hclose is not used to close files in the SD interface. SDend is used for this purpose. (Refer to Chapter 3, Scientific Data Sets (SD API), of this document for more information on SDend.)
TABLE 2C - Hclose Parameter List
|
|
|
| |
|
| |||
|
|
|
File identifier
|
Hgetfileversion returns the version information of the HDF file specified by the parameter file_id
, as well as additional textual information regarding the nature of the file. The parameter names and data types are listed in Table 2D. Refer also to the HDF Reference Manual for additional information regarding Hgetfileversion.
The syntax of these routines is as follows:
C: status = Hgetlibversion(&major_v, &minor_v, &release, string);
status = Hgetfileversion(file_id, &major_v, &minor_v, &release, string);
FORTRAN: status = hglibver(major_v, minor_v, release, string)
status = hgfilver(file_id, major_v, minor_v, release, string)
Both routines return a value of SUCCEED
(or 0
) if successful or FAIL
(or -1
) otherwise.TABLE 2D - Hgetlibversion and Hgetfileversion Parameter Lists