From 22146f6ee0aac92b328f071e900a70599ba39222 Mon Sep 17 00:00:00 2001 From: "Martin D. Weinberg" Date: Fri, 27 Mar 2026 11:15:41 -0400 Subject: [PATCH 1/2] Manual cherry pick of chunk logic fix to devel --- src/Component.cc | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/Component.cc b/src/Component.cc index dfcf394e1..c50884ce6 100644 --- a/src/Component.cc +++ b/src/Component.cc @@ -2501,13 +2501,23 @@ void Component::write_HDF5(HighFive::Group& group, bool masses, bool IDs) auto dcplI = HighFive::DataSetCreateProps{}; auto dcplD = HighFive::DataSetCreateProps{}; - if (H5compress or H5chunk) { + // Compression and chunking. Do not set chunk size larger than + // nbodies. Turn off compression altogether if nbodies = 0 to avoid + // HDF5 errors. + // + if ((H5compress or H5chunk) and nbodies > 0) { int chunk = H5chunk; - // Sanity + // Clamp chunk to [1, nbodies]: use nbodies/8 as a downsize when + // H5chunk would exceed the dataset extent, then ensure at least 1 if (H5chunk >= nbodies) { chunk = nbodies/8; } + if (chunk < 1) { + chunk = 1; + } else if (static_cast(chunk) > nbodies) { + chunk = static_cast(nbodies); + } dcpl1.add(HighFive::Chunking(chunk)); if (H5shuffle) dcpl1.add(HighFive::Shuffle()); @@ -2636,14 +2646,20 @@ void Component::write_H5(H5::Group& group) // This could be generalized by registering a user filter, like // blosc. Right now, we're using the default (which is gzip) - if (H5compress or H5chunk) { + // + // Do not set chunk size larger than number of particles. If the + // particle number is zero, do not compress. + // + if ((H5compress or H5chunk) and h5_particles.size() > 0) { // Set chunking if (H5chunk) { - // Sanity + // Clamp chunk to [1, nbodies]: use nbodies/8 as a downsize when + // H5chunk would exceed the dataset extent, then ensure at least 1 int chunk = H5chunk; if (H5chunk >= nbodies) { chunk = nbodies/8; } + chunk = std::clamp(chunk, 1, static_cast(nbodies)); hsize_t chunk_dims[1] = {static_cast(chunk)}; dcpl.setChunk(1, chunk_dims); } From 1952df71ab4641f010c7ae5a446a8811652da5ae Mon Sep 17 00:00:00 2001 From: "Martin D. Weinberg" Date: Fri, 27 Mar 2026 12:14:43 -0400 Subject: [PATCH 2/2] Version bump for bug fix --- CMakeLists.txt | 2 +- doc/exp.cfg | 2 +- doc/exp.cfg.breathe | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e2d49dba5..9d3dd2947 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.25) # Needed for CUDA, MPI, and CTest features project( EXP - VERSION "7.10.1" + VERSION "7.10.2" HOMEPAGE_URL https://github.com/EXP-code/EXP LANGUAGES C CXX Fortran) diff --git a/doc/exp.cfg b/doc/exp.cfg index d6a169162..c930e7812 100644 --- a/doc/exp.cfg +++ b/doc/exp.cfg @@ -48,7 +48,7 @@ PROJECT_NAME = EXP # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 7.10.1 +PROJECT_NUMBER = 7.10.2 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/doc/exp.cfg.breathe b/doc/exp.cfg.breathe index 95375995d..96b4b616b 100644 --- a/doc/exp.cfg.breathe +++ b/doc/exp.cfg.breathe @@ -48,7 +48,7 @@ PROJECT_NAME = EXP # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 7.10.1 +PROJECT_NUMBER = 7.10.2 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a