@@ -489,14 +489,22 @@ class ADIOS2IOHandlerImpl
489489 }
490490 }
491491 auto joinedDim = joinedDimension (shape);
492- if (joinedDim.has_value ())
492+ if (joinedDim.has_value () ||
493+ var.ShapeID () == adios2::ShapeID::JoinedArray)
493494 {
494495 if (!offset.empty ())
495496 {
496497 throw std::runtime_error (
497498 " [ADIOS2] Offset must be an empty vector in case of joined "
498499 " array." );
499500 }
501+ if (!joinedDim.has_value ())
502+ {
503+ throw std::runtime_error (
504+ " [ADIOS2] Trying to access a dataset as a non-joined "
505+ " array, but it has previously been configured as a joined "
506+ " array." );
507+ }
500508 for (unsigned int i = 0 ; i < actualDim; i++)
501509 {
502510 if (*joinedDim != i && extent[i] != shape[i])
@@ -509,35 +517,16 @@ class ADIOS2IOHandlerImpl
509517 }
510518 else
511519 {
512- if (var. ShapeID () == adios2::ShapeID::JoinedArray )
520+ for ( unsigned int i = 0 ; i < actualDim; i++ )
513521 {
514- // When you reach here due to a mysterious inconsistency
515- // observed from time to time e.g.
516- // adios2::JoinedDim=(~(size_t)0) which for 64 bits =
517- // 18446744073709551615 but the particle shape, when printed
518- // out, turns out to be [18446744073709551614]
519- //
520- if (!offset.empty ())
522+ if (!(joinedDim.has_value () && *joinedDim == i) &&
523+ offset[i] + extent[i] > shape[i])
521524 {
522525 throw std::runtime_error (
523- " [ADIOS2] Offset must be an empty vector in case of "
524- " joined "
525- " array." );
526+ " [ADIOS2] Dataset access out of bounds." );
526527 }
527528 }
528- else
529- {
530- for (unsigned int i = 0 ; i < actualDim; i++)
531- {
532- if (!(joinedDim.has_value () && *joinedDim == i) &&
533- offset[i] + extent[i] > shape[i])
534- {
535- throw std::runtime_error (
536- " [ADIOS2] Dataset access out of bounds." );
537- }
538- }
539- } // else
540- }
529+ } // else
541530
542531 var.SetSelection (
543532 {adios2::Dims (offset.begin (), offset.end ()),
0 commit comments