Hi,
I am having problems with some code. I was able to reproduce what I think is a bug of the compiler on a simple example:
Program Strange
Implicit None
Type Link
Integer, Dimension(2) :: Next
End Type Link
Integer, Parameter :: N = 2
Integer :: i, j
Type(Link), Dimension(:,:), Pointer :: Perm
Integer, Dimension(2) :: Current
Allocate (Perm(N,N))
Print*, 'Spanned by indices'
Do i = 1, N**2
Perm(mod(i-1,N)+1, (i-1)/N+1)%Next = (/ Mod(i,N) + 1, Mod(i/N+1,N)+1/)
Write(*,100) mod(i-1,N)+1, (i-1)/N+1, Perm(mod(i-1,N)+1, (i-1)/N+1)%Next
End Do
Print*, 'Spanned as a cycle'
Current = (/1,1/)
Do i = 1, n**2
Write(*,100) Current, Perm(Current(1), Current(2))%Next
Current = Perm(Current(1), Current(2))%Next
End Do
100 Format( 2I3, '--->', 2I3)
DeAllocate (Perm)
End Program Strange
Here, Mat represent a permutation matrice. The output of the first loop is as follow:
Spanned by indices
1 1---> 2 2
2 1---> 1 1
1 2---> 2 1
2 2---> 1 2
Now, in the second loop, Map is spanned as a cycle. The expected output should then be:
1 1---> 2 2
2 2---> 1 2
1 2---> 2 1
2 1---> 1 1
However, Intel Fortran 7.0 returns
Spanned by indices
1 1---> 2 2
2 1---> 1 1
1 2---> 2 1
2 2---> 1 2
PGI returns the very same sequence, while an old version of the Fujitsu compiler (1.01), as well as sun 6.0 compiler return the correct answer:
Spanned by indices
1 1---> 2 2
2 1---> 1 1
1 2---> 2 1
2 2---> 1 2
Spanned as a cycle
1 1---> 2 2
2 2---> 1 2
1 2---> 2 1
2 1---> 1 1
I am misunderstanding the code I write, I am writing something illegal or are Intel and PGI compiler wrong?
Thanks,
Blaise
"Self referring" affectations
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.


