Skip to content

Commit

Permalink
Merge pull request #2362 from bradking/minor-cleanup
Browse files Browse the repository at this point in the history
bpls: Minor cleanup of variable and attribute lookup
  • Loading branch information
pnorbert authored Jul 9, 2020
2 parents 1a727f6 + eeb9521 commit 9b4f877
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 35 deletions.
23 changes: 0 additions & 23 deletions source/adios2/common/ADIOSMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,21 +169,6 @@
MACRO(std::complex<float>) \
MACRO(std::complex<double>)

#define ADIOS2_FOREACH_NUMERIC_ATTRIBUTE_TYPE_1ARG(MACRO) \
MACRO(short) \
MACRO(unsigned short) \
MACRO(int) \
MACRO(unsigned int) \
MACRO(long int) \
MACRO(long long int) \
MACRO(unsigned long int) \
MACRO(unsigned long long int) \
MACRO(float) \
MACRO(double) \
MACRO(long double) \
MACRO(std::complex<float>) \
MACRO(std::complex<double>)

/**
<pre>
The ADIOS2_FOREACH_STDTYPE_2ARGS macro assumes the given argument is a macro
Expand Down Expand Up @@ -242,14 +227,6 @@
#define ADIOS2_FOREACH_STDTYPE_2ARGS(MACRO) \
ADIOS2_FOREACH_ATTRIBUTE_STDTYPE_2ARGS(MACRO)

#define ADIOS2_FOREACH_COMPLEX_TYPE_2ARGS(MACRO) \
MACRO(std::complex<float>, CFloat) \
MACRO(std::complex<double>, CDouble)

#define ADIOS2_FOREACH_LAUNCH_MODE(MACRO) \
MACRO(Sync) \
MACRO(Deferred)

#define ADIOS2_CLASS_iterator \
class iterator \
{ \
Expand Down
16 changes: 6 additions & 10 deletions source/utils/bpls/bpls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -907,15 +907,15 @@ int doList_vars(core::Engine *fp, core::IO *io)
{
for (const auto &vpair : variables)
{
Entry e(true, vpair.second->m_Type);
Entry e(vpair.second->m_Type, vpair.second.get());
entries.emplace(vpair.first, e);
}
}
if (listattrs)
{
for (const auto &apair : attributes)
{
Entry e(false, apair.second->m_Type);
Entry e(apair.second->m_Type, apair.second.get());
entries.emplace(apair.first, e);
}
}
Expand Down Expand Up @@ -963,7 +963,7 @@ int doList_vars(core::Engine *fp, core::IO *io)
#define declare_template_instantiation(T) \
else if (entry.typeName == helper::GetDataType<T>()) \
{ \
core::Attribute<T> *a = io->InquireAttribute<T>(name); \
core::Attribute<T> *a = static_cast<core::Attribute<T> *>(entry.attr); \
retval = printAttributeValue(fp, io, a); \
}
ADIOS2_FOREACH_ATTRIBUTE_STDTYPE_1ARG(
Expand All @@ -986,7 +986,7 @@ int doList_vars(core::Engine *fp, core::IO *io)
#define declare_template_instantiation(T) \
else if (entry.typeName == helper::GetDataType<T>()) \
{ \
core::Variable<T> *v = io->InquireVariable<T>(name); \
core::Variable<T> *v = static_cast<core::Variable<T> *>(entry.var); \
retval = printVariableInfo(fp, io, v); \
}
ADIOS2_FOREACH_STDTYPE_1ARG(declare_template_instantiation)
Expand Down Expand Up @@ -1474,13 +1474,9 @@ int doList(const char *path)
// ntsteps = fp->tidx_stop - fp->tidx_start + 1;
if (verbose)
{
const std::map<std::string, Params> &variablesInfo =
io.GetAvailableVariables();
const std::map<std::string, Params> &attributesInfo =
io.GetAvailableAttributes();
printf("File info:\n");
printf(" of variables: %zu\n", variablesInfo.size());
printf(" of attributes: %zu\n", attributesInfo.size());
printf(" of variables: %zu\n", io.GetVariables().size());
printf(" of attributes: %zu\n", io.GetAttributes().size());
// printf(" of meshes: %d\n", fp->nmeshes);
// print_file_size(fp->file_size);
// printf(" bp version: %d\n", fp->version);
Expand Down
16 changes: 14 additions & 2 deletions source/utils/bpls/bpls.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,21 @@ namespace utils

struct Entry
{
bool isVar;
DataType typeName;
Entry(bool b, DataType type) : isVar(b), typeName(type) {}
bool isVar;
union
{
core::VariableBase *var;
core::AttributeBase *attr;
};
Entry(DataType type, core::VariableBase *v)
: typeName(type), isVar(true), var(v)
{
}
Entry(DataType type, core::AttributeBase *a)
: typeName(type), isVar(false), attr(a)
{
}
};

// how to print one data item of an array
Expand Down

0 comments on commit 9b4f877

Please sign in to comment.