Newer
Older
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
Podhorszki, Norbert
committed
* ADIOS1Reader.cpp
*
* Created on: Feb 27, 2017
* Author: wfg
*/
#include "ADIOS1Reader.h"
#include "adios2/core/Support.h"
#include "adios2/core/adiosFunctions.h" // CSVToVector
#include "adios2/transport/file/FStream.h" // uses C++ fstream
#include "adios2/transport/file/FileDescriptor.h" // uses POSIX
#include "adios2/transport/file/FilePointer.h" // uses C FILE*
ADIOS1Reader::ADIOS1Reader(ADIOS &adios, const std::string &name,
const std::string accessMode, MPI_Comm mpiComm,
const Method &method)
Podhorszki, Norbert
committed
: Engine(adios, "ADIOS1Reader", name, accessMode, mpiComm, method,
" ADIOS1Reader constructor (or call to ADIOS Open).\n")
Podhorszki, Norbert
committed
adios_read_init_method(m_ReadMethod, mpiComm, "");
Podhorszki, Norbert
committed
m_fh = adios_read_open(name.c_str(), m_ReadMethod, mpiComm,
ADIOS_LOCKMODE_CURRENT, 0.0);
Podhorszki, Norbert
committed
ADIOS1Reader::~ADIOS1Reader()
{
if (m_fh != nullptr)
adios_read_close(m_fh);
adios_read_finalize_method(m_ReadMethod);
}
Podhorszki, Norbert
committed
Podhorszki, Norbert
committed
ADIOS1Reader::InquireVariable(const std::string &variableName,
const bool readIn) // not yet implemented
{
Podhorszki, Norbert
committed
ADIOS1Reader::InquireVariableChar(const std::string &variableName,
const bool readIn)
return InquireVariableCommon<char>(variableName, readIn);
Podhorszki, Norbert
committed
ADIOS1Reader::InquireVariableUChar(const std::string &variableName,
const bool readIn)
return InquireVariableCommon<unsigned char>(variableName, readIn);
Podhorszki, Norbert
committed
ADIOS1Reader::InquireVariableShort(const std::string &variableName,
const bool readIn)
return InquireVariableCommon<short>(variableName, readIn);
Podhorszki, Norbert
committed
ADIOS1Reader::InquireVariableUShort(const std::string &variableName,
const bool readIn)
return InquireVariableCommon<unsigned short>(variableName, readIn);
Podhorszki, Norbert
committed
Variable<int> *ADIOS1Reader::InquireVariableInt(const std::string &variableName,
return InquireVariableCommon<int>(variableName, readIn);
Podhorszki, Norbert
committed
ADIOS1Reader::InquireVariableUInt(const std::string &variableName,
const bool readIn)
return InquireVariableCommon<unsigned int>(variableName, readIn);
Variable<long int> *
Podhorszki, Norbert
committed
ADIOS1Reader::InquireVariableLInt(const std::string &variableName,
const bool readIn)
return InquireVariableCommon<long int>(variableName, readIn);
Podhorszki, Norbert
committed
ADIOS1Reader::InquireVariableULInt(const std::string &variableName,
const bool readIn)
return InquireVariableCommon<unsigned long int>(variableName, readIn);
Podhorszki, Norbert
committed
ADIOS1Reader::InquireVariableLLInt(const std::string &variableName,
const bool readIn)
return InquireVariableCommon<long long int>(variableName, readIn);
}
Variable<unsigned long long int> *
Podhorszki, Norbert
committed
ADIOS1Reader::InquireVariableULLInt(const std::string &variableName,
const bool readIn)
return InquireVariableCommon<unsigned long long int>(variableName, readIn);
Variable<float> *
Podhorszki, Norbert
committed
ADIOS1Reader::InquireVariableFloat(const std::string &variableName,
const bool readIn)
return InquireVariableCommon<float>(variableName, readIn);
Variable<double> *
Podhorszki, Norbert
committed
ADIOS1Reader::InquireVariableDouble(const std::string &variableName,
const bool readIn)
return InquireVariableCommon<double>(variableName, readIn);
Podhorszki, Norbert
committed
ADIOS1Reader::InquireVariableLDouble(const std::string &variableName,
const bool readIn)
return InquireVariableCommon<long double>(variableName, readIn);
Podhorszki, Norbert
committed
ADIOS1Reader::InquireVariableCFloat(const std::string &variableName,
const bool readIn)
return InquireVariableCommon<std::complex<float>>(variableName, readIn);
Podhorszki, Norbert
committed
ADIOS1Reader::InquireVariableCDouble(const std::string &variableName,
const bool readIn)
return InquireVariableCommon<std::complex<double>>(variableName, readIn);
}
Variable<std::complex<long double>> *
Podhorszki, Norbert
committed
ADIOS1Reader::InquireVariableCLDouble(const std::string &variableName,
const bool readIn)
return InquireVariableCommon<std::complex<long double>>(variableName,
readIn);
VariableCompound *
Podhorszki, Norbert
committed
ADIOS1Reader::InquireVariableCompound(const std::string &variableName,
const bool readIn)
Podhorszki, Norbert
committed
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
void ADIOS1Reader::ScheduleReadCommon(const std::string &name,
const Dims &ldims, const Dims &offs,
void *data)
{
uint64_t start[32], count[32];
for (int i = 0; i < ldims.size(); i++)
{
start[i] = (uint64_t)offs[i];
count[i] = (uint64_t)ldims[i];
}
ADIOS_SELECTION *sel =
adios_selection_boundingbox(ldims.size(), start, count);
adios_schedule_read(m_fh, sel, name.c_str(), 1, 0, data);
adios_selection_delete(sel);
}
void ADIOS1Reader::ScheduleRead(Variable<double> &variable, double *values)
{
ScheduleReadCommon(variable.m_Name, variable.m_LocalDimensions,
variable.m_Offsets, (void *)values);
}
void ADIOS1Reader::ScheduleRead(const std::string variableName, double *values)
{
ScheduleRead(m_ADIOS.GetVariable<double>(variableName), values);
}
void ADIOS1Reader::PerformReads(PerformReadMode mode)
{
adios_perform_reads(m_fh, (int)mode);
}
void ADIOS1Reader::Close(const int transportIndex) { adios_read_close(m_fh); }
Podhorszki, Norbert
committed
void ADIOS1Reader::Init()
if (m_DebugMode == true)
{
if (m_AccessMode != "r" && m_AccessMode != "read")
throw std::invalid_argument(
Podhorszki, Norbert
committed
"ERROR: ADIOS1Reader doesn't support access mode " +
Podhorszki, Norbert
committed
", in call to ADIOS Open or ADIOS1Reader constructor\n");
Podhorszki, Norbert
committed
InitParameters();
Podhorszki, Norbert
committed
void ADIOS1Reader::InitParameters() {}
void ADIOS1Reader::InitTransports()
Podhorszki, Norbert
committed
if (TransportNamesUniqueness() == false)
{
throw std::invalid_argument(
"ERROR: two transports of the same kind (e.g file IO) "
"can't have the same name, modify with name= in Method "
"AddTransport\n");
}
for (const auto ¶meters : m_Method.m_TransportParameters)
auto itTransport = parameters.find("transport");
Podhorszki, Norbert
committed
if (itTransport->second == "file" || itTransport->second == "File" ||
itTransport->second == "bp" || itTransport->second == "BP")
Podhorszki, Norbert
committed
m_ReadMethod = ADIOS_READ_METHOD_BP;
}
else
{
if (m_DebugMode == true)
throw std::invalid_argument(
"ERROR: transport " + itTransport->second +
" (you mean File?) not supported, in " + m_Name +
m_EndMessage);
}