Skip to content
Snippets Groups Projects
Commit 28cbc571 authored by Podhorszki, Norbert's avatar Podhorszki, Norbert
Browse files

Attributes are supported in ADIOS1 engine

parent 5471c6a2
No related branches found
No related tags found
1 merge request!338Heat
...@@ -43,6 +43,7 @@ bool ADIOS1CommonRead::Open(IO &io) ...@@ -43,6 +43,7 @@ bool ADIOS1CommonRead::Open(IO &io)
m_fh = m_fh =
adios_read_open_file(m_FileName.c_str(), m_ReadMethod, m_MPIComm); adios_read_open_file(m_FileName.c_str(), m_ReadMethod, m_MPIComm);
GenerateVariables(io); GenerateVariables(io);
GenerateAttributes(io);
} }
else else
{ {
...@@ -71,12 +72,12 @@ void ADIOS1CommonRead::DefineADIOS2Variable(IO &io, const char *name, ...@@ -71,12 +72,12 @@ void ADIOS1CommonRead::DefineADIOS2Variable(IO &io, const char *name,
isGlobal); isGlobal);
break; break;
case adios_unsigned_long: case adios_unsigned_long:
DefineADIOS2Variable<unsigned long long int>(io, name, vi, gdims, DefineADIOS2Variable<uint64_t>(io, name, vi, gdims, isJoined, isGlobal);
isJoined, isGlobal);
break; break;
case adios_byte: case adios_byte:
DefineADIOS2Variable<char>(io, name, vi, gdims, isJoined, isGlobal); DefineADIOS2Variable<signed char>(io, name, vi, gdims, isJoined,
isGlobal);
break; break;
case adios_short: case adios_short:
DefineADIOS2Variable<short>(io, name, vi, gdims, isJoined, isGlobal); DefineADIOS2Variable<short>(io, name, vi, gdims, isJoined, isGlobal);
...@@ -85,8 +86,7 @@ void ADIOS1CommonRead::DefineADIOS2Variable(IO &io, const char *name, ...@@ -85,8 +86,7 @@ void ADIOS1CommonRead::DefineADIOS2Variable(IO &io, const char *name,
DefineADIOS2Variable<int>(io, name, vi, gdims, isJoined, isGlobal); DefineADIOS2Variable<int>(io, name, vi, gdims, isJoined, isGlobal);
break; break;
case adios_long: case adios_long:
DefineADIOS2Variable<long long int>(io, name, vi, gdims, isJoined, DefineADIOS2Variable<int64_t>(io, name, vi, gdims, isJoined, isGlobal);
isGlobal);
break; break;
case adios_real: case adios_real:
...@@ -212,6 +212,89 @@ void ADIOS1CommonRead::GenerateVariables(IO &io) ...@@ -212,6 +212,89 @@ void ADIOS1CommonRead::GenerateVariables(IO &io)
} }
} }
void ADIOS1CommonRead::DefineADIOS2Attribute(IO &io, const char *name,
enum ADIOS_DATATYPES type,
void *value)
{
switch (type)
{
case adios_unsigned_byte:
DefineADIOS2Attribute<unsigned char>(io, name, value);
break;
case adios_unsigned_short:
DefineADIOS2Attribute<unsigned short>(io, name, value);
break;
case adios_unsigned_integer:
DefineADIOS2Attribute<unsigned int>(io, name, value);
break;
case adios_unsigned_long:
DefineADIOS2Attribute<uint64_t>(io, name, value);
break;
case adios_byte:
DefineADIOS2Attribute<signed char>(io, name, value);
break;
case adios_short:
DefineADIOS2Attribute<short>(io, name, value);
break;
case adios_integer:
DefineADIOS2Attribute<int>(io, name, value);
break;
case adios_long:
DefineADIOS2Attribute<int64_t>(io, name, value);
break;
case adios_real:
DefineADIOS2Attribute<float>(io, name, value);
break;
case adios_double:
DefineADIOS2Attribute<double>(io, name, value);
break;
case adios_long_double:
DefineADIOS2Attribute<long double>(io, name, value);
break;
case adios_string:
{
std::string str(reinterpret_cast<char *>(value));
io.DefineAttribute<std::string>(name, str);
break;
}
case adios_complex:
/*FIXME: DefineADIOS2Attribute<std::complex<float>>(io, name, value);*/
break;
case adios_double_complex:
/*FIXME: DefineADIOS2Attribute<std::complex<double>>(io, name, value);*/
break;
default:
break;
}
}
void ADIOS1CommonRead::GenerateAttributes(IO &io)
{
if (!m_fh)
return;
/* Create a Variable for each variable in the file */
for (int attid = 0; attid < m_fh->nattrs; attid++)
{
// here read attribute metadata (dimensions, type, etc.)...then create a
// Variable like below:
// Variable<T>& variable = io.DefineVariable<T>( m_Name + "/" +
// name, )
// return &variable; //return address if success
enum ADIOS_DATATYPES atype;
int asize;
void *adata;
int status = adios_get_attr_byid(m_fh, attid, &atype, &asize, &adata);
if (status == err_no_error)
{
DefineADIOS2Attribute(io, m_fh->attr_namelist[attid], atype, adata);
free(adata);
}
}
}
void ADIOS1CommonRead::ScheduleReadCommon(const std::string &name, void ADIOS1CommonRead::ScheduleReadCommon(const std::string &name,
const Dims &offs, const Dims &ldims, const Dims &offs, const Dims &ldims,
const int fromStep, const int nSteps, const int fromStep, const int nSteps,
...@@ -296,6 +379,7 @@ StepStatus ADIOS1CommonRead::AdvanceStep(IO &io, const StepMode mode, ...@@ -296,6 +379,7 @@ StepStatus ADIOS1CommonRead::AdvanceStep(IO &io, const StepMode mode,
*/ */
m_IsBeforeFirstStep = false; m_IsBeforeFirstStep = false;
GenerateAttributes(io);
adios_errno = err_no_error; adios_errno = err_no_error;
} }
else else
......
...@@ -49,7 +49,6 @@ public: ...@@ -49,7 +49,6 @@ public:
void InitParameters(const Params &parameters); void InitParameters(const Params &parameters);
void InitTransports(const std::vector<Params> &transportsParameters); void InitTransports(const std::vector<Params> &transportsParameters);
bool Open(IO &io); // return true if file is opened successfully bool Open(IO &io); // return true if file is opened successfully
void GenerateVariables(IO &io);
void ScheduleReadCommon(const std::string &name, const Dims &offs, void ScheduleReadCommon(const std::string &name, const Dims &offs,
const Dims &ldims, const int fromStep, const Dims &ldims, const int fromStep,
...@@ -87,6 +86,16 @@ private: ...@@ -87,6 +86,16 @@ private:
template <class T> template <class T>
void DefineADIOS2Variable(IO &io, const char *name, const ADIOS_VARINFO *vi, void DefineADIOS2Variable(IO &io, const char *name, const ADIOS_VARINFO *vi,
Dims gdims, bool isJoined, bool isGlobal); Dims gdims, bool isJoined, bool isGlobal);
void GenerateVariables(IO &io);
void DefineADIOS2Attribute(IO &io, const char *name,
enum ADIOS_DATATYPES type, void *value);
template <class T>
void DefineADIOS2Attribute(IO &io, const char *name, void *value);
void GenerateAttributes(IO &io);
}; };
} // end namespace interop } // end namespace interop
......
...@@ -44,6 +44,14 @@ void ADIOS1CommonRead::DefineADIOS2Variable(IO &io, const char *name, ...@@ -44,6 +44,14 @@ void ADIOS1CommonRead::DefineADIOS2Variable(IO &io, const char *name,
} }
} }
template <class T>
void ADIOS1CommonRead::DefineADIOS2Attribute(IO &io, const char *name,
void *value)
{
adios2::Attribute<T> &attr = io.DefineAttribute<T>(
name, *(reinterpret_cast<typename TypeInfo<T>::ValueType *>(value)));
}
} // end namespace interop } // end namespace interop
} // end namespace adios2 } // end namespace adios2
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment