subroutineparse_int
subroutine parse_int(text, value, ok)
Read a decimal integer.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| text | character(len=*) | in | the text | |
| value | integer | out | the value | |
| ok | logical | out | false if |
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