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"
43 enum class GroupOrDataset
51 enum class FlushTarget : unsigned char
59 using FlushTarget = adios_defs::FlushTarget;
60 FlushTarget flushTargetFromString(std::string
const &str);
62 enum class UseGroupTable
73 namespace adios_defaults
75 using const_str =
char const *
const;
76 constexpr const_str str_engine =
"engine";
77 constexpr const_str str_type =
"type";
78 constexpr const_str str_params =
"parameters";
79 constexpr const_str str_usesteps =
"usesteps";
80 constexpr const_str str_flushtarget =
"preferred_flush_target";
81 constexpr const_str str_usesstepsAttribute =
"__openPMD_internal/useSteps";
82 constexpr const_str str_adios2Schema =
83 "__openPMD_internal/openPMD2_adios2_schema";
84 constexpr const_str str_isBoolean =
"__is_boolean__";
85 constexpr const_str str_activeTablePrefix =
"__openPMD_groups";
86 constexpr const_str str_groupBasedWarning =
87 "__openPMD_internal/warning_bugprone_groupbased_encoding";
90 #if openPMD_HAVE_ADIOS2
96 using bool_representation =
unsigned char;
101 static std::string type();
104 template <
typename T>
107 static std::string type();
110 template <
typename T,
size_t n>
113 static std::string type();
119 static std::string type();
124 template <
typename T>
125 std::string operator()();
128 std::string operator()();
137 Datatype fromADIOS2Type(std::string
const &dt,
bool verbose =
true);
139 enum class VariableOrAttribute : unsigned char
147 template <
typename T>
150 std::string
const &attributeName,
151 VariableOrAttribute);
153 template <
int n,
typename... Params>
154 static Extent call(Params &&...);
171 std::string
const &attributeName,
173 VariableOrAttribute voa = VariableOrAttribute::Attribute);
175 inline bool readOnly(adios2::Mode mode)
179 case adios2::Mode::Append:
180 case adios2::Mode::Write:
182 case adios2::Mode::Read:
183 #if openPMD_HAS_ADIOS_2_8
184 case adios2::Mode::ReadRandomAccess:
187 case adios2::Mode::Undefined:
188 case adios2::Mode::Sync:
189 case adios2::Mode::Deferred:
194 inline bool writeOnly(adios2::Mode mode)
198 case adios2::Mode::Append:
199 case adios2::Mode::Write:
201 case adios2::Mode::Read:
202 #if openPMD_HAS_ADIOS_2_8
203 case adios2::Mode::ReadRandomAccess:
206 case adios2::Mode::Undefined:
207 case adios2::Mode::Sync:
208 case adios2::Mode::Deferred:
211 throw error::Internal(
"Control flow error: No ADIOS2 open mode.");
230 template <
typename Action,
typename... Args>
232 -> decltype(Action::template call<char>(std::forward<Args>(args)...))
235 decltype(Action::template call<char>(std::forward<Args>(args)...));
239 return Action::template call<char>(std::forward<Args>(args)...);
240 case Datatype::UCHAR:
241 return Action::template call<unsigned char>(
242 std::forward<Args>(args)...);
243 case Datatype::SCHAR:
244 return Action::template call<signed char>(std::forward<Args>(args)...);
245 case Datatype::SHORT:
246 return Action::template call<short>(std::forward<Args>(args)...);
248 return Action::template call<int>(std::forward<Args>(args)...);
250 return Action::template call<long>(std::forward<Args>(args)...);
251 case Datatype::LONGLONG:
252 return Action::template call<long long>(std::forward<Args>(args)...);
253 case Datatype::USHORT:
254 return Action::template call<unsigned short>(
255 std::forward<Args>(args)...);
257 return Action::template call<unsigned int>(std::forward<Args>(args)...);
258 case Datatype::ULONG:
259 return Action::template call<unsigned long>(
260 std::forward<Args>(args)...);
261 case Datatype::ULONGLONG:
262 return Action::template call<unsigned long long>(
263 std::forward<Args>(args)...);
264 case Datatype::FLOAT:
265 return Action::template call<float>(std::forward<Args>(args)...);
266 case Datatype::DOUBLE:
267 return Action::template call<double>(std::forward<Args>(args)...);
268 case Datatype::LONG_DOUBLE:
269 return Action::template call<long double>(std::forward<Args>(args)...);
270 case Datatype::CFLOAT:
271 return Action::template call<std::complex<float>>(
272 std::forward<Args>(args)...);
273 case Datatype::CDOUBLE:
274 return Action::template call<std::complex<double>>(
275 std::forward<Args>(args)...);
281 case Datatype::STRING:
282 return Action::template call<std::string>(std::forward<Args>(args)...);
283 case Datatype::UNDEFINED:
285 CallUndefinedDatatype<0, ReturnType, Action, Args &&...>::call(
286 std::forward<Args>(args)...);
288 throw std::runtime_error(
289 "Internal error: Encountered unknown datatype (switchType) ->" +
290 std::to_string(
static_cast<int>(dt)));
310 template <
typename Action,
typename... Args>
312 -> decltype(Action::template call<char>(std::forward<Args>(args)...))
315 decltype(Action::template call<char>(std::forward<Args>(args)...));
319 return Action::template call<char>(std::forward<Args>(args)...);
320 case Datatype::UCHAR:
321 return Action::template call<unsigned char>(
322 std::forward<Args>(args)...);
323 case Datatype::SCHAR:
324 return Action::template call<signed char>(std::forward<Args>(args)...);
325 case Datatype::SHORT:
326 return Action::template call<short>(std::forward<Args>(args)...);
328 return Action::template call<int>(std::forward<Args>(args)...);
330 return Action::template call<long>(std::forward<Args>(args)...);
331 case Datatype::LONGLONG:
332 return Action::template call<long long>(std::forward<Args>(args)...);
333 case Datatype::USHORT:
334 return Action::template call<unsigned short>(
335 std::forward<Args>(args)...);
337 return Action::template call<unsigned int>(std::forward<Args>(args)...);
338 case Datatype::ULONG:
339 return Action::template call<unsigned long>(
340 std::forward<Args>(args)...);
341 case Datatype::ULONGLONG:
342 return Action::template call<unsigned long long>(
343 std::forward<Args>(args)...);
344 case Datatype::FLOAT:
345 return Action::template call<float>(std::forward<Args>(args)...);
346 case Datatype::DOUBLE:
347 return Action::template call<double>(std::forward<Args>(args)...);
348 case Datatype::LONG_DOUBLE:
349 return Action::template call<long double>(std::forward<Args>(args)...);
350 case Datatype::CFLOAT:
351 return Action::template call<std::complex<float>>(
352 std::forward<Args>(args)...);
353 case Datatype::CDOUBLE:
354 return Action::template call<std::complex<double>>(
355 std::forward<Args>(args)...);
361 case Datatype::UNDEFINED:
363 CallUndefinedDatatype<0, ReturnType, Action, Args &&...>::call(
364 std::forward<Args>(args)...);
366 throw std::runtime_error(
367 "Internal error: Encountered unknown datatype (switchType) ->" +
368 std::to_string(
static_cast<int>(dt)));
Variant datatype supporting at least all formats for attributes specified in the openPMD standard.
Definition: Attribute.hpp:56
Internal errors that should not happen.
Definition: Error.hpp:83
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:311
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:231
Definition: ADIOS2Auxiliary.hpp:146
Definition: ADIOS2Auxiliary.hpp:100
Definition: ADIOS2Auxiliary.hpp:123