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> 40 getBP1Extent(Extent
const& e, std::string
const& delimiter =
",")
47 return std::to_string(e[0]);
49 std::ostringstream os;
50 std::for_each(e.begin(),
52 [&os, &delimiter](std::uint64_t
const ext) { os << std::to_string(ext) << delimiter; });
53 os << std::to_string(*e.rbegin());
59 getZerosLikeBP1Extent(Extent
const& e, std::string
const& delimiter =
",")
68 std::ostringstream os;
69 std::for_each(e.begin(),
71 [&os, &delimiter](std::uint64_t
const) { os <<
"0" << delimiter; });
77 inline ADIOS_DATATYPES
92 return adios_unsigned_byte;
95 if(
sizeof(
short) == 2u )
97 else if(
sizeof(
short) == 4u )
99 else if(
sizeof(
long) == 8u )
102 throw unsupported_data_error(
"No native equivalent for Datatype::SHORT found.");
105 if(
sizeof(
int) == 2u )
107 else if(
sizeof(
int) == 4u )
108 return adios_integer;
109 else if(
sizeof(
int) == 8u )
112 throw unsupported_data_error(
"No native equivalent for Datatype::INT found.");
115 if(
sizeof(
long) == 2u )
117 else if(
sizeof(
long) == 4u )
118 return adios_integer;
119 else if(
sizeof(
long) == 8u )
122 throw unsupported_data_error(
"No native equivalent for Datatype::LONG found.");
124 case DT::VEC_LONGLONG:
125 if(
sizeof(
long long) == 2u )
127 else if(
sizeof(
long long) == 4u )
128 return adios_integer;
129 else if(
sizeof(
long long) == 8u )
132 throw unsupported_data_error(
"No native equivalent for Datatype::LONGLONG found.");
135 if(
sizeof(
unsigned short) == 2u )
136 return adios_unsigned_short;
137 else if(
sizeof(
unsigned short) == 4u )
138 return adios_unsigned_integer;
139 else if(
sizeof(
unsigned long) == 8u )
140 return adios_unsigned_long;
142 throw unsupported_data_error(
"No native equivalent for Datatype::USHORT found.");
145 if(
sizeof(
unsigned int) == 2u )
146 return adios_unsigned_short;
147 else if(
sizeof(
unsigned int) == 4u )
148 return adios_unsigned_integer;
149 else if(
sizeof(
unsigned int) == 8u )
150 return adios_unsigned_long;
152 throw unsupported_data_error(
"No native equivalent for Datatype::UINT found.");
155 if(
sizeof(
unsigned long) == 2u )
156 return adios_unsigned_short;
157 else if(
sizeof(
unsigned long) == 4u )
158 return adios_unsigned_integer;
159 else if(
sizeof(
unsigned long) == 8u )
160 return adios_unsigned_long;
162 throw unsupported_data_error(
"No native equivalent for Datatype::ULONG found.");
164 case DT::VEC_ULONGLONG:
165 if(
sizeof(
unsigned long long) == 2u )
166 return adios_unsigned_short;
167 else if(
sizeof(
unsigned long long) == 4u )
168 return adios_unsigned_integer;
169 else if(
sizeof(
unsigned long long) == 8u )
170 return adios_unsigned_long;
172 throw unsupported_data_error(
"No native equivalent for Datatype::ULONGLONG found.");
180 case DT::LONG_DOUBLE:
181 case DT::VEC_LONG_DOUBLE:
182 return adios_long_double;
186 return adios_string_array;
188 throw std::runtime_error(
"Meta-Datatype leaked into IO");
190 throw std::runtime_error(
"Unknown Attribute datatype (ADIOS datatype)");
192 throw std::runtime_error(
"Datatype not implemented in ADIOS IO");
197 concrete_bp1_file_position(Writable* w)
199 std::stack< Writable* > hierarchy;
200 if( !w->abstractFilePosition )
209 while( !hierarchy.empty() )
211 pos += std::dynamic_pointer_cast< ADIOS1FilePosition >(hierarchy.top()->abstractFilePosition)->location;
215 return auxiliary::replace_all(pos,
"//",
"/");
219 getEnvNum(std::string
const& key, std::string
const& defaultValue)
221 char const* env = std::getenv(key.c_str());
224 char const* tmp = env;
231 std::cerr << key <<
" is invalid" << std::endl;
236 return std::string(env, std::strlen(env));
245 readVectorAttributeInternal(
void* data,
int size )
247 auto d =
reinterpret_cast< T*
>(data);
250 for(
int i = 0; i < size; ++i )
Datatype
Concrete datatype of an object available at runtime.
Definition: Datatype.hpp:38
Public definitions of openPMD-api.
Definition: Date.cpp:28