XL Fortran for AIX 8.1

Language Reference

WRITE

Purpose

The WRITE statement is a data transfer output statement.

Format



>>-WRITE--(--io_control_list--)--+------------------+----------><
                                 '-output_item_list-'
 
 

output_item
is an output list item. An output list specifies the data to be transferred. An output list item can be:

io_control
is a list that must contain one unit specifier (UNIT=), and can also contain one of each of the other valid specifiers:

[UNIT=] u
is a unit specifier that specifies the unit to be used in the output operation. u is an external unit identifier or internal file identifier.

+-------------------------------IBM Extension--------------------------------+

An external unit identifier refers to an external file. It is one of the following:

+----------------------------End of IBM Extension----------------------------+

An internal file identifier refers to an internal file. It is the name of a character variable, which cannot be an array section with a vector subscript.

If the optional characters UNIT= are omitted, u must be the first item in io_control_list. If UNIT= is specified, FMT= must also be specified.

[FMT=] format
is a format specifier that specifies the format to be used in the output operation. format is a format identifier that can be:

If the optional characters FMT= are omitted, format must be the second item in io_control_list, and the first item must be the unit specifier with UNIT= omitted. NML= and FMT= cannot both be specified in the same output statement.

REC= integer_expr
is a record specifier that specifies the number of the record to be written in a file connected for direct access. The REC= specifier is only permitted for direct output. integer_expr is an integer expression whose value is positive. A record specifier is not valid if formatting is list-directed or if the unit specifier specifies an internal file. The record specifier represents the relative position of a record within a file. The relative position number of the first record is 1.

IOSTAT= ios
is an input/output status specifier that specifies the status of the input/output operation. ios is a scalar variable of type INTEGER(4) or default integer. Coding the IOSTAT= specifier suppresses error messages. When the statement finishes execution, ios is defined with:

+-------------------------------IBM Extension--------------------------------+

ID= integer_variable
indicates that the data transfer is to be done asynchronously. The integer_variable is a scalar of type INTEGER(4) or default integer. If no error is encountered, the integer_variable is defined with a value after executing the asynchronous data transfer statement. This value must be used in the matching WAIT statement.

Asynchronous data transfer must either be direct unformatted or sequential unformatted. Asynchronous I/O to internal files is prohibited. Asynchronous I/O to raw character devices (for example, tapes or raw logical volumes) is prohibited. The integer_variable must not be associated with any entity in the data transfer I/O list, or with a do_variable of an io_implied_do in the data transfer I/O list. If the integer_variable is an array element reference, its subscript values must not be affected by the data transfer, the io_implied_do processing, or the definition or evaluation of any other specifier in the io_control_spec.

+----------------------------End of IBM Extension----------------------------+

ERR= stmt_label
is an error specifier that specifies the statement label of an executable statement in the same scoping unit to which control is to transfer in the case of an error. Coding the ERR= specifier suppresses error messages.

+-------------------------------IBM Extension--------------------------------+

NUM= integer_variable
is a number specifier that specifies the number of bytes of data transmitted between the I/O list and the file. integer_variable is a variable name of type INTEGER(4), type INTEGER(8) in 64-bit, or type default integer. The NUM= specifier is only permitted for unformatted output. Coding the NUM parameter suppresses the indication of an error that would occur if the number of bytes represented by the output list is greater than the number of bytes that can be written into the record. In this case, integer_variable is set to a value that is the maximum length record that can be written. Data from remaining output list items is not written into subsequent records. In the portion of the program that executes between the asynchronous data transfer statement and the matching WAIT statement, the integer_variable in the NUM= specifier or any variable associated with it must not be referenced, become defined, or become undefined.

+----------------------------End of IBM Extension----------------------------+

[NML=] name
is a namelist specifier that specifies the name of a namelist list that you have previously defined. If the optional characters NML= are not specified, the namelist name must appear as the second parameter in the list, and the first item must be the unit specifier with UNIT= omitted. If both NML= and UNIT= are specified, all the parameters can appear in any order. The NML= specifier is an alternative to FMT=. Both NML= and FMT= cannot be specified in the same output statement.

ADVANCE= char_expr
is an advance specifier that determines whether nonadvancing output occurs for this statement. char_expr is a character expression that must evaluate to YES or NO. If NO is specified, nonadvancing output occurs. If YES is specified, advancing, formatted sequential output occurs. The default value is YES. ADVANCE= can be specified only in a formatted sequential WRITE statement with an explicit format specification that does not specify an internal file unit specifier.

Implied-DO List



>>-(--do_object_list-- , --------------------------------------->
 
>--do_variable = arith_expr1arith_expr2----------------------->
 
>--+---+--+-------------+--)-----------------------------------><
   '-,-'  '-arith_expr3-'
 
 

do_object
is an output list item

do_variable
is a named scalar variable of type integer or real

arith_expr1, arith_expr2,  and  arith_expr3
are scalar numeric expressions

The range of an implied-DO list is the list do_object_list. The iteration count and values of the DO variable are established from arith_expr1, arith_expr2, and arith_expr3, the same as for a DO statement. When the implied-DO list is executed, the items in the do_object_list are specified once for each iteration of the implied-DO list, with the appropriate substitution of values for any occurrence of the DO variable.

Rules

+-------------------------------IBM Extension--------------------------------+

If a NUM= specifier is present, neither a format specifier nor a namelist specifier can be present.

+----------------------------End of IBM Extension----------------------------+

Variables specified for the IOSTAT= and NUM= specifiers must not be associated with any output list item, namelist list item, or DO variable of an implied-DO list. If such a specifier variable is an array element, its subscript values must not be affected by the data transfer, any implied-DO processing, or the definition or evaluation of any other specifier.

If the ERR= and IOSTAT= specifiers are set and an error is encountered during a synchronous data transfer, transfer is made to the statement specified by the ERR= specifier and a positive integer value is assigned to ios.

+-------------------------------IBM Extension--------------------------------+

If the ERR= or IOSTAT= specifiers are set and an error is encountered during an asynchronous data transfer, execution of the matching WAIT statement is not required.

If a conversion error is encountered and the CNVERR run-time option is set to NO, ERR= is not branched to, although IOSTAT= may be set.

If IOSTAT= and ERR= are not specified,

+----------------------------End of IBM Extension----------------------------+

PRINT format has the same effect as WRITE(*,format).

Examples

WRITE (6,FMT='(10F8.2)') (LOG(A(I)),I=1,N+9,K),G

Related Information


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]