parse_for_chars Subroutine

private subroutine parse_for_chars(unit, chars)

Arguments

Type IntentOptional AttributesName
integer, intent(in) :: unit
character(len=*), intent(in) :: chars

Contents

Source Code


Source Code

  subroutine parse_for_chars(unit, chars)
    integer, intent(in) :: unit
    character(len = *), intent(in) :: chars
    integer :: i, length
    logical :: eof
    character :: c

    length = len_trim(chars)

    do i = 1, length
       c = pop_char(unit, eof=eof, skip_ws=.true.)
       if (eof) then
          print *, "ERROR: Unexpected end of file while parsing array."
          call exit (1)
       else if (c /= chars(i:i)) then
          print *, "ERROR: Unexpected character.'", c,"'", chars(i:i)
          call exit (1)
       end if
    end do

  end subroutine parse_for_chars