Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 3/22/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

GETARG

Intrinsic Subroutine: Returns the specified command-line argument (where the command itself is argument number zero). Intrinsic subroutines cannot be passed as actual arguments.

CALL GETARG (n,buffer[,status])

n

(Input) Must be a scalar of type integer. This value is the position of the command-line argument to retrieve. The command itself is argument number 0.

buffer

(Output) Must be a scalar of type default character. Its value is the returned command-line argument.

status

(Output; optional) Must be a scalar of type integer. If specified, its value is the returned completion status.

If there were no errors, status returns the number of characters in the retrieved command-line argument before truncation or blank-padding. (That is, status is the original number of characters in the command-line argument.) Errors return a value of -1. Errors include specifying an argument position less than 0 or greater than the value returned by IARGC.

GETARG returns the nth command-line argument. If n is zero, the name of the executing program file is returned.

GETARG returns command-line arguments as they were entered. There is no case conversion.

If the command-line argument is shorter than buffer, GETARG pads buffer on the right with blanks. If the argument is longer than buffer, GETARG truncates the argument on the right. If there is an error, GETARG fills buffer with blanks.

Example

Assume a command-line invocation of PROG1 -g -c -a, and that buffer is at least five characters long. The following calls to GETARG return the corresponding arguments in buffer and status:

Statement

String returned in buffer

Length returned in status

CALL GETARG (0, buffer, status)

PROG1

5

CALL GETARG (1, buffer)

-g

undefined

CALL GETARG (2, buffer, status)

-c

2

CALL GETARG (3, buffer)

-a

undefined

CALL GETARG (4, buffer, status)

all blanks

-1