Next:
General Form of Up: Data Parallel Statements Previous: Data Parallel Statements


The FORALL Statement

Fortran 90 places several restrictions on array assignments. In particular, it requires that operands of the right side expressions be conformable with the left hand side array. These restrictions can be relaxed by introducing the element array assignment statement, usually referred to as the FORALL statement. This statement is used to specify an array assignment in terms of array elements or groups of array sections, possibly masked with a scalar logical expression. In functionality, it is similar to array assignment statements and WHERE statements. The FORALL statement essentially preserves the semantics of Fortran 90 array assignments and allows for convenient assignments like FORALL ( i=1:n, j=1:m ) a(i,j)=i+j as opposed to standard Fortran 90 a = SPREAD((/(i,i=1,n)/), DIM=2, NCOPIES=m) + & SPREAD((/(i,i=1,m)/), DIM=1, NCOPIES=n) It can also express more general array sections than the standard triplet notation for array expressions. For example, FORALL ( i = 1:n ) a(i,i) = b(i) assigns to the elements on the main diagonal of array a.


paula@erc.msstate.edu
Thu Jul 21 17:05:43 CDT 1994