Intel fortran-80 Laptop User Manual


 
FORTRAN-80
Program Execution Controls
DO
loops
may
be nested,
that
is, a
DO
loop
can
contain
another
DO
loop, etc.
If
a
DO
statement
appears
within the range
of
another
DO
loop,
the
loop
specified by
the second
DO
statement
must
be within the range
of
the
outer
DO
loop.
DO
loops
can
share the same last statement.
I f a
DO
statement lies within
an
IF
block,
ELSE
IF
block,
or
ELSE
block, the range
of
the
DO
loop
must
be entirely within
that
block.
I f a block
IF
statement
is
within the range
of
a
DO
loop, its corresponding
END
IF
statement must also be within the range
of
the
DO
loop.
Examples:
The
first example demonstrates the looping process.
N=O
DO 100 I
==
1,10
J = I
DO
100 K = 1,5
L=K
100 N = N + 1
110 CONTINUE
When
looping
is
completed~
I = 11, J = 10, K = 6, L = 5,
and
N = 50.
Note
the
use
of
blanks
to
isolate the nested
DO
loop
in this example.
The following example
is
another
program
to
compute
batting averages for
25
players (one team).
Compare
this
program
to Figure 1-1...
CHARACTER*12 PNAME
DO
30
1=1,25
READ 10, PNAME, AB, HITS
10 FORMAT
(A12, 2(2X, F3.0))
AVG = HITS/AB
PRINT 20,
PNAME, AVG
20
FORMAT (A12,
5X,
F4.3)
30 CONTINUE
C LOOP
CAN NOT TERM I NATE WITH STATEM ENT 20
C
BECAUSE
'FORMAT'
IS
NONEXECUTABLE
4.2.3 CONTINUE Statement
The
format
of
the
CONTINUE
statement
is
CONTINUE
as shown in the preceding example.
This
statement
has
no
effect
on
program
execution, which simply continues with the
next executable statement.
4.3 Program Termination Statements
FORTRAN
provides three statements for halting
or
terminating
program
execution.
The
PAUSE
statement
halts execution,
but
allows execution
to
resume.
The
STOP
statement
terminates
program
execution.
The
END
statement
marks
the end
of
a
program
unit. It terminates a
main
program
and
acts as a
RETURN
from
a sub-
program.
4-7