Skip to content

Commit

Permalink
Merge pull request #4124 from pnorbert/campaign-attributes
Browse files Browse the repository at this point in the history
Add attribute support to campaign
  • Loading branch information
pnorbert committed Apr 3, 2024
2 parents 696096f + 723f297 commit 1e82328
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
1 change: 0 additions & 1 deletion docs/user_guide/source/advanced/campaign_management.rst
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,4 @@ Limitations
===========

- The Campaign Reader engine only supports ReadRandomAccess mode, not step-by-step reading. Campaign management will need to change in the future to support sorting the steps from different outputs to a coherent order.
- Attributes are not processed by the Campaign Reader yet
- Updates to moving data for other location is not supported yet
22 changes: 22 additions & 0 deletions source/adios2/engine/campaign/CampaignReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,28 @@ void CampaignReader::InitTransports()
ADIOS2_FOREACH_STDTYPE_1ARG(declare_type)
#undef declare_type
}

for (auto &ar : amap)
{
auto aname = ar.first;
std::string fname = ds.name;
std::string newname = fname + "/" + aname;

const DataType type = io.InquireAttributeType(aname);

if (type == DataType::Struct)
{
}
#define declare_type(T) \
else if (type == helper::GetDataType<T>()) \
{ \
Attribute<T> *ai = io.InquireAttribute<T>(aname); \
Attribute<T> v = DuplicateAttribute(ai, m_IO, newname); \
}

ADIOS2_FOREACH_STDTYPE_1ARG(declare_type)
#undef declare_type
}
++i;
}
}
Expand Down
7 changes: 7 additions & 0 deletions source/adios2/engine/campaign/CampaignReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ class CampaignReader : public Engine
Variable<T> DuplicateVariable(Variable<T> *variable, IO &io, std::string &name,
VarInternalInfo &vii);

/**
* Create a new attribute with name `name` in `io`
* based on an existing attribute.
*/
template <class T>
Attribute<T> DuplicateAttribute(Attribute<T> *attribute, IO &io, std::string &name);

/**
* Create a new variable with name `name` in `io`
* based on an existing variable.
Expand Down
13 changes: 13 additions & 0 deletions source/adios2/engine/campaign/CampaignReader.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ inline Variable<T> CampaignReader::DuplicateVariable(Variable<T> *variable, IO &
return v;
}

template <class T>
inline Attribute<T> CampaignReader::DuplicateAttribute(Attribute<T> *attribute, IO &io,
std::string &name)
{
if (attribute->m_IsSingleValue)
{
auto &a = io.DefineAttribute<T>(name, attribute->m_DataSingleValue);
return a;
}
auto &a = io.DefineAttribute<T>(name, attribute->m_DataArray.data(), attribute->m_Elements);
return a;
}

template <class T>
inline std::pair<Variable<T> *, Engine *>
CampaignReader::TranslateToActualVariable(Variable<T> &variable)
Expand Down

0 comments on commit 1e82328

Please sign in to comment.