Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 7/13/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Rules for List-Directed Sequential WRITE Statements

List-directed, sequential WRITE statements transfer data from binary to character form by using the data types of the corresponding I/O list item to determine the form of the data. The translated data is then written to an external file.

In general, values transferred as output have the same forms as values transferred as input. However, there is no guarantee that a REAL internal value transferred as output and then transferred as input as a REAL value will be the same internal value.

The following table shows the default output formats for each intrinsic data type:

Default Formats for List-Directed Output

Data Type

Output Format

BYTE

I5

LOGICAL(1)

L2

LOGICAL(2)

L2

LOGICAL(4)

L2

LOGICAL(8)

L2

INTEGER(1)

I5

INTEGER(2)

I7

INTEGER(4)

I12

INTEGER(8)

I22

REAL(4)

1PG15.7E2 2

REAL(8)

1PG24.15E3 2

REAL(16)

1PG43.33E4 2

COMPLEX(4)

'(',1PG14.7E2,',',1PG14.7E2,')' 2

COMPLEX(8)

'(',1PG23.15E3,',',1PG23.15E3,')' 2

COMPLEX(16)

'(',1PG42.33E4,',',1PG42.33E4,')' 2

CHARACTER

Aw1

1 Where w is the length of the character expression.

2 If option assume noold_ldout_format is in effect, the compiler uses Fortran 2018 standard semantics for output of integer and real values in list-directed and namelist-directed output. This means that for real and complex values, the output is in E or F format depending on the magnitude of the value. For more information, see the description of option assume.

By default, character constants are not delimited by apostrophes or quotation marks, and each internal apostrophe or quotation mark is represented externally by one apostrophe or quotation mark.

This behavior can be changed by the DELIM specifier (in an OPEN statement) as follows:

  • If the file is opened with the DELIM='QUOTE' specifier, character constants are delimited by quotation marks and each internal quotation mark is represented externally by two consecutive quotation marks.

  • If the file is opened with the DELIM='APOSTROPHE' specifier, character constants are delimited by apostrophes and each internal apostrophe is represented externally by two consecutive apostrophes.

Each output statement writes one or more complete records.

If DECIMAL='POINT', the decimal point in a numeric value is displayed as a period, values are separated by commas, and the separator between the real and imaginary parts of a complex value is a comma. If DECIMAL='COMMA', the decimal point is displayed as a comma, values are separated by semicolons, and the separator between the real and imaginary parts of a complex value is a semicolon.

A literal character constant or complex constant can be longer than an entire record. For complex constants, the end of the record can occur between the comma or semicolon and the imaginary part, if the imaginary part and closing right parenthesis cannot fit in the current record. For literal constants that are longer than an entire record, the constant is continued onto as many records as necessary.

Each output record begins with a blank character for carriage control.

Slashes, octal values, null values, and repeated forms of values are not output.

If the file is connected for unformatted I/O, list-directed data transfer is prohibited.

Examples

Suppose the following statements are specified:


  DIMENSION A(4)
  DATA A/4*3.4/
  WRITE (1,*) 'ARRAY VALUES FOLLOW'
  WRITE (1,*) A,4

The following records are then written to external unit 1:

ARRAY VALUES FOLLOW
   3.400000      3.400000      3.400000      3.400000      4

The following shows another example:


  INTEGER       i, j
  REAL          a, b
  LOGICAL       on, off
  CHARACTER(20) c
  DATA i /123456/, j /500/, a /28.22/, b /.0015555/
  DATA on /.TRUE./, off/.FALSE./
  DATA c /'Here''s a string'/
  WRITE (*, *)  i, j
  WRITE (*, *)  a, b, on, off
  WRITE (*, *)  c
  END

The preceding example produces the following output:

     123456         500
  28.22000      1.555500E-03 T F
Here's a string