Skip to content

Commit

Permalink
Fixes for building with and without support for Derived Variables
Browse files Browse the repository at this point in the history
  • Loading branch information
pnorbert committed Jul 30, 2024
1 parent eb73147 commit 30d5b69
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
2 changes: 2 additions & 0 deletions bindings/Python/py11IO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ VariableDerived IO::DefineDerivedVariable(const std::string &name, const std::st
adios2::py11::VariableDerived vd(dv);
#else
adios2::py11::VariableDerived vd;
throw std::invalid_argument("ERROR: Derived Variables are not supported in this adios2 build "
", in call to DefineDerivedVariable\n");
#endif
return vd;
}
Expand Down
14 changes: 14 additions & 0 deletions bindings/Python/py11VariableDerived.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace adios2
namespace py11
{

#ifdef ADIOS2_HAVE_DERIVED_VARIABLE
VariableDerived::VariableDerived(core::VariableDerived *v) : m_VariableDerived(v) {}

VariableDerived::operator bool() const noexcept
Expand All @@ -33,5 +34,18 @@ DerivedVarType VariableDerived::Type() const
return m_VariableDerived->GetDerivedType();
}

#else

VariableDerived::operator bool() const noexcept { return false; }

std::string VariableDerived::Name() const
{
return "DerivedVariables are not supported in this ADIOS2 build";
}

DerivedVarType VariableDerived::Type() const { return DerivedVarType::ExpressionString; }

#endif

} // end namespace py11
} // end namespace adios2
13 changes: 10 additions & 3 deletions bindings/Python/py11VariableDerived.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
#ifndef ADIOS2_BINDINGS_PYTHON_VARIABLEDERIVED_H_
#define ADIOS2_BINDINGS_PYTHON_VARIABLEDERIVED_H_

#include "adios2/common/ADIOSConfig.h"

#ifdef ADIOS2_HAVE_DERIVED_VARIABLE
#include "adios2/core/VariableDerived.h"
#else
#include "adios2/common/ADIOSTypes.h"
#endif

namespace adios2
{
Expand All @@ -36,9 +42,10 @@ class VariableDerived
DerivedVarType Type() const;

private:
VariableDerived(core::VariableDerived *v);

core::VariableDerived *m_VariableDerived = nullptr;
#ifdef ADIOS2_HAVE_DERIVED_VARIABLE
VariableDerived(adios2::core::VariableDerived *v);
adios2::core::VariableDerived *m_VariableDerived = nullptr;
#endif
};

} // end namespace py11
Expand Down
2 changes: 0 additions & 2 deletions source/adios2/common/ADIOSTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,13 @@
namespace adios2
{

#ifdef ADIOS2_HAVE_DERIVED_VARIABLE
/** Type of derived variables */
enum class DerivedVarType
{
MetadataOnly, ///< Store only the metadata (default)
ExpressionString, ///< Store only the expression string
StoreData ///< Store data and metadata
};
#endif

/** Memory space for the user provided buffers */
enum class MemorySpace
Expand Down
5 changes: 4 additions & 1 deletion testing/adios2/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ python_add_test(NAME Api.Python.Variable SCRIPT TestVariable.py)
python_add_test(NAME Api.Python.Attribute SCRIPT TestAttribute.py)
python_add_test(NAME Api.Python.Stream SCRIPT TestStream.py)
python_add_test(NAME Api.Python.FileReader SCRIPT TestFileReader.py)
python_add_test(NAME Api.Python.DerivedVariable SCRIPT TestDerivedVariable.py)

if (ADIOS2_HAVE_Derived_Variable)
python_add_test(NAME Api.Python.DerivedVariable SCRIPT TestDerivedVariable.py)
endif()

if(ADIOS2_HAVE_MPI)
add_python_mpi_test(BPWriteReadString)
Expand Down

0 comments on commit 30d5b69

Please sign in to comment.