Page tree

The license could not be verified: License Certificate has expired!

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The HDF5 Application Programming Interface is extensive, but a few functions do most of the work.

 To To introduce the programming model, examples in Python and C are included below. The HDF5 Python APIs (h5py) are included for their simplicity of use. However, they were not created and are not maintained by The HDF Group.

The general paradigm for working with objects in HDF5 is to:

 

  • Open the object.
  • Access the object.
  • Close the object.

 

The library imposes an order on the operations by argument dependencies. For example, a file must be opened before a dataset because the dataset open call requires a file handle as an argument. Objects can be closed in any order. However, once an object is closed it no longer can be accessed.

...

  • C routines begin with the prefix “H5H5*” where * is a single letter indicating the object on which the operation is to be performed.  FORTRAN routines are similar; they begin with “h5h5*” and end with “_f”f. For example:

 

            File Interface:              H5Fopen (C) and h5fopen_f (FORTRAN)

            Dataset Interface:             H5Dopen (C) and h5fdopen h5dopen_f (FORTRAN)

            Dataspace interface:   H5Sclose (C) and h5sclose_f (FORTRAN)

 

The HDF5 Python APIs use methods associated with specific objects.

 

  • For portability, the HDF5 library has its own defined types.  Some common types that you will see in the example code are:

 

...

hid_t is used for object handles

                        hsize_t is used for dimensions

                        herr_tis used for many return values

...

  • Language specific files must be included in applications:

Python:            Add

...

import h5py” / “import numpy

C:                     Add

...

#include hdf5.

...

h

...

FORTRAN:       Add

...

USE HDF5" and call h5open_f and h5close_f to initialize and close the HDF5 FORTRAN  interface

 

Steps to create a file:

To create an HDF5 file you must:

...