diff --git a/include/openPMD/IO/ADIOS/ADIOS2Auxiliary.hpp b/include/openPMD/IO/ADIOS/ADIOS2Auxiliary.hpp index 87bf66381e..97a3f5539a 100644 --- a/include/openPMD/IO/ADIOS/ADIOS2Auxiliary.hpp +++ b/include/openPMD/IO/ADIOS/ADIOS2Auxiliary.hpp @@ -22,6 +22,7 @@ #pragma once #include "openPMD/Error.hpp" +#include "openPMD/IO/ADIOS/macros.hpp" #include "openPMD/config.hpp" #if openPMD_HAVE_ADIOS2 @@ -35,18 +36,6 @@ #include #include #include - -/* - * ADIOS2 v2.8 brings mode::ReadRandomAccess - */ -#define HAS_ADIOS_2_8 (ADIOS2_VERSION_MAJOR * 100 + ADIOS2_VERSION_MINOR >= 208) -/* - * ADIOS2 v2.9 brings modifiable attributes (technically already in v2.8, but - * there are too many bugs, so we only support it beginning with v2.9). - * Group table feature requires ADIOS2 v2.9. - */ -#define HAS_ADIOS_2_9 (ADIOS2_VERSION_MAJOR * 100 + ADIOS2_VERSION_MINOR >= 209) - #endif namespace openPMD @@ -150,7 +139,7 @@ namespace detail case adios2::Mode::Write: return false; case adios2::Mode::Read: -#if HAS_ADIOS_2_8 +#if openPMD_HAS_ADIOS_2_8 case adios2::Mode::ReadRandomAccess: #endif return true; @@ -169,7 +158,7 @@ namespace detail case adios2::Mode::Write: return true; case adios2::Mode::Read: -#if HAS_ADIOS_2_8 +#if openPMD_HAS_ADIOS_2_8 case adios2::Mode::ReadRandomAccess: #endif return false; diff --git a/include/openPMD/IO/ADIOS/macros.hpp b/include/openPMD/IO/ADIOS/macros.hpp new file mode 100644 index 0000000000..59b630a112 --- /dev/null +++ b/include/openPMD/IO/ADIOS/macros.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include "openPMD/config.hpp" + +#if openPMD_HAVE_ADIOS2 + +#include + +/* + * ADIOS2 v2.8 brings mode::ReadRandomAccess + */ +#define openPMD_HAS_ADIOS_2_8 \ + (ADIOS2_VERSION_MAJOR * 100 + ADIOS2_VERSION_MINOR >= 208) +/* + * ADIOS2 v2.9 brings modifiable attributes (technically already in v2.8, but + * there are too many bugs, so we only support it beginning with v2.9). + * Group table feature requires ADIOS2 v2.9. + */ +#define openPMD_HAS_ADIOS_2_9 \ + (ADIOS2_VERSION_MAJOR * 100 + ADIOS2_VERSION_MINOR >= 209) + +#else + +#define openPMD_HAS_ADIOS_2_8 0 +#define openPMD_HAS_ADIOS_2_9 0 + +#endif diff --git a/src/IO/ADIOS/ADIOS2IOHandler.cpp b/src/IO/ADIOS/ADIOS2IOHandler.cpp index fa2e397709..08dd81ff56 100644 --- a/src/IO/ADIOS/ADIOS2IOHandler.cpp +++ b/src/IO/ADIOS/ADIOS2IOHandler.cpp @@ -210,7 +210,7 @@ void ADIOS2IOHandlerImpl::init(json::TracingJSON cfg) defaultOperators = std::move(operators.value()); } } -#if !HAS_ADIOS_2_9 +#if !openPMD_HAS_ADIOS_2_9 if (m_modifiableAttributes == ModifiableAttributes::Yes) { throw error::OperationUnsupportedInBackend( @@ -879,7 +879,7 @@ void ADIOS2IOHandlerImpl::writeDataset( void ADIOS2IOHandlerImpl::writeAttribute( Writable *writable, const Parameter ¶meters) { -#if HAS_ADIOS_2_9 +#if openPMD_HAS_ADIOS_2_9 switch (useGroupTable()) { case UseGroupTable::No: @@ -1354,7 +1354,7 @@ adios2::Mode ADIOS2IOHandlerImpl::adios2AccessMode(std::string const &fullPath) { case Access::CREATE: return adios2::Mode::Write; -#if HAS_ADIOS_2_8 +#if openPMD_HAS_ADIOS_2_8 case Access::READ_LINEAR: return adios2::Mode::Read; case Access::READ_ONLY: @@ -1368,7 +1368,7 @@ adios2::Mode ADIOS2IOHandlerImpl::adios2AccessMode(std::string const &fullPath) if (auxiliary::directory_exists(fullPath) || auxiliary::file_exists(fullPath)) { -#if HAS_ADIOS_2_8 +#if openPMD_HAS_ADIOS_2_8 return adios2::Mode::ReadRandomAccess; #else return adios2::Mode::Read; @@ -1707,7 +1707,7 @@ namespace detail adios2::IO IO = filedata.m_IO; impl->m_dirty.emplace(std::move(file)); -#if HAS_ADIOS_2_9 +#if openPMD_HAS_ADIOS_2_9 if (impl->m_modifiableAttributes == ADIOS2IOHandlerImpl::ModifiableAttributes::No && parameters.changesOverSteps == @@ -1773,7 +1773,7 @@ namespace detail } auto &value = std::get(parameters.resource); -#if HAS_ADIOS_2_9 +#if openPMD_HAS_ADIOS_2_9 bool modifiable = impl->m_modifiableAttributes == ADIOS2IOHandlerImpl::ModifiableAttributes::Yes || parameters.changesOverSteps != @@ -1787,7 +1787,7 @@ namespace detail auto defineAttribute = [&IO, &fullName, &modifiable, &impl](auto const &...args) { -#if HAS_ADIOS_2_9 +#if openPMD_HAS_ADIOS_2_9 auto attr = IO.DefineAttribute( fullName, args..., @@ -2333,7 +2333,7 @@ namespace detail * BP3 or HDF5, or by BP5 without group table and normal read * mode. Need to fall back to random access parsing. */ -#if HAS_ADIOS_2_8 +#if openPMD_HAS_ADIOS_2_8 m_mode = adios2::Mode::ReadRandomAccess; #endif break; @@ -2411,7 +2411,7 @@ namespace detail if (writeOnly(m_mode)) { -#if HAS_ADIOS_2_9 +#if openPMD_HAS_ADIOS_2_9 if (!m_impl->m_useGroupTable.has_value()) { switch (m_impl->m_iterationEncoding) @@ -2726,7 +2726,7 @@ namespace detail adios2::Engine(m_IO.Open(m_file, tempMode))); break; } -#if HAS_ADIOS_2_8 +#if openPMD_HAS_ADIOS_2_8 case adios2::Mode::ReadRandomAccess: #endif case adios2::Mode::Read: { @@ -3293,7 +3293,7 @@ namespace detail case UseGroupTable::No: break; case UseGroupTable::Yes: -#if HAS_ADIOS_2_9 +#if openPMD_HAS_ADIOS_2_9 { if (writeOnly(m_mode)) { diff --git a/test/SerialIOTest.cpp b/test/SerialIOTest.cpp index 0fbba4269d..8b359988e8 100644 --- a/test/SerialIOTest.cpp +++ b/test/SerialIOTest.cpp @@ -6,16 +6,12 @@ #define OPENPMD_protected public: #endif +#include "openPMD/IO/ADIOS/macros.hpp" #include "openPMD/auxiliary/Environment.hpp" #include "openPMD/auxiliary/Filesystem.hpp" #include "openPMD/auxiliary/StringManip.hpp" #include "openPMD/openPMD.hpp" -#if openPMD_HAVE_ADIOS2 -#include -#define HAS_ADIOS_2_8 (ADIOS2_VERSION_MAJOR * 100 + ADIOS2_VERSION_MINOR >= 209) -#define HAS_ADIOS_2_9 (ADIOS2_VERSION_MAJOR * 100 + ADIOS2_VERSION_MINOR >= 209) -#endif #include #include @@ -563,9 +559,9 @@ TEST_CASE("close_iteration_interleaved_test", "[serial]") // run this test for ADIOS2 & JSON only if (t == "h5") continue; -#if HAS_ADIOS_2_9 +#if openPMD_HAS_ADIOS_2_9 close_iteration_interleaved_test(t, IterationEncoding::variableBased); -#endif // HAS_ADIOS_2_9 +#endif // openPMD_HAS_ADIOS_2_9 } } @@ -4903,7 +4899,7 @@ TEST_CASE("bp4_steps", "[serial][adios2]") // dontUseSteps, // Access::READ_LINEAR); -#if HAS_ADIOS_2_9 +#if openPMD_HAS_ADIOS_2_9 /* * Do this whole thing once more, but this time use the new attribute * layout. @@ -5350,7 +5346,7 @@ TEST_CASE("git_adios2_sample_test", "[serial][adios2]") } } -#if HAS_ADIOS_2_9 +#if openPMD_HAS_ADIOS_2_9 void adios2_group_table( std::string const &jsonWrite, std::string const &jsonRead, @@ -5699,7 +5695,7 @@ TEST_CASE("variableBasedParticleData", "[serial][adios2]") { variableBasedParticleData(); } -#endif // HAS_ADIOS_2_9 +#endif // openPMD_HAS_ADIOS_2_9 #endif // openPMD_HAS_ADIOS2 #if openPMD_HAVE_ADIOS2 @@ -6025,7 +6021,7 @@ TEST_CASE("iterate_nonstreaming_series", "[serial][adios2]") } #endif } -#if openPMD_HAVE_ADIOS2 && HAS_ADIOS_2_9 +#if openPMD_HAVE_ADIOS2 && openPMD_HAS_ADIOS_2_9 iterate_nonstreaming_series( "../samples/iterate_nonstreaming_series_variablebased.bp", true, @@ -6404,7 +6400,7 @@ TEST_CASE("deferred_parsing", "[serial]") } } -#if HAS_ADIOS_2_9 +#if openPMD_HAS_ADIOS_2_9 void chaotic_stream(std::string filename, bool variableBased) { /* @@ -6482,7 +6478,7 @@ TEST_CASE("chaotic_stream", "[serial]") chaotic_stream("../samples/chaotic_stream_vbased." + t, true); } } -#endif // HAS_ADIOS_2_9 +#endif // openPMD_HAS_ADIOS_2_9 #ifdef openPMD_USE_INVASIVE_TESTS void unfinished_iteration_test( @@ -6598,7 +6594,7 @@ TEST_CASE("unfinished_iteration_test", "[serial]") #if openPMD_HAVE_ADIOS2 unfinished_iteration_test( "bp", IterationEncoding::groupBased, R"({"backend": "adios2"})"); -#if HAS_ADIOS_2_9 +#if openPMD_HAS_ADIOS_2_9 unfinished_iteration_test( "bp5", IterationEncoding::variableBased, @@ -6611,7 +6607,7 @@ TEST_CASE("unfinished_iteration_test", "[serial]") } } )"); -#endif // HAS_ADIOS_2_9 +#endif // openPMD_HAS_ADIOS_2_9 unfinished_iteration_test( "bp", IterationEncoding::fileBased, R"({"backend": "adios2"})"); #endif @@ -7098,7 +7094,7 @@ TEST_CASE("append_mode", "[serial]") false, ParseMode::LinearWithoutSnapshot, jsonConfigOld); -#if HAS_ADIOS_2_9 +#if openPMD_HAS_ADIOS_2_9 append_mode( "../samples/append/append_groupbased." + t, false, @@ -7127,7 +7123,7 @@ TEST_CASE("append_mode", "[serial]") } } -#if HAS_ADIOS_2_8 +#if openPMD_HAS_ADIOS_2_9 void append_mode_filebased(std::string const &extension) { std::string jsonConfig = R"END( @@ -7207,7 +7203,7 @@ TEST_CASE("append_mode_filebased", "[serial]") append_mode_filebased(t); } } -#endif // HAS_ADIOS_2_8 +#endif // openPMD_HAS_ADIOS_2_8 void groupbased_read_write(std::string const &ext) {