Skip to content
Snippets Groups Projects
Commit 083f3a52 authored by Evgeny Mortikov's avatar Evgeny Mortikov
Browse files

adding common module

parent 727005a6
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,7 @@ endif(BUILD_DOC)
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/modules/)
set(SOURCES
obl_common.f90
obl_grid.f90
obl_tslice.f90
obl_tseries.f90
......
!> @brief ocean boundary layer model common subroutines
module obl_common
public
contains
!> @brief string to int conversion
elemental subroutine str2int(int, str, stat)
! ----------------------------------------------------------------------------
implicit none
integer, intent(out) :: int
integer, intent(out) :: stat !> output status, /= 0 signals ERROR
character(len = *), intent(in) :: str
! ----------------------------------------------------------------------------
read(str, * , iostat = stat) int
end subroutine str2int
! ----------------------------------------------------------------------------
!> @brief string to real conversion
elemental subroutine str2real(x, str, stat)
! ----------------------------------------------------------------------------
implicit none
real, intent(out) :: x
integer, intent(out) :: stat !> output status, /= 0 signals ERROR
character(len = *), intent(in) :: str
! ----------------------------------------------------------------------------
read(str, * , iostat = stat) x
end subroutine str2real
! ----------------------------------------------------------------------------
!> @brief character array to string conversion
function char_array2str(char_array) result(str)
! ----------------------------------------------------------------------------
implicit none
character, intent(in) :: char_array(:)
character(len=:), allocatable :: str
integer :: i
! ----------------------------------------------------------------------------
str = ""
do i = 1, size(char_array)
str = str(:) // char_array(i)
end do
end function
! ----------------------------------------------------------------------------
end module obl_common
......@@ -18,8 +18,7 @@ module obl_math
public :: c_interp_linear
public :: limit_min_array, limit_max_array
public :: tma
public :: is_finite
public :: char_array2str
public :: is_finite, is_finite_array
! --------------------------------------------------------------------------------
......@@ -127,42 +126,37 @@ module obl_math
end subroutine tma
! --------------------------------------------------------------------------------
function is_finite(F, n)
!> @brief check if any value in array is finite
elemental function is_finite(value)
!> @brief check if value is finite
! ----------------------------------------------------------------------------
use ieee_arithmetic
implicit none
logical :: is_finite
integer, intent(in) :: n
real, intent(in), dimension(n) :: F
integer :: k
real, intent(in) :: value
! ----------------------------------------------------------------------------
is_finite = .true.
do k=1, n
is_finite = ieee_is_finite(F(k))
if (is_finite.eqv..false.) exit
enddo
is_finite = ieee_is_finite(value)
end function is_finite
!> @brief character array to string conversion
function char_array2str(char_array) result(str)
function is_finite_array(F, n)
!> @brief check if any value in array is finite
! ----------------------------------------------------------------------------
use ieee_arithmetic
implicit none
character, intent(in) :: char_array(:)
character(len=:), allocatable :: str
integer :: i
! ----------------------------------------------------------------------------
logical :: is_finite_array
str = ""
do i = 1, size(char_array)
str = str(:) // char_array(i)
end do
integer, intent(in) :: n
real, intent(in), dimension(n) :: F
end function
integer :: k
! ----------------------------------------------------------------------------
is_finite_array = .true.
do k=1, n
is_finite_array = ieee_is_finite(F(k))
if (.not.is_finite_array) exit
enddo
end function is_finite_array
end module
......@@ -136,7 +136,7 @@ module obl_tforcing
subroutine set_config_tforcing(tforcing, tag, ierr)
!> @brief generic forcing setup
! ----------------------------------------------------------------------------
use obl_math, only : char_array2str
use obl_common, only : char_array2str
type (timeForcingDataType), intent(inout) :: tforcing
integer, intent(out) :: ierr
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment