At 12:42 15-11-02 +0000, Niki Reid wrote:
>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).
>
>Any responses to either query will be very much appreciated.
>
>Thanks!
>
>Niki
>
My results:
Absoft Pro Fortran 7.5 correct results,
N.A.Software : Correct
Salford FTN95 v 2.52p: Different results for both cases:
E:\Fortran\Test\Divers>Testforall ! Salford
1 0 0 0 0
2 1 1 1 0
1 2 2 0 2
2 1 0 2 3
1 0 0 0 0
1 0 0 0 0
1 1 1 1 0
1 2 2 0 5
1 1 6 2 5
1 2 0 0 5
1 0 0 0 0
1 1 1 1 0
1 2 2 0 5
1 1 6 2 5
1 2 0 0 5
>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
Best regards,
\---
Jan van Oosterwijk
Netherlands
mailto:Jan.vanOosterwijk<at>DTO.TUDelft.NL
http://huizen.dto . tudelft.nl/vanOosterwijk/
|