parse_integer Function

private function parse_integer(unit, digit_count) result(integral)

Arguments

Type IntentOptional AttributesName
integer, intent(in) :: unit
integer, intent(inout), optional :: digit_count

Return Value integer(kind=8)


Contents

Source Code


Source Code

  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