Skip to content
Snippets Groups Projects
Unverified Commit 5a8d1544 authored by williamfgc's avatar williamfgc Committed by GitHub
Browse files

Merge pull request #308 from williamfgc/column

Reader column-major ordering and tests
parents 837deb8b 31b0e67e
No related branches found
No related tags found
No related merge requests found
Showing
with 2166 additions and 15 deletions
......@@ -9,6 +9,7 @@ ${CMAKE_CURRENT_SOURCE_DIR}/adios2/adios2_c_adios.cpp
${CMAKE_CURRENT_SOURCE_DIR}/adios2/adios2_c_glue.cpp
${CMAKE_CURRENT_SOURCE_DIR}/adios2/adios2_c_io.cpp
${CMAKE_CURRENT_SOURCE_DIR}/adios2/adios2_c_engine.cpp
${CMAKE_CURRENT_SOURCE_DIR}/adios2/adios2_c_variable.cpp
)
target_include_directories(adios2
......@@ -26,6 +27,7 @@ install(
adios2/adios2_c_adios.h
adios2/adios2_c_glue.h
adios2/adios2_c_io.h
adios2/adios2_c_variable.h
adios2/adios2_c_engine.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/adios2
)
......@@ -156,6 +156,142 @@ void adios2_perform_puts(adios2_Engine *engine)
engineCpp.PerformPuts();
}
void adios2_get_sync(adios2_Engine *engine, adios2_Variable *variable,
void *values)
{
adios2::VariableBase *variableBase =
reinterpret_cast<adios2::VariableBase *>(variable);
const std::string type(variableBase->m_Type);
adios2::Engine &engineCpp = *reinterpret_cast<adios2::Engine *>(engine);
if (type == "compound")
{
// not supported
}
#define declare_template_instantiation(T) \
else if (type == adios2::GetType<T>()) \
{ \
engineCpp.GetSync(*dynamic_cast<adios2::Variable<T> *>(variableBase), \
reinterpret_cast<T *>(values)); \
}
ADIOS2_FOREACH_TYPE_1ARG(declare_template_instantiation)
#undef declare_template_instantiation
}
void adios2_get_sync_self(adios2_Engine *engine, adios2_Variable *variable)
{
adios2::VariableBase *variableBase =
reinterpret_cast<adios2::VariableBase *>(variable);
const std::string type(variableBase->m_Type);
adios2::Engine &engineCpp = *reinterpret_cast<adios2::Engine *>(engine);
if (type == "compound")
{
// not supported
}
#define declare_template_instantiation(T) \
else if (type == adios2::GetType<T>()) \
{ \
engineCpp.GetSync(*dynamic_cast<adios2::Variable<T> *>(variableBase)); \
}
ADIOS2_FOREACH_TYPE_1ARG(declare_template_instantiation)
#undef declare_template_instantiation
}
void adios2_get_sync_by_name(adios2_Engine *engine, const char *variable_name,
void *values)
{
auto &engineCpp = *reinterpret_cast<adios2::Engine *>(engine);
const std::string type(
engineCpp.GetIO().InquireVariableType(variable_name));
if (type == "compound")
{
// not supported
}
#define declare_template_instantiation(T) \
else if (type == adios2::GetType<T>()) \
{ \
engineCpp.GetSync(variable_name, reinterpret_cast<T *>(values)); \
}
ADIOS2_FOREACH_TYPE_1ARG(declare_template_instantiation)
#undef declare_template_instantiation
}
void adios2_get_deferred(adios2_Engine *engine, adios2_Variable *variable,
void *values)
{
adios2::VariableBase *variableBase =
reinterpret_cast<adios2::VariableBase *>(variable);
const std::string type(variableBase->m_Type);
adios2::Engine &engineCpp = *reinterpret_cast<adios2::Engine *>(engine);
if (type == "compound")
{
// not supported
}
#define declare_template_instantiation(T) \
else if (type == adios2::GetType<T>()) \
{ \
engineCpp.GetDeferred( \
*dynamic_cast<adios2::Variable<T> *>(variableBase), \
reinterpret_cast<T *>(values)); \
}
ADIOS2_FOREACH_TYPE_1ARG(declare_template_instantiation)
#undef declare_template_instantiation
}
void adios2_get_deferred_self(adios2_Engine *engine, adios2_Variable *variable)
{
adios2::VariableBase *variableBase =
reinterpret_cast<adios2::VariableBase *>(variable);
const std::string type(variableBase->m_Type);
adios2::Engine &engineCpp = *reinterpret_cast<adios2::Engine *>(engine);
if (type == "compound")
{
// not supported
}
#define declare_template_instantiation(T) \
else if (type == adios2::GetType<T>()) \
{ \
engineCpp.GetDeferred( \
*dynamic_cast<adios2::Variable<T> *>(variableBase)); \
}
ADIOS2_FOREACH_TYPE_1ARG(declare_template_instantiation)
#undef declare_template_instantiation
}
void adios2_get_deferred_by_name(adios2_Engine *engine,
const char *variable_name, void *values)
{
auto &engineCpp = *reinterpret_cast<adios2::Engine *>(engine);
const std::string type(
engineCpp.GetIO().InquireVariableType(variable_name));
if (type == "compound")
{
// not supported
}
#define declare_template_instantiation(T) \
else if (type == adios2::GetType<T>()) \
{ \
engineCpp.GetDeferred(variable_name, reinterpret_cast<T *>(values)); \
}
ADIOS2_FOREACH_TYPE_1ARG(declare_template_instantiation)
#undef declare_template_instantiation
}
void adios2_perform_gets(adios2_Engine *engine)
{
auto &engineCpp = *reinterpret_cast<adios2::Engine *>(engine);
engineCpp.PerformGets();
}
void adios2_end_step(adios2_Engine *engine)
{
auto &engineCpp = *reinterpret_cast<adios2::Engine *>(engine);
......
......@@ -22,6 +22,8 @@ extern "C" {
*/
void adios2_begin_step(adios2_Engine *engine);
//***************** PUT *****************
/**
* Put a variable in IO using a adios2_Variable handler
* @param engine handler for engine executing the write
......@@ -33,7 +35,7 @@ void adios2_put_sync(adios2_Engine *engine, adios2_Variable *variable,
void adios2_put_sync_self(adios2_Engine *engine, adios2_Variable *variable);
void adios2_put_sync_by_name(adios2_Engine *engine, const char *variableName,
void adios2_put_sync_by_name(adios2_Engine *engine, const char *variable_name,
const void *values);
/**
......@@ -48,10 +50,29 @@ void adios2_put_deferred(adios2_Engine *engine, adios2_Variable *variable,
void adios2_put_deferred_self(adios2_Engine *engine, adios2_Variable *variable);
void adios2_put_deferred_by_name(adios2_Engine *engine,
const char *variableName, const void *values);
const char *variable_name, const void *values);
void adios2_perform_puts(adios2_Engine *engine);
//***************** GET *****************
void adios2_get_sync(adios2_Engine *engine, adios2_Variable *variable,
void *values);
void adios2_get_sync_self(adios2_Engine *engine, adios2_Variable *variable);
void adios2_get_sync_by_name(adios2_Engine *engine, const char *variable_name,
void *values);
void adios2_get_deferred(adios2_Engine *engine, adios2_Variable *variable,
void *values);
void adios2_get_deferred_self(adios2_Engine *engine, adios2_Variable *variable);
void adios2_get_deferred_by_name(adios2_Engine *engine,
const char *variable_name, void *values);
void adios2_perform_gets(adios2_Engine *engine);
/**
* terminates interaction with current step
* @param engine handler executing IO tasks
......
......@@ -3,7 +3,7 @@
* accompanying file Copyright.txt for details.
*
* adios2_c_glue.h : used by languages other than C, using the C-bindings API
* (e.g. Fortran), not meant to be for applications
* (e.g. Fortran), not meant to be used by applications
*
* Created on: Nov 3, 2017
* Author: William F Godoy godoywf@ornl.gov
......
......@@ -31,6 +31,7 @@ typedef enum {
} adios2_constant_dims;
typedef enum {
adios2_type_unknown = -1,
adios2_type_char = 0,
adios2_type_int = 1,
......@@ -44,7 +45,9 @@ typedef enum {
adios2_type_int32_t = 8,
adios2_type_int64_t = 9,
adios2_type_string,
adios2_type_string = 10,
adios2_type_string_array = 11,
adios2_type_signed_char,
adios2_type_short,
......
/*
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* adios2_c_variable.cpp
*
* Created on: Nov 10, 2017
* Author: William F Godoy godoywf@ornl.gov
*/
#include "adios2_c_variable.h"
#include "adios2/core/Variable.h"
#include "adios2/helper/adiosFunctions.h"
const std::map<std::string, std::vector<adios2_type>> adios2_types_map = {
{"char", {adios2_type_char}},
{"int", {adios2_type_int, adios2_type_int32_t}},
{"float", {adios2_type_float}},
{"double", {adios2_type_double}},
{"float complex", {adios2_type_float_complex}},
{"double complex", {adios2_type_double_complex}},
{"signed char", {adios2_type_int8_t, adios2_type_signed_char}},
{"short", {adios2_type_int16_t, adios2_type_short}},
{"long int", {adios2_type_int64_t, adios2_type_long_int}},
{"long long int", {adios2_type_int64_t, adios2_type_long_long_int}},
{"string", {adios2_type_string}},
{"string array", {adios2_type_string_array}},
{"unsigned char", {adios2_type_unsigned_char, adios2_type_uint8_t}},
{"unsigned short", {adios2_type_unsigned_short, adios2_type_uint16_t}},
{"unsigned int", {adios2_type_unsigned_int, adios2_type_uint32_t}},
{"unsigned long int",
{adios2_type_unsigned_long_int, adios2_type_uint64_t}},
{"unsigned long long int",
{adios2_type_unsigned_long_long_int, adios2_type_uint64_t}},
};
const char *adios2_variable_name(const adios2_Variable *variable,
size_t *length)
{
const adios2::VariableBase *variableBase =
reinterpret_cast<const adios2::VariableBase *>(variable);
if (length != nullptr)
{
*length = variableBase->m_Name.size();
}
return variableBase->m_Name.c_str();
}
adios2_type adios2_variable_type(const adios2_Variable *variable)
{
const adios2::VariableBase *variableBase =
reinterpret_cast<const adios2::VariableBase *>(variable);
auto itType = adios2_types_map.find(variableBase->m_Type);
if (itType == adios2_types_map.end())
{
return adios2_type_unknown;
}
return itType->second.front();
}
int adios2_variable_is_constant_dims(const adios2_Variable *variable)
{
const adios2::VariableBase *variableBase =
reinterpret_cast<const adios2::VariableBase *>(variable);
const int isConstantDims = (variableBase->m_ConstantDims) ? 1 : 0;
return isConstantDims;
}
const size_t adios2_variable_ndims(const adios2_Variable *variable)
{
const adios2::VariableBase *variableBase =
reinterpret_cast<const adios2::VariableBase *>(variable);
return variableBase->m_Shape.size();
}
const size_t *adios2_variable_shape(const adios2_Variable *variable)
{
const adios2::VariableBase *variableBase =
reinterpret_cast<const adios2::VariableBase *>(variable);
return variableBase->m_Shape.data();
}
const size_t *adios2_variable_start(const adios2_Variable *variable)
{
const adios2::VariableBase *variableBase =
reinterpret_cast<const adios2::VariableBase *>(variable);
return variableBase->m_Start.data();
}
const size_t *adios2_variable_count(const adios2_Variable *variable)
{
const adios2::VariableBase *variableBase =
reinterpret_cast<const adios2::VariableBase *>(variable);
return variableBase->m_Count.data();
}
const size_t
adios2_variable_available_steps_start(const adios2_Variable *variable)
{
const adios2::VariableBase *variableBase =
reinterpret_cast<const adios2::VariableBase *>(variable);
return variableBase->m_AvailableStepsStart;
}
const size_t
adios2_variable_available_steps_count(const adios2_Variable *variable)
{
const adios2::VariableBase *variableBase =
reinterpret_cast<const adios2::VariableBase *>(variable);
return variableBase->m_AvailableStepsCount;
}
void adios2_set_dimensions(adios2_Variable *variable, const size_t ndims,
const size_t *shape, const size_t *start,
const size_t *count)
{
auto lf_Assign = [](const size_t ndims, const size_t *input,
adios2::Dims &dims) {
if (input != nullptr)
{
dims.clear();
dims.assign(input, input + ndims);
}
};
adios2::VariableBase *variableBase =
reinterpret_cast<adios2::VariableBase *>(variable);
lf_Assign(ndims, shape, variableBase->m_Shape);
lf_Assign(ndims, start, variableBase->m_Start);
lf_Assign(ndims, count, variableBase->m_Count);
variableBase->CheckDimensions("in call to adios2_set_selection");
}
void adios2_set_selection(adios2_Variable *variable, const size_t ndims,
const size_t *start, const size_t *count)
{
adios2::VariableBase *variableBase =
reinterpret_cast<adios2::VariableBase *>(variable);
const adios2::Dims startV(start, start + ndims);
const adios2::Dims countV(count, count + ndims);
variableBase->SetSelection({startV, countV});
variableBase->CheckDimensions("in call to adios2_set_selection");
}
void adios2_set_step_selection(adios2_Variable *variable,
const size_t step_start, const size_t step_count)
{
adios2::VariableBase *variableBase =
reinterpret_cast<adios2::VariableBase *>(variable);
variableBase->SetStepSelection(adios2::Box<size_t>{step_start, step_count});
}
void *adios2_get_data(const adios2_Variable *variable)
{
const adios2::VariableBase *variableBase =
reinterpret_cast<const adios2::VariableBase *>(variable);
const std::string type(variableBase->m_Type);
void *data = nullptr;
if (type == "compound")
{
// not supported
}
#define declare_template_instantiation(T) \
else if (type == adios2::GetType<T>()) \
{ \
const adios2::Variable<T> *variableCpp = \
reinterpret_cast<const adios2::Variable<T> *>(variable); \
data = variableCpp->GetData(); \
}
ADIOS2_FOREACH_TYPE_1ARG(declare_template_instantiation)
#undef declare_template_instantiation
return data;
}
void adios2_set_data(adios2_Variable *variable, const void *data)
{
adios2::VariableBase *variableBase =
reinterpret_cast<adios2::VariableBase *>(variable);
const std::string type(variableBase->m_Type);
if (type == "compound")
{
// not supported
}
#define declare_template_instantiation(T) \
else if (type == adios2::GetType<T>()) \
{ \
adios2::Variable<T> *variableCpp = \
reinterpret_cast<adios2::Variable<T> *>(variable); \
variableCpp->SetData(reinterpret_cast<const T *>(data)); \
}
ADIOS2_FOREACH_TYPE_1ARG(declare_template_instantiation)
#undef declare_template_instantiation
}
/*
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* adios2_c_variable.h : exposes some members of the Variable handler
*
* Created on: Nov 10, 2017
* Author: William F Godoy godoywf@ornl.gov
*/
#ifndef BINDINGS_C_ADIOS2_ADIOS2_C_VARIABLE_H_
#define BINDINGS_C_ADIOS2_ADIOS2_C_VARIABLE_H_
#include "adios2_c_types.h"
#include <stddef.h> //size_t
#ifdef __cplusplus
extern "C" {
#endif
/**
* Retrieve variable name (read-only)
* @param variable handler
* @return name
*/
const char *adios2_variable_name(const adios2_Variable *variable,
size_t *length);
/**
* Retrieve variable type (read-only)
* @param variable handler
* @return type
*/
adios2_type adios2_variable_type(const adios2_Variable *variable);
/**
* Check if dimensions are constant
* @param variable
* @return 0: false (dimensions are not constant), 1: true dimensions are
* declared constant
*/
int adios2_variable_is_constant_dims(const adios2_Variable *variable);
const size_t adios2_variable_ndims(const adios2_Variable *variable);
/**
* Retrieve current variable shape (read-only)
* @param variable handler
* @return shape
*/
const size_t *adios2_variable_shape(const adios2_Variable *variable);
/**
* Retrieve current variable start (read-only)
* @param variable handler
* @return
*/
const size_t *adios2_variable_start(const adios2_Variable *variable);
/**
* Retrieve current variable shape (read-only)
* @param variable
* @return type
*/
const size_t *adios2_variable_count(const adios2_Variable *variable);
const size_t
adios2_variable_available_steps_start(const adios2_Variable *variable);
const size_t
adios2_variable_available_steps_count(const adios2_Variable *variable);
/**
* Set new dimensions
* @param variable
* @param shape
* @param start
* @param count
*/
void adios2_set_dimensions(adios2_Variable *variable, const size_t ndims,
const size_t *shape, const size_t *start,
const size_t *count);
/**
* Set new selection using start and count
* @param variable
* @param start
* @param count
*/
void adios2_set_selection(adios2_Variable *variable, const size_t ndims,
const size_t *start, const size_t *count);
/**
* Set new step selection using step_start and step_count
* @param variable
* @param step_start
* @param step_count
*/
void adios2_set_step_selection(adios2_Variable *variable,
const size_t step_start,
const size_t step_count);
/**
* Returns the minimum required allocation (in number of elements of a certain
* type, not bytes)
* for the current selection
* @param variable
* @return memory size to be allocated by a pointer/vector to read this
*/
size_t adios2_selection_size(const adios2_Variable *variable);
/**
* Get current data pointer, types must match
* @param variable
*/
void *adios2_get_data(const adios2_Variable *variable);
/**
* Sets current data pointer, types must match
* @param variable
* @param data
*/
void adios2_set_data(adios2_Variable *variable, const void *data);
#ifdef __cplusplus
} // end extern C
#endif
#endif /* BINDINGS_C_ADIOS2_ADIOS2_C_VARIABLE_H_ */
......@@ -16,5 +16,6 @@
#include "adios2/adios2_c_engine.h"
#include "adios2/adios2_c_glue.h"
#include "adios2/adios2_c_io.h"
#include "adios2/adios2_c_variable.h"
#endif /* ADIOS2_BINDINGS_C_ADIOS2_C_H_ */
......@@ -11,6 +11,7 @@ FortranCInterface_VERIFY(CXX QUIET)
set(F2C
f2c/adios2_f2c_adios.cpp
f2c/adios2_f2c_io.cpp
f2c/adios2_f2c_variable.cpp
f2c/adios2_f2c_engine.cpp
)
......@@ -20,9 +21,12 @@ set(MODULES
modules/adios2_parameters_mod.f90
modules/adios2_adios_mod.f90
modules/adios2_io_mod.f90
modules/adios2_variable_mod.f90
modules/adios2_engine_mod.f90
modules/adios2_engine_write_mod.f90
modules/adios2_engine_iwrite_mod.f90
modules/adios2_engine_read_mod.f90
modules/adios2_engine_iread_mod.f90
)
add_library(adios2_f ${MODULES} ${F2C})
......
......@@ -13,7 +13,7 @@ module adios2
use adios2_parameters
use adios2_adios
use adios2_io
! TODO use adios2_variable
use adios2_variable
use adios2_engine
end module
......@@ -26,6 +26,7 @@ void FC_GLOBAL(adios2_begin_step_f2c,
}
}
// ******** PUTS */
void FC_GLOBAL(adios2_put_sync_f2c,
ADIOS2_PUT_SYNC_F2C)(adios2_Engine **engine,
adios2_Variable **variable,
......@@ -50,7 +51,68 @@ void FC_GLOBAL(adios2_put_deferred_f2c,
*ierr = 0;
try
{
adios2_put_sync(*engine, *variable, values);
adios2_put_deferred(*engine, *variable, values);
}
catch (std::exception &e)
{
*ierr = 1;
}
}
void FC_GLOBAL(adios2_perform_puts_f2c,
ADIOS2_PERFORM_PUTS_F2C)(adios2_Engine **engine, int *ierr)
{
*ierr = 0;
try
{
adios2_perform_puts(*engine);
}
catch (std::exception &e)
{
*ierr = 1;
}
}
// ******** GETS */
void FC_GLOBAL(adios2_get_sync_f2c,
ADIOS2_get_SYNC_F2C)(adios2_Engine **engine,
adios2_Variable **variable, void *values,
int *ierr)
{
*ierr = 0;
try
{
adios2_get_sync(*engine, *variable, values);
}
catch (std::exception &e)
{
*ierr = 1;
}
}
void FC_GLOBAL(adios2_get_deferred_f2c,
ADIOS2_get_DEFERRED_F2C)(adios2_Engine **engine,
adios2_Variable **variable,
void *values, int *ierr)
{
*ierr = 0;
try
{
adios2_get_deferred(*engine, *variable, values);
}
catch (std::exception &e)
{
*ierr = 1;
}
}
void FC_GLOBAL(adios2_perform_gets_f2c,
ADIOS2_PERFORM_GETS_F2C)(adios2_Engine **engine, int *ierr)
{
*ierr = 0;
try
{
adios2_perform_gets(*engine);
}
catch (std::exception &e)
{
......
......@@ -22,6 +22,7 @@ extern "C" {
void FC_GLOBAL(adios2_begin_step_f2c,
ADIOS2_BEGIN_STEP_F2C)(adios2_Engine **engine, int *ierr);
// ************** PUT
void FC_GLOBAL(adios2_put_sync_f2c,
ADIOS2_PUT_SYNC_F2C)(adios2_Engine **engine,
adios2_Variable **variable,
......@@ -32,15 +33,29 @@ void FC_GLOBAL(adios2_put_deferred_f2c,
adios2_Variable **variable,
const void *values, int *ierr);
void FC_GLOBAL(adios2_perform_puts_f2c,
ADIOS2_PERFORM_PUTS_F2C)(adios2_Engine **engine, int *ierr);
// ************** GET
void FC_GLOBAL(adios2_get_sync_f2c,
ADIOS2_get_SYNC_F2C)(adios2_Engine **engine,
adios2_Variable **variable, void *values,
int *ierr);
void FC_GLOBAL(adios2_get_deferred_f2c,
ADIOS2_get_DEFERRED_F2C)(adios2_Engine **engine,
adios2_Variable **variable,
void *values, int *ierr);
void FC_GLOBAL(adios2_perform_gets_f2c,
ADIOS2_PERFORM_GETS_F2C)(adios2_Engine **engine, int *ierr);
void FC_GLOBAL(adios2_end_step_f2c, ADIOS2_END_STEP_F2C)(adios2_Engine **engine,
int *ierr);
void FC_GLOBAL(adios2_close_f2c, ADIOS2_CLOSE_F2C)(adios2_Engine **engine,
int *ierr);
void FC_GLOBAL(adios2_finalize_f2c, ADIOS2_FINALIZE_F2C)(adios2_ADIOS **adios,
int *ierr);
#ifdef __cplusplus
}
#endif
......
......@@ -78,7 +78,8 @@ void FC_GLOBAL(adios2_define_variable_f2c, ADIOS2_DEFINE_VARIABLE_F2C)(
const int *count, const int *constant_dims, int *ierr)
{
auto lf_IntToSizeT = [](const int *dimensions, const int size,
std::vector<std::size_t> &output) {
std::vector<std::size_t> &output,
const bool offset) {
if (dimensions == nullptr)
{
......@@ -86,18 +87,29 @@ void FC_GLOBAL(adios2_define_variable_f2c, ADIOS2_DEFINE_VARIABLE_F2C)(
}
output.resize(size);
for (unsigned int d = 0; d < size; ++d)
if (offset)
{
for (unsigned int d = 0; d < size; ++d)
{
output[d] = dimensions[d] - 1;
}
}
else
{
output[d] = dimensions[d];
for (unsigned int d = 0; d < size; ++d)
{
output[d] = dimensions[d];
}
}
};
*ierr = 0;
std::vector<std::size_t> shapeV, startV, countV;
lf_IntToSizeT(shape, *ndims, shapeV);
lf_IntToSizeT(start, *ndims, startV);
lf_IntToSizeT(count, *ndims, countV);
lf_IntToSizeT(shape, *ndims, shapeV, false);
lf_IntToSizeT(start, *ndims, startV, true);
lf_IntToSizeT(count, *ndims, countV, false);
try
{
......@@ -112,6 +124,27 @@ void FC_GLOBAL(adios2_define_variable_f2c, ADIOS2_DEFINE_VARIABLE_F2C)(
}
}
void FC_GLOBAL(adios2_inquire_variable_f2c,
ADIOS2_INQUIRE_VARIABLE_F2C)(adios2_Variable **variable,
adios2_IO **io,
const char *variable_name,
int *ierr)
{
*ierr = 0;
try
{
*variable = adios2_inquire_variable(*io, variable_name);
if (*variable == nullptr)
{
*ierr = 2;
}
}
catch (std::exception &e)
{
*ierr = 1;
}
}
void FC_GLOBAL(adios2_open_f2c,
ADIOS2_OPEN_F2C)(adios2_Engine **engine, adios2_IO **io,
const char *name, const int *open_mode,
......
......@@ -39,6 +39,12 @@ void FC_GLOBAL(adios2_define_variable_f2c, ADIOS2_DEFINE_VARIABLE_F2C)(
const int *type, const int *ndims, const int *shape, const int *start,
const int *count, const int *constant_dims, int *ierr);
void FC_GLOBAL(adios2_inquire_variable_f2c,
ADIOS2_INQUIRE_VARIABLE_F2C)(adios2_Variable **variable,
adios2_IO **io,
const char *variable_name,
int *ierr);
void FC_GLOBAL(adios2_open_f2c,
ADIOS2_OPEN_F2C)(adios2_Engine **engine, adios2_IO **io,
const char *name, const int *open_mode,
......
/*
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* adios2_f2c_variable.cpp
*
* Created on: Nov 12, 2017
* Author: William F Godoy godoywf@ornl.gov
*/
#include "adios2_f2c_variable.h"
#include <cstddef>
#include <stdexcept>
#include <string.h> //strcpy
#include <vector>
void FC_GLOBAL(adios2_variable_name_f2c,
ADIOS2_VARIABLE_NAME_F2C)(const adios2_Variable **variable,
char name[1024], int *length,
int *ierr)
{
*ierr = 0;
try
{
size_t lengthC = 0;
const char *nameC = adios2_variable_name(*variable, &lengthC);
if (nameC == nullptr)
{
throw std::runtime_error("ERROR: null pointer\n");
}
for (size_t i = 0; i < lengthC; ++i)
{
name[i] = nameC[i];
}
*length = static_cast<int>(lengthC);
}
catch (std::exception &e)
{
*ierr = 1;
}
}
void FC_GLOBAL(adios2_variable_type_f2c,
ADIOS2_VARIABLE_TYPE_F2C)(const adios2_Variable **variable,
int *type, int *ierr)
{
*ierr = 0;
try
{
*type = static_cast<int>(adios2_variable_type(*variable));
}
catch (std::exception &e)
{
*ierr = 1;
}
}
void FC_GLOBAL(adios2_set_selection_f2c,
ADIOS2_SET_SELECTION_F2C)(adios2_Variable **variable,
const int *ndims, const int *start,
const int *count, int *ierr)
{
auto lf_IntToSizeT = [](const int *dimensions, const int size,
std::vector<std::size_t> &output,
const bool offset) {
if (dimensions == nullptr)
{
return;
}
output.resize(size);
if (offset)
{
for (unsigned int d = 0; d < size; ++d)
{
output[d] = dimensions[d] - 1;
}
}
else
{
for (unsigned int d = 0; d < size; ++d)
{
output[d] = dimensions[d];
}
}
};
*ierr = 0;
if (start == nullptr || count == nullptr)
{
*ierr = 1;
return;
}
std::vector<std::size_t> startV, countV;
lf_IntToSizeT(start, *ndims, startV, true);
lf_IntToSizeT(count, *ndims, countV, false);
try
{
adios2_set_selection(*variable, *ndims, startV.data(), countV.data());
}
catch (std::exception &e)
{
*ierr = 1;
}
}
/*
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* adios2_f2c_variable.h : variable handle functions
*
* Created on: Nov 12, 2017
* Author: William F Godoy godoywf@ornl.gov
*/
#ifndef BINDINGS_FORTRAN_F2C_ADIOS2_F2C_VARIABLE_H_
#define BINDINGS_FORTRAN_F2C_ADIOS2_F2C_VARIABLE_H_
#include "adios2/ADIOSConfig.h"
#include <FC.h>
#include <adios2_c.h>
#ifdef __cplusplus
extern "C" {
#endif
void FC_GLOBAL(adios2_variable_name_f2c,
ADIOS2_VARIABLE_NAME_F2C)(const adios2_Variable **variable,
char name[1024], int *length,
int *ierr);
void FC_GLOBAL(adios2_variable_type_f2c,
ADIOS2_VARIABLE_TYPE_F2C)(const adios2_Variable **variable,
int *c_type, int *ierr);
void FC_GLOBAL(adios2_set_selection_f2c,
ADIOS2_SET_SELECTION_F2C)(adios2_Variable **variable,
const int *ndims, const int *start,
const int *count, int *ierr);
#ifdef __cplusplus
}
#endif
#endif /* BINDINGS_FORTRAN_F2C_ADIOS2_F2C_VARIABLE_H_ */
This diff is collapsed.
......@@ -10,10 +10,39 @@
module adios2_engine
use adios2_engine_write
use adios2_engine_iwrite
use adios2_engine_read
use adios2_engine_iread
implicit none
contains
subroutine adios2_begin_step(engine, ierr)
integer(kind=8), intent(in) :: engine
integer, intent(out) :: ierr
call adios2_begin_step_f2c(engine, ierr)
end subroutine
subroutine adios2_perform_puts(engine, ierr)
integer(kind=8), intent(in) :: engine
integer, intent(out) :: ierr
call adios2_perform_puts_f2c(engine, ierr)
end subroutine
subroutine adios2_perform_gets(engine, ierr)
integer(kind=8), intent(in) :: engine
integer, intent(out) :: ierr
call adios2_perform_gets_f2c(engine, ierr)
end subroutine
subroutine adios2_end_step(engine, ierr)
integer(kind=8), intent(in) :: engine
integer, intent(out) :: ierr
......
This diff is collapsed.
module adios2_functions
use adios2_parameters
implicit none
contains
......@@ -13,4 +14,36 @@ contains
end function
subroutine adios2_StringC2F( c_string, length, f_string )
character*(*), intent(in) :: c_string
integer, intent(in) :: length
character(len=:), allocatable, intent(out) :: f_string
if( allocated(f_string) ) deallocate(f_string)
if( length > 0 ) then
allocate( character(length) :: f_string )
f_string = c_string(1:length)
end if
end subroutine
subroutine adios2_TypeC2F( c_type, f_type )
integer, intent(in) :: c_type
integer, intent(out) :: f_type
integer :: i
f_type = adios2_type_unknown
do i=-1,11
if( c_type == i ) then
f_type = c_type
exit
end if
end do
end subroutine
end module
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment