next up previous contents index
Next: Other Pre-connected Files Up: Pre-Connected Files Previous: Pre-Connected Files

Terminal Input/Output

 

Many programs are interactive and need to access the user's terminal. Although the terminal is a file which can be connected with an OPEN statement, its name is system-dependent. Fortran solves the problem by providing two special files usually called the standard input file and the standard output file. These files are pre-connected, i.e. no OPEN statement is needed (or permitted). They are both formatted sequential files and, on interactive systems, handle input and output to the terminal. You can READ and WRITE from these files simply by having an asterisk ``*" as the unit identifier. These files make terminal I/O simple and portable; examples of their use can be found throughout this book.

When a program is run in batch mode most systems arrange for standard output to be diverted to a log file or to the system printer. There may be some similar arrangement for the standard input file.

The asterisk notation has one slight drawback: the unit numbers is often specified by an integer variable so that the source of input or destination of output can be switched from one file to another merely be altering the value of this integer. This cannot be done with the standard input or output files.


next up previous contents index
Next: Other Pre-connected Files Up: Pre-Connected Files Previous: Pre-Connected Files
Helen Rowlands
8/27/1998