![]() |
HDF5 Last Updated on 2025-11-11
The HDF5 Field Guide
|
This file contains instructions for installing parallel HDF5 (PHDF5) using CMake. The document covers:
PHDF5 requires:
You should first consult with your system support staff for information on:
Sample MPI-IO C and Fortran programs are provided in Appendix A. Use them to test your MPI compiler and parallel file system before building HDF5.
When building on HPC systems:
For Cray and other systems with recommend compiler wrappers, set compiler environment variables AFTER loading modules:
For installation help, post questions to the HDF Forum or HDF Support:
Include the output of uname -a and the contents of CMakeCache.txt and CMakeError.log from your build directory, and the loaded modules if applicable.
Obtain HDF5 source code from the HDF5 repository or from a release tar file:
If no branch is specified, the develop branch will be checked out. If no directory is specified, source will be in the hdf5 directory.
For release or snapshot tar files, extract them to your working directory.
Note: When using the ctest automated build method (Section 4), the source directory should be named
hdf5-<version>, where version uses format1.xx.xxor2.xx.xx. Usebin/h5versto determine the version string if needed.
For building with CMake 3.26 or greater using presets:
Note: Standard presets do not enable parallel by default. To enable parallel support, you need to create a custom preset in
CMakeUserPresets.jsonthat sets-DHDF5_ENABLE_PARALLEL=ON, or use the standard CMake build approach below.
For a basic parallel build:
CMake can usually find MPI automatically. To specify explicitly:
Or use MPI compiler wrappers:
| Option | Description |
|---|---|
-DHDF5_ENABLE_PARALLEL=ON | Enable parallel HDF5 (required) |
-DBUILD_SHARED_LIBS=ON | Build shared libraries |
-DBUILD_STATIC_LIBS=ON | Build static libraries |
-DHDF5_BUILD_FORTRAN=ON | Build Fortran interface |
-DHDF5_BUILD_CPP_LIB=OFF | C++ disabled in parallel builds |
-DHDF5_ENABLE_THREADSAFE=OFF | Thread safety disabled in parallel builds |
-DHDF5_ENABLE_SUBFILING_VFD=ON | Enable subfiling VFD (parallel I/O optimization) |
-DMPIEXEC_EXECUTABLE=mpiexec | MPI launcher executable |
-DMPIEXEC_NUMPROC_FLAG=-n | MPI flag for number of processes |
-DMPIEXEC_MAX_NUMPROCS=6 | Number of processes for tests |
Note: Some MPI implementations (e.g., OpenMPI 4.0+) disallow oversubscribing by default. Set
MPIEXEC_MAX_NUMPROCSto available processors or fewer, or add appropriate flags (e.g.,--oversubscribefor OpenMPI).
The ctest command provides automated configure, build, test, and package workflow for HPC systems with batch schedulers.
hdf5-<version> (e.g., hdf5-2.0.0)hdf5-<version>/config/cmake/scripts/HDF5config.cmakehdf5-<version>/config/cmake/scripts/CTestScript.cmakehdf5-<version>/config/cmake/scripts/HDF5options.cmakeBasic ctest command:
For parallel builds on HPC systems with batch schedulers:
Add after HDF5config.cmake, separated by commas:
| Option | Description |
|---|---|
HPC=sbatch | Use SLURM batch system |
HPC=bsub | Use LSF batch system |
MPI=true | Enable parallel (disables C++, Java, threadsafe) |
LOCAL_BATCH_SCRIPT_ARGS="--account=<acct>" | Supply batch job account information |
SLURM system with parallel:
Use -VV instead of -V for more detailed logging.
If the automated ctest approach is not suitable, you can manually configure and build HDF5.
Example for parallel build with Fortran on HPC system:
For systems where you can run MPI directly:
For batch systems, create and submit batch scripts (see section 7.3).
Cross-compiling is the process of building software on one system architecture (like a login node) to be run on a different architecture (like a compute node). This section provides a historical overview of how this was done on systems that are no longer in service.
A common historical use case was compiling for Intel Knights Landing (KNL) nodes on Cray XC40 systems, such as the retired Mutrino and Cori machines. These supercomputers had login nodes with a standard CPU architecture (e.g., Haswell) but used the different KNL architecture for their compute nodes.
To build software for KNL, a "module swapping" technique was required. The build process involved:
craype-haswell) to configure the project.craype-mic-knl) before starting the actual compilation.This process was managed by special CMake toolchain files and custom batch scripts, which were often automated within the ctest framework.
The specific hardware (Cray XC40, KNL) and the build procedures described above are historical and no longer in use.
While cross-compilation is less common on many modern, homogeneous HPC clusters, it is still a necessary technique for advanced architectures, such as systems with different processor types or accelerators (e.g., GPUs).
If you need assistance with cross-compiling for a current HPC system, please contact the facility administrators or The HDF Group (Section 1.3).
The parallel test suite (testpar/) contains tests for Parallel HDF5 and MPI-IO.
By default, tests use the current directory for test files. To specify a different location (e.g., parallel file system):
Important: This is critical for performance - avoid using NFS or home directories for parallel testing.
Tests basic MPI-IO features used by Parallel HDF5. Returns non-zero exit code if required features fail.
Exception: Testing files >2GB will print informational messages but not fail, as HDF5 can use alternative file drivers (e.g., family driver) to handle size limits.
Performs many small I/O requests. May run slowly on NFS or other non-parallel file systems. Set HDF5_PARAPREFIX to a parallel file system if this test is slow.
Controls test thoroughness:
Default is 1200 seconds (20 minutes). Modify in CMake with:
For SLURM systems:
For LSF systems:
Batch scripts are generated during CMake configuration in the build directory.
To run specific test suites:
For MPICH on Linux, ensure >2GB file support by configuring MPICH with:
This is available on Linux kernels 2.4 and greater.
CC=cc, FC=ftn, CXX=CC after loading compiler modulescraype-hugepages2M if loaded (Note: This is situational advice and is not a universal rule, but it may be a valid troubleshooting step if you encounter memory-related performance issues or allocation errors.)OpenMPI 4.0+ disallows oversubscribing by default. Either:
MPIEXEC_MAX_NUMPROCS to actual processor count, or--oversubscribe flag: -DMPIEXEC_PREFLAGS=--oversubscribePOSIX Compliant: After a write() to a regular file has successfully returned, any successful read() from each byte position modified by that write() will return the data that was written. A subsequent write() to the same byte will overwrite the file data. If a read() can be proven by any means [e.g., MPI_Barrier()] to occur after a write() of that data, it must reflect that write(), even if calls are made by different processes.
Lewin, D. (1994). "POSIX Programmer's Guide (pg. 513-4)". O'Reilly & Associates.
Here are sample MPI-IO C and Fortran programs to test your MPI compiler and parallel file system before building HDF5. The programs assume they run in a parallel file system (create test files in current directory). For more examples, please refer to the following directories: HDF5Examples/C/H5PAR and HDF5Examples/FORTRAN/H5PAR