Skip to content

Commit

Permalink
C and C++ bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
eisenhauer committed Jun 14, 2021
1 parent e7895d9 commit 3de1eec
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 3 deletions.
43 changes: 43 additions & 0 deletions bindings/C/adios2/c/adios2_c_adios.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,30 @@
extern "C" {
#endif

adios2::ArrayOrdering adios2_ToArrayOrdering(const adios2_arrayordering Corder)
{
adios2::ArrayOrdering order = adios2::ArrayOrdering::Auto;
switch (Corder)
{

case adios2_arrayordering_rowmajor:
order = adios2::ArrayOrdering::RowMajor;
break;

case adios2_arrayordering_columnmajor:
order = adios2::ArrayOrdering::ColumnMajor;
break;

case adios2_arrayordering_auto:
order = adios2::ArrayOrdering::Auto;
break;

default:
break;
}
return order;
}

adios2_adios *adios2_init_config_glue_serial(const char *config_file,
const adios2_debug_mode debug_mode,
const char *host_language)
Expand Down Expand Up @@ -68,6 +92,25 @@ adios2_io *adios2_declare_io(adios2_adios *adios, const char *name)
return io;
}

adios2_io *adios2_declare_io_order(adios2_adios *adios, const char *name,
adios2_arrayordering order)
{
adios2_io *io = nullptr;
try
{
adios2::helper::CheckForNullptr(
adios, "for adios2_adios, in call to adios2_declare_io");
io = reinterpret_cast<adios2_io *>(
&reinterpret_cast<adios2::core::ADIOS *>(adios)->DeclareIO(
name, adios2_ToArrayOrdering(order)));
}
catch (...)
{
adios2::helper::ExceptionToError("adios2_declare_io");
}
return io;
}

adios2_io *adios2_at_io(adios2_adios *adios, const char *name)
{
adios2_io *io = nullptr;
Expand Down
10 changes: 10 additions & 0 deletions bindings/C/adios2/c/adios2_c_adios.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ adios2_adios *adios2_init_config_serial(const char *config_file);
*/
adios2_io *adios2_declare_io(adios2_adios *adios, const char *name);

/**
* Declares a new io handler with specific array ordering
* @param adios owner the io handler
* @param name unique io identifier within current adios handler
* @param order array ordering
* @return success: handler, failure: NULL
*/
adios2_io *adios2_declare_io_order(adios2_adios *adios, const char *name,
adios2_arrayordering order);

/**
* Retrieves a previously declared io handler by name
* @param adios owner the io handler
Expand Down
1 change: 1 addition & 0 deletions bindings/C/adios2/c/adios2_c_io.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ adios2::Mode adios2_ToOpenMode(const adios2_mode modeC)
}
return mode;
}

} // end anonymous namespace

#endif
7 changes: 7 additions & 0 deletions bindings/C/adios2/c/adios2_c_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ typedef enum
adios2_shapeid_local_array = 4
} adios2_shapeid;

typedef enum
{
adios2_arrayordering_rowmajor,
adios2_arrayordering_columnmajor,
adios2_arrayordering_auto
} adios2_arrayordering;

static const size_t adios2_string_array_element_max_size = 4096;

static const size_t adios2_local_value_dim = SIZE_MAX - 2;
Expand Down
4 changes: 2 additions & 2 deletions bindings/CXX11/adios2/cxx11/ADIOS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ ADIOS::ADIOS(const std::string &configFile, const std::string &hostLanguage,

ADIOS::operator bool() const noexcept { return m_ADIOS ? true : false; }

IO ADIOS::DeclareIO(const std::string name)
IO ADIOS::DeclareIO(const std::string name, const ArrayOrdering ArrayOrder)
{
CheckPointer("for io name " + name + ", in call to ADIOS::DeclareIO");
return IO(&m_ADIOS->DeclareIO(name));
return IO(&m_ADIOS->DeclareIO(name, ArrayOrder));
}

IO ADIOS::AtIO(const std::string name)
Expand Down
3 changes: 2 additions & 1 deletion bindings/CXX11/adios2/cxx11/ADIOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ class ADIOS
* @exception std::invalid_argument if IO with unique name is already
* declared
*/
IO DeclareIO(const std::string name);
IO DeclareIO(const std::string name,
const ArrayOrdering ArrayOrder = ArrayOrdering::Auto);

/**
* Retrieve an existing IO object previously created with DeclareIO.
Expand Down

0 comments on commit 3de1eec

Please sign in to comment.