HP Fortran Programmer's Reference (September 2007)

I/O formatting
Nested format specifications
Chapter 9 265
Nested format specifications
A format specification can include a nested format specification (another set of edit
descriptors, enclosed in parentheses). You can also precede the nested format specification
with a repeat factor, as in the following example:
(1H , 2(I5, F10.5))
This is equivalent to:
(1H , I5, F10.5, I5, F10.5)
Each nested specification is known as a group at nested level
n
. The value of
n
begins at 1. For
each successive level of nesting,
n
is incremented by 1. Each group at nested level 1 can
contain one or more groups at nested level 2, and so on.
For example:
(E9.3,I6,(2X,I4))
contains one group at nested level 1.
(L2,A3/(E10.3,4(A2,L4)))
has one group at nested level 1 and one at nested level 2.
(A,(3X,(I2,(A3)),I3),A)
contains one group at nested level 1, one at level 2, and one at level 3.
A nested format specification can be preceded by a repeat specification. For example, the
following input record
b
26
b
6.4336
b
373.86
b
39
bb
49.79
bb
4
bbb
4395.4972
could be accessed with the following FORMAT statement:
10 FORMAT (I3,F7.4,2(F7.2,I3),F12.4)
The list of variables following READ statement corresponds to the preceding FORMAT statement:
READ 10,i,a,b,j,d,k,f
The READ statement would read values for i and a; repeat the nested format specification
F7.2,I3 twice to read values for b, j, d, and k; and, finally, read a value for f.