Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | unit | |||
integer, | intent(inout), | optional | :: | digit_count |
integer function parse_integer(chars) result(integral)
character(len=*) :: chars
character :: c
integer :: tmp, i
integral = 0
do i=1, len_trim(chars)
c = chars(i:i)
select case(c)
case ("0":"9")
! digit
read (c, '(i1)') tmp
! shift
if (i > 1) then
integral = integral * 10
end if
! add
integral = integral + tmp
case default
return
end select
end do
end function parse_integer