HDF5 documents and links Introduction to HDF5 HDF5 User Guide | And in this document, the HDF5 Reference Manual H5 H5A H5D H5E H5F H5G H5I H5P H5R H5S H5T H5Z Tools Datatypes

# H5: General Library Functions

These functions serve general-purpose needs of the HDF5 library and it users.

The C Interfaces:

- H5open
- H5close

- H5get_libversion
- H5check_version

- H5set_free_list_limits
- H5garbage_collect
- H5dont_atexit

Alphabetical Listing

- H5check_version
- H5close
- H5dont_atexit

- H5garbage_collect
- H5get_libversion
- H5open

- H5set_free_list_limits

The FORTRAN90 Interfaces:
In general, each FORTRAN90 subroutine performs exactly the same task as the corresponding C function.

- h5open_f
- h5close_f

- h5get_libversion_f
- h5check_version_f

- h5set_free_list_limits_f
- h5garbage_collect_f
- h5dont_atexit_f

Name: H5check_version
Signature:
  herr_t `H5check_version`(unsigned `majnum`, unsigned `minnum`, unsigned `relnum` )
Purpose:
  Verifies that library versions are consistent.
Description:
  `H5check_version` verifies that the arguments provided with the function call match the version numbers compiled into the library.

  `H5check_version` serves two slightly differing purposes.

  First, the function is intended to be called by the user to verify that the version of the header files compiled into an application matches the version of the HDF5 library being used. One may look at the `H5check` definition in the file `H5public.h` as an example.

  Due to the risks of data corruption or segmentation faults, `H5check_version` causes the application to abort if the version numbers do not match. The abort is achieved by means of a call to the standard C function `abort()`.

  Note that `H5check_version` verifies only the major and minor version numbers and the release number; it does not verify the sub-release value as that should be an empty string for any official release. This means that any two incompatible library versions must have different {major,minor,release} numbers. (Notice the reverse is not necessarily true.)

  Secondarily, `H5check_version` verifies that the library version identifiers `H5_VERS_MAJOR`, `H5_VERS_MINOR`, `H5_VERS_RELEASE`, `H5_VERS_SUBRELEASE`, and `H5_VERS_INFO` are consistent. This is designed to catch source code inconsistencies, but does not generate the fatal error as in the first stage because this inconsistency does not cause errors in the data files. If this check reveals inconsistencies, the library issues a warning but the function does not fail.

Parameters:

unsigned `majnum`
  IN: The major version of the library.
unsigned `minnum`
  IN: The minor version of the library.
unsigned `relnum`
  IN: The release number of the library.

Returns:
  Returns a non-negative value if successful. Upon failure, this function causes the application to abort.
Fortran90 Interface: h5check_version_f

      SUBROUTINE h5check_version_f(hdferr)
        IMPLICIT NONE
        INTEGER, INTENT(IN)  :: majnum      ! The major version of the library
        INTEGER, INTENT(IN)  :: minnum      ! The minor version of the library
        INTEGER, INTENT(IN)  :: relnum      ! The release number
        INTEGER, INTENT(OUT) :: hdferr      ! Error code

      END SUBROUTINE h5check_version_f

Name: H5close
Signature:
  herr_t `H5close`(void)
Purpose:
  Flushes all data to disk, closes file identifiers, and cleans up memory.
Description:
  `H5close` flushes all data to disk, closes all file identifiers, and cleans up all memory used by the library. This function is generally called when the application calls `exit()`, but may be called earlier in event of an emergency shutdown or out of desire to free all resources used by the HDF5 library.

  `h5close_f` and `h5open_f` are required calls in Fortran90 applications.

Parameters:

None.

Returns:
  Returns a non-negative value if successful; otherwise returns a negative value.
Fortran90 Interface: h5close_f

      SUBROUTINE h5close_f(hdferr)
        IMPLICIT NONE
        INTEGER, INTENT(OUT) :: hdferr      ! Error code

      END SUBROUTINE h5close_f

Name: H5dont_atexit
Signature:
  herr_t `H5dont_atexit`(void)
Purpose:
  Instructs library not to install `atexit` cleanup routine.
Description:
  `H5dont_atexit` indicates to the library that an `atexit()` cleanup routine should not be installed. The major purpose for this is in situations where the library is dynamically linked into an application and is un-linked from the application before `exit()` gets called. In those situations, a routine installed with `atexit()` would jump to a routine which was no longer in memory, causing errors.

  In order to be effective, this routine must be called before any other HDF function calls, and must be called each time the library is loaded/linked into the application (the first time and after it's been un-loaded).

Parameters:

None.

Returns:
  Returns a non-negative value if successful; otherwise returns a negative value.
Fortran90 Interface: h5dont_atexit_f

      SUBROUTINE h5dont_atexit_f(hdferr)
        IMPLICIT NONE
        INTEGER, INTENT(OUT) :: hdferr      ! Error code

      END SUBROUTINE h5dont_atexit_f

Name: H5garbage_collect
Signature:
  herr_t `H5garbage_collect`(void)
Purpose:
  Garbage collects on all free-lists of all types.
Description:
  `H5garbage_collect` walks through all the garbage collection routines of the library, freeing any unused memory.

  It is not required that `H5garbage_collect` be called at any particular time; it is only necessary in certain situations where the application has performed actions that cause the library to allocate many objects. The application should call `H5garbage_collect` if it eventually releases those objects and wants to reduce the memory used by the library from the peak usage required.

  The library automatically garbage collects all the free lists when the application ends.

Parameters:

None.

Returns:
  Returns a non-negative value if successful; otherwise returns a negative value.
Fortran90 Interface: h5garbage_collect_f

      SUBROUTINE h5garbage_collect_f(hdferr)
        IMPLICIT NONE
        INTEGER, INTENT(OUT) :: hdferr      ! Error code

      END SUBROUTINE h5garbage_collect_f

Name: H5get_libversion
Signature:
  herr_t `H5get_libversion`(unsigned *`majnum`, unsigned *`minnum`, unsigned *`relnum` )
Purpose:
  Returns the HDF library release number.
Description:
  `H5get_libversion` retrieves the major, minor, and release numbers of the version of the HDF library which is linked to the application.
Parameters:

unsigned *`majnum`
  OUT: The major version of the library.
unsigned *`minnum`
  OUT: The minor version of the library.
unsigned *`relnum`
  OUT: The release number of the library.

Returns:
  Returns a non-negative value if successful; otherwise returns a negative value.
Fortran90 Interface: h5get_libversion_f

      SUBROUTINE h5get_libversion_f(hdferr)
        IMPLICIT NONE
        INTEGER, INTENT(OUT) :: majnum      ! The major version of the library
        INTEGER, INTENT(OUT) :: minnum      ! The minor version of the library
        INTEGER, INTENT(OUT) :: relnum      ! The release number
        INTEGER, INTENT(OUT) :: hdferr      ! Error code

      END SUBROUTINE h5get_libversion_f

Name: H5open
Signature:
  herr_t `H5open`(void)
Purpose:
  Initializes the HDF5 library.
Description:
  `H5open` initialize the library.

  When the HDF5 Library is employed in a C application, this function is normally called automatically, but if you find that an HDF5 library function is failing inexplicably, try calling this function first. If you wish to elimnate this possibility, it is safe to routinely call `H5open` before an application starts working with the library as there are no damaging side-effects in calling it more than once.

  When the HDF5 Library is employed in a Fortran90 application, `h5open_f` initializes global variables (e.g. predefined types) and performs other tasks required to initialize the library. `h5open_f` and `h5close_f` are therefore required calls in Fortran90 applications.

Parameters:

None.

Returns:
  Returns a non-negative value if successful; otherwise returns a negative value.
Fortran90 Interface: h5open_f

      SUBROUTINE h5open_f(hdferr)
        IMPLICIT NONE
        INTEGER, INTENT(OUT) :: hdferr      ! Error code

      END SUBROUTINE h5open_f

Name: H5set_free_list_limits
Signature:
  herr_t `H5set_free_list_limits`(int `reg_global_lim`, int `reg_list_lim`, int `arr_global_lim`, int `arr_list_lim`, int `blk_global_lim`, int `blk_list_lim` )
Purpose:
  Sets free-list size limits.
Description:
  `H5set_free_list_limits` sets size limits on all types of free lists. The HDF5 library uses free lists internally to manage memory. There are three types of free lists:
  - Regular free lists manage a single data structure.
  - Array free lists manage arrays of a data structure.
  - Block free lists manage blocks of bytes.
  Alternate phrasing?:
  - Regular free lists manage data structures containing atomic data.
  - Array free lists manage data structures containing array data.
  - Block free lists manage blocks of bytes.

  These are global limits, but each limit applies only to free lists of the specified type. Therefore, if an application sets a 1Mb limit on each of the global lists, up to 3Mb of total storage might be allocated, 1Mb for each of the regular, array, and block type lists.

  Using a value of `-1` for a limit means that no limit is set for the specified type of free list.

Parameters:

int `reg_global_lim`
  IN: The limit on all regular free list memory used
int `reg_list_lim`
  IN: The limit on memory used in each regular free list
int `arr_global_lim`
  IN: The limit on all array free list memory used
int `arr_list_lim`
  IN: The limit on memory used in each array free list
int `blk_global_lim`
  IN: The limit on all block free list memory used
int `blk_list_lim`
  IN: The limit on memory used in each block free list

Returns:
  Returns a non-negative value if successful; otherwise returns a negative value.
Fortran90 Interface:
  None.

HDF5 documents and links Introduction to HDF5 HDF5 User Guide | And in this document, the HDF5 Reference Manual H5 H5A H5D H5E H5F H5G H5I H5P H5R H5S H5T H5Z Tools Datatypes