HP 3000 Manuals

WRITE Statement (Executable) [ HP FORTRAN 77/iX Reference ] MPE/iX 5.0 Documentation


HP FORTRAN 77/iX Reference

WRITE Statement (Executable) 

The WRITE statement transfers data from memory to a file or device.

[]
---------------------------------------------------------------------------------------------- | | | | | Item | Description/Default | Restrictions | | | | | ---------------------------------------------------------------------------------------------- | | | | | unit | Integer expression | Must be zero or positive. | | | specifying the unit number | | | | of a file. | | | | | | ---------------------------------------------------------------------------------------------- | | | | | address | Arithmetic expression of | See "Semantics". | | | type integer. | | | | | | ---------------------------------------------------------------------------------------------- | | | | | char_variable | Internal file written. | Character variable or scalar | | | | record field. | | | | | ---------------------------------------------------------------------------------------------- | | | | | char_array_element | Internal file written. | Character array element or | | | | scalar record field. | | | | | ---------------------------------------------------------------------------------------------- | | | | | char_substring | Internal file written. | Character substring. | | | | | ---------------------------------------------------------------------------------------------- | | | | | integer_expression | Integer expression | Must be zero or positive. | | | specifying the unit number | | | | of an internal file. | | | | | | ---------------------------------------------------------------------------------------------- | | | | | * | Asterisk indicates that the | None. | | | standard output device (unit | | | | 6, usually a terminal) is to | | | | be used. | | | | | | ---------------------------------------------------------------------------------------------- | | | | | fmt | Format designator. | fmt must be as specified in | | | | the PRINT statement. | | | | | ---------------------------------------------------------------------------------------------- | | | | | namelist_group_name | Symbolic name specifying a | Cannot appear in a statement | | | list of variables or arrays | containing a format | | | previously declared in a | specifier. | | | NAMELIST statement. | | | | | | ---------------------------------------------------------------------------------------------- | | | | | ios | Integer variable, array | Must be an integer type. | | | element, or scalar record | | | | field name for error return. | | | | | | ---------------------------------------------------------------------------------------------- | | | | | label | Statement label of an | Must be the label of a | | | executable statement. | statement in the same | | | | program unit. | | | | | ---------------------------------------------------------------------------------------------- | | | | | rec | Specifies the record number | If fmt is an asterisk, a | | | in a direct access file. | record specifier must not be | | | | present. | | | | | ---------------------------------------------------------------------------------------------- | | | | | zbf | Variable, array name, or | Extension to ANSI 77 | | | array element name. | standard; cannot be a | | | | character type. | | | | | ---------------------------------------------------------------------------------------------- | | | | | zln | Integer expression. | None. | | | | | ---------------------------------------------------------------------------------------------- Semantics A WRITE statement must contain a unit number and at most one of each of the other options. If the prefix UNIT= is omitted, unit must be the first item in the list. This is the unit number for the output device or file. If the prefix FMT= is omitted, fmt must be the second item in the list and unit (without a prefix) must be the first item. If fmt is not present and a namelist group name is not specified, the write is unformatted (binary). record_name and aggregate variables can only be used in unformatted writes. If the IOSTAT specifier is present and an error occurs, the error code is returned in the IOSTAT variable and the program is not aborted. Refer to Appendix A for the IOSTAT error codes. You must specify a record number if a file is direct access. The record number can be specified through REC. You can also specify the record number by following the unit number with the @ specifier. If the ERR specifier is present and an error occurs during execution of the WRITE statement, control transfers to the specified statement rather than aborting the program. The ZBUF and ZLEN specifiers and the address alternative used as a parameter of the UNIT specifier are included for compatibility with programs originally written in another version of FORTRAN. If one is used in a program, its syntax is checked but it is otherwise ignored by the compiler. As an extension to the ANSI 77 standard, sequential WRITE operations (without the REC specifier) are allowed on files open for direct access. If the REC specifier is omitted, a WRITE statement writes the next record. Refer to Chapter 4 for more information on the WRITE statement. Examples Notes -------------------------------------------------------------------------------------- WRITE (7,10) a,b,c The values of a, b, and c are written to the file connected to unit 7 according to FORMAT statement 10. ASSIGN 4 TO num The value of z is written to the file connected to WRITE (UNIT=3,IOSTAT=j, unit 3, according to FORMAT statement 4. If an +ERR=5,FMT=num) z error occurs, control transfers to statement 5 and the error code is returned in j. WRITE (10) (x + y) The value of the expression (x + y) is written to the file connected to unit 10. Because fmt is omitted, the data is unformatted. WRITE (10,FMT=*) b The value of b is written to the file connected to unit 10 according to list-directed formatting. WRITE (2,'(I3)',REC=10) i The value of i is written to the 10th record of the direct file connected to unit 2 according to the format specification in the WRITE statement itself. WRITE (*) One record is skipped on the standard output device.


MPE/iX 5.0 Documentation