To: X3J3 J3/98-135r1 From: JOR page 1 of 3 Subject: Command line arguments, specs,syntax,edits Date: Feb. 18, 1998 Changes since "r0" are marked with "|" in the left column. I did search chapters 1-15 for all occurences of "assumed", and added a few edits below. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Specification and Syntax: The PROGRAM statement may include the following arguments, as shown. The type of argument is what determines what is stored into it by the processor, not the actual name of the dummy argument. PROGRAM jerry (argument_text, argument_length, command_line) CHARACTER (LEN=*) :: command_line CHARACTER (LEN=*), DIMENSION (0:) :: argument_text INTEGER, DIMENSION (0:) :: argument_length The dummy arguments above, if specified, will have the following values: command_line -- the text of the command_line, in a processor dependent form argument_text -- the "parsed" command line. Parsing (delimiters etc.) is processor dependent argument_text(0) is the command name (if available) which invoked the current program argument_text(1) is the first argument on the command line . . . argument_text(size(argument_text)-1) is the last argument from the command line argument_length -- the effective lengths of the parsed arguments in "argument_text", used to trim insignificant blanks from the end of argument in "argument_text" (only needed if there might be significant trailing blanks, otherwise TRIM seems preferable). The "command_line" and "argument_text" arguments shall be of type default character and assumed length. The "argument_text" and "argument_length" arguments must be assumed shape. The "argument_length" argument must be of type default integer. An element of "argument_text" and the "command_line" argument will always be at least of length 1. When argument_text or argument_length is present on the PROGRAM statement, the lower bound shall be present in the declaration for that variable, and shall be zero. A length of zero (and therefore all blanks) for an argument indicates no argument was present, the argument was null, or the processor could not obtain the argument (in this position). argument_length(0) may be zero if the processor does not support the concept of, or cannot obtain a command name. The argument_text and argument_length arrays will always have at least one element (element (0)). J3/98-135r1 page 2 of 3 Edits: | Section 5.1.1.5 [53:12], change "dummy argument" to | "dummy argument or program-arg" | | Section 5.1.1.5 [53:19+], add list item (2), and renumber existing (2) and (3): | "(2) It may be used to declare a "program-arg" (11.1), in which case the | processor determines the length." | | Section 5.1.2.4.2 [57:42], change "." to | ", or a program-arg (11.1) whose shape is determined by the processor." | | Section 5.1.2.4.2 [58:1], change "assumed-shape array" to | "assumed-shape array dummy argument" Section 11.1, R1102 [195:14], change "is PROGRAM program-name" to "is PROGRAM program-name [( program-arg-list )] R11xx program-arg is program-arg-name " Add a new section 11.1.1 [195:37+] and renumber the sections 11.1.1 - 11.1.3. "11.1.1 Main program arguments The PROGRAM statement may include the arguments described in this section. These variables, if present, are initialized by the processor as described below. The meaning and interpretation of the terms "command line", "command line argument", "delimiter", and "command name" are processor dependent. The actual name of each main program argument is not significant. The | type and rank of each argument shall be one of those described in this | section, and only one variable of each type and rank shall appear in a PROGRAM statement. Program statement argument types and values: CHARACTER (LEN=*) :: command_line The "command_line" argument contains the processor dependent representation of the command line which invoked the program. | The "command_line" argument, if present, shall be declared assumed length, and of type default character. LEN(command_line) will always be at least one. Note: Various user interfaces, including text and graphical user interfaces, may process the command line. Note: A program's command line includes information which is associated with the program at startup. This information includes, but is not limited to, character strings included with the program's startup command. CHARACTER (LEN=*), DIMENSION (0:) :: argument_text The "argument_text" array argument contains the text of the command line. "argument_text(0)" contains the command name from the command line. "argument_text(i)" contains the i'th argument after the command name. "argument_text(size(argument_text)-1)" contains the last argument from the command line. | The "argument_text" argument, if present, shall be declared assumed length, assumed shape with an explicit lower bound of zero, and of type default character. LEN(argument_text(0)) will always be at least one. SIZE(argument_text) will be at least one. An element of "argument_text" will always be at least of length one. J3/98-135r1 page 3 of 3 INTEGER, DIMENSION (0:) :: argument_length The "argument_length" array argument contains the length of the significant character string in each corresponding element in the "argument_text" array. The characters in a particular element of "argument_text" beyond the "argument_length(i)" position will be blanks. | The "argument_length" argument, if present, shall be declared assumed shape with an explicit lower bound of zero, and of type default integer. SIZE(argument_length) will be equal to SIZE(argument_text). Note: A value of zero for an element of argument_length indicates the | argument was not present, was zero length, or could not be obtained by the processor. Note: A value of zero for argument_length(0) indicates the processor did not provide a command name. | A program-arg variable declaration may include the TARGET and INTENT(INOUT) | attributes. No other attributes may be specified for a program-arg variable.