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( tex2html_wrap_inline43037  forall-triplet-list  tex2html_wrap_inline43039 [, tex2html_wrap_inline43037  scalar-mask  tex2html_wrap_inline43039 ])

tex2html_wrap_inline43037  assignment-stmt tex2html_wrap_inline43039

....

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

Adam Marshall ©University of Liverpool, 1996
Fri Dec 6 18:56:08 GMT 1996
Not for commercial use.