J3/06-138r1 To: J3 From: R. Bleikamp/JOR Subject: work item J3-002 Date: 16 Feb 2006 This paper describes the specification, syntax, and edits for WG5 work item J3-002. Specification: Provide the programmer the ability to get an available external number and OPEN an external file, without having to worry about selecting a valid and available I/O unit number. This capability is expected to work in the presence of parallel (i.e. openMP) execution, and should not interfere with any existing UNIT number usage in existing code. Syntax and intended semantics: Add the following keywords to the OPEN statement: NEWUNIT=variable When the NEWUNIT specifier is present, the processor will attempt to OPEN the specified file, with a currently unused negative unit number, and, if the OPEN is successful, will assign that negative unit number to variable. The unit number selected shall be negative, and will not conflict with any positive unit number, any negative unit number used for uddtio child unit number, error codes (INQUIRE), nor the * units. If the OPEN is not successful, variable shall not be defined by the OPEN statement. When the NEWUNIT specifier is present, file-unit-number shall not be present. When the NEWUNIT specifier is present, the FILE= specifier shall be present. Allow INQUIRE on internal units, and return a new IOSTAT value for an internal file. Needed because negative unit numbers are now used for both child data statements (which may be internal units), and processor assigned external unit #s. Edits: [178:17-18] Replace "a file positioning statement, or a file inquiry statement" with "or a file positioning statement" [178:30-32] Replace " whose value is nonnegative or equal to one of the named constants INPUT_UNIT, OUTPUT_UNIT, or ERROR_UNIT of the ISO_FORTRAN_ENV module (13.8.2). " with ". The value of shall be nonnegative, one of the named constants that identify unit numbers in the ISO_FORTRAN_ENV module (INPUT_UNIT, OUTPUT_UNIT, or ERROR_UNIT) (13.8.2), or a NEWUNIT value (9.4.5.10)" [181:33+] Insert "<> NEWUNIT = " [181:43] Replace "A" with: "If the NEWUNIT= specifier does not appear, a" [181:44+] Insert two new constraints: "(Cxxx) R(905) If a NEWUNIT= specifier appears, a shall not appear. [182:3+] Insert a new paragraph "If the NEWUNIT= specifier appears in an OPEN statement, either the FILE= specifier shall appear, or the STATUS= specifier shall appear with a value of SCRATCH. The unit identified by a NEWUNIT value shall not be preconnected." [183:32+] Insert a new paragraph and renumber all subsequent OPEN statement specifier paragraphs: "<<9.4.5.10 NEWUNIT= specifier in the OPEN statement>> The is defined with a processor determined NEWUNIT value if no error occurs during the execution of the OPEN statement. If an error occurs, the processor shall not change the value of . A NEWUNIT value is a negative number, and shall not be -1, ERROR_UNIT, INPUT_UNIT, OUTPUT_UNIT, any value used by the processor for the unit argument to a user-defined derived type input/output procedure, nor any value used to OPEN a file that is currently OPEN." [201:12] Replace Note 9.44 with: "<> The argument passed to a user defined derived type input/output procedure will be negative when the parent I/O statement identified an internal unit, or the parent’s unit value was a processor determined NEWUNIT value. When a unit that identifes an internal unit is used with the INQUIRE statement, an error condition will occur, and the IOSTAT specifier’s will be assigned the value IOSTAT_INQUIRE_INTERNAL_UNIT from the ISO_FORTRAN_ENV intrinsic module (13.8.2). When an internal unit is used with an INQUIRE statement that contains neither an IOSTAT= specifier nor an ERR= specifier, execution of the program is terminated. (end note)" [211:8-9] Replace these lines with "If identifies an internal unit (9.5.3.7.2), an error condition occurs." [218:25+] add a list item, and renumber the rest of the list: "(2) The processor-dependent positive integer value of the constant IOSTAT_INQUIRE_INTERNAL_UNIT if an error occurred due to a unit number identifying an internal file being used in an INQUIRE statement." [218:26] Replace "an error" with "any other error" [360:26+] Insert "<<13.8.2.7 IOSTAT_INQUIRE_INTERNAL_UNIT>> The value of the default integer scalar constant IOSTAT_INQUIRE_INTERNAL_UNIT is assigned to the variable specified in an IOSTAT= specifier in an INQUIRE statement (9.9.1) if a identifies an internal unit in an INQUIRE statement. <> This can only occur when a user defined derived type input/output procedure is called by the processor as the result of executing a parent data transfer statement for an internal unit. (end note)" End of Edits Note to editor, please add a note on page xiii: xx) OPEN statement enhancements that allow the processor to select a ‘safe’ unit number when opening an external unit. Such a unit number is guaranteed not to interfere with any program managed unit numbers.