An HDF5 file is a binary file which contains scientific data and supporting metadata. The two primary objects stored in an HDF5 file are groups and datasets. Groups and datasets will be discussed in the other sessions.
To create a file, the program application must specify a file name, file access mode, file creation property list, and file access property list.
The user-block is a fixed length block of data located at the beginning of the file which is ignored by the HDF5 library and may be used to store any data information found to be useful to applications.
For more details, see the HDF5 documentation. In this tutorial, the default file metadata is used.
The steps to create and close an HDF5 file are as follows:
file_id = H5Fcreate(filename, access_mode, create_id, access_id); H5Fclose(file_id);
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #include <hdf5.h> #define FILE "file.h5" 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); } +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
hid_t H5Fcreate (const char *name, unsigned flags, hid_t create_id, hid_t access_id)
herr_t H5Fclose (hid_t file_id)
h5dump <filename>Figure 4.1 describes the file contents of 'file.h5' using a directed graph. Each HDF5 object is represented by a rectangle and the arrows indicate the structure of the contents. In Fig. 4.2, 'file.h5' contains a group object named '/' (the root group).
Fig. 4.1 Contents of 'file.h5'
Figure 4.2 is the text-description of 'file.h5' generated by h5dump. The HDF5 file called 'file.h5' contains a group called '/'.
Fig. 4.2 'file.h5' in DDL
HDF5 "file.h5" { GROUP "/" { } }
Fig. 4.3 HDF5 File Definition
The explanation of the symbols used in the DDL:
::= defined as <tname> a token with the name tname <a> | <b> one of <a> or <b> <a>* zero or more occurrences of <a>The simplified DDL file definition:
<file> ::= HDF5 "<file_name>" { <root_group> } <root_group> ::= GROUP "/" { <group_attribute>* <group_member>* } <group_attribute> ::= <attribute> <group_member> ::= <group> | <dataset>