Fortran Programming Guide

File Descriptors and stdio

Fortran I/O channels are in terms of unit numbers. The I/O system does not deal with unit numbers but with file descriptors. The Fortran runtime system translates from one to the other, so most Fortran programs do not have to recognize file descriptors.

Many C programs use a set of subroutines, called standard I/O (or stdio). Many functions of Fortran I/O use standard I/O, which in turn uses operating system I/O calls. Some of the characteristics of these I/O systems are listed in in the following table.

Table 11-3 Comparing I/O Between Fortran and C
 

Fortran Units 

Standard I/O File Pointers 

File Descriptors 

Files Open 

Opened for reading and writing  

Opened for reading; or Opened for writing; or Opened for both; or Opened for appending; See OPEN(3S)

Opened for reading; or Opened for writing; or Opened for both 

Attributes 

Formatted or unformatted 

Always unformatted, but can be read or written with format-interpreting routines 

Always unformatted 

Access 

Direct or sequential  

Direct access if the physical file representation is direct access, but can always be read sequentially  

Direct access if the physical file representation is direct access, but can always be read sequentially 

Structure 

Record 

Byte stream 

Byte stream 

Form 

Arbitrary nonnegative integers from 0-2147483647 

Pointers to structures in the user's address space  

Integers from 0-1023