Dear all.
I have a couple of queries that I would appreciate some help
with - I'll try to keep it as brief as possible!
1) A couple of years ago there was a thread running where users
were testing the WHERE within a FORALL example of C.4.5 of the
standard, and reporting back whether their compiler could handle
it. I would be grateful if anyone could spare the time to
re-run the example, to see how things have changed since then.
The necessary code may be found at the end of the message
(note: this code has been 'taken' from the original thread &
may be attributed to Friedrich Hertweck, the thread's originator).
2) I'm curious as to who is using the FORALL, and for what.
Specifically, I'm interested to know:
a) Platform (PC, shared memory, dedicated distributed memory,
workstation clusters, etc.)
b) Sphere of application: e.g. aeronautics, fluid dynamics,
etc.
c) Typical array dimensions and extents/size
(e.g. 3 dimensions, 10 x 20 x 2000 (= 400,000 elements))
c) Whether any array subscript (within a FORALL) relies on
more than one FORALL index name, for example, given:
FORALL (i=1:2, j=3:4 ....
does any one subscript use more than one of the FORALL
index names, e.g.
A(i*j, 2)
Any responses to either query will be very much appreciated.
Thanks!
Niki
CODE:
Note that the required results are (to save looking up the
standard):
1 0 0 0 0
1 1 1 1 5
1 2 2 4 6
1 1 3 2 6
1 2 0 0 5
program TestForall
implicit none
integer :: a(5,5), c(5,5), i
logical :: m(5,5)
c(1,:) = (/ 1, 0, 0, 0, 0 /)
c(2,:) = (/ 2, 1, 1, 1, 0 /)
c(3,:) = (/ 1, 2, 2, 0, 2 /)
c(4,:) = (/ 2, 1, 0, 2, 3 /)
c(5,:) = (/ 1, 0, 0, 0, 0 /)
print "(5i4)", (c(i,:),i=1,5)
print *
!
! Original code from section C.4.5
!
a = c
forall (i=1:5)
where (a(i,:) == 0)
a(:,i) = i
elsewhere (a(i,:) > 2)
a(i,:) = 6
end where
end forall
print "(5i4)", (a(i,:),i=1,5)
print *
!
! Equivalent code, produces expected result:
!
a = c
forall (i=1:5)
m(i,:) = a(i,:) == 0 ! compute mask explicitly
where (m(i,:)) a(:,i) = i
where (.not. m(i,:) .and. a(i,:) > 2) a(i,:) = 6
end forall
print "(5i4)", (a(i,:),i=1,5)
end program
|