check_command_line Subroutine

public subroutine check_command_line()

Checks that a suitable number of command line arguments has been supplied and handles some special cases of command line inputs

'check_command_line' will write to stdout instead of the log file to give direct feedback to the user

Arguments

None

Calls

proc~~check_command_line~~CallsGraph proc~check_command_line check_command_line proc~print_help_page print_help_page proc~check_command_line->proc~print_help_page proc~print_version print_version proc~check_command_line->proc~print_version

Called by

proc~~check_command_line~~CalledByGraph proc~check_command_line check_command_line program~uemep uEMEP program~uemep->proc~check_command_line

Source Code

    subroutine check_command_line()
        !! Checks that a suitable number of command line arguments has been supplied
        !! and handles some special cases of command line inputs
        !!
        !! 'check_command_line' will write to stdout instead of the log file
        !! to give direct feedback to the user

        ! Local variables
        integer :: n_args, i
        character(len=256) :: arg

        ! Check if no arguments are found
        n_args = command_argument_count()
        if (n_args <= 0) then
            write(*,"(a)") " Insufficient number of command line arguments"
            write(*,"(a)") " Try 'uemep --help' for more information"
            stop
        end if

        ! Loop over input arguments to handle special cases
        do i = 1, n_args
            call get_command_argument(i, arg)
            select case(adjustl(arg))
            case("--help")
                call print_help_page()
                stop
            case("--version")
                call print_version()
                stop
            end select
        end do

        ! After checking that no special cases are found, check if the number of 
        ! arguments are within acceptable bounds (2:n_max_config_files+1)
        if (n_args < 2) then
            write(*,"(a)") " Insufficient number of command line arguments"
            write(*,"(a)") " Try 'uemep --help' for more information"
            stop
        else if (n_args > n_max_config_files + 1) then
            write(*,"(a)") " Too many command line arguments"
            write(*,"(a)") " Try 'uemep --help' for more information"
            stop
        end if
    end subroutine check_command_line