Skip to content
Snippets Groups Projects
Commit abd92a30 authored by William F Godoy's avatar William F Godoy
Browse files

Added variable module in Fortran bindings

parent dfb96539
No related branches found
No related tags found
1 merge request!308Reader column-major ordering and tests
......@@ -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,6 +21,7 @@ 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
......
......@@ -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
......@@ -50,7 +50,7 @@ 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)
{
......
......@@ -38,9 +38,6 @@ void FC_GLOBAL(adios2_end_step_f2c, ADIOS2_END_STEP_F2C)(adios2_Engine **engine,
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
......
/*
* 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 <vector>
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)
{
*ierr = 0;
if (start == nullptr || count == nullptr)
{
*ierr = 1;
return;
}
std::vector<std::size_t> startV(start, start + *ndims);
std::vector<std::size_t> countV(count, count + *ndims);
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_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_ */
......@@ -2,7 +2,7 @@
! Distributed under the OSI-approved Apache License, Version 2.0. See
! accompanying file Copyright.txt for details.
!
! adios2_io.f90 : ADIOS2 Fortran bindings for IO class
! adios2_io_mod.f90 : ADIOS2 Fortran bindings for IO class
!
! Created on: Mar 13, 2017
! Author: William F Godoy godoywf@ornl.gov
......
!
! Distributed under the OSI-approved Apache License, Version 2.0. See
! accompanying file Copyright.txt for details.
!
! adios2_variable_mod.f90 : ADIOS2 Fortran bindings for Variable class
!
! Created on: Mar 13, 2017
! Author: William F Godoy godoywf@ornl.gov
!
module adios2_variable
implicit none
contains
subroutine adios2_set_selection(variable, ndims, start_dims, count_dims, &
& ierr)
integer(kind=8), intent(out) :: variable
integer, intent(in) :: ndims
integer, dimension(:), intent(in) :: start_dims
integer, dimension(:), intent(in) :: count_dims
integer, intent(out) :: ierr
call adios2_set_selection_f2c(variable, ndims, start_dims, &
& count_dims, ierr)
end subroutine
end module
......@@ -8,6 +8,7 @@
* Author: William F Godoy godoywf@ornl.gov
*/
#include <mpi.h>
#include <stdio.h> // TO BE REMOVED
#include <stdlib.h> // malloc, free
#include <adios2_c.h>
......@@ -46,6 +47,10 @@ int main(int argc, char *argv[])
adios2_Variable *variableH =
adios2_define_variable(ioH, "bpFloats", adios2_type_float, 1, shape,
start, count, adios2_constant_dims_true);
const char *name = adios2_variable_name(variableH);
printf("Variable name %s\n", name);
adios2_Engine *engineH =
adios2_open(ioH, "myVector_c.bp", adios2_mode_write);
......
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