type_conversion_m.f90 Source File


Contents

Source Code


Source Code

module type_conversion_m
    !! Functions for converting datatypes
    implicit none

contains

    pure integer function logical_to_integer(login)
        !! Returns 1 if input = true, otherwise 0
        logical, intent(in) :: login
        !! Logical to be converted to integer
        if (login) then
            logical_to_integer = 1
        else
            logical_to_integer = 0
        endif
    end function

    pure logical function integer_to_logical(intin)
        !! Returns true if input = 1, otherwise 0
        integer, intent(in) :: intin
        !! Integer to be converted to logical
        if (intin == 1) then
            integer_to_logical = .true.
        else
            integer_to_logical = .false.
        endif
    end function

end module