module Scan_m

  implicit NONE
  public

contains

  subroutine Scan ( Line, Token )
    ! Trim a quoted string from Line and put it in Token, else
    ! Trim nonblanks from the beginning of Line and put them in Token
    ! Assume line is initially left adjusted, leave it left adjusted.
    character(*), intent(inout) :: Line
    character(*), intent(out) :: Token
    integer :: J
    if ( line(1:1) == "'" .or. line(1:1) == '"' ) then
      j = index(line(2:),line(1:1)) + 1
      line(1:1) = '"'
      line(j:j) = ''
    else
      j = index(line,' ')
    end if
    token = line(1:j-1)
    line = adjustl(line(j:))
  end subroutine Scan

end module Scan_m
