is valid this use of forall
lluvia_lists@lavabit.com
lluvia_lists@lavabit.com
Tue May 28 22:11:00 GMT 2013
>> forall (i=1:n) a(b(i)) = a(b(i)) + 1
> [..]
>> However, I'm debugging an erratic program based on that and I'm asking
>> myself if that could be reason. I'm using a cluster with different CPUs
>> of
>> different procesor families.
>
> I changed the forall by a do loop and I didn't see the strange behavior
> yet. I don't consider it a proof yet, but maybe it could be bug, maybe
> solved in since a newer version. I'm using GNU Fortran (SUSE Linux) 4.5.1
> 20101208 [gcc-4_5-branch revision 167585]
CONFIRMED: It is causing differences. I used the test of below and have an
infinite loop in a machine with one CPU and final execution at first
iteration in another machine. The exact result on the last one was:
forall: 1 do: 5
forall: 0 do: 0
forall: 0 do: 0
forall: 0 do: 0
forall: 0 do: 0
Can anyone explain me if it is the desired behavior?
Thanks,
program test
integer, parameter :: d=5
integer :: a1(d), a2(d), b(d)
integer :: i
do
! generate a random array of indexes
b = 1
a1 = 0
a2 = 0
forall (i=1:d) a1(b(i)) = a1(b(i)) + 1
do i=1, d
a2(b(i)) = a2(b(i)) + 1
enddo
if (any((a1-a2) .ne. 0)) then
do i=1, d
print *, "forall: ", a1(i), "do:", a2(i)
enddo
call system ("touch ERROR_TEST_ERROR")
stop
else
print *, "hello"
endif
enddo
end program test
More information about the Fortran
mailing list