CRC Wiki
CRC Wiki
Log in


From CRC Wiki

General Description

HDF5 is a data model, library, and file format for storing and managing data. It supports an unlimited variety of datatypes, and is designed for flexible and efficient I/O and for high volume and complex data. HDF5 is portable and is extensible, allowing applications to evolve in their use of HDF5. The HDF5 Technology suite includes tools and applications for managing, manipulating, viewing, and analyzing data in the HDF5 format.

Note: There are two HDF formats, HDF (4.x and previous releases) and HDF5. These formats are completely different and NOT compatible, but conversion software is available for converting HDF4 data to HDF5, and vice versa.

Basic Usage

HDF5 can be incorporated into source code by calling HDF5 library routines. A simple example of creating a dataset is given below. Please see the HDF5 website for more complete details.

C - Example

#define FILE "file.h5"

int main() {

 hid_t       file_id;   /* file identifier */
 herr_t      status;

 /* Create a new file using default properties. */
 file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);

 /* Terminate access to the file. */
 status = H5Fclose(file_id);

Fortran - Example


    USE HDF5 ! This module contains all necessary modules 

    CHARACTER(LEN=8), PARAMETER :: filename = "filef.h5" ! File name
    INTEGER(HID_T) :: file_id                            ! File identifier
    INTEGER     ::   error  ! Error flag
    !    Initialize FORTRAN interface.
    CALL h5open_f (error)
    ! Create a new file using default properties.
    CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error)

    ! Terminate access to the file.
    CALL h5fclose_f(file_id, error)

    !    Close FORTRAN interface.

    CALL h5close_f(error)


Compiling HDF5 Applications

To compile HDF5 applications use the following command line environment variables:

icc -I$HDF5_INC -o foo foo.c $HDF5_LIBS

Further Information

See the official website: HDF5