FORTRAN Reference Manual
Statements
FORTRAN Reference Manual—528615-001
7-60
IF Statement—Block
Considerations
The logical IF statement executes statement if exp is true, or continues to the next
executable statement if exp is false.
Example
IF (balance .GT. 10000) account = preferred account
IF Statement—Block
The block IF statement is used with the END IF statement and, optionally, with the
ELSE IF and ELSE statements, to select groups of statements to execute.
exp
is a logical expression.
if-block
consists of all the executable statements following the block IF statement up to, but
not including, the next ELSE IF, ELSE, or END IF statement at the same level as
the block IF statement.
Considerations
•
A block IF statement begins with an IF statement and ends with an END IF
statement. A block IF statement can include ELSE and ELSE IF statements that
define the execution of subgroups of statements within the larger block. The
following example illustrates the simplest form of the block IF statement:
READ (*,*) answer
IF (answer .EQ. 1) THEN
deductions = 1000
END IF
If ANSWER equals 1, the program executes the statement between the IF and the
END IF statements. Otherwise, control passes to the first executable statement
after the END IF statement.
IF ( exp) THEN if-block
[ ELSE IF ( exp ) THEN if-block ]...
[ ELSE if-block ]
END IF










