6.1.30 Extended I/O specifiers

GNU Fortran supports the additional legacy I/O specifiers CARRIAGECONTROL, READONLY, and SHARE with the compile flag -fdec, for compatibility.

CARRIAGECONTROL

The CARRIAGECONTROL specifier allows a user to control line termination settings between output records for an I/O unit. The specifier has no meaning for readonly files. When CARRAIGECONTROL is specified upon opening a unit for formatted writing, the exact CARRIAGECONTROL setting determines what characters to write between output records. The syntax is:

OPEN(..., CARRIAGECONTROL=cc)

Where cc is a character expression that evaluates to one of the following values:

'LIST' One line feed between records (default)
'FORTRAN' Legacy interpretation of the first character (see below)
'NONE' No separator between records

With CARRIAGECONTROL='FORTRAN', when a record is written, the first character of the input record is not written, and instead determines the output record separator as follows:

Leading character Meaning Output separating character(s)
'+' Overprinting Carriage return only
'-' New line Line feed and carriage return
'0' Skip line Two line feeds and carriage return
'1' New page Form feed and carriage return
'$' Prompting Line feed (no carriage return)
CHAR(0) Overprinting (no advance) None
READONLY

The READONLY specifier may be given upon opening a unit, and is equivalent to specifying ACTION='READ', except that the file may not be deleted on close (i.e. CLOSE with STATUS="DELETE"). The syntax is:

OPEN(..., READONLY)
SHARE

The SHARE specifier allows system-level locking on a unit upon opening it for controlled access from multiple processes/threads. The SHARE specifier has several forms:

OPEN(..., SHARE=sh)
OPEN(..., SHARED)
OPEN(..., NOSHARED)

Where sh in the first form is a character expression that evaluates to a value as seen in the table below. The latter two forms are aliases for particular values of sh:

Explicit form Short form Meaning
SHARE='DENYRW' NOSHARED Exclusive (write) lock
SHARE='DENYNONE' SHARED Shared (read) lock

In general only one process may hold an exclusive (write) lock for a given file at a time, whereas many processes may hold shared (read) locks for the same file.

The behavior of locking may vary with your operating system. On POSIX systems, locking is implemented with fcntl. Consult your corresponding operating system’s manual pages for further details. Locking via SHARE= is not supported on other systems.

Next: , Previous: , Up: Extensions implemented in GNU Fortran [Contents][Index]

© Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
https://gcc.gnu.org/onlinedocs/gcc-8.4.0/gfortran/Extended-I_002fO-specifiers.html