The Salford FTN95 (V1.6) compiler produces the same result as Cray T3E for
the original code and then (consistently) also produces the identical output
for the final equivalent code!
Peter Jewell
----------------------------------------------------------------------
Mr P.A.Jewell
Computer Officer &
Health and Safety Departmental Liaison Officer
Computer Centre
University of Bradford
BRADFORD
West Yorkshire
BD7 1DP
Phone: 01274 233322
Fax: 01274 304354
email: [log in to unmask]
----------------------------------------------------------------------
"Seek not to
understand that you may believe,
but believe that you may understand."
St. Augustine
-----Original Message-----
From: [log in to unmask]
[mailto:[log in to unmask]]On Behalf Of Friedrich
Hertweck
Sent: Thursday, September 30, 1999 6:59 AM
To: [log in to unmask]
Subject: Tricky forall/where/elsewhere construct
Hi,
when a couple of days ago I scanned through the F95 Standards document,
ISO 1559-1:1997 (E), I came across a tricky program given as an example
in Appendix C.4.5: a WHERE and ELSEWHERE(cond) statement in a FORALL
construct.
It took me a while to understand what happens. Then I became curious
what compilers will make out of it, or did they also have some
difficulties
understanding it? And voila: I have not found a system where it works:
(1) IBM RS/6000 with xlf90: compiles, but wrong results
(2) IBM RS/6000 with NAG f95: compiler "panics"
(3) Cray T3E: compiles, but wrong results (other than on IBM)
(4) DVF on Intel PC: compiler has internal error
I would like to know of other compilers. So somebody might like to try
the program. It contains in its first part the code from C.4.5, in its
second part a work-around which should do the same thing (and it
produces the claimed results). Following the program, I included the
results from the four systems.
Cheers,
Friedrich
=====================================================================
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
======================================================================
frh@sp11> f90 Forall.f90
** testforall === End of Compilation 1 ===
1501-510 Compilation successful for file Forall.f90.
frh@sp11> a.out
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 6
1 2 2 6 6
1 1 6 2 6
1 2 0 0 6
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
======================================================================
frh@sp11> f95n Forall.f90
----------------------------------------------------------------------
Starting f95n version 4.0
To use a different version of f95n use option "-v <version-number>"
Available versions:
1.0 -> type "f95n -v 1.0"
4.0 -> type "f95n -v 4.0" or just "f95n"
----------------------------------------------------------------------
Panic: Forall.f90: mkarraydesc unexpected node type 100
Internal Error -- please report this bug
Abort - core dumped
======================================================================
T3E>f90 Forall.f90
T3E> a.out
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 5
1 2 2 4 6
1 1 3 2 6
1 2 0 0 5
======================================================================
DVF>
Compiling Fortran...
C:\F95\VisualFortranBugs\Forall.f90
C:\F95\VisualFortranBugs\Forall.f90(19) : Severe: **Internal compiler
error: internal abort**
Please report this error along with the circumstances in which it
occurred in a
Software Problem Report.
Note: File and line given may not be explicit cause of this error.
forall (i=1:5)
---^
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|