------- Additional Comments From Thomas dot Koenig at online dot de 2004-12-27
22:24 -------
I did some more digging around, and found that
the error only occurred when the mask parameter
was generated "on the fly". If the mask is a
precomputed logical array, the function works
correctly.
$ cat maxloc-4.f90
program main
implicit none
integer, dimension(3,3) :: n
integer, dimension(2) :: i1, i2
integer :: j
integer, parameter :: limit=9
logical, dimension(3,3) :: l
n = reshape((/3, 2, 1, 4, 7, 8, 7, 8, 9/), shape(n))
l = n<limit
i1 = maxloc(n, mask = l )
i2 = maxloc(n, n<limit)
print '(3I3)',(n(:,j),j=1,3)
print '(3L3)',(n(:,j)<limit,j=1,3)
print '(A,I3)','limit ',limit
print '(A,2I3,A,I3)','maxloc using array. Position ',i1(1),i1(2),' value', &
n(i1(1),i1(2))
print '(A,2I3,A,I3)','maxloc using expr. Position ',i2(1),i2(2),' value', &
n(i2(1),i2(2))
end program
$ ./a.out
3 2 1
4 7 8
7 8 9
T T T
T T T
T T F
limit 9
maxloc using array. Position 3 2 value 8
maxloc using expr. Position 3 3 value 9
$ gfortran -v
Using built-in specs.
Configured with: ../gcc/configure --prefix=/home/ig25
--enable-languages=c,c++,f95
Thread model: posix
gcc version 4.0.0 20041227 (experimental)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19016