to_integer Subroutine

private pure elemental subroutine to_integer(str, val, status_ok)

Convert a string to an integer

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: str
integer, intent(out) :: val
logical, intent(out) :: status_ok

Called by

proc~~to_integer~~CalledByGraph proc~to_integer namelist_parser_module::to_integer proc~add_variable namelist_parser_module::add_variable proc~add_variable->proc~to_integer proc~parse_namelist namelist_parser_module::parse_namelist proc~parse_namelist->proc~add_variable

Source Code

    pure elemental subroutine to_integer(str,val,status_ok)

    implicit none

    character(len=*),intent(in) :: str
    integer,intent(out) :: val
    logical,intent(out) :: status_ok

    integer :: istat  !! read `iostat` error code

    character(len=*),parameter :: default_int_fmt  = '(I256)'

    read(str,fmt=default_int_fmt,iostat=istat) val
    if (istat==0) then
        status_ok = .true.
    else
        status_ok = .false.
        val = 0
    end if

    end subroutine to_integer