HP Fortran Programmer's Reference (September 2007)

HP Fortran statements
ELSE IF
Chapter 10 335
ELSE IF
Provides alternate path of execution for IF construct.
Syntax
ELSE IF (
logical-expression
) THEN [
construct-name
]
logical-expression
is a scalar logical expression.
construct-name
is the name given to the IF construct. If
construct-name
is specified, the
same name must also appear in the IF statement and in the END IF
statement.
Description
The ELSE IF statement executes the immediately following statement block, if the following
conditions are met:
None of the logical expressions in the IF statement and any previous ELSE IF statements
evaluates to true.
logical-expression
evaluates to true.
Branching to an ELSE IF statement is illegal.
Examples
INTEGER temperature
INTEGER, PARAMETER :: hot=1, cold=2
IF (temperature == hot) THEN
PRINT *, 'Turn down your thermostat.'
ELSE IF (temperature == cold) THEN
PRINT *, 'Turn up your thermostat.'
ELSE
PRINT *, 'Your thermostat is working OK.'
END IF
Related statements
ELSE, END IF, and IF (construct)