HP Fortran Programmer's Reference (September 2007)

HP Fortran statements
WHERE (statement and construct)
Chapter 10492
WHERE (statement and construct)
Performs masked array assignments.
Syntax
WHERE (
array-logical-expr
) [
array-assignment-statement
]
If the optional array-assignment clause is present, the WHERE statement is syntactically
complete and does not require the END WHERE statement.
If the array-assignment clause is not present, the WHERE statement is the first statement of a
WHERE construct. The syntax of the WHERE construct is:
WHERE (
array-logical-expr
)
array-assignment-statement
...
[ ELSEWHERE
array-assignment-statement
... ]
END WHERE
array-logical-expr
is a logical array expression.
array-assignment-statement
is an array assignment statement.
Description
Certain array elements can be selected by a mask and assigned in array-assignment
statements using the WHERE statement or WHERE construct.
array-logical-expr
establishes
the mask.
For any elemental operation in the array assignments, only the elements selected by the mask
participate in the computation. The elemental operations include the usual intrinsic
operations and the elemental intrinsic functions such as ABS. Masked array assignments are
useful when certain elemental operations involving arrays need to be avoided because of
program exceptions.
The following rules and restrictions apply:
The shape of the result of
array-logical-expr
and the arrays in each
array-assignment-statement
must be the same; they may be of size zero.