10. Executable Statements
10.1. IF-THEN-ELSE
-
At last, the
if-then-else
branching structure has been added to Fortran.
It is called a ``Block If''.
A Block If begins with a statement of the form
-
if ( . . . ) then
and ends with an
-
end if
statement.
Two other new statements may appear in a Block If.
There may be several
-
else if(. . .) then
statements,
followed by at most one
-
else
statement.
If the logical expression in the Block If statement is true, the statements following it up to the
next
elseif,
else,
or
endif
are executed.
Otherwise, the next
elseif
statement in the group is executed.
If none of the
elseif
conditions are true, control passes to the statements following the
else
statement, if any.
(The
else
must follow all elseifs in a Block If.
Of course, there may be Block Ifs embedded inside of other Block If structures).
A
case
construct may be rendered
-
if (s .eq. 'ab') then
. . .
else if (s .eq. 'cd') then
. . .
else
. . .
end if
10.2. Alternate Returns
-
Some of the arguments of a subroutine call may be statement labels preceded by an asterisk, as in
-
call joe(j, *10, m, *2)
A
return
statement may have an integer expression, such as
-
return k
If the entry point has
alternate return (asterisk) arguments
and if , the return is followed by a branch to the corresponding statement label;
otherwise the usual return to the statement following the
call
is executed.