I read this article: Parallel programming in Fortran 95 using OpenMP
Where it reads on pages 11 and 12, which:
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
It cannot work because matrix values are Bnot guaranteed to ! $OMP END (PARALLEL) DO. For me, this is crucial. I have several loops with many statements that depend on previous statements in the do loop, and I thought it would be natural. I get that B(j)cannot be provided at the iteration i, given that i/=j, but at the same iteration I thought it was a given. Am I right or wrong? If so, is there a command to ensure that, at least during the iteration, the values of the variables are updated for each statement to the next?
I tried a few simple loops that seem to work as if it were serial code, but I have another code where it seems a bit more random: it works with / O 3 but not / O 0, the code is pretty big and a bit hard to read, so I won’t post it here ...)
source
share