Commit bd6af6ad authored by William F Godoy's avatar William F Godoy
Browse files

Added Fortran min max

Needed to test non-contiguous min max function
#1002 and #378 write-side
parent 68ef6945
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ set(MODULES
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_io_mod.f90 
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_io_define_variable_mod.f90
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_io_define_attribute_mod.f90
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_variable_mod.f90
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_engine_mod.f90 
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_engine_begin_step_mod.f90
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_engine_put_mod.f90 
@@ -34,6 +33,9 @@ set(MODULES
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_file_mod.f90
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_fwrite_mod.f90
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_fread_mod.f90
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_variable_mod.f90
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_variable_min_mod.f90
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_variable_max_mod.f90
)

add_library(adios2_f ${MODULES} ${F2C})
+16 −14
Original line number Diff line number Diff line
@@ -135,9 +135,9 @@ void FC_GLOBAL(adios2_fwrite_value_f2c,
                                        const int *type, const void *data,
                                        const int *end_step, int *ierr)
{
    *ierr = adios2_fwrite(*fh, name, static_cast<adios2_type>(*type), data, 0,
                          nullptr, nullptr, nullptr,
                          static_cast<adios2_bool>(*end_step));
    *ierr = static_cast<int>(adios2_fwrite(
        *fh, name, static_cast<adios2_type>(*type), data, 0, nullptr, nullptr,
        nullptr, static_cast<adios2_bool>(*end_step)));
}

void FC_GLOBAL(adios2_fwrite_f2c,
@@ -181,8 +181,9 @@ void FC_GLOBAL(adios2_fread_value_f2c,
                "adios2_advance_no(0), in call to adios2_fread");
        }

        *ierr = adios2_fread(*fh, name, static_cast<adios2_type>(*type), data,
                             0, nullptr, nullptr);
        *ierr = static_cast<int>(adios2_fread(*fh, name,
                                              static_cast<adios2_type>(*type),
                                              data, 0, nullptr, nullptr));
        if (*end_step == 1)
        {
            if (adios2_fgets(*fh, *fh) == nullptr)
@@ -224,9 +225,10 @@ void FC_GLOBAL(adios2_fread_f2c,
        const std::vector<std::size_t> countV =
            adios2_Int64ToSizeTVector(count, *ndims);

        *ierr = adios2_fread(*fh, name, static_cast<adios2_type>(*type), data,
                             static_cast<size_t>(*ndims), startV.data(),
                             countV.data());
        *ierr = static_cast<int>(adios2_fread(
            *fh, name, static_cast<adios2_type>(*type), data,
            static_cast<size_t>(*ndims), startV.data(), countV.data()));

        if (*end_step == 1)
        {
            if (adios2_fgets(*fh, *fh) == nullptr)
@@ -255,11 +257,11 @@ void FC_GLOBAL(adios2_fread_steps_f2c, adios2_FREAD_STEPS_F2C)(
        const std::vector<std::size_t> countV =
            adios2_Int64ToSizeTVector(count, *ndims);

        *ierr = adios2_fread_steps(*fh, name, static_cast<adios2_type>(*type),
                                   data, static_cast<std::size_t>(*ndims),
                                   startV.data(), countV.data(),
        *ierr = static_cast<int>(adios2_fread_steps(
            *fh, name, static_cast<adios2_type>(*type), data,
            static_cast<std::size_t>(*ndims), startV.data(), countV.data(),
            static_cast<std::size_t>(*step_start),
                                   static_cast<std::size_t>(*step_count));
            static_cast<std::size_t>(*step_count)));
    }
    catch (std::exception &e)
    {
@@ -272,7 +274,7 @@ void FC_GLOBAL(adios2_fread_steps_f2c, adios2_FREAD_STEPS_F2C)(
void FC_GLOBAL(adios2_fclose_f2c, adios2_FCLOSE_F2C)(adios2_FILE **fh,
                                                     int *ierr)
{
    *ierr = adios2_fclose(*fh);
    *ierr = static_cast<int>(adios2_fclose(*fh));
}

#ifdef __cplusplus
+16 −0
Original line number Diff line number Diff line
@@ -256,6 +256,22 @@ void FC_GLOBAL(adios2_set_operation_parameter_f2c,
    }
}

void FC_GLOBAL(adios2_variable_min_f2c,
               adios2_variable_MIN_F2C)(void *min,
                                        const adios2_variable **variable,
                                        int *ierr)
{
    *ierr = static_cast<int>(adios2_variable_min(min, *variable));
}

void FC_GLOBAL(adios2_variable_max_f2c,
               adios2_variable_MAX_F2C)(void *max,
                                        const adios2_variable **variable,
                                        int *ierr)
{
    *ierr = static_cast<int>(adios2_variable_max(max, *variable));
}

#ifdef __cplusplus
}
#endif
+2 −0
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@ module adios2
    use adios2_adios_mod
    use adios2_io_mod
    use adios2_variable_mod
    use adios2_variable_min_mod
    use adios2_variable_max_mod
    use adios2_engine_mod
    use adios2_file_mod

+136 −0
Original line number Diff line number Diff line
!
! Distributed under the OSI-approved Apache License, Version 2.0.  See
!  accompanying file Copyright.txt for details.
!
!  adios2_variable_max_mod.f90 : ADIOS2 Fortran bindings for overloaded
!                                adios2_variable_max subroutine
!   Created on: Nov 15, 2018
!       Author: William F Godoy godoywf@ornl.gov
!

module adios2_variable_max_mod
    use adios2_parameters_mod
    use adios2_variable_mod
    implicit none

    interface adios2_variable_max

        ! Single Value
        module procedure adios2_variable_max_real
        module procedure adios2_variable_max_dp
        module procedure adios2_variable_max_complex
        module procedure adios2_variable_max_complex_dp
        module procedure adios2_variable_max_integer1
        module procedure adios2_variable_max_integer2
        module procedure adios2_variable_max_integer4
        module procedure adios2_variable_max_integer8

    end interface

contains

    subroutine adios2_variable_max_real(maximum, variable, ierr)
        real, intent(out) :: maximum
        type(adios2_variable), intent(in) :: variable
        integer, intent(out) :: ierr

        call adios2_variable_check_type(variable, adios2_type_real, &
                                        'variable_max', ierr)
        if (ierr == 0) then
            call adios2_variable_max_f2c(maximum, variable, ierr)
        end if

    end subroutine

    subroutine adios2_variable_max_dp(maximum, variable, ierr)
        real(kind=8), intent(out) :: maximum
        type(adios2_variable), intent(in) :: variable
        integer, intent(out) :: ierr

        call adios2_variable_check_type(variable, adios2_type_dp, &
                                        'variable_max', ierr)
        if (ierr == 0) then
            call adios2_variable_max_f2c(maximum, variable, ierr)
        end if

    end subroutine

    subroutine adios2_variable_max_complex(maximum, variable, ierr)
        complex, intent(out) :: maximum
        type(adios2_variable), intent(in) :: variable
        integer, intent(out) :: ierr

        call adios2_variable_check_type(variable, adios2_type_complex, &
                                        'variable_max', ierr)
        if (ierr == 0) then
            call adios2_variable_max_f2c(maximum, variable, ierr)
        end if

    end subroutine

    subroutine adios2_variable_max_complex_dp(maximum, variable, ierr)
        complex(kind=8), intent(out) :: maximum
        type(adios2_variable), intent(in) :: variable
        integer, intent(out) :: ierr

        call adios2_variable_check_type(variable, adios2_type_complex_dp, &
                                        'variable_max', ierr)
        if (ierr == 0) then
            call adios2_variable_max_f2c(maximum, variable, ierr)
        end if

    end subroutine

    subroutine adios2_variable_max_integer1(maximum, variable, ierr)
        integer(kind=1), intent(out) :: maximum
        type(adios2_variable), intent(in) :: variable
        integer, intent(out) :: ierr

        call adios2_variable_check_type(variable, adios2_type_integer1, &
                                        'variable_max', ierr)
        if (ierr == 0) then
            call adios2_variable_max_f2c(maximum, variable, ierr)
        end if

    end subroutine

    subroutine adios2_variable_max_integer2(maximum, variable, ierr)
        integer(kind=2), intent(out) :: maximum
        type(adios2_variable), intent(in) :: variable
        integer, intent(out) :: ierr

        call adios2_variable_check_type(variable, adios2_type_integer2, &
                                        'variable_max', ierr)
        if (ierr == 0) then
            call adios2_variable_max_f2c(maximum, variable, ierr)
        end if

    end subroutine

    subroutine adios2_variable_max_integer4(maximum, variable, ierr)
        integer(kind=4), intent(out) :: maximum
        type(adios2_variable), intent(in) :: variable
        integer, intent(out) :: ierr

        call adios2_variable_check_type(variable, adios2_type_integer4, &
                                        'variable_max', ierr)
        if (ierr == 0) then
            call adios2_variable_max_f2c(maximum, variable, ierr)
        end if

    end subroutine

    subroutine adios2_variable_max_integer8(maximum, variable, ierr)
        integer(kind=8), intent(out) :: maximum
        type(adios2_variable), intent(in) :: variable
        integer, intent(out) :: ierr

        call adios2_variable_check_type(variable, adios2_type_integer8, &
                                        'variable_max', ierr)
        if (ierr == 0) then
            call adios2_variable_max_f2c(maximum, variable, ierr)
        end if

    end subroutine

end module
Loading