Skip to content

Commit

Permalink
HDF5: Fix chunking warning (AMReX-Codes#4033) (AMReX-Codes#4034)
Browse files Browse the repository at this point in the history
## Summary
Fixes AMReX-Codes#4033, where chunk value is read regardless of storage format.

## Checklist

The proposed changes:
- [x] fix a bug or incorrect behavior in AMReX
- [ ] add new capabilities to AMReX
- [ ] changes answers in the test suite to more than roundoff level
- [ ] are likely to significantly affect the results of downstream AMReX
users
- [ ] include documentation in the code and/or rst files, if appropriate
  • Loading branch information
arnav-singhal authored Jul 17, 2024
1 parent dcb9cc0 commit 8b3ffe6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
17 changes: 10 additions & 7 deletions Src/Extern/HDF5/AMReX_ParticleHDF5.H
Original file line number Diff line number Diff line change
Expand Up @@ -765,9 +765,11 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
/* #endif */

hsize_t chunk_size;
if (H5Pget_chunk(dcpl_int, 1, &chunk_size) > -1) {
if ((int)chunk_size > total_int_size) {
H5Pset_chunk(dcpl_int, 1, &total_int_size);
if (H5Pget_layout(dcpl_int) == H5D_CHUNKED) {
if (H5Pget_chunk(dcpl_int, 1, &chunk_size) > -1) {
if ((int)chunk_size > total_int_size) {
H5Pset_chunk(dcpl_int, 1, &total_int_size);
}
}
}

Expand Down Expand Up @@ -806,10 +808,11 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
}
}
#endif

if (H5Pget_chunk(dcpl_real, 1, &chunk_size) > -1) {
if ((int)chunk_size > total_real_size) {
H5Pset_chunk(dcpl_real, 1, &total_real_size);
if (H5Pget_layout(dcpl_real) == H5D_CHUNKED) {
if (H5Pget_chunk(dcpl_real, 1, &chunk_size) > -1) {
if ((int)chunk_size > total_real_size) {
H5Pset_chunk(dcpl_real, 1, &total_real_size);
}
}
}

Expand Down
20 changes: 12 additions & 8 deletions Src/Extern/HDF5/AMReX_PlotFileUtilHDF5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,10 +720,12 @@ void WriteMultiLevelPlotfileHDF5SingleDset (const std::string& plotfilename,
#endif

// Force maximum chunk size to be size of write
hsize_t chunk_size;
if (H5Pget_chunk(lev_dcpl_id, 1, &chunk_size) > -1) {
if ((int)chunk_size > hs_allprocsize[0]) {
H5Pset_chunk(lev_dcpl_id, 1, hs_allprocsize);
if (H5Pget_layout(lev_dcpl_id) == H5D_CHUNKED) {
hsize_t chunk_size;
if (H5Pget_chunk(lev_dcpl_id, 1, &chunk_size) > -1) {
if ((int)chunk_size > hs_allprocsize[0]) {
H5Pset_chunk(lev_dcpl_id, 1, hs_allprocsize);
}
}
}

Expand Down Expand Up @@ -1190,10 +1192,12 @@ void WriteMultiLevelPlotfileHDF5MultiDset (const std::string& plotfilename,
hid_t dataspace = H5Screate_simple(1, hs_allprocsize, NULL);
snprintf(dataname, sizeof dataname, "data:datatype=%d", jj);
// Force maximum chunk size to be size of write
hsize_t chunk_size;
if (H5Pget_chunk(lev_dcpl_id, 1, &chunk_size) > -1) {
if ((int)chunk_size > hs_allprocsize[0]) {
H5Pset_chunk(lev_dcpl_id, 1, hs_allprocsize);
if (H5Pget_layout(lev_dcpl_id) == H5D_CHUNKED) {
hsize_t chunk_size;
if (H5Pget_chunk(lev_dcpl_id, 1, &chunk_size) > -1) {
if ((int)chunk_size > hs_allprocsize[0]) {
H5Pset_chunk(lev_dcpl_id, 1, hs_allprocsize);
}
}
}
#ifdef AMREX_USE_HDF5_ASYNC
Expand Down

0 comments on commit 8b3ffe6

Please sign in to comment.