Miscellaneous Example Programs
These examples resulted from working with users,
and have only been tried on one or two platforms. They have NOT
been fully tested.
Most of these examples are in C and were created with HDF5 1.6 or earlier.
They can be compiled with the 1.8 library* by using the option:
-D H5_USE_16_API
*Unless your HDF5 1.8 library was configured with the
--disable-deprecated-symbols option.
Contents:
Attributes:
Datasets:
- Datatypes - Datasets with different datatypes
- Dynamic arrays for reading/writing data:
- Moving a Dataset
- Read in data in exponential form that is of type double,
and write out to an HDF5 file:
crtc64.c
coordinates.txt - Text file read in
- Reading in data from text file (originally an
HDF 4.x raster image, dumped with hdp), and write
that out as an HDF5 file:
h5_ri.c
storm110.txt - Text file
- Read in floating point data from a text file
and write that out as an HDF5 file:
h5float.c
float.txt - Text file
- Split Files: create a dataset in which the data is in
a separate directory from the metadata:
h5dirsplit.c
- Unlimited Dimension Dataset (loop by slabs):
appslab.c
uslab.c - Similar to appslab.c, but uses H5Pset_buffer
- Write to Finite Dimension Dataset by slabs:
wrtslab.c
- Writing to 4D dataset by slab and how can have performance issue:
h5pmem.c
Dataspaces:
- How to use selections in memory and file dataspaces (see H5Dwrite in RM):
h5_write_sel.c
- These are example programs that you can use to experiment with
hyperslab selections for simple 1 and 2-Dimensional Datasets:
Datatypes:
File:
Groups:
Identifiers: (H5I)
Properties: (H5P)
References:
- h5ref.c - How to get information about a
dereferenced object.
- h5ref2d.c - call H5Sget_select_hyper_blocklist
for 2D dataset
- h5ref3d.c - call H5Sget_select_hyper_blocklist
for 3D dataset
Fortran:
- Example code
from the Belgian Institute for Space Astronomy of reading HDF5 files with Fortran.
- There are a few other example programs under Datatypes. Search
for "F90".
Parallel:
- If you are having problems building/using Parallel HDF5, here are
some handy sample programs that you can run to be sure that MPI I/O
is installed properly on your machine for use with HDF5:
Sample MPI programs
- The following examples show how to write data collectively and
independently when one process doesn't have data or does not need to write
data.
- coll_test.c - Uses H5Sset_none to tell
H5Dwrite call that there will be no data. 4-th process HAS to participate
since we are in a collective mode.
- ind_test.c - Specifies which process writes data. H5Dwrite is not called by
the 4-th process at all in this case; this approach will work only when
independent mode is used.