Introduction to the f77 I/O Library David L. Wasley J. Berkman University of California, Berkeley Berkeley, California 94720 _A_B_S_T_R_A_C_T The f77 I/O library, libI77.a, includes rou- tines to perform all of the standard types of For- tran input and output specified in the ANSI 1978 Fortran standard. The I/O Library was written originally by Peter J. Weinberger at Bell Labs. Where the original implementation was incomplete, it has been rewritten to more closely implement the standard. Where the standard is vague, we have tried to provide flexibility within the con- straints of the UNIX* operating system. A number of logical extensions and enhancements have been provided such as the use of the C stdio library routines to provide efficient buffering for file I/O. Revised September, 1985 __________________________ * UNIX is a Trademark of Bell Laboratories. - 3 - _1. _F_o_r_t_r_a_n _I/_O _1. _F_o_r_t_r_a_n _I/_O The requirements of the ANSI standard impose signifi- cant overhead on programs that do large amounts of I/O. For- matted I/O can be very ``expensive'' while direct access binary I/O is usually very efficient. Because of the com- plexity of Fortran I/O, some general concepts deserve cla- rification. _1._1. _T_y_p_e_s _o_f _I/_O _a_n_d _l_o_g_i_c_a_l _r_e_c_o_r_d_s _1._1. _T_y_p_e_s _o_f _I/_O _a_n_d _l_o_g_i_c_a_l _r_e_c_o_r_d_s There are four forms of I/O: _f_o_r_m_a_t_t_e_d, _u_n_f_o_r_m_a_t_t_e_d, _l_i_s_t _d_i_r_e_c_t_e_d, and _n_a_m_e_l_i_s_t. The last two are related to formatted but do not obey all the rules for formatted I/O. There are two types of ``files'': _e_x_t_e_r_n_a_l and _i_n_t_e_r_n_a_l and two modes of access to files: _d_i_r_e_c_t and _s_e_q_u_e_n_t_i_a_l. The definition of a logical record depends upon the combination of I/O form, file type, and access mode specified by the Fortran I/O statement. _1._1._1. _D_i_r_e_c_t _a_c_c_e_s_s _e_x_t_e_r_n_a_l _I/_O _1._1._1. _D_i_r_e_c_t _a_c_c_e_s_s _e_x_t_e_r_n_a_l _I/_O A logical record in a _d_i_r_e_c_t access _e_x_t_e_r_n_a_l file is a string of bytes of a length specified when the file is opened. Read and write statements must not specify logical records longer than the original record size definition. Shorter logical records are allowed. _U_n_f_o_r_m_a_t_t_e_d direct writes leave the unfilled part of the record undefined. _F_o_r_m_a_t_t_e_d direct writes cause the unfilled record to be pad- ded with blanks. _1._1._2. _S_e_q_u_e_n_t_i_a_l _a_c_c_e_s_s _e_x_t_e_r_n_a_l _I/_O _1._1._2. _S_e_q_u_e_n_t_i_a_l _a_c_c_e_s_s _e_x_t_e_r_n_a_l _I/_O Logical records in _s_e_q_u_e_n_t_i_a_l_l_y accessed _e_x_t_e_r_n_a_l files may be of arbitrary and variable length. Logical record length for _u_n_f_o_r_m_a_t_t_e_d sequential files is determined by the size of items in the iolist. The requirements of this form of I/O cause the external physical record size to be some- what larger than the logical record size. For _f_o_r_m_a_t_t_e_d write statements, logical record length is determined by the format statement interacting with the iolist at execution time. The ``newline'' character is the logical record del- imiter. Formatted sequential access causes one or more log- ical records ending with ``newline'' characters to be read or written. _1._1._3. _L_i_s_t _d_i_r_e_c_t_e_d _a_n_d _n_a_m_e_l_i_s_t _s_e_q_u_e_n_t_i_a_l _e_x_t_e_r_n_a_l _I/_O _1._1._3. _L_i_s_t _d_i_r_e_c_t_e_d _a_n_d _n_a_m_e_l_i_s_t _s_e_q_u_e_n_t_i_a_l _e_x_t_e_r_n_a_l _I/_O Logical record length for _l_i_s_t _d_i_r_e_c_t_e_d and _n_a_m_e_l_i_s_t - 4 - I/O is relatively meaningless. On output, the record length is dependent on the magnitude of the data items. On input, the record length is determined by the data types and the file contents. By ANSI definition, a slash, ``/'', ter- minates execution of a list directed input operation. Namelist input is terminated by ``&end'' or ``$end'' (depending on whether the character before the namelist name was ``&'' or ``$''). _1._1._4. _I_n_t_e_r_n_a_l _I/_O _1._1._4. _I_n_t_e_r_n_a_l _I/_O The logical record length for an _i_n_t_e_r_n_a_l read or write is the length of the character variable or array element. Thus a simple character variable is a single logical record. A character variable array is similar to a fixed length direct access file, and obeys the same rules. _U_n_f_o_r_m_a_t_t_e_d and _n_a_m_e_l_i_s_t I/O are not allowed on ``internal'' files. _1._2. _I/_O _e_x_e_c_u_t_i_o_n _1._2. _I/_O _e_x_e_c_u_t_i_o_n Note that each execution of a Fortran _u_n_f_o_r_m_a_t_t_e_d I/O statement causes a single logical record to be read or writ- ten. Each execution of a Fortran _f_o_r_m_a_t_t_e_d I/O statement causes one or more logical records to be read or written. A slash, ``/'', will terminate assignment of values to the input list during _l_i_s_t _d_i_r_e_c_t_e_d input and the remainder of the current input line is skipped. The standard is rather vague on this point but seems to require that a new external logical record be found at the start of any format- ted input. Therefore data following the slash is ignored and may be used to comment the data file. _D_i_r_e_c_t _a_c_c_e_s_s _l_i_s_t _d_i_r_e_c_t_e_d I/O is not allowed. _U_n_f_o_r_- _m_a_t_t_e_d _i_n_t_e_r_n_a_l I/O is not allowed. _N_a_m_e_l_i_s_t I/O is allowed only with _e_x_t_e_r_n_a_l _s_e_q_u_e_n_t_i_a_l files. All other flavors of I/O are allowed, although some are not part of the ANSI standard. Any I/O statement may include an _e_r_r= clause to specify an alternative branch to be taken on errors and/or an _i_o_s_- _t_a_t= clause to return the specific error code. Any error detected during I/O processing will cause the program to abort unless either _e_r_r= or _i_o_s_t_a_t= has been specificed in the program. Read statements may include _e_n_d= to branch on end-of-file. The end-of-file indication for that logical unit may be reset with a backspace statement. File position and the value of I/O list items is undefined following an error. - 5 - _2. _I_m_p_l_e_m_e_n_t_a_t_i_o_n _d_e_t_a_i_l_s _2. _I_m_p_l_e_m_e_n_t_a_t_i_o_n _d_e_t_a_i_l_s Some details of the current implementation may be use- ful in understanding constraints on Fortran I/O. _2._1. _N_u_m_b_e_r _o_f _l_o_g_i_c_a_l _u_n_i_t_s _2._1. _N_u_m_b_e_r _o_f _l_o_g_i_c_a_l _u_n_i_t_s Unit numbers must be in the range 0 - 99. The maximum number of logical units that a program may have open at one time is the same as the UNIX system limit, currently 48. _2._2. _S_t_a_n_d_a_r_d _l_o_g_i_c_a_l _u_n_i_t_s _2._2. _S_t_a_n_d_a_r_d _l_o_g_i_c_a_l _u_n_i_t_s By default, logical units 0, 5, and 6 are opened to ``stderr'', ``stdin'', and ``stdout'' respectively. However they can be re-defined with an _o_p_e_n statement. To preserve error reporting, it is an error to close logical unit 0 although it may be reopened to another file. If you want to open the default file name for any preconnected logical unit, remember to _c_l_o_s_e the unit first. Redefining the standard units may impair normal console I/O. An alternative is to use shell re-direction to externally re-define the above units. To re-define default blank con- trol or format of the standard input or output files, use the _o_p_e_n statement specifying the unit number and no file name (see 2.4). The standard units, 0, 5, and 6, are named internally ``stderr'', ``stdin'', and ``stdout'' respectively. These are not actual file names and can not be used for opening these units. _I_n_q_u_i_r_e will not return these names and will indicate that the above units are not named unless they have been opened to real files. The names are meant to make error reporting more meaningful. _2._3. _V_e_r_t_i_c_a_l _f_o_r_m_a_t _c_o_n_t_r_o_l _2._3. _V_e_r_t_i_c_a_l _f_o_r_m_a_t _c_o_n_t_r_o_l Simple vertical format control is implemented. The log- ical unit must be opened for sequential access with _f_o_r_m = '_p_r_i_n_t' (see 3.2). Control codes ``0'' and ``1'' are replaced in the output file with ``\n'' and ``\f'' respec- tively. The control character ``+'' is not implemented and, like any other character in the first position of a record written to a ``print'' file, is dropped. The _f_o_r_m = '_p_r_i_n_t' mode does not recognize vertical format control for _d_i_r_e_c_t _f_o_r_m_a_t_t_e_d, _l_i_s_t _d_i_r_e_c_t_e_d, or _n_a_m_e_l_i_s_t output. An alternative is to use the filter _f_p_r(1) for vertical format control. It replaces ``0'' and ``1'' by ``\n'' and ``\f'' respectively, and implements the ``+'' control code. - 6 - Unlike _f_o_r_m = '_p_r_i_n_t' which drops unrecognized form control characters, _f_p_r copies those characters to the output file. _2._4. _F_i_l_e _n_a_m_e_s _a_n_d _t_h_e _o_p_e_n _s_t_a_t_e_m_e_n_t _2._4. _F_i_l_e _n_a_m_e_s _a_n_d _t_h_e _o_p_e_n _s_t_a_t_e_m_e_n_t A file name may be specified in an open statement for the logical unit. If a logical unit is opened by an open statement which does not specify a file name, or it is opened implicitly by the execution of a read, write, or end- file statement, then the default file name is _f_o_r_t._N where _N is the logical unit number. Before opening the file, the library checks for an environment variable with a name identical to the tail of the file name with periods removed.|- If it finds such an environment variable, it uses its value as the actual name of the file. For example, a program containing: open(32,file='/usr/guest/census/data.d') read(32,100) vec write(44) vec normally will read from /_u_s_r/_g_u_e_s_t/_c_e_n_s_u_s/_d_a_t_a._d and write to _f_o_r_t._4_4 in the current directory. If the environment variables _d_a_t_a_d and _f_o_r_t_4_4 are set, e.g.: % setenv datad mydata % setenv fort44 myout in the C shell or: $ datad=mydata $ fort44=myout $ export datad fort44 in the Bourne shell, then the program will read from _m_y_d_a_t_a and write to _m_y_o_u_t. An _o_p_e_n statement need not specify a file name. If it refers to a logical unit that is already open, the _b_l_a_n_k= and _f_o_r_m= specifiers may be redefined without affecting the current file position. Otherwise, if _s_t_a_t_u_s = '_s_c_r_a_t_c_h' is specified, a temporary file with a name of the form _t_m_p._F_X_X_X_X_X_X will be opened, and, by default, will be deleted when closed or during termination of program execution. It is an error to try to open an existing file with _s_t_a_t_u_s = '_n_e_w' . It is an error to try to open a nonex- istent file with _s_t_a_t_u_s = '_o_l_d' . By default, _s_t_a_t_u_s = '_u_n_k_n_o_w_n' will be assumed, and a file will be created if __________________________ |-Periods are deleted because they can not be part of environment variable names in the Bourne shell. - 7 - necessary. By default, files are positioned at their beginning upon opening, but see _f_s_e_e_k(3f) and _i_o_i_n_i_t(3f) for alterna- tives. Existing files are never truncated on opening. Sequentially accessed external files are truncated to the current file position on close, backspace, or rewind only if the last access to the file was a write. An _e_n_d_f_i_l_e always causes such files to be truncated to the current file posi- tion. _2._5. _F_o_r_m_a_t _i_n_t_e_r_p_r_e_t_a_t_i_o_n _2._5. _F_o_r_m_a_t _i_n_t_e_r_p_r_e_t_a_t_i_o_n Formats which are in format statements are parsed by the compiler; formats in read, write, and print statements are parsed during execution by the I/O library. Upper as well as lower case characters are recognized in format statements and all the alphabetic arguments to the I/O library routines. If the external representation of a datum is too large for the field width specified, the specified field is filled with asterisks (*). On Ew.dEe output, the exponent field will be filled with asterisks if the exponent representation is too large. This will only happen if ``e'' is zero (see appendix B). On output, a real value that is truly zero will display as ``0.'' to distinguish it from a very small non-zero value. If this causes problems for other input systems, the BZ edit descriptor may be used to cause the field following the decimal point to be filled with zero's. Non-destructive tabbing is implemented for both inter- nal and external formatted I/O. Tabbing left or right on output does not affect previously written portions of a record. Tabbing right on output causes unwritten portions of a record to be filled with blanks. Tabbing right off the end of an input logical record is an error. Tabbing left beyond the beginning of an input logical record leaves the input pointer at the beginning of the record. The format specifier _T must be followed by a positive non-zero number. If it is not, it will have a different meaning (see 3.1). Tabbing left requires seek ability on the logical unit. Therefore it is not allowed in I/O to a terminal or pipe. Likewise, nondestructive tabbing in either direction is pos- sible only on a unit that can seek. Otherwise tabbing right or spacing with _X will write blanks on the output. - 8 - _2._6. _L_i_s_t _d_i_r_e_c_t_e_d _o_u_t_p_u_t _2._6. _L_i_s_t _d_i_r_e_c_t_e_d _o_u_t_p_u_t In formatting list directed output, the I/O system tries to prevent output lines longer than 80 characters. Each external datum will be separated by two spaces. List directed output of _c_o_m_p_l_e_x values includes an appropriate comma. List directed output distinguishes between _r_e_a_l and _d_o_u_b_l_e _p_r_e_c_i_s_i_o_n values and formats them differently. Out- put of a character string that includes ``\n'' is inter- preted reasonably by the output system. _2._7. _I/_O _e_r_r_o_r_s _2._7. _I/_O _e_r_r_o_r_s If I/O errors are not trapped by the user's program an appropriate error message will be written to ``stderr'' before aborting. An error number will be printed in ``[ ]'' along with a brief error message showing the logical unit and I/O state. Error numbers < 100 refer to UNIX errors, and are described in the introduction to chapter 2 of the UNIX Programmer's Manual. Error numbers >_ 100 come from the I/O library, and are described further in the appendix to this writeup|=. For internal I/O, part of the string will be printed with ``|'' at the current position in the string. For external I/O, part of the current record will be displayed if the error was caused during reading from a file that can backspace. _3. _N_o_n-``_A_N_S_I _S_t_a_n_d_a_r_d'' _e_x_t_e_n_s_i_o_n_s _3. _N_o_n-``_A_N_S_I _S_t_a_n_- _d_a_r_d'' _e_x_t_e_n_s_i_o_n_s Several extensions have been added to the I/O system to provide for functions omitted or poorly defined in the stan- dard. Programmers should be aware that these are non- portable. _3._1. _F_o_r_m_a_t _s_p_e_c_i_f_i_e_r_s _3._1. _F_o_r_m_a_t _s_p_e_c_i_f_i_e_r_s _B is an acceptable edit control specifier. It causes return to the logical unit's default mode of blank interpre- tation. This is consistent with _S which returns to default sign control. _P by itself is equivalent to _0_P . It resets the scale factor to the default value, 0. The form of the Ew.dEe format specifier has been __________________________ |= On many systems, these are also available in _h_e_l_p _f_7_7 _i_o__e_r_r__m_s_g_s. - 9 - extended to _D also. The form Ew.d.e is allowed but is not standard. The ``e'' field specifies the minimum number of digits or spaces in the exponent field on output. If the value of the exponent is too large, the exponent notation _e or _d will be dropped from the output to allow one more char- acter position. If this is still not adequate, the ``e'' field will be filled with asterisks (*). The default value for ``e'' is 2. An additional form of tab control specification has been added. The ANSI standard forms TRn, TLn, and Tn are supported where _n is a positive non-zero number. If _T or nT is specified, tabbing will be to the next (or n-th) 8-column tab stop. Thus columns of alphanumerics can be lined up without counting. A format control specifier has been added to suppress the newline at the end of the last record of a formatted sequential write. The specifier is a dollar sign ($). It is constrained by the same rules as the colon (:). It is used typically for console prompts. For example: write (*, "('enter value for x: ',$)") read (*,*) x Radices other than 10 can be specified for formatted integer I/O conversion. The specifier is patterned after _P, the scale factor for floating point conversion. It remains in effect until another radix is specified or format interpretation is complete. The specifier is defined as [n]R where 2 <_ _n <_ 36. If _n is omitted, the default decimal radix is restored. The format specifier Om.n may be used for an octal conversion; it is equivalent to 8R,Im.n,10R. Similarly, Zm.n is equivalent to 16R,Im.n,10R and may be used for an hexadecimal conversion; In conjunction with the above, a sign control specifier has been added to cause integer values to be interpreted as unsigned during output conversion. The specifier is _S_U and remains in effect until another sign control specifier is encountered, or format interpretation is complete.|- Radix and ``unsigned'' specifiers could be used to format a hexa- decimal dump, as follows: __________________________ |-Note: Unsigned integer values greater than (2**31 - 1), can be read and written using SU. However they can not be used in computations because Fortran uses signed arithmetic and such values appear to the arithmetic unit as negative numbers. - 10 - 2000 format ( SU, 8Z10.8 ) _3._2. _P_r_i_n_t _f_i_l_e_s _3._2. _P_r_i_n_t _f_i_l_e_s The ANSI standard is ambiguous regarding the definition of a ``print'' file. Since UNIX has no default ``print'' file, an additional _f_o_r_m= specifier is now recognized in the _o_p_e_n statement. Specifying _f_o_r_m = '_p_r_i_n_t' implies _f_o_r_m_a_t_t_e_d and enables vertical format control for that logical unit (see 2.3). Vertical format control is interpreted only on sequential formatted writes to a ``print'' file. The _i_n_q_u_i_r_e statement will return _p_r_i_n_t in the _f_o_r_m= string variable for logical units opened as ``print'' files. It will return -1 for the unit number of an unconnected file. If a logical unit is already open, an _o_p_e_n statement including the _f_o_r_m= option or the _b_l_a_n_k= option will do nothing but re-define those options. This instance of the _o_p_e_n statement need not include the file name, and must not include a file name if _u_n_i_t= refers to a standard input or output. Therefore, to re-define the standard output as a ``print'' file, use: open (unit=6, form='print') _3._3. _S_c_r_a_t_c_h _f_i_l_e_s _3._3. _S_c_r_a_t_c_h _f_i_l_e_s A _c_l_o_s_e statement with _s_t_a_t_u_s = '_k_e_e_p' may be specified for temporary files. This is the default for all other files. Remember to get the scratch file's real name, using _i_n_q_u_i_r_e , if you want to re-open it later. _3._4. _L_i_s_t _d_i_r_e_c_t_e_d _I/_O _3._4. _L_i_s_t _d_i_r_e_c_t_e_d _I/_O List directed read has been modified to allow tab char- acters wherever blanks are allowed. It also allows input of a string not enclosed in quotes. The string must not start with a digit or quote, and can not contain any separators ( ``,'', ``/'', blank or tab ). A newline will terminate the string unless escaped with \. Any string not meeting the above restrictions must be enclosed in quotes (`` " '' or `` ' ''). Internal list directed I/O has been implemented. During - 11 - internal list reads, bytes are consumed until the iolist is satisfied, or the ``end-of-file'' is reached. During inter- nal list writes, records are filled until the iolist is satisfied. The length of an internal array element should be at least 20 bytes to avoid logical record overflow when writing double precision values. Internal list read was implemented to make command line decoding easier. Internal list write should be avoided. _3._5. _N_a_m_e_l_i_s_t _I/_O _3._5. _N_a_m_e_l_i_s_t _I/_O Namelist I/O is a common extension in Fortran systems. The f77 version was designed to be compatible with other vendors versions; it is described in ``A Portable Fortran 77 Compiler'', by Feldman and Weinberger, August, 1985. _4. _R_u_n_n_i_n_g _o_l_d_e_r _p_r_o_g_r_a_m_s _4. _R_u_n_n_i_n_g _o_l_d_e_r _p_r_o_g_r_a_m_s Traditional Fortran environments usually assume car- riage control on all logical units, usually interpret blank spaces on input as ``0''s, and often provide attachment of global file names to logical units at run time. There are several routines in the I/O library to provide these func- tions. _4._1. _T_r_a_d_i_t_i_o_n_a_l _u_n_i_t _c_o_n_t_r_o_l _p_a_r_a_m_e_t_e_r_s _4._1. _T_r_a_d_i_t_i_o_n_a_l _u_n_i_t _c_o_n_t_r_o_l _p_a_r_a_m_e_t_e_r_s If a program reads and writes only units 5 and 6, then including -_l_I_6_6 in the f77 command will cause carriage con- trol to be interpreted on output and cause blanks to be zeros on input without further modification of the program. If this is not adequate, the routine _i_o_i_n_i_t(3f) can be called to specify control parameters separately, including whether files should be positioned at their beginning or end upon opening. _4._2. _I_o_i_n_i_t() _4._2. _I_o_i_n_i_t() _I_o_i_n_i_t(3f) can be used to attach logical units to specific files at run time, and to set global parameters for the I/O system. It will look for names of a user specified form in the environment and open the corresponding logical unit for _s_e_q_u_e_n_t_i_a_l _f_o_r_m_a_t_t_e_d I/O. Names must be of the form PREFIX_n_n where _P_R_E_F_I_X is specified in the call to _i_o_i_n_i_t and _n_n is the logical unit to be opened. Unit numbers < 10 must include the leading ``0''. _I_o_i_n_i_t should prove adequate for most programs as writ- ten. However, it is written in Fortran-77 specifically so that it may serve as an example for similar user-supplied - 12 - routines. A copy may be retrieved by ``ar x /usr/lib/libU77.a ioinit.f''. See 2.4 for another way to override program file names through environment variables. _5. _M_a_g_n_e_t_i_c _t_a_p_e _I/_O _5. _M_a_g_n_e_t_i_c _t_a_p_e _I/_O Because the I/O library uses stdio buffering, reading or writing magnetic tapes should be done with great caution, or avoided if possible. A set of routines has been provided to read and write arbitrary sized buffers to or from tape directly. The buffer must be a _c_h_a_r_a_c_t_e_r object. _I_n_t_e_r_n_a_l I/O can be used to fill or interpret the buffer. These rou- tines do not use normal Fortran I/O processing and do not obey Fortran I/O rules. See _t_o_p_e_n(3f). _6. _C_a_v_e_a_t _P_r_o_g_r_a_m_m_e_r _6. _C_a_v_e_a_t _P_r_o_g_r_a_m_m_e_r The I/O library is extremely complex yet we believe there are few bugs left. We've tried to make the system as correct as possible according to the ANSI X3.9-1978 document and keep it compatible with the UNIX file system. Excep- tions to the standard are noted in appendix B. - 13 - _A_p_p_e_n_d_i_x _A _I/_O _L_i_b_r_a_r_y _E_r_r_o_r _M_e_s_s_a_g_e_s Appendix A: I/O Library Error Messages The following error messages are generated by the I/O library. The error numbers are returned in the iostat= variable. Error numbers < 100 are generated by the UNIX kernel. See the introduction to chapter 2 of the UNIX Pro- grammers Manual for their description. 100 _e_r_r_o_r _i_n _f_o_r_m_a_t See error message output for the location of the error in the format. Can be caused by more than 10 levels of nested parentheses, or an extremely long format statement. 101 _i_l_l_e_g_a_l _u_n_i_t _n_u_m_b_e_r It is illegal to close logical unit 0. Unit numbers must be between 0 and 99 inclusive. 102 _f_o_r_m_a_t_t_e_d _i/_o _n_o_t _a_l_l_o_w_e_d The logical unit was opened for unformatted I/O. 103 _u_n_f_o_r_m_a_t_t_e_d _i/_o _n_o_t _a_l_l_o_w_e_d The logical unit was opened for formatted I/O. 104 _d_i_r_e_c_t _i/_o _n_o_t _a_l_l_o_w_e_d The logical unit was opened for sequential access, or the logical record length was specified as 0. 105 _s_e_q_u_e_n_t_i_a_l _i/_o _n_o_t _a_l_l_o_w_e_d The logical unit was opened for direct access I/O. 106 _c_a_n'_t _b_a_c_k_s_p_a_c_e _f_i_l_e The file associated with the logical unit can't seek. May be a device or a pipe. 107 _o_f_f _b_e_g_i_n_n_i_n_g _o_f _r_e_c_o_r_d The format specified a left tab beyond the begin- ning of an internal input record. 108 _c_a_n'_t _s_t_a_t _f_i_l_e The system can't return status information about the file. Perhaps the directory is unreadable. 109 _n_o * _a_f_t_e_r _r_e_p_e_a_t _c_o_u_n_t Repeat counts in list directed I/O must be fol- lowed by an * with no blank spaces. - 14 - 110 _o_f_f _e_n_d _o_f _r_e_c_o_r_d A formatted write tried to go beyond the logical end-of-record. An unformatted read or write will also cause this. 111 _t_r_u_n_c_a_t_i_o_n _f_a_i_l_e_d The truncation of an external sequential file on _c_l_o_s_e, _b_a_c_k_s_p_a_c_e, _r_e_w_i_n_d, or _e_n_d_f_i_l_e failed. 112 _i_n_c_o_m_p_r_e_h_e_n_s_i_b_l_e _l_i_s_t _i_n_p_u_t List input has to be just right. 113 _o_u_t _o_f _f_r_e_e _s_p_a_c_e The library dynamically creates buffers for inter- nal use. You ran out of memory for this. Your program is too big! 114 _u_n_i_t _n_o_t _c_o_n_n_e_c_t_e_d The logical unit was not open. 115 _i_n_v_a_l_i_d _d_a_t_a _f_o_r _i_n_t_e_g_e_r _f_o_r_m_a_t _t_e_r_m Only spaces, a leading sign and digits are allowed. 116 _i_n_v_a_l_i_d _d_a_t_a _f_o_r _l_o_g_i_c_a_l _f_o_r_m_a_t _t_e_r_m Legal input consists of spaces (optional), a period (optional), and then a ``t'', ``T'', ``f'', or ``F''. 117 '_n_e_w' _f_i_l_e _e_x_i_s_t_s You tried to open an existing file with ``status='new'''. 118 _c_a_n'_t _f_i_n_d '_o_l_d' _f_i_l_e You tried to open a non-existent file with ``status='old'''. 119 _o_p_e_n_i_n_g _t_o_o _m_a_n_y _f_i_l_e_s _o_r _u_n_k_n_o_w_n _s_y_s_t_e_m _e_r_r_o_r Either you are trying to open too many files simultaneously or there has been an undetected system error. 120 _r_e_q_u_i_r_e_s _s_e_e_k _a_b_i_l_i_t_y Direct access requires seek ability. Sequential unformatted I/O requires seek ability on the file due to the special data structure required. Tab- bing left also requires seek ability. 121 _i_l_l_e_g_a_l _a_r_g_u_m_e_n_t Certain arguments to _o_p_e_n, etc. will be checked for legitimacy. Often only non-default forms are looked for. - 15 - 122 _n_e_g_a_t_i_v_e _r_e_p_e_a_t _c_o_u_n_t The repeat count for list directed input must be a positive integer. 123 _i_l_l_e_g_a_l _o_p_e_r_a_t_i_o_n _f_o_r _u_n_i_t An operation was requested for a device associated with the logical unit which was not possible. This error is returned by the tape I/O routines if attempting to read past end-of-tape, etc. 124 _i_n_v_a_l_i_d _d_a_t_a _f_o_r _d, _e, _f _o_r _g _f_o_r_m_a_t _t_e_r_m Input data must be legal. 125 _i_l_l_e_g_a_l _i_n_p_u_t _f_o_r _n_a_m_e_l_i_s_t Column one of input is ignored, the namelist name must match, the variables must be in the namelist, and the data must be of the right type. - 16 - _A_p_p_e_n_d_i_x _B _E_x_c_e_p_t_i_o_n_s _t_o _t_h_e _A_N_S_I _S_t_a_n_d_a_r_d Appendix B: Exceptions to the ANSI Standard A few exceptions to the ANSI standard remain. _V_e_r_t_i_c_a_l _f_o_r_m_a_t _c_o_n_t_r_o_l The ``+'' carriage control specifier is not fully implemented (see 2.3). It would be difficult to implement it correctly and still provide UNIX-like file I/O. Furthermore, the carriage control implementation is asymmetrical. A file written with carriage control interpretation can not be read again with the same charac- ters in column 1. An alternative to interpreting carriage control inter- nally is to run the output file through a ``Fortran output filter'' before printing. This filter could recognize a much broader range of carriage control and include terminal dependent processing. One such filter is _f_p_r(1). _D_e_f_a_u_l_t _f_i_l_e_s Files created by default use of _e_n_d_f_i_l_e statements are opened for _s_e_q_u_e_n_t_i_a_l _f_o_r_m_a_t_t_e_d access. There is no way to redefine such a file to allow _d_i_r_e_c_t or _u_n_f_o_r_m_a_t_t_e_d access. _L_o_w_e_r _c_a_s_e _s_t_r_i_n_g_s It is not clear if the ANSI standard requires inter- nally generated strings to be upper case or not. As currently written, the _i_n_q_u_i_r_e statement will return lower case strings for any alphanumeric data. _E_x_p_o_n_e_n_t _r_e_p_r_e_s_e_n_t_a_t_i_o_n _o_n _E_w._d_E_e _o_u_t_p_u_t If the field width for the exponent is too small, the standard allows dropping the exponent character but only if the exponent is > 99. This system does not enforce that res- triction. Further, the standard implies that the entire field, ``w'', should be filled with asterisks if the exponent can not be displayed. This system fills only the exponent field in the above case since that is more diagnos- tic. - 17 - _P_r_e-_c_o_n_n_e_c_t_i_o_n _o_f _f_i_l_e_s The standard says units must be pre-connected to files before the program starts or must be explicitly opened. Instead, the I/O library connects the unit to a file on its first use in a read, write, print, or endfile statement. Thus inquire by unit can not tell prior to a unit number use the characteristics or name of the file corresponding to a unit. - 2 -