next up previous contents
Next: Pure Procedures Up: Data Parallel Execution Previous: Do-loops and Forall Statements

 

Forall Construct

FORALL construct is also in Fortran 95, syntax:

 
FORALL(< forall-triplet-list >[,< scalar-mask >])

< assignment-stmt >

....

END FORALL

For example,

  
    FORALL (i=1:n:2, j=n:1:-2, A(i,j).NE.0) 
           A(i,j) = 1/A(i,j) ! s1
           A(i,i) = B(i)     ! s2
    END FORALL

s1 executed first followed by s2

Can also nest FORALL s,

    FORALL (i=1:3, j=1:3, i>j)
     WHERE  (ABS(A(i,i,j,j)) .LT. 0.1) A(i,i,j,j) = 0.0 
     FORALL (k=1:3, l=1:j, k+l>i) A(i,j,k,l) = j*k+l
    END FORALL

For more information, click here gif

Now try this question gif


next up previous contents
Next: Pure Procedures Up: Data Parallel Execution Previous: Do-loops and Forall Statements

©University of Liverpool, 1997
Wed May 28 23:37:18 BST 1997
Not for commercial use.