FORTRAN 77 Language Reference

F Editing

The F specifier is for decimal real data items. The general form is


   F [ w [
.d ] ]

:

The Fw and Fw.d edit specifiers indicate that the field to be edited occupies w positions.

d indicates that the fractional part of the number (the part to the right of the decimal point) has d digits. However, if the input datum contains a decimal point, that decimal point overrides the d value.

The specified input/output list item must be of type real. On input, the specified list item becomes defined with a real datum. On output, the specified list item must be defined as a real datum.

The output field for the F w.d edit specifier has the width w. The value is right-justified in that field. The field consists of zero or more leading blanks followed by either a minus if the value is negative, or an optional plus, followed by the magnitude of the value of the list item rounded to d decimal digits.

w must allow for a minus sign, at least one digit to the left of the decimal point, the decimal point, and d digits to the right of the decimal point. Therefore, it must be the case that w.le.d+3.

Example: Real input with F editing in the program Finp.f:


	CHARACTER LINE*24 / '12345678 23.5678 .345678' / 
	READ( LINE, '( F8.3, F8.3, F8.3 )') R, S, T 
	PRINT '( F9.3, F9.4, F9.6 )', R, S, T 
	END 

The program displays:


12345.678DD23.5678D0.345678

In the above example, the first input data item has no decimal point, so F8.3 determines the decimal point. The other input data items have decimal points, so those decimal points override the F edit descriptor as far as decimal points are concerned.

Example: Real output with F editing in the program Fout.f:


	R = 1234.678 
	PRINT 1, R, R, R 
1	FORMAT( F9.3 / F8.4 / F13.4 ) 
	END

The above program displays:


¤1234.678 
******** 
¤¤¤¤1234.6780

In the above example, F8.4 does not allow for the sign; F13.4 results in four leading blanks and one trailing zero.