GET_COMMAND_ARGUMENT — Get command line arguments¶
- GET_COMMAND_ARGUMENT()¶
Retrieve the
NUMBER-th argument that was passed on the command line when the containing program was invoked.- Parameters
NUMBER – Shall be a scalar of type
INTEGERand of default kind,NUMBERgeq 0VALUE – (Optional) Shall be a scalar of type
CHARACTERand of default kind.LENGTH – (Optional) Shall be a scalar of type
INTEGERand of default kind.STATUS – (Optional) Shall be a scalar of type
INTEGERand of default kind.
- Returns
After
GET_COMMAND_ARGUMENTreturns, theVALUEargument holds theNUMBER-th command line argument. IfVALUEcannot hold the argument, it is truncated to fit the length ofVALUE. If there are less thanNUMBERarguments specified at the command line,VALUEwill be filled with blanks. IfNUMBER= 0,VALUEis set to the name of the program (on systems that support this feature). TheLENGTHargument contains the length of theNUMBER-th command line argument. If the argument retrieval fails,STATUSis a positive number; ifVALUEcontains a truncated command line argument,STATUSis -1; and otherwise theSTATUSis zero.
Standard:Fortran 2003 and later
Class:Subroutine
Syntax:CALL GET_COMMAND_ARGUMENT(NUMBER [, VALUE, LENGTH, STATUS])
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