This project demonstrates parallel writing to an HDF5 file using MPI and the HDF5 C++ API, and includes a verification step to validate the written data.
main.cpp
: Uses MPI to run multiple processes, each writing its rank to a shared HDF5 dataset (rank_data
) in parallel using collective I/O.verify.cpp
: Reads the resulting HDF5 file and verifies that each rank wrote the correct value.CMakeLists.txt
: CMake configuration to build both programs and run tests.
- CMake ≥ 3.20
- MPI (e.g., OpenMPI or MPICH)
- HDF5 with C++ support
mkdir build
cd build
cmake ..
make
This builds the following executables:
hello_mpi_hdf5
: Writes an HDF5 file in parallel using MPI
verify_hdf5
: Verifies the contents of the HDF5 file
You can run the parallel writer manually with a specified number of MPI processes:
mpirun -np 4 ./hello_mpi_hdf5
This will generate a file named parallel_hello.h5, with each process writing its rank to the dataset.
Then run the verifier:
./verify_hdf5
It will read the file and confirm that the data is correct.
You may provide a custom filename as the first argument:
mpirun -np 4 ./hello_mpi_hdf5 my_output_file.h5
You can run the built-in CMake tests using:
ctest --output-on-failure --verbose
This performs:
- A 4-process MPI run that writes the file.
- A verification step to ensure the output is correct.
To install the executables:
make install
They will be placed in your system's binary directory (e.g., /usr/local/bin
or ${CMAKE_INSTALL_PREFIX}/bin
).
This project is licensed under the GNU General Public License v3.0 (GPL-3.0).
See the LICENSE file for full license text.