@@ -873,7 +873,10 @@ namespace detail
873873 {
874874 template <typename T, typename ... Args>
875875 static void call (
876- adios2::IO &IO, std::string const &variable, Extent const &newShape)
876+ adios2::IO &IO,
877+ std::string const &variable,
878+ Extent const &newShape,
879+ std::optional<size_t > const &newJoinedDim)
877880 {
878881 auto var = IO.InquireVariable <T>(variable);
879882 if (!var)
@@ -888,54 +891,60 @@ namespace detail
888891 {
889892 dims.push_back (ext);
890893 }
891- auto joinedDim = joinedDimension (var.Shape ());
894+ auto oldJoinedDim = joinedDimension (var.Shape ());
892895 auto make_runtime_error = [&](char const *message) {
893896 std::stringstream s;
894897 s << " [ADIOS2IOHandlerImpl::extendDataset()] " << message
895898 << " \n Note: Variable '" << variable << " ' has old shape " ;
896899 auxiliary::write_vec_to_stream (s, var.Shape ());
897- if (joinedDim .has_value ())
900+ if (oldJoinedDim .has_value ())
898901 {
899- s << " (joined dimension on index " << *joinedDim << " ). " ;
902+ s << " (joined dimension on index " << *oldJoinedDim << " )" ;
900903 }
901904 else
902905 {
903906 s << " (no joined dimension)" ;
904907 }
905908 s << " and is extended to new shape " ;
906- auxiliary::write_vec_to_stream (s, newShape) << " ." ;
909+ auxiliary::write_vec_to_stream (s, newShape);
910+ if (newJoinedDim.has_value ())
911+ {
912+ s << " (joined dimension on index " << *newJoinedDim
913+ << " )." ;
914+ }
915+ else
916+ {
917+ s << " (no joined dimension)." ;
918+ }
907919 return std::runtime_error (s.str ());
908920 };
909- if (joinedDim .has_value () ||
921+ if (oldJoinedDim .has_value () ||
910922 var.ShapeID () == adios2::ShapeID::JoinedArray)
911923 {
912- if (!joinedDim .has_value ())
924+ if (!oldJoinedDim .has_value ())
913925 {
914926 throw make_runtime_error (
915927 " Inconsistent state of variable: Has shape ID "
916928 " JoinedArray, but its shape contains no value "
917929 " adios2::JoinedDim." );
918930 }
919- if (newShape. at (*joinedDim) != Dataset::JOINED_DIMENSION )
931+ if (newJoinedDim != oldJoinedDim )
920932 {
921933 throw make_runtime_error (
922934 " Variable was previously configured with a joined "
923935 " dimension, so the new dataset extent must keep the "
924936 " joined dimension on that index." );
925937 }
926- dims[*joinedDim ] = adios2::JoinedDim;
938+ dims[*newJoinedDim ] = adios2::JoinedDim;
927939 }
928940 else
929941 {
930- for ( auto s : newShape )
942+ if (newJoinedDim. has_value () )
931943 {
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- }
944+ throw make_runtime_error (
945+ " Variable was not previously configured with a "
946+ " joined dimension, but is now requested to change "
947+ " extent to a joined array." );
939948 }
940949 }
941950
@@ -958,7 +967,7 @@ void ADIOS2IOHandlerImpl::extendDataset(
958967 auto &filedata = getFileData (file, IfFileNotOpen::ThrowError);
959968 Datatype dt = detail::fromADIOS2Type (filedata.m_IO .VariableType (name));
960969 switchAdios2VariableType<detail::DatasetExtender>(
961- dt, filedata.m_IO , name, parameters.extent );
970+ dt, filedata.m_IO , name, parameters.extent , parameters. joinedDimension );
962971}
963972
964973void ADIOS2IOHandlerImpl::openFile (
0 commit comments