For further information on datatypes, see The Datatype Interface (H5T) in the HDF5 User's Guide, in addition to the Datatypes tutorial topic.
Fig 5.1 HDF5 datatypes
The High Level HDF5 Lite APIs (H5LT) include functions that simplify and condense the steps for creating datasets in HDF5. The examples in the following section use the standard APIs. For a quick start you may prefer to look at the HDF5 Lite APIs at this time.
If you plan to work with images, please look at the High Level HDF5 Image APIs (H5IM), as well.
The following example shows how to create an empty dataset. It creates a file called
dset.h5 in the C version (
dsetf.h5 in Fortran), defines the dataset dataspace, creates a dataset which is a 4x6 integer array, and then closes the dataspace, the dataset, and the file:
See HDF5 Introductory Examples for the examples used in the Learning the Basics tutorial. There are examples for several other languages, including Java.
For details on compiling an HDF5 application: [ Compile Information ]
C: dataspace_id = H5Screate_simple (rank, dims, maxdims); status = H5Sclose (dataspace_id ); FORTRAN: CALL h5screate_simple_f (rank, dims, dataspace_id, hdferr, maxdims=max_dims) or CALL h5screate_simple_f (rank, dims, dataspace_id, hdferr) CALL h5sclose_f (dataspace_id, hdferr)
H5Dcreate / h5dcreateH5D_fCREATE creates an empty dataset at the specified location and returns a dataset identifier.
H5Dclose / h5dcloseH5D_fCLOSE closes the dataset and releases the resource used by the dataset. This call is mandatory.
CALL h5open_f (hdferr) CALL h5close_f (hdferr)