To: J3 J3/21-197 From: Steve Lionel Subject: Changeable modes and derived type I/O Date: 2021-October-20 Reference: 21-007r2 Introduction ------------ Van Snyder's paper 21-177 raises the question of just what the standard says should be the value of the scale factor for a child data transfer statement in derived type formatted I/O. The issue is broader in that the same question applies to all of the "changeable modes" (12.5.2). For example, if the parent transfer has a 3P edit descriptor, is that in effect for the child transfer? And, what happens if the child transfer has its own control edit descriptor or keyword to change one or more of the modes - does this change flow back to the parent upon completion? A related question is whether the connection of the child transfer is the same as that of the parent. This is plausibly the case for external I/O, but for internal I/O, the child is supplied a negative unit number and not the character variable used in the parent - is this really the same connection? 12.5.2p2 says: "Values for the modes of a connection are established when the connection is initiated. If the connection is initiated by an OPEN statement, the values are as specified, either explicitly or implicitly, by the OPEN statement. If the connection is initiated other than by an OPEN statement (that is, if the file is an internal file or preconnected file) the values established are those that would be implied by an initial OPEN statement without the corresponding keywords." The concensus of JOR is that changeable modes are intended to "flow in" to a child transfer, but not flow back out. There is note 12.1 that says, in part: "The effect of executing thedefined input/output procedure is similar to that of substituting the list items from any child data transfer statements into the parent data transfer statement's list items, along with similar substitutions in the format specification." If one takes this literally, then mode changes flow in and out of child transfers, which seems undesirable. A test of four current compilers shows that three do not inherit modes from the parent and one does. None of the four have mode changes flow back out to the parent. However, the note does say "is similar to", so perhaps it is not intended to be exact. Proposal -------- Specify that, upon initiation of a defined input/output procedure, the unit specified by the UNIT dummy argument identifies a temporary copy of the parent's file connection, including the current values of all changeable modes. 12.5.2p5 already says "When a data transfer statement terminates, the values for the modes are reset to the values in effect immediately before the data transfer statement was executed." Note that one is allowed to use INQUIRE to ask about the changeable modes other than scale factor. (See note 12.6 on p253.) Edits to 21-007r2 ----------------- 230:23-26 12.5.2p2 "Connection Modes" Replace the third sentence ("If the connection is initiated other than by an OPEN statement") with: "If a defined input/output procedure (12.6.4.8.2) is called, the values for the connection identified by the *unit* dummy argument are those presently in effect in the parent data transfer statement. Otherwise (that is, if the file is an internal file or preconnected file) the values established are those that would be implied by an initial OPEN statement without the corresponding keywords." --END--