FORTRAN 77 Language Reference

Carriage Control ($, Space,0,1)

Use edit descriptor $, and space, 0, or 1 for carriage control.

Dollar $

The special edit descriptor $ suppresses the carriage return. @

The action does not depend on the first character of the format. It is used typically for console prompts. For instance, you can use this descriptor to make a typed response follow the output prompt on the same line. This edit descriptor is constrained by the same rules as the colon (:).

Example: The $ carriage control:


* dol1.f The $ edit descriptor with space 
	WRITE ( *, 2 ) 
2	FORMAT (' Enter the node number: ', $ ) 
	READ ( *, * ) NODENUM 
	END 

The above code produces a displayed prompt and user input response, such as:


Enter the node number:  82 

The first character of the format is printed out, in this case, a blank. For an input statement, the $ descriptor is ignored.

Space, 0, 1, and +

The following first-character slew controls and actions are provided:

Table 5-4 Carriage Control with Blank, 0, 1, and +

Character  

Vertical spacing before printing  

Blank

0

1

+

One line  

Two lines  

To first line of next page  

No advance (stdout only, not files)

If the first character of the format is not space, 0, 1, or +, then it is treated as a space, and it is not printed.

The behavior of the slew control character + is: if the character in the first column is +, it is replaced by a control sequence that causes printing to return to the first column of the previous line, where the rest of the input line is printed.

Space, 0, 1, and + work for stdout if piped through asa.

Example: First-character formatting, standard output piped through asa:


demo% cat slew1.f
	WRITE( *, '("abcd")') 
	WRITE( *, '(" efg")')  The blank single spaces
	WRITE( *, '("0hij")')  The "0" double spaces
	WRITE( *, '("1klm")')  The "1" starts this on a new page
	WRITE( *, '("+", T5, "nop")')  The "+" starts this at col 1 of latest line
	END
demo% f77 -silent slew1.f
demo% a.out | asa | lpr
demo%

The program, slew1.f produces file, slew1.out, as printed by lpr:


 bcd
 efg

 hij
 klmnop               This starts on a new page.  The + of +nop is obeyed.

The results are different on a screen; the tabbing puts in spaces:


 demo% cat slew1.out
 bcd
 efg

 hij
    nop       This starts on a new page. The + of +nop is obeyed.
 demo% 

See asa(1).

The space, 0, and 1, and + work for a file opened with:

Example: First-character formatting, file output:


demo% cat slew2.f
	OPEN( 1,FILE='slew.out',FORM='PRINT' ) 
	WRITE( 1, '("abcd")') 
	WRITE( 1, '("efg")') 
	WRITE( 1, '("0hij")') 
	WRITE( 1, '("1klm")') 
	WRITE( 1, '("+", T5, "nop")') 
	CLOSE( 1, STATUS='KEEP') 
	END
demo% f77 -silent slew2.f
demo% a.out

The program, slew2.f, produces the file, slew2.out, that is equal to the file, slew1.out, in the example above.

Slew control codes '0', '1', and '+' in column one are in the output file as '\n', '\f', and '\r', respectively.