XL Fortran for AIX 8.1

Language Reference

ELSEWHERE

Purpose

The ELSEWHERE statement is the first statement of the optional ELSEWHERE or masked ELSEWHERE block within a WHERE construct.

Format



>>-ELSEWHERE--+----------------------+--+---------------------------+-><
              |              (1)     |  |                      (2)  |
              '-(--mask_expr-------)-'  '-where_construct_name------'
 
 


Notes:


  1. Fortran 95.

  2. Fortran 95.


+---------------------------------Fortran 95---------------------------------+

mask_expr
is a logical array expression

+-----------------------------End of Fortran 95------------------------------+

+---------------------------------Fortran 95---------------------------------+

where_construct_name
is a name that identifies a WHERE construct

+-----------------------------End of Fortran 95------------------------------+

Rules

+---------------------------------Fortran 95---------------------------------+

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.

+-----------------------------End of Fortran 95------------------------------+

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


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]