FORTRAN Reference Manual

Statements
FORTRAN Reference Manual528615-001
7-44
Editing Numeric Data
the format specification of F5.2 and the imaginary part has the format specification
of E6.3:
COMPLEX a
WRITE (6, 5) a, b
5 FORMAT(F5.2,E6.3,F4.2)
The I Descriptor
The I w, I w. m, and I w. m. b descriptors specify that the field occupies w character
positions. Optionally, they also define the number base for the output data (b) and the
minimum number of digits (m). Base 10 is assumed when b is omitted; 1 is assumed
when m is omitted. The corresponding I/O list item can be any numeric type.
On input, the string in the input field must be of an optionally-signed integer constant.
An I w. m descriptor is equivalent to an I w descriptor.
The following example shows an input record (circumflexes designate blanks) and a
READ statement that reads the data:
135
^
-12
^
10
^^^
5
^
1
READ (*,8) i, j, k, l, m
8 FORMAT(BN,I3, I4, I3, I2, I4)
After executing the READ statement, the variables contain the following values: I
contains 135, J contains -12, K contains 10, L contains 0, and M contains 51.
The output field for the I w or I w.1. b edit descriptor consists of zero or more leading
blanks followed by a minus sign (if the value of the datum is negative), or an optional
plus sign, followed by the magnitude of the internal value as an unsigned integer
constant without leading zeros. An integer constant always consists of at least one
digit.
The output field for an I w. m or I w. m. b descriptor is the same as for an I w or I w.1. b
descriptor, except that the unsigned integer constant always consists of at least m
digits, so the number might contain leading zeros. m must be less than or equal to w.
For example, if I contains 33, J contains -99, and K contains 239134, the following
statements:
WRITE(*,9) i, j, k
9 FORMAT(I3,2(I6))
output the following data (circumflexes indicate blanks):
^
33
^^^
-99239134