vector expression question.

Mike Kumbera kumbera1@llnl.gov
Thu Nov 17 19:31:00 GMT 2011


I would like to start out with I'm not sure if this is a bug or not... The program bellow computes xser and x and I expected them to have the same answer. They didn't.
The results with 4.6.1 were xser(:) = 2 and x(:)=1. 

Should vector operations like x(i)=x(i)+1 act like it was looping over the values of i in a do loop or act like an atomic assignment statement x=x+1? I didn't see anything glaring in my
reference books and the commercial compilers are split on the results.

intel 10 x=1...
Intel 11 x=2...
Intel 12 x=2...
Gnu 4.6.1 x=1...
pathscale x=1...
pgi (all version) x=2...
sun studio 12.1 x=1...

-----

program test

integer, parameter :: n = 10
integer :: i(n) = (/ 1, 2, 3, 4, 5, 5, 4, 3, 2, 1/)
integer x(5),xser(5)

! cumaddin
xser = 0;
do j = 1, n
    xser (i (j)) =  xser (i (j)) + 1
enddo
write (*,*) xser

x = 0; 
x(i) = x(i) + 1   ! same as the loop above
write (*,*) x

end program test



More information about the Fortran mailing list