ISO/IEC JTC1/SC22/WG5/N1363 Derived-Type I/O : Reentrant I/O --------------------------------- Currently, the Fortran standard prohibits reentrant I/O. Reentrant I/O allows I/O operations while I/O is active. At present, the desire to do reentrant I/O is largely motivated by the desire to report errors in a function called while calculating the value of an output item in the output list of a WRITE statement. The only way in which such a function call in the output list of a WRITE statement might violate the current prohibition of reentrant I/O is if the called function attempts to do any kind of I/O of its own (which constitutes a side-effect of the function). The restriction applies even if the function attempts to write on the unit that is already currently active. With the advent of derived-type I/O, the user-defined procedures used to read or write objects of a derived type are expected/required to do I/O while I/O is active --- it is their normal mode of operation! The reason why this does not constitute reentrant I/O is that such procedures are only allowed to do I/O in the same direction (READ or WRITE) on the same unit that is already active: the runtime system temporarily suspends its own format- and io-list handling, calls the user-defined derived-type I/O procedure which continues to do I/O in the same direction on the same unit, and then resumes its own format- and io-list handling. However, the added flexibility and generality which the user may rightly expect from a user-defined I/O routine is greatly reduced by the prohibition of reentrant I/O. Many desirable features of a user-defined I/O routine are currently prohibited: 1. Interactive I/O control requiring questions to and answers from the user at runtime 2. Reading information from a file while writing a complicated data object to another file 3. Writing informative or error messages to a file while doing I/O with another file 4. Writing different external forms of a complicated data object to different files We propose the deletion of the two small paragraphs in section 9.5.4.4.3 directly following Note 9.43 which prohibit reentrant I/O during user-defined derived-type I/O, and possibly removal of the prohibition of reentrant I/O altogether.