Page tree









Terminates access to an HDF5 file




herr_t H5Fclose( hid_t file_id )

SUBROUTINE h5fclose_f(file_id, hdferr) 
  INTEGER(HID_T), INTENT(IN) :: file_id ! File identifier
  INTEGER, INTENT(OUT) :: hdferr        ! Error code
                                        ! 0 on success and -1 on failure
END SUBROUTINE h5fclose_f 

hid_t file_id    IN: Identifier of a file to terminate access to


H5F_CLOSE terminates access to an HDF5 file (specified by file_id) by flushing all data to storage. 

If this is the last file identifier open for the file and no other access identifier is open (e.g., a dataset identifier, group identifier, or shared datatype identifier), the file will be fully closed and access will end.

PLEASE be aware that by default when opening and then closing objects in an HDF5 file, the file close is delayed until ALL objects in the file are closed (in other words, a WEAK file close degree is used). This behavior can be changed by modifying the file close degree file access property list with H5P_SET_FCLOSE_DEGREE when the file is opened. See the notes below and the H5P_SET_FCLOSE_DEGREE function for more information.


Delayed close: 
Note the following deviation from the above-described behavior. If H5F_CLOSE is called for a file but one or more objects within the file remain open, those objects will remain accessible until they are individually closed. Thus, if the dataset data_sample is open when H5F_CLOSE is called for the file containing it, data_sample will remain open and accessible (including writable) until it is explicitly closed. The file will be automatically closed once all objects in the file have been closed.

Be warned, however, that there are circumstances where it is not possible to delay closing a file. For example, an MPI-IO file close is a collective call; all of the processes that opened the file must close it collectively. The file cannot be closed at some time in the future by each process in an independent fashion. Another example is that an application using an AFS token-based file access privilege may destroy its AFS token after H5F_CLOSE has returned successfully. This would make any future access to the file, or any object within it, illegal.

In such situations, applications must close all open objects in a file before calling H5F_CLOSE. It is generally recommended to do so in all cases.


Returns a non-negative value if successful; otherwise returns a negative value. 

1.4.0Fortran API introduced in this release.
1.0.0C function introduced in this release.

--- Last Modified: October 23, 2020 | 02:54 PM