24#include "openPMD/Error.hpp"
25#include "openPMD/IO/ADIOS/macros.hpp"
26#include "openPMD/config.hpp"
28#if openPMD_HAVE_ADIOS2
29#include "openPMD/Dataset.hpp"
30#include "openPMD/Datatype.hpp"
31#include "openPMD/DatatypeHelpers.hpp"
43enum class GroupOrDataset
51 enum class FlushTarget :
unsigned char
61 using FlushTarget = adios_defs::FlushTarget;
62 FlushTarget flushTargetFromString(std::string
const &str);
64 enum class UseGroupTable
82 ReopenFileThatWeCreated
90namespace adios_defaults
92 using const_str =
char const *
const;
93 constexpr const_str str_engine =
"engine";
94 constexpr const_str str_type =
"type";
95 constexpr const_str str_treat_unsupported_engine_like =
"pretend_engine";
96 constexpr const_str str_params =
"parameters";
97 constexpr const_str str_usesteps =
"usesteps";
98 constexpr const_str str_flushtarget =
"preferred_flush_target";
99 constexpr const_str str_usesstepsAttribute =
"__openPMD_internal/useSteps";
100 constexpr const_str str_useModifiableAttributes =
101 "__openPMD_internal/useModifiableAttributes";
102 constexpr const_str str_adios2Schema =
103 "__openPMD_internal/openPMD2_adios2_schema";
104 constexpr const_str str_isBoolean =
"__is_boolean__";
105 constexpr const_str str_activeTablePrefix =
"__openPMD_groups";
106 constexpr const_str str_groupBasedWarning =
107 "__openPMD_internal/warning_bugprone_groupbased_encoding";
110#if openPMD_HAVE_ADIOS2
116 using bool_representation =
unsigned char;
118 template <
typename T>
121 static std::string type();
124 template <
typename T>
127 static std::string type();
130 template <
typename T,
size_t n>
133 static std::string type();
139 static std::string type();
144 template <
typename T>
145 std::string operator()();
148 std::string operator()();
157 Datatype fromADIOS2Type(std::string
const &dt,
bool verbose =
true);
159 enum class VariableOrAttribute :
unsigned char
167 template <
typename T>
170 std::string
const &attributeName,
171 VariableOrAttribute);
173 template <
int n,
typename... Params>
174 static Extent call(Params &&...);
191 std::string
const &attributeName,
193 VariableOrAttribute voa = VariableOrAttribute::Attribute);
195 inline bool readOnly(adios2::Mode mode)
199 case adios2::Mode::Append:
200 case adios2::Mode::Write:
202 case adios2::Mode::Read:
203 case adios2::Mode::ReadRandomAccess:
205 case adios2::Mode::Undefined:
206 case adios2::Mode::Sync:
207 case adios2::Mode::Deferred:
212 inline bool writeOnly(adios2::Mode mode)
216 case adios2::Mode::Append:
217 case adios2::Mode::Write:
219 case adios2::Mode::Read:
220 case adios2::Mode::ReadRandomAccess:
222 case adios2::Mode::Undefined:
223 case adios2::Mode::Sync:
224 case adios2::Mode::Deferred:
227 throw error::Internal(
"Control flow error: No ADIOS2 open mode.");
246template <
typename Action,
typename... Args>
248 ->
decltype(Action::template call<char>(std::forward<Args>(args)...))
251 decltype(Action::template call<char>(std::forward<Args>(args)...));
255 return Action::template call<char>(std::forward<Args>(args)...);
256 case Datatype::UCHAR:
257 return Action::template call<unsigned char>(
258 std::forward<Args>(args)...);
259 case Datatype::SCHAR:
260 return Action::template call<signed char>(std::forward<Args>(args)...);
261 case Datatype::SHORT:
262 return Action::template call<short>(std::forward<Args>(args)...);
264 return Action::template call<int>(std::forward<Args>(args)...);
266 return Action::template call<long>(std::forward<Args>(args)...);
267 case Datatype::LONGLONG:
268 return Action::template call<long long>(std::forward<Args>(args)...);
269 case Datatype::USHORT:
270 return Action::template call<unsigned short>(
271 std::forward<Args>(args)...);
273 return Action::template call<unsigned int>(std::forward<Args>(args)...);
274 case Datatype::ULONG:
275 return Action::template call<unsigned long>(
276 std::forward<Args>(args)...);
277 case Datatype::ULONGLONG:
278 return Action::template call<unsigned long long>(
279 std::forward<Args>(args)...);
280 case Datatype::FLOAT:
281 return Action::template call<float>(std::forward<Args>(args)...);
282 case Datatype::DOUBLE:
283 return Action::template call<double>(std::forward<Args>(args)...);
284 case Datatype::LONG_DOUBLE:
285 return Action::template call<long double>(std::forward<Args>(args)...);
286 case Datatype::CFLOAT:
287 return Action::template call<std::complex<float>>(
288 std::forward<Args>(args)...);
289 case Datatype::CDOUBLE:
290 return Action::template call<std::complex<double>>(
291 std::forward<Args>(args)...);
297 case Datatype::STRING:
298 return Action::template call<std::string>(std::forward<Args>(args)...);
299 case Datatype::UNDEFINED:
301 CallUndefinedDatatype<0, ReturnType, Action, Args &&...>::call(
302 std::forward<Args>(args)...);
304 throw std::runtime_error(
305 "Internal error: Encountered unknown datatype (switchType) ->" +
306 std::to_string(
static_cast<int>(dt)));
326template <
typename Action,
typename... Args>
328 ->
decltype(Action::template call<char>(std::forward<Args>(args)...))
331 decltype(Action::template call<char>(std::forward<Args>(args)...));
335 return Action::template call<char>(std::forward<Args>(args)...);
336 case Datatype::UCHAR:
337 return Action::template call<unsigned char>(
338 std::forward<Args>(args)...);
339 case Datatype::SCHAR:
340 return Action::template call<signed char>(std::forward<Args>(args)...);
341 case Datatype::SHORT:
342 return Action::template call<short>(std::forward<Args>(args)...);
344 return Action::template call<int>(std::forward<Args>(args)...);
346 return Action::template call<long>(std::forward<Args>(args)...);
347 case Datatype::LONGLONG:
348 return Action::template call<long long>(std::forward<Args>(args)...);
349 case Datatype::USHORT:
350 return Action::template call<unsigned short>(
351 std::forward<Args>(args)...);
353 return Action::template call<unsigned int>(std::forward<Args>(args)...);
354 case Datatype::ULONG:
355 return Action::template call<unsigned long>(
356 std::forward<Args>(args)...);
357 case Datatype::ULONGLONG:
358 return Action::template call<unsigned long long>(
359 std::forward<Args>(args)...);
360 case Datatype::FLOAT:
361 return Action::template call<float>(std::forward<Args>(args)...);
362 case Datatype::DOUBLE:
363 return Action::template call<double>(std::forward<Args>(args)...);
364 case Datatype::LONG_DOUBLE:
365 return Action::template call<long double>(std::forward<Args>(args)...);
366 case Datatype::CFLOAT:
367 return Action::template call<std::complex<float>>(
368 std::forward<Args>(args)...);
369 case Datatype::CDOUBLE:
370 return Action::template call<std::complex<double>>(
371 std::forward<Args>(args)...);
377 case Datatype::UNDEFINED:
379 CallUndefinedDatatype<0, ReturnType, Action, Args &&...>::call(
380 std::forward<Args>(args)...);
382 throw std::runtime_error(
383 "Internal error: Encountered unknown datatype (switchType) ->" +
384 std::to_string(
static_cast<int>(dt)));
Internal errors that should not happen.
Definition Error.hpp:103
Public definitions of openPMD-api.
Definition Date.cpp:29
auto switchAdios2VariableType(Datatype dt, Args &&...args) -> decltype(Action::template call< char >(std::forward< Args >(args)...))
Generalizes switching over an openPMD datatype.
Definition ADIOS2Auxiliary.hpp:327
Datatype
Concrete datatype of an object available at runtime.
Definition Datatype.hpp:51
auto switchAdios2AttributeType(Datatype dt, Args &&...args) -> decltype(Action::template call< char >(std::forward< Args >(args)...))
Generalizes switching over an openPMD datatype.
Definition ADIOS2Auxiliary.hpp:247
Definition ADIOS2Auxiliary.hpp:166
Definition ADIOS2Auxiliary.hpp:120
Definition ADIOS2Auxiliary.hpp:143