diff --git a/source/adios2/toolkit/format/bp/bp4/BP4Serializer.cpp b/source/adios2/toolkit/format/bp/bp4/BP4Serializer.cpp index ed394632f5..277063ee53 100644 --- a/source/adios2/toolkit/format/bp/bp4/BP4Serializer.cpp +++ b/source/adios2/toolkit/format/bp/bp4/BP4Serializer.cpp @@ -958,12 +958,10 @@ void BP4Serializer::AggregateCollectiveMetadataIndices(helper::Comm const &comm, const uint64_t variablesIndexStart = position; ptrs.push_back(variablesIndexStart); - if (!varIndicesInfo.empty()) + const auto itvars = varIndicesInfo.find(t); + if (itvars != varIndicesInfo.end()) { - - std::unordered_map>> - perStepVarIndicesInfo = varIndicesInfo.at(t); + const auto perStepVarIndicesInfo = itvars->second; size_t perStepVarCountPosition = position; const uint32_t perStepVarCountU32 = static_cast(perStepVarIndicesInfo.size()); @@ -1026,11 +1024,10 @@ void BP4Serializer::AggregateCollectiveMetadataIndices(helper::Comm const &comm, const uint64_t attributesIndexStart = position; ptrs.push_back(attributesIndexStart); - if (!attrIndicesInfo.empty()) + const auto itattrs = attrIndicesInfo.find(t); + if (itattrs != attrIndicesInfo.end()) { - std::unordered_map>> - perStepAttrIndicesInfo = attrIndicesInfo.at(t); + const auto perStepAttrIndicesInfo = itattrs->second; size_t perStepAttrCountPosition = position; const uint32_t perStepAttrCountU32 = static_cast(perStepAttrIndicesInfo.size()); diff --git a/testing/adios2/engine/bp/TestBPTimeAggregation.cpp b/testing/adios2/engine/bp/TestBPTimeAggregation.cpp index f93c24f95f..8c66874f65 100644 --- a/testing/adios2/engine/bp/TestBPTimeAggregation.cpp +++ b/testing/adios2/engine/bp/TestBPTimeAggregation.cpp @@ -42,6 +42,8 @@ void TimeAggregation1D8(const std::string flushstepscount) #else adios2::ADIOS adios; #endif + const std::string TestName = + "TimeAggregation1D8 flush every " + flushstepscount + " steps"; { adios2::IO io = adios.DeclareIO("TestIO"); @@ -73,6 +75,8 @@ void TimeAggregation1D8(const std::string flushstepscount) auto var_r32 = io.DefineVariable("r32", shape, start, count); auto var_r64 = io.DefineVariable("r64", shape, start, count); + + io.DefineAttribute("TestName", TestName); } if (!engineName.empty()) @@ -230,6 +234,12 @@ void TimeAggregation1D8(const std::string flushstepscount) ASSERT_EQ(var_r64.Steps(), NSteps); ASSERT_EQ(var_r64.Shape()[0], mpiSize * Nx); + auto attr = io.InquireAttribute("TestName"); + EXPECT_TRUE(attr); + ASSERT_EQ(attr.Data().size() == 1, true); + ASSERT_EQ(attr.Type(), adios2::GetType()); + ASSERT_EQ(attr.Data().front(), TestName); + // TODO: other types SmallTestData testData; @@ -355,6 +365,9 @@ void TimeAggregation2D4x2(const std::string flushstepscount) #else adios2::ADIOS adios; #endif + const std::string TestName = + "TimeAggregation2D4x2 flush every " + flushstepscount + " steps"; + { adios2::IO io = adios.DeclareIO("TestIO"); @@ -387,6 +400,8 @@ void TimeAggregation2D4x2(const std::string flushstepscount) auto var_r32 = io.DefineVariable("r32", shape, start, count); auto var_r64 = io.DefineVariable("r64", shape, start, count); + + io.DefineAttribute("TestName", TestName); } if (!engineName.empty()) @@ -552,6 +567,12 @@ void TimeAggregation2D4x2(const std::string flushstepscount) ASSERT_EQ(var_r64.Shape()[0], Ny); ASSERT_EQ(var_r64.Shape()[1], static_cast(mpiSize * Nx)); + auto attr = io.InquireAttribute("TestName"); + EXPECT_TRUE(attr); + ASSERT_EQ(attr.Data().size() == 1, true); + ASSERT_EQ(attr.Type(), adios2::GetType()); + ASSERT_EQ(attr.Data().front(), TestName); + std::string IString; std::array I8; std::array I16;