To: J3 J3/19-130 From: Malcolm Cohen Subject: Connection of INPUT_UNIT and * Date: 2019-February-07 ---------------------------------------------------------------------- NUMBER: F18/0005 TITLE: Does INPUT_UNIT really identify the same unit as *? KEYWORDS: Connection, INPUT_UNIT DEFECT TYPE: Clarification STATUS: J3 consideration in progress QUESTION: According to 16.10.2.13 INPUT_UNIT [429:8-9], "The value of the default integer scalar constant INPUT_UNIT identifies the same processor-dependent external unit preconnected for sequential formatted input as the one identified by an asterisk in a READ statement;" Consider the program: PROGRAM input_unit_test USE iso_fortran_env CHARACTER(80) line OPEN(input_unit,FILE='test.dat',ACTION='read') READ(input_unit,'(a)') line PRINT *,TRIM(line) READ(*,'(a)') line PRINT *,TRIM(line) END PROGRAM Furthermore, let us suppose the file test.dat contains the following two lines: dat line 1 dat line 2 and let us further suppose the file that was preconnected before the OPEN statement contains the following single line: inp line 2 Is the output of the program (1): dat line 1 dat line 2 or is it (2): dat line 1 inp line 1 ? The plain meaning of the words "identifies the same processor-dependent external unit... ...as the one identified by an asterisk in a READ" would seem to imply that (1) is expected, not (2); however, only some Fortran processors produce output (1), while others have been observed to produce output (2). ANSWER: Output (1) is correct. According to the quoted words, using INPUT_UNIT in a READ statement must have the same effect as UNIT=* (which is the same effect as not having a input/output control list). It is common for unit 5 to be effectively preconnected to stdin, but on some processors changing the connection of unit 5 (e.g. with an OPEN statement) does not affect unit=*. On such a processor, the value of INPUT_UNIT should not be equal to 5, but to whatever value, possibly negative, that will continue to connect to unit=*. EDIT to 18-007r1: None. SUBMITTED BY: Malcolm Cohen HISTORY: 19-nnn m218 Submitted ----------------------------------------------------------------------