get_next_token Subroutine

private subroutine get_next_token(token_file_unit, buf)

Extract the next token from the config file

Each token is on a separate line. There may be multiple comments (lines beginning with #) and blank lines in between. The purpose of this subroutine is to ignore all these lines and return the next "useful" line.

Arguments

Type IntentOptional AttributesName
integer, intent(in) :: token_file_unit
character(len=STRING_BUFFER_LENGTH), intent(out) :: buf

Called by

proc~~get_next_token~~CalledByGraph proc~get_next_token get_next_token proc~read_controls read_controls proc~read_controls->proc~get_next_token proc~read_scheme read_scheme proc~read_scheme->proc~get_next_token proc~read_flow read_flow proc~read_flow->proc~get_next_token proc~read_input_and_controls read_input_and_controls proc~read_input_and_controls->proc~read_controls proc~read_input_and_controls->proc~read_scheme proc~read_input_and_controls->proc~read_flow proc~setup_solver setup_solver proc~setup_solver->proc~read_input_and_controls proc~start_run start_run proc~start_run->proc~setup_solver program~main main program~main->proc~start_run

Contents

Source Code


Source Code

      subroutine get_next_token(token_file_unit, buf)
        !< Extract the next token from the config file
        !<
        !< Each token is on a separate line.
        !< There may be multiple comments (lines beginning with #) 
        !< and blank lines in between.
        !< The purpose of this subroutine is to ignore all these 
        !< lines and return the next "useful" line.
        !-----------------------------------------------------------

        implicit none
        integer                            , intent(in)  :: token_file_unit
        character(len=STRING_BUFFER_LENGTH), intent(out) :: buf
        integer :: ios

        do
            read(token_file_unit, '(A)', iostat=ios) buf
            if (ios /= 0) then
                print *, 'Error while reading config file.'
                print *, 'Current buffer length is set to: ', &
                        STRING_BUFFER_LENGTH
                stop
            end if
            if (index(buf, '#') == 1) then
                ! The current line begins with a hash
                ! Ignore it
                continue
            else if (len_trim(buf) == 0) then
                ! The current line is empty
                ! Ignore it
                continue
            else
                ! A new token has been found
                ! Break out
                exit
            end if
        end do

      end subroutine get_next_token