next up previous contents
Next: Masked Assignment - Where Up: Arrays Previous: Array I/O Example

 

Masked Assignment - Where Statement

 

The WHERE statement is used when an array assignment is to be performed on a non-regular section of the LHS array elements, in other words, the whole array assignment is masked so that it only applies to specified elements. Masked array assignment is achieved using the WHERE statement:

    WHERE (I .NE. 0) A = B/I

the effect of this statement is to perform the assignment A(j,k) = B(j,k)/I(j,k) for all values of j and k where the mask, (I(j,k) .NE. 0), is .TRUE.. In the cases where the mask is .FALSE. no action is taken.

For example, if

displaymath22898

and,

displaymath22899

then

displaymath22886

Only the indicated elements, corresponding to the non-zero elements of I, have been assigned to.

Conformable array sections may be used in place of the whole arrays, for example,

    WHERE (I(j:k,j:k) .NE. 0) A(j+1:k+1,j-1:k-1) = B(j:k,j:k)/I(j:k,j:k)
is perfectly valid.


next up previous contents
Next: Masked Assignment - Where Up: Arrays Previous: Array I/O Example

Adam Marshall ©University of Liverpool, 1996
Fri Dec 6 15:03:35 GMT 1996
Not for commercial use.