23 #include "openPMD/IO/ADIOS/ADIOS1FilePosition.hpp" 24 #include "openPMD/ThrowError.hpp" 25 #include "openPMD/auxiliary/StringManip.hpp" 26 #include "openPMD/backend/Attribute.hpp" 27 #include "openPMD/backend/Writable.hpp" 29 #include <adios_types.h> 41 getBP1Extent(Extent
const &e, std::string
const &delimiter =
",")
48 return std::to_string(e[0]);
50 std::ostringstream os;
52 e.begin(), e.end() - 1, [&os, &delimiter](std::uint64_t
const ext) {
53 os << std::to_string(ext) << delimiter;
55 os << std::to_string(*e.rbegin());
61 getZerosLikeBP1Extent(Extent
const &e, std::string
const &delimiter =
",")
70 std::ostringstream os;
72 e.begin(), e.end() - 1, [&os, &delimiter](std::uint64_t
const) {
73 os <<
"0" << delimiter;
80 inline ADIOS_DATATYPES getBP1DataType(
Datatype dtype)
96 return adios_unsigned_byte;
99 if (
sizeof(
short) == 2u)
101 else if (
sizeof(
short) == 4u)
102 return adios_integer;
103 else if (
sizeof(
long) == 8u)
106 error::throwOperationUnsupportedInBackend(
107 "ADIOS1",
"No native equivalent for Datatype::SHORT found.");
110 if (
sizeof(
int) == 2u)
112 else if (
sizeof(
int) == 4u)
113 return adios_integer;
114 else if (
sizeof(
int) == 8u)
117 error::throwOperationUnsupportedInBackend(
118 "ADIOS1",
"No native equivalent for Datatype::INT found.");
121 if (
sizeof(
long) == 2u)
123 else if (
sizeof(
long) == 4u)
124 return adios_integer;
125 else if (
sizeof(
long) == 8u)
128 error::throwOperationUnsupportedInBackend(
129 "ADIOS1",
"No native equivalent for Datatype::LONG found.");
131 case DT::VEC_LONGLONG:
132 if (
sizeof(
long long) == 2u)
134 else if (
sizeof(
long long) == 4u)
135 return adios_integer;
136 else if (
sizeof(
long long) == 8u)
139 error::throwOperationUnsupportedInBackend(
140 "ADIOS1",
"No native equivalent for Datatype::LONGLONG found.");
143 if (
sizeof(
unsigned short) == 2u)
144 return adios_unsigned_short;
145 else if (
sizeof(
unsigned short) == 4u)
146 return adios_unsigned_integer;
147 else if (
sizeof(
unsigned long) == 8u)
148 return adios_unsigned_long;
150 error::throwOperationUnsupportedInBackend(
151 "ADIOS1",
"No native equivalent for Datatype::USHORT found.");
154 if (
sizeof(
unsigned int) == 2u)
155 return adios_unsigned_short;
156 else if (
sizeof(
unsigned int) == 4u)
157 return adios_unsigned_integer;
158 else if (
sizeof(
unsigned int) == 8u)
159 return adios_unsigned_long;
161 error::throwOperationUnsupportedInBackend(
162 "ADIOS1",
"No native equivalent for Datatype::UINT found.");
165 if (
sizeof(
unsigned long) == 2u)
166 return adios_unsigned_short;
167 else if (
sizeof(
unsigned long) == 4u)
168 return adios_unsigned_integer;
169 else if (
sizeof(
unsigned long) == 8u)
170 return adios_unsigned_long;
172 error::throwOperationUnsupportedInBackend(
173 "ADIOS1",
"No native equivalent for Datatype::ULONG found.");
175 case DT::VEC_ULONGLONG:
176 if (
sizeof(
unsigned long long) == 2u)
177 return adios_unsigned_short;
178 else if (
sizeof(
unsigned long long) == 4u)
179 return adios_unsigned_integer;
180 else if (
sizeof(
unsigned long long) == 8u)
181 return adios_unsigned_long;
183 error::throwOperationUnsupportedInBackend(
185 "No native equivalent for Datatype::ULONGLONG found.");
193 case DT::LONG_DOUBLE:
194 case DT::VEC_LONG_DOUBLE:
195 return adios_long_double;
198 return adios_complex;
200 case DT::VEC_CDOUBLE:
201 return adios_double_complex;
202 case DT::CLONG_DOUBLE:
203 case DT::VEC_CLONG_DOUBLE:
204 error::throwOperationUnsupportedInBackend(
205 "ADIOS1",
"No native equivalent for Datatype::CLONG_DOUBLE found.");
209 return adios_string_array;
211 throw std::runtime_error(
"Unknown Attribute datatype (ADIOS datatype)");
213 throw std::runtime_error(
"Datatype not implemented in ADIOS IO");
217 inline std::string concrete_bp1_file_position(Writable *w)
219 std::stack<Writable *> hierarchy;
220 if (!w->abstractFilePosition)
229 while (!hierarchy.empty())
231 auto const tmp_ptr = std::dynamic_pointer_cast<ADIOS1FilePosition>(
232 hierarchy.top()->abstractFilePosition);
233 if (tmp_ptr ==
nullptr)
234 throw std::runtime_error(
235 "Dynamic pointer cast returned a nullptr!");
236 pos += tmp_ptr->location;
240 return auxiliary::replace_all(pos,
"//",
"/");
244 getEnvNum(std::string
const &key, std::string
const &defaultValue)
246 char const *env = std::getenv(key.c_str());
249 char const *tmp = env;
256 std::cerr << key <<
" is invalid" << std::endl;
261 return std::string(env, std::strlen(env));
269 template <
typename T>
270 inline Attribute readVectorAttributeInternal(
void *data,
int size)
272 auto d =
reinterpret_cast<T *
>(data);
275 for (
int i = 0; i < size; ++i)
Datatype
Concrete datatype of an object available at runtime.
Definition: Datatype.hpp:45
Public definitions of openPMD-api.