Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP Fortran Compiler for HP-UX: HP Fortran Programmer's Reference > Chapter 10 HP Fortran statements

ELSE IF

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

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)

Related concepts

See IF construct”.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.