23 #include "openPMD/auxiliary/StringManip.hpp" 24 #include "openPMD/backend/Attribute.hpp" 25 #include "openPMD/backend/Writable.hpp" 26 #include "openPMD/IO/ADIOS/ADIOS1FilePosition.hpp" 28 #include <adios_types.h> 41 getBP1Extent(Extent
const& e, std::string
const& delimiter =
",")
48 return std::to_string(e[0]);
50 std::ostringstream os;
51 std::for_each(e.begin(),
53 [&os, &delimiter](std::uint64_t
const ext) { os << std::to_string(ext) << delimiter; });
54 os << std::to_string(*e.rbegin());
60 getZerosLikeBP1Extent(Extent
const& e, std::string
const& delimiter =
",")
69 std::ostringstream os;
70 std::for_each(e.begin(),
72 [&os, &delimiter](std::uint64_t
const) { os <<
"0" << delimiter; });
78 inline ADIOS_DATATYPES
93 return adios_unsigned_byte;
96 if(
sizeof(
short) == 2u )
98 else if(
sizeof(
short) == 4u )
100 else if(
sizeof(
long) == 8u )
103 throw unsupported_data_error(
"No native equivalent for Datatype::SHORT found.");
106 if(
sizeof(
int) == 2u )
108 else if(
sizeof(
int) == 4u )
109 return adios_integer;
110 else if(
sizeof(
int) == 8u )
113 throw unsupported_data_error(
"No native equivalent for Datatype::INT found.");
116 if(
sizeof(
long) == 2u )
118 else if(
sizeof(
long) == 4u )
119 return adios_integer;
120 else if(
sizeof(
long) == 8u )
123 throw unsupported_data_error(
"No native equivalent for Datatype::LONG found.");
125 case DT::VEC_LONGLONG:
126 if(
sizeof(
long long) == 2u )
128 else if(
sizeof(
long long) == 4u )
129 return adios_integer;
130 else if(
sizeof(
long long) == 8u )
133 throw unsupported_data_error(
"No native equivalent for Datatype::LONGLONG found.");
136 if(
sizeof(
unsigned short) == 2u )
137 return adios_unsigned_short;
138 else if(
sizeof(
unsigned short) == 4u )
139 return adios_unsigned_integer;
140 else if(
sizeof(
unsigned long) == 8u )
141 return adios_unsigned_long;
143 throw unsupported_data_error(
"No native equivalent for Datatype::USHORT found.");
146 if(
sizeof(
unsigned int) == 2u )
147 return adios_unsigned_short;
148 else if(
sizeof(
unsigned int) == 4u )
149 return adios_unsigned_integer;
150 else if(
sizeof(
unsigned int) == 8u )
151 return adios_unsigned_long;
153 throw unsupported_data_error(
"No native equivalent for Datatype::UINT found.");
156 if(
sizeof(
unsigned long) == 2u )
157 return adios_unsigned_short;
158 else if(
sizeof(
unsigned long) == 4u )
159 return adios_unsigned_integer;
160 else if(
sizeof(
unsigned long) == 8u )
161 return adios_unsigned_long;
163 throw unsupported_data_error(
"No native equivalent for Datatype::ULONG found.");
165 case DT::VEC_ULONGLONG:
166 if(
sizeof(
unsigned long long) == 2u )
167 return adios_unsigned_short;
168 else if(
sizeof(
unsigned long long) == 4u )
169 return adios_unsigned_integer;
170 else if(
sizeof(
unsigned long long) == 8u )
171 return adios_unsigned_long;
173 throw unsupported_data_error(
"No native equivalent for Datatype::ULONGLONG found.");
181 case DT::LONG_DOUBLE:
182 case DT::VEC_LONG_DOUBLE:
183 return adios_long_double;
186 return adios_complex;
188 case DT::VEC_CDOUBLE:
189 return adios_double_complex;
190 case DT::CLONG_DOUBLE:
191 case DT::VEC_CLONG_DOUBLE:
192 throw unsupported_data_error(
"No native equivalent for Datatype::CLONG_DOUBLE found.");
196 return adios_string_array;
198 throw std::runtime_error(
"Meta-Datatype leaked into IO");
200 throw std::runtime_error(
"Unknown Attribute datatype (ADIOS datatype)");
202 throw std::runtime_error(
"Datatype not implemented in ADIOS IO");
207 concrete_bp1_file_position(Writable* w)
209 std::stack< Writable* > hierarchy;
210 if( !w->abstractFilePosition )
219 while( !hierarchy.empty() )
221 auto const tmp_ptr = std::dynamic_pointer_cast< ADIOS1FilePosition >(hierarchy.top()->abstractFilePosition);
222 if( tmp_ptr ==
nullptr )
223 throw std::runtime_error(
"Dynamic pointer cast returned a nullptr!");
224 pos += tmp_ptr->location;
228 return auxiliary::replace_all(pos,
"//",
"/");
232 getEnvNum(std::string
const& key, std::string
const& defaultValue)
234 char const* env = std::getenv(key.c_str());
237 char const* tmp = env;
244 std::cerr << key <<
" is invalid" << std::endl;
249 return std::string(env, std::strlen(env));
258 readVectorAttributeInternal(
void* data,
int size )
260 auto d =
reinterpret_cast< T*
>(data);
263 for(
int i = 0; i < size; ++i )
Datatype
Concrete datatype of an object available at runtime.
Definition: Datatype.hpp:42
Public definitions of openPMD-api.
Definition: Date.cpp:29