subroutinedigits_valuepure
pure subroutine digits_value(text, value, stat)
The value of text, without an internal read, as those take a lock.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| text | character(len=*) | in | the digits | |
| value | integer | out | their value | |
| stat | integer | out | nonzero if there are none, or something else |
Calls
Source
Show the code
pure subroutine digits_value(text, value, stat)
character(len=*), intent(in) :: text !! the digits
integer, intent(out) :: value !! their value
integer, intent(out) :: stat !! nonzero if there are none, or something else
integer :: k
value = 0
stat = merge(1, 0, len(text) == 0)
do k = 1, len(text)
if (.not. is_digit(text(k:k))) then
stat = 1
return
end if
value = 10*value + iachar(text(k:k)) - iachar('0')
end do
end subroutine digits_value