External Links:
HDF5 support page
HDF5: Examples from Learning The Basics
Here is an example C code that uses the HDF5 library from the HDF5 support website.
To avoid copy/paste errors when using, please copy this from the apps directory:
/usr/local/apps/examples/code/hdf5
To put the HDF5 libraries in the path for Intel, use
module load hdf5/1.10.2-intel2017
-lhdf5
to include the library and use -I/usr/local/apps/hdf-centos7/hdf5/v1.10.2/include
to include the header files.
To test linking HDF5 with the Intel compiler, compile the example code above, run it, and check that it creates a properly formatted HDF5 file. (Note that normally code should never be run on a login node; this small test is an exception.)
[unityID@login]$ cp -r /usr/local/apps/examples/code/hdf5 . [unityID@login]$ cd hdf5 [unityID@login]$ module purge [unityID@login]$ module load hdf5/1.10.2-intel2017 [unityID@login]$ mpicc -o test_hdf5_intel h5_crtdat.c -lhdf5 -I/usr/local/apps/hdf-centos7/hdf5/v1.10.2/include [unityID@login]$ ./test_hdf5_intel [unityID@login]$ file dset.h5 dset.h5: Hierarchical Data Format (version 5) dataHere, the MPI compile wrapper (mpicc) is necessary because the HDF5 includes an MPI header file.
To put the HDF libraries in the path for GNU, use
module load hdf5/1.10.5-gcc4.8.5
-lhdf5
to include the library and use -I/usr/local/apps/hdf-centos7/hdf5/v1.10.5-gcc4.8.5/include
to include the header files.
To test linking HDF5 with the GNU compiler, compile the example code above, run it, and check that it creates a properly formatted HDF5 file. (Note that normally code should never be run on a login node; this small test is an exception.)
[unityID@login]$ cp -r /usr/local/apps/examples/code/hdf5 . [unityID@login]$ cd hdf5 [unityID@login]$ module purge [unityID@login]$ module load hdf5/1.10.5-gcc4.8.5 [unityID@login]$ gcc -o test_hdf5 h5_crtdat.c -lhdf5 -I/usr/local/apps/hdf-centos7/hdf5/v1.10.5-gcc4.8.5/include [unityID@login]$ ./test_hdf5 [unityID@login]$ file dset.h5 dset.h5: Hierarchical Data Format (version 5) dataHere, HDF5 was also compiled with MPI, but the MPI compile wrapper (mpicc) is not necessary. The code will correctly compile with mpicc as well.
HDF5 modules include the MPI libraries (IntelMPI for Intel, and OpenMPI for GNU). After loading the HDF5 module, type module list
for the list of other included modules. To use HDF5 with another code, the MPI libraries must be the same.
HDF5 was compiled with the following compiler flags. Intel was compiled similarly but with a different prefix.
HDF5: ./configure --prefix=/usr/local/apps/hdf-centos7/hdf5/v1.10.5-gcc4.8.5 --enable-hl --enable-parallelIf an application requires the HDF5 libraries/modules to be compiled with different flags, the user must install a custom version under a space for user maintained software.
Last modified: May 24 2024 12:31:32.