Printer Control

Traditionally Fortran provides a unique way for controlling printers. Except that your output are always sent to files, you need to know how Fortran controls printers.

As discussed in edit descriptors, the values of variables and expressions of a WRITE statement are evaluated in the given order and based on the the width of field (i.e., the value of w) an output line is composed. In the good old days, printers have 133 positions per line and the content in the first position is for printer control. Nowadays, the length of a line is no more an issue; but, the content in the first position of an output line is still for printer control. Therefore, when you want to print your result with a printer, any printer, you should remember the following figure:

The way Fortran prints your information is line-oriented. More precisely, the information of each edit descriptor are not printed directly to a printer. Instead, they are "printed" to a buffer line. Once the construction of that buffer line completes (e.g., all values are processed), this buffer line is sent to printer and based on the content in the first position the printer advances to next line, advances two lines, jumps to the first line of the next page, or stays on the same line. Then, the contents from position 2 to the end of that line are printed. As a result, the content of the first position is not printed!

As mentioned above, there are four printer controls, each of which is presented by a character:

Printer Control Character Effect
space Advance to the next line before printing
0 Advance two lines before printing
1 Advance to the first line of the next page before printing
+ No advancing, print on the current line (overprinting)

Let us discuss all four printer control characters in some detail: