J3/04-328 To: J3 From: Dan Nagle Subject: Obtain a logical unit for opening Date: 2004 June 3 Logical Unit numbers are processor dependent, there is no guaranteed way to obtain one. Rules of thumb, such as "use a number greater than ten and less than a hundred" are only somewhat portable. Large programs developed by several programmers may benefit from a standard systematic way of obtaining unit numbers. This proposal is for an intrinsic module procedure to return a logical unit number which may be opened. Following suggestions made by Walt the name is changed and wording suggested by Van is used to improve the wording and change slightly the semantics. Number: Title: GET_IO_UNIT Submitted By: J3 Status: For Consideration References: Basic Functionality: Add an procedure to ISO_FORTRAN_ENV to return a logical unit number which may be opened. Rationale: Logical unit numbers are processor-dependent, some method of getting one should be supported. Some programs (for example, multithreaded programs) may want units to be distributed according to a rule (for example, 1000 times thread number plus offset). Thus, some flexibility should be part of this intrinsic. Estimated Impact: The impact was estimated by J3/JoR at 167 as Trivial. Detailed Specification: Edits: See paper 04-327 regards possible renumbering of 13.8.2. These edits assume that paper passes. [360:33++] Add: "13.8.2.2.x GET_IO_UNIT( UNIT, [ NOTUNIT, MINUNIT, MAXUNIT, IOSTAT, IOMSG ] ) *Description.* Return values that exist, are not connected to an external file, and can be connected to an external file. *Class.* Subroutine. *Arguments.* UNIT shall be of type integer and may be of any rank. It is an INTENT(OUT) argument. It is assigned values of logical units that exist, are not connected to an external file, and can be connected to an external file. It shall not be assigned a value equal to INPUT_UNIT, OUTPUT_UNIT or ERROR_UNIT. If it is scalar, one value is returned; if it is an array, SIZE(UNIT) unique values are returned. NOTUNIT shall be of type integer. It shall (optional) be a scalar or a rank 1 array. It is an INTENT(IN) argument. The value of UNIT, or an element of UNIT if it is an array, shall not be equal to the value of NOTUNIT, or any element of NOTUNIT if it is an array. MINUNIT shall be a scalar of type integer. (optional) It is an INTENT(IN) argument. The value of UNIT, or an element of UNIT if it is an array, shall not be less than the value of MINUNIT. MAXUNIT shall be a scalar of type integer. (optional) It is an INTENT(IN) argument. The value of UNIT, or an element of UNIT if it is an array, shall not be greater than the value of MAXUNIT. IOSTAT shall be a scalar of type default integer. (optional) It is an INTENT(OUT) argument. It is assigned the value zero if the variable associated with UNIT contains valid values and assigned a processor-dependent positive value otherwise. IOMSG shall be a scalar of type default character. (optional) It is an INTENT(INOUT) argument. It is assigned a processor-dependent error message if the value of the variable associated with the IOSTAT argument indicates an error occurred. Otherwise, its value is unchanged. History: Submitted as 04-107 and 04-186 at 167