FORTRAN 77 Language Reference

Integer Editing (I)

The I specifier is used for decimal integer data items. The general form is:


I [w [ . m ] ] 

The I w and I w.m edit specifiers indicate that the field to be edited occupies w positions. The specified input/output list item must be of type integer. On input, the specified list item becomes defined with an integer datum. On output, the specified list item must be defined as an integer datum.

On input, an I w.m edit specifier is treated identically to an I w edit specifier.

The output field for the I w edit specifier consists of:

An integer constant always has at least one digit.

The output field for the I w.m edit specifier is the same as for the I w edit specifier, except that the unsigned integer constant consists of at least m digits, and, if necessary, has leading zeros. The value of m must not exceed the value of w. If m is zero, and the value of the item is zero, the output field consists of only blank characters, regardless of the sign control in effect.

Example: int1.f, integer input:


	CHARACTER LINE*8 / '12345678' / 
	READ( LINE, '(I2, I3, I2 )') I, J, K 
	PRINT *, I, J, K 
	END 

The program above displays:


     12 345 67

Example: int2.f, integer output:


	N = 1234 
	PRINT 1, N, N, N, N 
1	FORMAT( I6 / I4 / I2 / I6.5 ) 
	END 

The above program displays:


  1234 
1234 
** 
01234