@@ -888,6 +888,57 @@ namespace detail
888888 {
889889 dims.push_back (ext);
890890 }
891+ auto joinedDim = joinedDimension (var.Shape ());
892+ auto make_runtime_error = [&](char const *message) {
893+ std::stringstream s;
894+ s << " [ADIOS2IOHandlerImpl::extendDataset()] " << message
895+ << " \n Note: Variable '" << variable << " ' has old shape " ;
896+ auxiliary::write_vec_to_stream (s, var.Shape ());
897+ if (joinedDim.has_value ())
898+ {
899+ s << " (joined dimension on index " << *joinedDim << " )." ;
900+ }
901+ else
902+ {
903+ s << " (no joined dimension)" ;
904+ }
905+ s << " and is extended to new shape " ;
906+ auxiliary::write_vec_to_stream (s, newShape) << " ." ;
907+ return std::runtime_error (s.str ());
908+ };
909+ if (joinedDim.has_value () ||
910+ var.ShapeID () == adios2::ShapeID::JoinedArray)
911+ {
912+ if (!joinedDim.has_value ())
913+ {
914+ throw make_runtime_error (
915+ " Inconsistent state of variable: Has shape ID "
916+ " JoinedArray, but its shape contains no value "
917+ " adios2::JoinedDim." );
918+ }
919+ if (newShape.at (*joinedDim) != Dataset::JOINED_DIMENSION)
920+ {
921+ throw make_runtime_error (
922+ " Variable was previously configured with a joined "
923+ " dimension, so the new dataset extent must keep the "
924+ " joined dimension on that index." );
925+ }
926+ dims[*joinedDim] = adios2::JoinedDim;
927+ }
928+ else
929+ {
930+ for (auto s : newShape)
931+ {
932+ if (s == Dataset::JOINED_DIMENSION)
933+ {
934+ throw make_runtime_error (
935+ " Variable was not previously configured with a "
936+ " joined dimension, but is now requested to change "
937+ " extent to a joined array." );
938+ }
939+ }
940+ }
941+
891942 var.SetShape (dims);
892943 }
893944
0 commit comments