Newer
Older
/*
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* Engine.tcc
*
* Created on: Jun 2, 2017
* Author: William F Godoy godoywf@ornl.gov
*/
#ifndef ADIOS2_CORE_ENGINE_TCC_
#define ADIOS2_CORE_ENGINE_TCC_
#include "Engine.h"
#include "adios2/helper/adiosFunctions.h" // IsLvalue
// Put
#define declare_launch_mode(L) \
\
template <class T> \
void Engine::Put##L(Variable<T> &variable, const T *data) \
{ \
if (m_DebugMode) \
{ \
if (&variable == nullptr) \
{ \
throw std::invalid_argument( \
"ERROR: variable reference is " \
"undefined, is good practice to check if " \
"IO::InquireVariable(name) is nullptr first " \
", in call to Put" + \
std::string(#L) + "\n"); \
} \
\
variable.CheckDimensions("Put" + std::string(#L)); \
\
if (data == nullptr) \
{ \
throw std::invalid_argument( \
"ERROR: found null pointer for Variable " + \
variable.m_Name + ", in call to Put" + std::string(#L) + \
"\n"); \
} \
} \
\
DoPut##L(variable, data); \
} \
\
template <class T> \
void Engine::Put##L(const std::string &variableName, const T *data) \
{ \
Put##L(FindVariable<T>(variableName), data); \
} \
\
template <class T> \
void Engine::Put##L(Variable<T> &variable) \
{ \
Put##L(variable, variable.GetData()); \
} \
\
template <class T> \
void Engine::Put##L(Variable<T> &variable, const T &value) \
PutSync(variable, &valueLocal); \
} \
\
template <class T> \
void Engine::Put##L(const std::string &variableName, const T &value) \
{ \
PutSync(FindVariable<T>(variableName), value); \
ADIOS2_FOREACH_LAUNCH_MODE(declare_launch_mode)
#undef declare_launch_mode
// Get
#define declare_launch_mode(L) \
\
template <class T> \
void Engine::Get##L(Variable<T> &variable, T *data) \
{ \
if (m_DebugMode) \
{ \
throw std::invalid_argument( \
"ERROR: variable reference is " \
"undefined, is good practice to check if " \
"IO::InquireVariable(name) is nullptr first, in call to " \
"Get" + \
std::string(#L) + "\n"); \
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
variable.CheckDimensions("Get" + std::string(#L)); \
\
if (data == nullptr) \
{ \
throw std::invalid_argument( \
"ERROR: found null pointer for Variable " + \
variable.m_Name + ", in call to Get" + std::string(#L) + \
"\n"); \
} \
} \
\
DoGet##L(variable, data); \
} \
\
template <class T> \
void Engine::Get##L(const std::string &variableName, T *data) \
{ \
Get##L(FindVariable<T>(variableName), data); \
} \
\
template <class T> \
void Engine::Get##L(Variable<T> &variable) \
{ \
Get##L(variable, variable.GetData()); \
} \
\
template <class T> \
void Engine::Get##L(Variable<T> &variable, T &value) \
{ \
GetSync(variable, &value); \
} \
\
template <class T> \
void Engine::Get##L(const std::string &variableName, T &value) \
{ \
GetSync(FindVariable<T>(variableName), value); \
ADIOS2_FOREACH_LAUNCH_MODE(declare_launch_mode)
#undef declare_launch_mode
Variable<T> &Engine::FindVariable(const std::string &variableName)
Variable<T> *variable = m_IO.InquireVariable<T>(variableName);
if (m_DebugMode && variable == nullptr)
{
throw std::invalid_argument("ERROR: Variable " + variableName +
" not found in IO " + m_IO.m_Name +
", in call to Put Synch\n");
}
return *variable;
} // end namespace adios2
#endif /** ADIOS2_CORE_ENGINE_TCC_ */