GET_COMMAND intrinsic subroutine

Standard: F77 F90 F95 F2003 F2008 F2018 Example program


<Syntax>

Call GET_COMMAND ( [ COMMAND, LENGTH, STATUS, ERRMSG ] )

COMMAND : scalar default Character, Intent(Out);
LENGTH : scalar Integer, 16 bits or larger, Intent(Out);
STATUS : scalar Integer, 16 bits or larger, Intent(Out);
ERRMSG : scalar default Character, Intent(Out).

Prior to Fortran 2018, the Integer arguments had to be of default kind.

<Semantics>

This intrinsic subroutine retrieves the command line for the current execution of the program, and assigns it to the COMMAND argument (if present), as if by normal character assignment.

If LENGTH is present, it is assigned the length of the command line (before its assignment to COMMAND). This may be used to allocate a COMMAND variable large enough to receive the full value of the argument.

If STATUS is present, it is assigned the value −1 if COMMAND was present but is shorter than the command line length, a positive value if an error occurs, and zero otherwise.

If an error occurs and ERRMSG is present, ERRMSG is assigned an explanatory message. Otherwise, ERRMSG is unchanged.

<Related>

COMMAND_ARGUMENT_COUNT intrinsic function, GET_COMMAND_ARGUMENT intrinsic subroutine