Next: , Previous: GET_COMMAND, Up: Intrinsic Procedures


6.87 GET_COMMAND_ARGUMENT — Get command line arguments

Description:
Retrieve the Nth argument that was passed on the command line when the containing program was invoked.
Standard:
F2003
Class:
Subroutine
Syntax:
CALL GET_COMMAND_ARGUMENT(N, ARG)
Arguments:

N Shall be of type INTEGER(4), N \geq 0
ARG Shall be of type CHARACTER(*).

Return value:
After GET_COMMAND_ARGUMENT returns, the ARG argument holds the Nth command line argument. If ARG can not hold the argument, it is truncated to fit the length of ARG. If there are less than N arguments specified at the command line, ARG will be filled with blanks. If N = 0, ARG is set to the name of the program (on systems that support this feature).
Example:
          PROGRAM test_get_command_argument
            INTEGER :: i
            CHARACTER(len=32) :: arg
          
            i = 0
            DO
              CALL get_command_argument(i, arg)
              IF (LEN_TRIM(arg) == 0) EXIT
          
              WRITE (*,*) TRIM(arg)
              i = i+1
            END DO
          END PROGRAM
     

See also:
GET_COMMAND, COMMAND_ARGUMENT_COUNT