Skip to content

Commit 04dd76a

Browse files
committed
Fix ADIOS2 checks for multidimensional joined arrays
1 parent d586f89 commit 04dd76a

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -446,21 +446,35 @@ class ADIOS2IOHandlerImpl
446446
}
447447
}
448448
auto joinedDim = joinedDimension(shape);
449-
for (unsigned int i = 0; i < actualDim; i++)
449+
if (joinedDim.has_value())
450450
{
451-
if (!(joinedDim.has_value() && *joinedDim == i) &&
452-
offset[i] + extent[i] > shape[i])
451+
if (!offset.empty())
453452
{
454453
throw std::runtime_error(
455-
"[ADIOS2] Dataset access out of bounds.");
454+
"[ADIOS2] Offset must be an empty vector in case of joined "
455+
"array.");
456+
}
457+
for (unsigned int i = 0; i < actualDim; i++)
458+
{
459+
if (*joinedDim != i && extent[i] != shape[i])
460+
{
461+
throw std::runtime_error(
462+
"[ADIOS2] store_chunk extent of non-joined dimensions "
463+
"must be equivalent to the total extent.");
464+
}
456465
}
457466
}
458-
459-
if (joinedDim.has_value() && !offset.empty())
467+
else
460468
{
461-
throw std::runtime_error(
462-
"[ADIOS2] Offset must be an empty vector in case of joined "
463-
"array.");
469+
for (unsigned int i = 0; i < actualDim; i++)
470+
{
471+
if (!(joinedDim.has_value() && *joinedDim == i) &&
472+
offset[i] + extent[i] > shape[i])
473+
{
474+
throw std::runtime_error(
475+
"[ADIOS2] Dataset access out of bounds.");
476+
}
477+
}
464478
}
465479

466480
var.SetSelection(

0 commit comments

Comments
 (0)