Fortran 90 has a wealth of I/O, too much to cover here. It has many statements, (for example, READ, WRITE, OPEN, CLOSE, REWIND and BACKSPACE) built in to the language and also has very powerful formatting commands for `pretty printing' or formatted output.
So far, all examples have performed I/O with a terminal. Fortran 90 allows a number of different streams (files) to be connected to a program for both reading and writing. In Fortran 90 a file is connected to a logical unit denoted by a number. This number must be positive and is often limited to be between 1 and 100, the exact number will be given in the compiler manual. Each logical unit can have many properties, for example,
The name is specified in the OPEN statement.
If a file is opened for one sort of action and another is attempted then an error will be generated, for example, it is not permissible to write to a file opened solely for reading.
similar to above, if we open a new file but the file already exists then an error results.
The maximum number of files which can be open at any one time will also be specified in the compiler manual.
Return to corresponding overview page