HP Fortran Programmer's Reference (September 2007)

Execution control
Control constructs and statement blocks
Chapter 6 139
Control constructs and statement blocks
A control construct consists of a statement block whose execution logic is defined by one of the
following control statements:
CASE statement
DO statement
IF statement
A statement block is a sequence of statements delimited by a control statements and its
corresponding terminal statement. A statement block consists of zero or more statements and
can include nested control constructs. However, any nested construct must have its beginning
and end within the same statement block.
Although the Standard forbids transferring control
into
a statement block except by means of
its control statement, HP Fortran allows it. The Standard does permit the transferring control
out of
a statement block. For example, the following IF construct contains a GO TO statement
that legally transfers control to a label that is defined outside the IF construct:
IF (var > 1) THEN
var1 = 1
ELSE
GO TO 2
END IF
...
2 var1 = var2
The next logical IF statement is nonstandard (but permitted by HP Fortran) because it would
transfer control into the DO construct:
IF (.NOT.done) GO TO 4 ! nonstandard!
...
DO i = 1, 100
sum = b + c
4 b = b + 1
END DO
The following sections describe the operations performed by the three control constructs.
CASE construct
The CASE construct selects (at most) one out of a number of statement blocks for execution.
Syntax