!> @brief surface flux model common subroutines
module sfx_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 check if value is finite
    elemental function is_finite(value)
        ! ----------------------------------------------------------------------------
        use ieee_arithmetic
        implicit none
        logical :: is_finite

        real, intent(in) :: value
        ! ----------------------------------------------------------------------------

        is_finite = ieee_is_finite(value)
    end function is_finite
    ! ----------------------------------------------------------------------------

end module sfx_common