diff --git a/bindings/Fortran/f2c/adios2_f2c_io.cpp b/bindings/Fortran/f2c/adios2_f2c_io.cpp index fd852259e7..532a9d0e48 100644 --- a/bindings/Fortran/f2c/adios2_f2c_io.cpp +++ b/bindings/Fortran/f2c/adios2_f2c_io.cpp @@ -15,6 +15,23 @@ #include #include +void FC_GLOBAL(adios2_set_engine_f2c, + ADIOS2_SET_ENGINE_F2C)(adios2_io **io, const char *engine_type, + int *ierr) +{ + *ierr = 0; + + try + { + adios2_set_engine(*io, engine_type); + } + catch (std::exception &e) + { + std::cerr << "ADIOS2 set_engine: " << e.what() << "\n"; + *ierr = -1; + } +} + void FC_GLOBAL(adios2_set_parameter_f2c, ADIOS2_SET_PARAMETER_F2C)(adios2_io **io, const char *key, const char *value, int *ierr) diff --git a/bindings/Fortran/f2c/adios2_f2c_io.h b/bindings/Fortran/f2c/adios2_f2c_io.h index 4a5913a318..60b7d90d73 100644 --- a/bindings/Fortran/f2c/adios2_f2c_io.h +++ b/bindings/Fortran/f2c/adios2_f2c_io.h @@ -21,6 +21,10 @@ extern "C" { #endif +void FC_GLOBAL(adios2_set_engine_f2c, + ADIOS2_SET_ENGINE_F2C)(adios2_io **io, const char *engine_type, + int *ierr); + void FC_GLOBAL(adios2_set_parameter_f2c, ADIOS2_SET_PARAMETER_F2C)(adios2_io **io, const char *key, const char *value, int *ierr); diff --git a/bindings/Fortran/modules/adios2_io_mod.f90 b/bindings/Fortran/modules/adios2_io_mod.f90 index fd81885bef..27bdb77b4e 100644 --- a/bindings/Fortran/modules/adios2_io_mod.f90 +++ b/bindings/Fortran/modules/adios2_io_mod.f90 @@ -16,6 +16,16 @@ module adios2_io_mod contains + subroutine adios2_set_engine(io, engine_type, ierr) + type(adios2_io), intent(in) :: io + character*(*), intent(in) :: engine_type + integer, intent(out) :: ierr + + call adios2_set_engine_f2c(io%f2c, & + TRIM(ADJUSTL(engine_type))//char(0), & + ierr) + end subroutine + subroutine adios2_set_parameter(io, key, value, ierr) type(adios2_io), intent(in) :: io character*(*), intent(in) :: key diff --git a/testing/adios2/bindings/fortran/TestBPWriteTypes.f90 b/testing/adios2/bindings/fortran/TestBPWriteTypes.f90 index 73af88e167..7ea86ff2bd 100644 --- a/testing/adios2/bindings/fortran/TestBPWriteTypes.f90 +++ b/testing/adios2/bindings/fortran/TestBPWriteTypes.f90 @@ -37,6 +37,8 @@ program TestBPWriteTypes ! Declare an IO process configuration inside adios call adios2_declare_io(ioWrite, adios, "ioWrite", ierr) + call adios2_set_engine(ioWrite, 'bpfile', ierr) + ! Defines a variable to be written in bp format call adios2_define_variable(variables(1), ioWrite, "var_I8", & adios2_type_integer1, 1, &