Re: forall and do loop



aeroguy wrote:

REAL :: DS(100),UTA(100),STA(100),ONE
ONE = 1.0000

! First case
DO I=1,NE
UTA(I)=DS(I)
STA(I)=ONE
END DO

! second case
FORALL(I=1:NE) UTA(I)=DS(I)
STA=ONE

In this two follwoing code which will be more efficient? Efficent in
execution time and in parallel processing?

It is really hard to say. As far as I know, FORALL was added to help
with some parallel processing problems, maybe especially on vector
machines, but I don't know of any examples where it is actually
much better than the DO case.

My personal feeling is that array operations (your STA=ONE)
are often faster for simple expressions and often slower for
more complex expressions, but that is likely also compiler dependent.

-- glen

.