However, when using the standard pre-connected I/O devices, the unit number may be replaced by an asterisk *. Unit numbers must be used when reading from or writing to external files. This example reads a single integer value from standard input and writes it to standard output: Two of these numbers are always pre-defined at the start of every FORTRAN 77 program: unit 5 corresponds to standard input, which is often the user's terminal, and unit 6 corresponds to standard output, which is also often the terminal but may be another device, such as a printer. These unit numbers are used in READ and WRITE statements to indicates the source or destination for the operation. Unit NumbersĮvery input or output device is identified by a small, positive integer known as the unit number. FORTRAN 77 provides a powerful and flexible set of features for reading and writing data which are independent of the underlying operating system.
Almost all FORTRAN 77 programs read data from external sources such as files or the user's terminal, perform calculations on that data, and then write the results to other files or the terminal.