I originally posted this in the forum on OpenMP’s website, but they said to try to post it here. The original question is here: http://openmp.org/forum/viewtopic.php?f=3&t=215.
I am trying to compile this with the PGI Fortran compiler version 6.1 on a 64 bit system. But it seems that it has some problems with OpenMP.
The code is shown below, and to get a full description of the problem, please see the above link…
Amax = 0.0_dbl !$OMP PARALLEL DEFAULT(SHARED) PRIVATE(j,alpha,beta,nu,A,priv_max,priv_numax) priv_max = 0.0_dbl !$OMP DO do j = 1,Nspec nu = nu_min+dF*(j-1) ! Calculate amplitude: call CalcAlphaBeta(t,f,w,nu,alpha,beta) A = sqrt(alpha**2 + beta**2) if (A > priv_max) then priv_max = A priv_numax = nu endif enddo !$OMP END DO NOWAIT !$OMP FLUSH if (priv_max > Amax) then !$OMP CRITICAL if (priv_max > Amax) then print *, priv_max Amax = priv_max !$OMP FLUSH numax = priv_numax endif !$OMP END CRITICAL endif !$OMP END PARALLEL ! If this line is included it works?! WHY?! ! print *, 'Result: ', Amax
Please help… I will be really grateful!