Annotation of 3BSD/new/libI77uc/writeup.tx, revision 1.1.1.1

1.1       root        1: .ND
                      2: .TL
                      3: Update to the f77 I/O Library
                      4:  January 1980
                      5: .AU
                      6: David L. Wasley
                      7: .AI
                      8: University of California
                      9: Berkeley, Calif. 94720
                     10: .PP
                     11: The fortran-77 I/O library, libI77.a, has been extensively updated.
                     12: All known bugs have been fixed, and
                     13: I/O error reporting has been improved.
                     14: Several non-standard extensions to FORTRAN I/O have been added.
                     15: .PP
                     16: Some general concepts regarding f77 I/O deserve clarification. There are three
                     17: forms of I/O: formatted, unformatted, and list-directed. The last is
                     18: related to formatted but does not obey all the rules for formatted I/O.
                     19: There are two modes of access to external and internal files: direct
                     20: and sequential. The definition of a logical record depends upon the
                     21: combination of I/O form and mode specified by the fortran I/O statement.
                     22: .PP
                     23: A logical record in direct access external files is a string of bytes
                     24: of a length specified when the file is opened.
                     25: Read and write statements must not specify logical records longer than
                     26: the original record size definition. Shorter logical records are allowed.
                     27: Unformatted direct writes leave the unfilled part of the record undefined.
                     28: Formatted direct writes cause the unfilled record to be padded with blanks.
                     29: .PP
                     30: Logical records in sequentially accessed external files may be of arbitrary
                     31: and variable length.
                     32: Logical record length for unformatted sequential files is determined by
                     33: the size of items in the iolist.
                     34: For formatted write statements, logical record length is determined by
                     35: the format statement interacting with the iolist at execution time.
                     36: Formatted sequential access causes one or more logical records
                     37: ending with 'newline' characters to be read or written.
                     38: .PP
                     39: Logical record length for list-directed I/O is relatively meaningless.
                     40: On output, the record length is dependent on the magnitude of the
                     41: data items.
                     42: On input, the record length is determined by the data types and the file
                     43: contents.
                     44: .PP
                     45: The logical record length for "internal" files is the length of the
                     46: character variable or array element. Thus a simple character variable
                     47: is a single logical record. A character variable array is similar to
                     48: a fixed length direct access file, and obeys the same rules.
                     49: Unformatted I/O is not allowed on "internal" files.
                     50: .PP
                     51: Note that each execution of a fortran unformatted I/O statement causes a single
                     52: logical record to be read or written. Each execution of a fortran formatted
                     53: I/O statement causes one or more logical records to be read or written.
                     54: .PP
                     55: Any error detected during I/O processing will cause the program to abort
                     56: unless alternate action has been provided for specifically in the program.
                     57: Any I/O statement may include an err= clause (and iostat= clause)
                     58: to specify an
                     59: alternate branch to be taken on errors (and return the specific error code).
                     60: Read or write statements may include end= to branch on end-of-file.
                     61: File position and the value of I/O list items is undefined following an error.
                     62: 
                     63: I. Implementation details.
                     64: .PP
                     65: The maximum number of logical units that a program may have open at one
                     66: time has been set to correspond with the UNIX system limit, currently 20.
                     67: However, the I/O library uses UNIX file access for internal purposes.
                     68: Therefore fatal errors are possible if the maximum number of files are open.
                     69: Specifically, 'close' or 'endfile' on an old file,
                     70: and "'inquire' by file" may fail.
                     71: .PP
                     72: Vertical format control is implemented. The logical unit must be opened
                     73: for sequential access and "form = 'print'" (see below).
                     74: Control codes '0' and '1' are replaced in the output file
                     75: with '\\n' and '\\f' respectively.
                     76: The control character '+' isn't implemented and, like
                     77: any other character in the first position of a record
                     78: written to a "print" file, is dropped.
                     79: No vertical format control is recognized for direct formatted output
                     80: or list directed output.
                     81: .PP
                     82: Default logical units 0, 5, and 6 can be re-defined with an 'open' statement.
                     83: To preserve error reporting, it is an error to close logical unit 0.
                     84: If you want to open the default filename for any preconnected logical unit,
                     85: remember to 'close' the unit first.
                     86: Redefining the standard units may impair normal console I/O.
                     87: An alternative is to
                     88: use shell re-direction to externally re-define the above units.
                     89: To re-define default blank control or format of the standard input or output
                     90: files, use the 'open' statement specifying the unit number and no
                     91: filename (see below).
                     92: .PP
                     93: An 'open' statement need not specify a filename. If it refers to a logical
                     94: unit that is already open, the "blank= " and "form= " specifiers may be
                     95: redefined without affecting the current file position.
                     96: Otherwise, if "status='scratch'" is specified, a temporary file with a
                     97: name of the form 'tmp.FXXXXXX' will be opened,
                     98: and, by default, will be deleted when closed or during
                     99: termination of program execution.
                    100: Any other "status= " specifier without an associated filename results in
                    101: opening a file named 'fort.N' where N is the specified logical unit number.
                    102: It is an error to try to open an existing file with "status='new'".
                    103: It is an error to try to open a nonexistent file with "status='old'".
                    104: By default "status='unknown'" will be assumed, and a file will be created
                    105: if necessary.
                    106: Existing files are never truncated on opening but are positioned
                    107: at the end-of-file.
                    108: .PP
                    109: Sequentially accessed external files are truncated to the current file
                    110: position on 'close', 'backspace', or 'rewind' only if the last
                    111: access to the file was a write.
                    112: .PP
                    113: Upper as well as lower case characters are recognized in format statements
                    114: and all alphabetic arguments to the I/O library routines.
                    115: This has always been true for statements that are
                    116: part of the source code, but not for format statements
                    117: or character arguments from a file.
                    118: .PP
                    119: If the external representation of a datum
                    120: is too large for the field width specified, the specified
                    121: field is filled with asterisks (*).
                    122: On 'Ew.dEe' output, the e field will be filled with asterisks if the
                    123: exponent representation is too large.
                    124: (This will only happen if e==0)
                    125: .PP
                    126: List-directed output of complex values now includes an appropriate comma.
                    127: List-directed output now distinguishes between real*4 and real*8 values
                    128: and formats them differently.
                    129: Output of a character string that includes '\\n' now works correctly.
                    130: .PP
                    131: If I/O errors are not trapped by the user's program an appropriate
                    132: error message will be written to 'stderr' before aborting.
                    133: An error number will be printed in [ ] along with a brief error message
                    134: showing the logical unit and I/O state.
                    135: Error numbers < 100 refer to UNIX errors, and are described in the
                    136: introduction to chapter 2 of the UNIX Programmer's Manual.
                    137: Error numbers >= 100 come from the I/O library, and are described
                    138: further in the appendix to this writeup.
                    139: For internal I/O, part of the string will be printed with '|' at the
                    140: current position in the string.
                    141: For external I/O, part of the current record will be displayed if
                    142: the error was caused during reading from a file that can backspace.
                    143: .PP
                    144: Direct access list-directed I/O is not allowed.
                    145: Unformatted internal I/O is not allowed.
                    146: Both the above will be caught by the compiler.
                    147: All other flavors of I/O are allowed, although some are not part of the ANSI
                    148: standard.
                    149: .PP
                    150: The standard units, 0, 5, and 6, are now named internally 'stderr', 'stdin',
                    151: and 'stdout' respectively.
                    152: These are not actual filenames and can not be used for opening these units.
                    153: \'inquire' will not return these names and will indicate
                    154: that the above units are not named unless they have been opened to real files.
                    155: The names are meant to make error reporting more meaningful.
                    156: .PP
                    157: On output, a real value that is truly zero will display as '0.' to
                    158: distinguish it from a very small non-zero value.
                    159: This occurs in 'F', 'E', 'D', and 'G' format conversions.
                    160: .PP
                    161: Non-destructive tabbing is implemented for both internal and external
                    162: formatted I/O.
                    163: Tabbing left or right on output
                    164: does not affect previously written portions of a record.
                    165: Tabbing right on output
                    166: causes unwritten portions of a record to be filled with blanks.
                    167: Tabbing left or right off the end of a logical record is an error.
                    168: The format specifier 'T' must be followed by a positive non-zero number.
                    169: If it is not, it will have a different meaning (See below).
                    170: Note that spacing with 'X' always writes blanks in the output record.
                    171: 
                    172: II. Non-"ANSI Standard" Extensions
                    173: .PP
                    174: B is an acceptable edit control specifier. It causes return to the
                    175: default mode of blank interpretation (NULL) and is identical to BN.
                    176: This is consistent with S which returns to default sign control.
                    177: .PP
                    178: P by itself is equivalent to 0P. It resets the scale factor to the
                    179: default value, 0.
                    180: .PP
                    181: The form of the 'Ew.dEe' format specifier has been extended to 'D' also.
                    182: The form 'Ew.d.e' is allowed but is not standard.
                    183: The 'e' field specifies the minimum number of digits or spaces in the
                    184: exponent field on output.
                    185: If the value of the exponent is too large, the exponent notation 'e'
                    186: or 'd' will be dropped from the output to allow one
                    187: more character position.
                    188: If this is still not adequate, the 'e' field will be filled with
                    189: asterisks (*). The default value for 'e' is 2.
                    190: .PP
                    191: An additional form of tab control specification has been added.
                    192: The ANSI standard forms 'TRn', 'TLn', and 'Tn' are supported where n is
                    193: a positive non-zero number. If 'T' or 'nT' is specified, tabbing will
                    194: be to the next (or n-th) 8-column tab stop.
                    195: Thus columns of alphanumerics can be lined up without counting.
                    196: (See above for a description of the tabbing implementation.)
                    197: .PP
                    198: A format control specifier has been added to suppress the newline
                    199: at the end of the last record of a formatted sequential write. The
                    200: specifier is a dollar sign ($). It is constrained by the same rules
                    201: as the colon (:). It is used typically for console prompts.
                    202: For example:
                    203: 
                    204: .DS
                    205: write (*, "('enter value for x: ',$)")
                    206: read (*,*) x
                    207: .DE
                    208: .PP
                    209: Radices other than 10 can be specified for formatted integer I/O
                    210: conversion. The specifier is patterned after P, the pre-scale factor for
                    211: floating point conversion. It remains in effect until another radix is
                    212: specified or format interpretation is complete. The specifier is defined
                    213: as [n]R where 2 <= n <= 36. If n is omitted,
                    214: the default decimal radix is restored.
                    215: .PP
                    216: In conjunction with the above, a sign control specifier has been added
                    217: to cause integer values to be interpreted as unsigned during output
                    218: conversion. The specifier is SU and remains in effect until another
                    219: sign control specifier is encountered, or format interpretation is
                    220: complete. Radix and 'unsigned' specifiers could be used to format
                    221: a hexadecimal dump, as follows:
                    222: 
                    223: .DS
                    224: 2000   format( SU, 16R, 8I10.8)
                    225: .DE
                    226: 
                    227: Note: Unsigned integer values greater than (2**30 - 1),
                    228: i.e. any signed negative value, can not be read by FORTRAN input routines.
                    229: All internal values will be output correctly.
                    230: .PP
                    231: The ANSI standard is ambiguous regarding the definition of a "print" file.
                    232: Since UNIX has no default "print" file, an additional 'form' specifier
                    233: is now recognized in the 'open' statement.
                    234: Specifying "form='print'" implies 'formatted' and enables vertical format
                    235: control for that logical unit (see above).
                    236: Vertical format control is interpreted only on sequential formatted writes
                    237: to a "print" file.
                    238: .PP
                    239: The 'inquire' statement will return 'print' in the 'FORM=' string variable
                    240: for logical units opened as "print" files.
                    241: It will return -1 for the unit number of an unconnected file.
                    242: .PP
                    243: If a logical unit is already open, an 'open' statement including the
                    244: 'form=' option or the 'blank=' option will do nothing but
                    245: re-define those options.
                    246: This instance of the 'open' statement need not include the filename, and
                    247: must not include a filename if 'unit=' refers to the standard input or outputs.
                    248: Therefore, to re-define the standard output as a "print" file, use:
                    249: 
                    250: .DS
                    251: open (unit=6, form='print')
                    252: .DE
                    253: .PP
                    254: In a 'close' statement, "status='keep'" may be specified for temporary files.
                    255: This is the default for all other files.
                    256: Remember to get the file's real name,
                    257: using 'inquire', if you want to re-open it later.
                    258: .PP
                    259: List directed read has been modified to allow input of a string not enclosed
                    260: in quotes. The string must not start with a digit, and can not contain a
                    261: separator (, or /) or blank (space or tab). A newline will terminate the
                    262: string unless escaped with \\. Any string not meeting the above restrictions
                    263: must be enclosed in quotes (" or ').
                    264: .PP
                    265: Internal list-directed I/O has been implemented. During internal list reads,
                    266: bytes are consummed until the iolist is satisfied, or the 'end-of-file'
                    267: is reached.
                    268: During internal list writes, records are filled until the iolist is satisfied.
                    269: The length of an internal array element should be at least 20 bytes to
                    270: avoid logical record overflow when writing double precision values.
                    271: Internal list read was implemented to make command line decoding easier.
                    272: Internal list write should be avoided.
                    273: .bp
                    274: .ce 2
                    275: Appendix A
                    276: I/O Library Error Messages
                    277: .PP
                    278: The following error messages are generated by the I/O library.
                    279: The error numbers are returned in the "iostat=" variable if the "err="
                    280: return is taken. Error numbers < 100 are generated by UNIX. See the
                    281: UNIX Programmers Manual, introduction to chapter 2.
                    282: .DS
                    283: /* 100 */      "error in format"
                    284:                See error message output for the location
                    285:                of the error in the format. Can be caused
                    286:                by more than 10 levels of nested (), or
                    287:                an extremely long format statement.
                    288: 
                    289: /* 101 */      "illegal unit number"
                    290:                It is illegal to close logical unit 0.
                    291:                Negative unit numbers are not allowed.
                    292:                The upper limit is system dependent.
                    293: 
                    294: /* 102 */      "formatted io not allowed"
                    295:                The logical unit was opened for
                    296:                unformatted I/O.
                    297: 
                    298: /* 103 */      "unformatted io not allowed"
                    299:                The logical unit was opened for
                    300:                formatted I/O.
                    301: 
                    302: /* 104 */      "direct io not allowed"
                    303:                The logical unit was opened for sequential
                    304:                access, or the logical record length was
                    305:                specified as 0.
                    306: 
                    307: /* 105 */      "sequential io not allowed"
                    308:                The logical unit was opened for direct
                    309:                access I/O.
                    310: 
                    311: /* 106 */      "can't backspace file"
                    312:                The file associated with the logical unit
                    313:                can't seek. May be a device or a pipe.
                    314: 
                    315: /* 107 */      "off beginning of record"
                    316:                The format specified a left tab off the
                    317:                beginning of the record.
                    318: 
                    319: /* 108 */      "can't stat file"
                    320:                The system can't return status information
                    321:                about the file. Perhaps the directory is
                    322:                unreadable.
                    323: 
                    324: /* 109 */      "no * after repeat count"
                    325:                Repeat counts in list-directed I/O must be
                    326:                followed by an * with no blank spaces.
                    327: 
                    328: .DE
                    329: .DS
                    330: /* 110 */      "off end of record"
                    331:                A formatted write tried to go beyond the
                    332:                logical end-of-record. An unformatted read
                    333:                or write will also cause this.
                    334: 
                    335: /* 111 */      "truncation failed"
                    336:                The truncation of external sequential files
                    337:                on 'close', 'backspace', or 'rewind' tries
                    338:                to do a copy. It failed. Perhaps the temp
                    339:                file couldn't be created.
                    340: 
                    341: /* 112 */      "incomprehensible list input"
                    342:                List input has to be just right.
                    343: 
                    344: /* 113 */      "out of free space"
                    345:                The library dynamically creates buffers for
                    346:                internal use. You ran out of memory for this.
                    347:                Your program is too big!
                    348: 
                    349: /* 114 */      "unit not connected"
                    350:                The logical unit was not open.
                    351: 
                    352: /* 115 */      "read unexpected character"
                    353:                Certain format conversions can't tolerate
                    354:                non-numeric data. Logical data must be
                    355:                T or F.
                    356: 
                    357: /* 116 */      "blank logical input field"
                    358: 
                    359: /* 117 */      "'new' file exists"
                    360:                You tried to open an existing file with
                    361:                "status='new'".
                    362: 
                    363: /* 118 */      "can't find 'old' file"
                    364:                You tried to open a non-existent file
                    365:                with "status='old'".
                    366: 
                    367: /* 119 */      "unknown system error"
                    368:                Shouldn't happen, but .....
                    369:                (Send me a documented example.)
                    370: 
                    371: /* 120 */      "requires seek ability"
                    372:                Direct access requires seek ability.
                    373:                Sequential unformatted I/O requires seek
                    374:                ability on the file due to the special
                    375:                data structure required. Tabbing left
                    376:                also requires seek ability.
                    377: 
                    378: /* 121 */      "illegal argument"
                    379:                Certain arguments to 'open', etc. will be
                    380:                checked for legitimacy. Often only non-
                    381:                default forms are looked for.
                    382: .DE

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.