I have read this article: Parallel Programming in Fortran 95 using OpenMP Where it reads on pages 11 and 12 that :
real(8) :: A(1000), B(1000)
! $OMP PARALLEL DO
do i = 1, 1000
B(i) = 10 * i
A(i) = A(i) + B(i)
enddo
! $OMP END PARALLEL DO
Might not work since the matrix B
's values are not ensured until ! $OMP END (PARALLEL) DO
. To me this is crucial. I have some loops with a lot of statements that depend on previous statements in a do loop and I thought this would be natural. I get that B(j)
cannot be ensured in iteration i
given that i/=j
but in the same iteration I thought it was as a given. Am I correct or have I misunderstood? If it is this way, is there a command to ensure that at least within the iteration the values of variables are updated for each statement before the next?
I have tried some simple loops that seems to be working, just as if it was serial code, but I have some other code where it seems a bit more random : works with /O3 but not /O0, the code is quite large and a bit hard to read so I won't post it here...)