Skip to content

Commit aafe37e

Browse files
dqwujayeshkrishna
authored andcommitted
Adding a configure option for HDF5/PnetCDF chunked variables
For HDF5 type, record variables are currently chunked using the full dimension length. With very large dimensions, this can cause dataset creation to fail in the HDF5 library. Introduce a configure option to set the chunk size (in bytes) for HDF5/PnetCDF chunked variables, with a default of 4 MB.
1 parent 399bec9 commit aafe37e

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,20 @@ else()
229229
message(STATUS "Reserving some extra space in the header when creating NetCDF files, requested bytes = " ${PIO_RESERVED_FILE_HEADER_SIZE} " (default)")
230230
endif()
231231

232+
# Set chunk size (in bytes) for HDF5/PnetCDF chunked variables. Default is 4 MB, same as NetCDF4.
233+
set(DEF_SPIO_CHUNK_SIZE 4194304)
234+
if(DEFINED PIO_CHUNK_SIZE)
235+
if(PIO_CHUNK_SIZE GREATER_EQUAL 1)
236+
message(STATUS "Setting chunk size (in bytes) for HDF5/PnetCDF chunked variables, requested bytes = " ${PIO_CHUNK_SIZE})
237+
else()
238+
message(WARNING "User-defined PIO_CHUNK_SIZE is invalid, setting it to " ${DEF_SPIO_CHUNK_SIZE} " (default)")
239+
set(PIO_CHUNK_SIZE ${DEF_SPIO_CHUNK_SIZE})
240+
endif()
241+
else()
242+
set(PIO_CHUNK_SIZE ${DEF_SPIO_CHUNK_SIZE})
243+
message(STATUS "Setting chunk size (in bytes) for HDF5/PnetCDF chunked variables, requested bytes = " ${PIO_CHUNK_SIZE} " (default)")
244+
endif()
245+
232246
if(WITH_ADIOS2)
233247
# Maximum number of I/O decompositions registered with ADIOS type
234248
set(DEF_SPIO_MAX_ADIOS_DECOMPS 65536)

src/clib/pio_config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@
5555
/** Extra bytes reserved in the header when creating NetCDF files. */
5656
#define PIO_RESERVED_FILE_HEADER_SIZE @PIO_RESERVED_FILE_HEADER_SIZE@
5757

58+
/** Set chunk size (in bytes) for HDF5/PnetCDF chunked variables. */
59+
#define PIO_CHUNK_SIZE @PIO_CHUNK_SIZE@
60+
5861
/** Maximum number of I/O decompositions registered with ADIOS type */
5962
#define PIO_MAX_ADIOS_DECOMPS @PIO_MAX_ADIOS_DECOMPS@
6063

0 commit comments

Comments
 (0)