Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 3/22/2024
Public
Document Table of Contents

ELSE WHERE

Statement: Marks the beginning of an ELSE WHERE block within a WHERE construct.

[name:]WHERE (mask-expr1)

   [where-body-stmt]...

[ELSE WHERE(mask-expr2) [name]

   [where-body-stmt]...]

[ELSE WHERE[name]

   [where-body-stmt]...]

END WHERE [name]

name

Is the name of the WHERE construct.

mask-expr1, mask-expr2

Are logical array expressions (called mask expressions).

where-body-stmt

Is one of the following:

  • An assignment statement of the form: array variable = array expression.

    The assignment can be a defined assignment only if the routine implementing the defined assignment is elemental.

  • A WHERE statement or construct

Description

Every assignment statement following the ELSE WHERE is executed as if it were a WHERE statement with ".NOT. mask-expr1". If ELSE WHERE specifies "mask-expr2", it is executed as "(.NOT. mask-expr1) .AND. mask-expr2" during the processing of the ELSE WHERE statement.

Example

WHERE (pressure <= 1.0)
  pressure = pressure + inc_pressure
  temp = temp - 5.0
ELSEWHERE
  raining = .TRUE.
END WHERE

The variables temp, pressure, and raining are all arrays.

See Also