Fortran 90

6.4 WHERE
Operations can be restricted to a set of array elements with the WHERE construct. It has the effect of a parallel IF statement. Note that nested WHERE's are not allowed within Fortran 90. The salient features of WHERE are:
  • Its syntax involves the use of a logical mask; in other words...
  • It is equivalent to doing an `IF' on all elements of an array of LOGICAL type
  • There can also be an ELSE WHERE clause
  • <, <=, ==, /=, > and => in place of .LT., .LE., .EQ., .NE., .GE. and .GT.
 REAL, DIMENSION(7,7) :: a, b
 ...
 WHERE (a /= 0) b = 1/a
 ...
 WHERE (a > 2.0)
  b = a * 9.0 
 ELSE WHERE
  b = a / 3.0
 END WHERE