fdoc

subroutineparse_int

subroutine parse_int(text, value, ok)

Read a decimal integer.

Arguments

NameTypeIntentAttributesDescription
textcharacter(len=*)in

the text

valueintegerout

the value

oklogicalout

false if text is not an integer

Calls

Source

Show the code
subroutine parse_int(text, value, ok)
    character(len=*), intent(in) :: text    !! the text
    integer, intent(out) :: value           !! the value
    logical, intent(out) :: ok              !! false if `text` is not an integer
    integer :: ios

    ok = verify(strip(text), '+-0123456789') == 0 .and. len(strip(text)) > 0
    value = 0
    if (.not. ok) return
    read (text, *, iostat=ios) value
    ok = ios == 0
end subroutine parse_int

Graphs

Calls

Called by