Input/Output List — iolist - Fortran

This section describes the components of I/O list (iolist), which can be specified as elements of the I/O statements described in this section. An input/output list specifies the memory locations of the data to be transferred by the I/O statements READ, WRITE, and PRINT.

If an array name is given as an I/O list item, the elements in the array are treated as though each element were explicitly specified in the I/O list in storage order. Note that the name of an assumed-size dummy array (that is, an array declared with an * for an upper bound) must not appear as an I/O list item.

Input List
An input list item can be one of the following:

  1. Variable name.
  2. Array element name.
  3. Substring name.
  4. Array name.
  5. Implied DO list containing any of the above and other implied-DO lists.
  6. An aggregate reference (a structured data item as defined by a RECORD and STRUCTURE statement). An aggregate reference can be used only in unformatted input statements. When an aggregate name appears in an iolist, only one record is read regardless of how many aggregates or other list items are present.

Examples of input lists are

READ(5,3000,END=2000)X,Y(J,K+3),C(2:4)
READ(JFILE,REC=KNUM,ERR=1200)M,SLIST(M,3),cilist

Output List
An output list item can be one of the following:

  • Variable name.
  • Array element name.
  • Substring name.
  • Array name.
  • Any expression, except a character expression involving concatenation of an operand with a length specification of asterisk (*), unless the operand is the symbolic name of a constant.
  • An implied DO list containing any of the above and other implied DO lists.
  • An aggregate reference (a structured data item as defined by a RECORD and STRUCTURE statement). An aggregate reference can be used only in unformatted output statements. When an aggregate name appears in an iolist, only one record is written regardless of how many aggregates or other list items are present.

Note that a constant, an expression involving operators or function references, or an expression enclosed in parentheses may appear in an output list but not in an input list.

An example of an output list is

WRITE(5,200,ERR=10)'ANSWER IS',N,SQRT(X)+1.23

Implied-DO Lists
An implied-DO list is a specification that follows the I/O list (iolist) in an I/O statement. The list permits the iteration of the statement as though it were contained within a DO loop. An implied-DO list has the form:

(iolist,i=e1,e2[,e3])

where
iolist is one or more valid names of the data to be acted on.
i is an iteration count.
e1, e2, and e3 are control parameters

The control variable i must not appear as an input list item in iolist. The list items in iolist are specified once for each iteration of the implied DO list with the appropriate substitution of values for each occurrence of the control variable i. When an I/O error occurs within the implied DO loop, the value of the control variable i is undefined.

Example
The following statements write Hello World to standard output 100 times:

write (*,111) ('Hello World',i=1,100)
111 format (1x,A)
End

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Fortran Topics