From 18fc18431173ca48736784d30394a4dddae9cd2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Tue, 11 Jun 2024 18:31:59 +0200 Subject: [PATCH] Test reading --- include/openPMD/IO/ADIOS/macros.hpp | 5 +++ test/SerialIOTest.cpp | 56 +++++++++++++++-------------- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/include/openPMD/IO/ADIOS/macros.hpp b/include/openPMD/IO/ADIOS/macros.hpp index 4e5f223e44..8618573713 100644 --- a/include/openPMD/IO/ADIOS/macros.hpp +++ b/include/openPMD/IO/ADIOS/macros.hpp @@ -22,6 +22,11 @@ #define openPMD_HAS_ADIOS_2_10 \ (ADIOS2_VERSION_MAJOR * 100 + ADIOS2_VERSION_MINOR >= 210) +#define openPMD_HAS_ADIOS_2_10_1 \ + (ADIOS2_VERSION_MAJOR * 1000 + ADIOS2_VERSION_MINOR * 10 + \ + ADIOS2_VERSION_PATCH >= \ + 2101) + #if defined(ADIOS2_HAVE_BP5) || openPMD_HAS_ADIOS_2_10 // ADIOS2 v2.10 no longer defines this #define openPMD_HAVE_ADIOS2_BP5 1 diff --git a/test/SerialIOTest.cpp b/test/SerialIOTest.cpp index ba164885a9..65c1b7b584 100644 --- a/test/SerialIOTest.cpp +++ b/test/SerialIOTest.cpp @@ -4439,39 +4439,43 @@ BufferChunkSize = 2147483646 # 2^31 - 2 TEST_CASE("adios2_flush_via_step") { - for (auto const suffix : {"bp4", "bp5"}) + Series write( + "../samples/adios2_flush_via_step/simData_%T.bp5", + Access::CREATE, + R"(adios2.engine.parameters.FlattenSteps = "on")"); + std::vector data(10); + for (Iteration::IterationIndex_t i = 0; i < 5; ++i) { - Series write( - "../samples/adios2_flush_via_step/simData_%T." + - std::string(suffix), - Access::CREATE); - std::vector data(10); - for (Iteration::IterationIndex_t i = 0; i < 5; ++i) + Iteration it = write.writeIterations()[i]; + auto E_x = it.meshes["E"]["x"]; + E_x.resetDataset({Datatype::FLOAT, {10, 10}}); + for (Extent::value_type j = 0; j < 10; ++j) { - Iteration it = write.writeIterations()[i]; - auto E_x = it.meshes["E"]["x"]; - E_x.resetDataset({Datatype::FLOAT, {10, 10}}); - for (Extent::value_type j = 0; j < 10; ++j) - { - std::iota(data.begin(), data.end(), i * 100 + j * 10); - E_x.storeChunk(data, {j, 0}, {1, 10}); - write.flush( - R"(adios2.engine.preferred_flush_target = "new_step")"); - } - it.close(); + std::iota(data.begin(), data.end(), i * 100 + j * 10); + E_x.storeChunk(data, {j, 0}, {1, 10}); + write.flush(R"(adios2.engine.preferred_flush_target = "new_step")"); } + it.close(); + } - for (Iteration::IterationIndex_t i = 0; i < 5; ++i) +#if openPMD_HAS_ADIOS_2_10_1 + for (auto access : {Access::READ_RANDOM_ACCESS, Access::READ_LINEAR}) + { + Series read( + "../samples/adios2_flush_via_step/simData_%T.bp5", + Access::READ_RANDOM_ACCESS); + std::vector load_data(100); + data.resize(100); + for (auto iteration : read.readIterations()) { - std::string filename = "../samples/adios2_flush_via_step/simData_" + - std::to_string(i) + "." + suffix; - adios2::ADIOS adios; - auto IO = adios.DeclareIO("IO"); - auto engine = IO.Open(filename, adios2::Mode::Read); - REQUIRE(engine.Steps() == (suffix == std::string("bp4") ? 10 : 11)); - engine.Close(); + std::iota(data.begin(), data.end(), iteration.iterationIndex * 100); + iteration.meshes["E"]["x"].loadChunkRaw( + load_data.data(), {0, 0}, {10, 10}); + iteration.close(); + REQUIRE(load_data == data); } } +#endif } TEST_CASE("adios2_engines_and_file_endings")