From b353f8ed9263549ce5a29aeaf73ace85d1702602 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 3 May 2021 15:20:59 +0200 Subject: [PATCH] workaround for HDF5: https://forum.hdfgroup.org/t/6186 writing chunked/compressed data can cause problems with MPI. Even though not 100% clear from the reference, it seems that the issue only appears for HDF5 < 1.12. Of special importance for Ubuntu since the Debian package is still at 1.10.6 --- src/HDF5_utilities.f90 | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/HDF5_utilities.f90 b/src/HDF5_utilities.f90 index ce00c4913..4ec7b8ea9 100644 --- a/src/HDF5_utilities.f90 +++ b/src/HDF5_utilities.f90 @@ -1775,7 +1775,7 @@ subroutine initialize_write(dset_id, filespace_id, memspace_id, plist_id, & integer, dimension(worldsize) :: writeSize !< contribution of all processes integer(HID_T) :: dcpl - integer :: ierr, hdferr + integer :: ierr, hdferr, HDF5_major, HDF5_minor, HDF5_release integer(HSIZE_T), parameter :: chunkSize = 1024_HSIZE_T**2/8_HSIZE_T !------------------------------------------------------------------------------------------------- @@ -1808,14 +1808,18 @@ subroutine initialize_write(dset_id, filespace_id, memspace_id, plist_id, & call h5pcreate_f(H5P_DATASET_CREATE_F, dcpl, hdferr) if(hdferr < 0) error stop 'HDF5 error' if(product(totalShape) >= chunkSize*2_HSIZE_T) then - call h5pset_chunk_f(dcpl, size(totalShape), getChunks(totalShape,chunkSize), hdferr) - if(hdferr < 0) error stop 'HDF5 error' - call h5pset_shuffle_f(dcpl, hdferr) - if(hdferr < 0) error stop 'HDF5 error' - call h5pset_deflate_f(dcpl, 6, hdferr) - if(hdferr < 0) error stop 'HDF5 error' - call h5pset_Fletcher32_f(dcpl,hdferr) - if(hdferr < 0) error stop 'HDF5 error' + call H5get_libversion_f(HDF5_major,HDF5_minor,HDF5_release,hdferr) + if (hdferr < 0) error stop 'HDF5 error' + if (HDF5_major == 1 .and. HDF5_minor >= 12) then ! https://forum.hdfgroup.org/t/6186 + call h5pset_chunk_f(dcpl, size(totalShape), getChunks(totalShape,chunkSize), hdferr) + if (hdferr < 0) error stop 'HDF5 error' + call h5pset_shuffle_f(dcpl, hdferr) + if (hdferr < 0) error stop 'HDF5 error' + call h5pset_deflate_f(dcpl, 6, hdferr) + if (hdferr < 0) error stop 'HDF5 error' + call h5pset_Fletcher32_f(dcpl,hdferr) + if (hdferr < 0) error stop 'HDF5 error' + endif endif !--------------------------------------------------------------------------------------------------