ELSEWHERE
Purpose
The ELSEWHERE statement is the first statement of the optional ELSEWHERE or masked ELSEWHERE block within a WHERE construct.
Syntax
- mask_expr
- is a logical array expression
- where_construct_name
- is a name that identifies a WHERE construct
Rules
A masked ELSEWHERE statement contains a mask_expr. See Interpreting masked array assignments for information on interpreting mask expressions. Each mask_expr in a WHERE construct must have the same shape.
If you specify a where_construct_name, it must be the same name that you specified on the WHERE construct statement.
ELSEWHERE and masked ELSEWHERE statements must not be branch target statements.
Examples
The following example shows a program that uses a simple masked
ELSEWHERE statement to change the data in an array:
INTEGER ARR1(3, 3), ARR2(3,3), FLAG(3, 3)
ARR1 = RESHAPE((/(I, I=1, 9)/), (/3, 3 /))
ARR2 = RESHAPE((/(I, I=9, 1, -1 /), (/3, 3 /))
FLAG = -99
! Data in arrays ARR1, ARR2, and FLAG at this point:
!
! ARR1 = | 1 4 7 | ARR2 = | 9 6 3 | FLAG = | -99 -99 -99 |
! | 2 5 8 | | 8 5 2 | | -99 -99 -99 |
! | 3 6 9 | | 7 4 1 | | -99 -99 -99 |
WHERE (ARR1 > ARR2)
FLAG = 1
ELSEWHERE (ARR1 == ARR2)
FLAG = 0
ELSEWHERE
FLAG = -1
END WHERE
! Data in arrays ARR1, ARR2, and FLAG at this point:
!
! ARR1 = | 1 4 7 | ARR2 = | 9 6 3 | FLAG = | -1 -1 1 |
! | 2 5 8 | | 8 5 2 | | -1 0 1 |
! | 3 6 9 | | 7 4 1 | | -1 1 1 |Related information
- WHERE construct
- WHERE
- END (Construct), for details on the END WHERE statement
