Skip to content

Commit

Permalink
Attributes: Allow Complex Types
Browse files Browse the repository at this point in the history
This is a quick hack, but it demonstrates that complex
attribute types are no problem, just as in ADIOS1.
  • Loading branch information
ax3l committed Dec 20, 2019
1 parent cc5f742 commit a9cc521
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 5 deletions.
10 changes: 5 additions & 5 deletions source/adios2/common/ADIOSMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

#define ADIOS2_FOREACH_ATTRIBUTE_STDTYPE_1ARG(MACRO) \
MACRO(std::string) \
ADIOS2_FOREACH_ATTRIBUTE_PRIMITIVE_STDTYPE_1ARG(MACRO)
ADIOS2_FOREACH_PRIMITIVE_STDTYPE_1ARG(MACRO)

#define ADIOS2_FOREACH_STDTYPE_1ARG(MACRO) \
MACRO(std::string) \
Expand Down Expand Up @@ -214,7 +214,9 @@
MACRO(uint64_t, uint64) \
MACRO(float, float) \
MACRO(double, double) \
MACRO(long double, ldouble)
MACRO(long double, ldouble) \
MACRO(std::complex<float>, cfloat) \
MACRO(std::complex<double>, cdouble)

#define ADIOS2_FOREACH_PRIMITVE_STDTYPE_2ARGS(MACRO) \
MACRO(int8_t, int8) \
Expand All @@ -232,9 +234,7 @@
MACRO(std::complex<double>, cdouble)

#define ADIOS2_FOREACH_STDTYPE_2ARGS(MACRO) \
ADIOS2_FOREACH_ATTRIBUTE_STDTYPE_2ARGS(MACRO) \
MACRO(std::complex<float>, cfloat) \
MACRO(std::complex<double>, cdouble)
ADIOS2_FOREACH_ATTRIBUTE_STDTYPE_2ARGS(MACRO)

#define ADIOS2_FOREACH_COMPLEX_TYPE_2ARGS(MACRO) \
MACRO(std::complex<float>, CFloat) \
Expand Down
1 change: 1 addition & 0 deletions source/adios2/engine/ssc/SscReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "SscReader.tcc"
#include "adios2/helper/adiosComm.h"
#include "adios2/helper/adiosFunctions.h"
#include "adios2/helper/adiosJSONcomplex.h"
#include "nlohmann/json.hpp"

namespace adios2
Expand Down
1 change: 1 addition & 0 deletions source/adios2/engine/ssc/SscWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "SscWriter.tcc"
#include "adios2/helper/adiosComm.h"
#include "adios2/helper/adiosJSONcomplex.h"
#include "nlohmann/json.hpp"

namespace adios2
Expand Down
34 changes: 34 additions & 0 deletions source/adios2/helper/adiosJSONcomplex.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* adiosYAML.h basic YAML parsing functionality for ADIOS config file schema
*
* Created on: Dec 19, 2019
* Author: Axel Huebl <[email protected]>
*/

#ifndef ADIOS2_HELPER_ADIOSJSONCOMPLEX_H_
#define ADIOS2_HELPER_ADIOSJSONCOMPLEX_H_

#include "nlohmann/json.hpp"
#include <complex>

// JSON std::complex handling
namespace std
{
template <class T>
inline void to_json(nlohmann::json &j, const std::complex<T> &p)
{
j = nlohmann::json{p.real(), p.imag()};
}

template <class T>
inline void from_json(const nlohmann::json &j, std::complex<T> &p)
{
p.real(j.at(0));
p.imag(j.at(1));
}
} // end namespace std

#endif /* ADIOS2_HELPER_ADIOSJSONCOMPLEX_H_ */
1 change: 1 addition & 0 deletions source/adios2/toolkit/format/dataman/DataManSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "adios2/common/ADIOSTypes.h"
#include "adios2/core/IO.h"
#include "adios2/helper/adiosComm.h"
#include "adios2/helper/adiosJSONcomplex.h"
#include "adios2/toolkit/profiling/taustubs/tautimer.hpp"

#include <mutex>
Expand Down

0 comments on commit a9cc521

Please sign in to comment.