2222#include " openPMD/IO/ADIOS/ADIOS2File.hpp"
2323#include " openPMD/Error.hpp"
2424#include " openPMD/IO/ADIOS/ADIOS2IOHandler.hpp"
25+ #include " openPMD/IO/ADIOS/macros.hpp"
2526#include " openPMD/auxiliary/Environment.hpp"
2627#include < optional>
2728
@@ -71,6 +72,12 @@ void DatasetReader::call(
7172template <class >
7273inline constexpr bool always_false_v = false ;
7374
75+ static constexpr char const *warningMemorySelection =
76+ " [Warning] Using a version of ADIOS2 that cannot reset memory selections "
77+ " on a variable, once specified. When using memory selections, then please "
78+ " specify it explicitly on all storeChunk() calls. Further info: "
79+ " https://github.com/ornladios/ADIOS2/pull/4169." ;
80+
7481template <typename T>
7582void WriteDataset::call (ADIOS2File &ba, detail::BufferedPut &bp)
7683{
@@ -93,6 +100,19 @@ void WriteDataset::call(ADIOS2File &ba, detail::BufferedPut &bp)
93100 bp.name );
94101
95102 ba.getEngine ().Put (var, ptr);
103+ if (bp.param .memorySelection .has_value ())
104+ {
105+ if constexpr (CanTheMemorySelectionBeReset)
106+ {
107+ var.SetMemorySelection ();
108+ }
109+ else if (!ba.m_impl ->printedWarningsAlready .memorySelection )
110+ {
111+ std::cerr << warningMemorySelection << std::endl;
112+ ba.m_impl ->printedWarningsAlready .memorySelection =
113+ true ;
114+ }
115+ }
96116 }
97117 else if constexpr (std::is_same_v<
98118 ptr_type,
@@ -155,6 +175,18 @@ struct RunUniquePtrPut
155175 ba.m_IO ,
156176 bufferedPut.name );
157177 ba.getEngine ().Put (var, ptr);
178+ if (bufferedPut.memorySelection .has_value ())
179+ {
180+ if constexpr (CanTheMemorySelectionBeReset)
181+ {
182+ var.SetMemorySelection ();
183+ }
184+ else if (!ba.m_impl ->printedWarningsAlready .memorySelection )
185+ {
186+ std::cerr << warningMemorySelection << std::endl;
187+ ba.m_impl ->printedWarningsAlready .memorySelection = true ;
188+ }
189+ }
158190 }
159191
160192 static constexpr char const *errorMsg = " RunUniquePtrPut" ;
0 commit comments