Hi all. I’d like to inform about the bug in pgf90 + OpenMP. We spent about 8 hours trying to find an error, eliminating lines of the code, switching off modules etc. Finally only 13 lines were left:
program bug
!$OMP PARALLEL DEFAULT(PRIVATE)
!$OMP DO
DO KK=1,5
DO IO=1,3
IF(IO.EQ.3) write(,) ORTL/(ORTL-ORTR),ORTL/(ORTL-ORTR)
IF(IO.EQ.1) ORTL=1.0
IF(IO.EQ.2) ORTR=2.0
ENDDO
ENDDO
!$OMP END DO
!$OMP END PARALLEL
end program bug
If it is compiled by pgf90, everything goes fine. The output looks (as expected) like:
-1.000000 -1.000000
-1.000000 -1.000000
-1.000000 -1.000000
-1.000000 -1.000000
-1.000000 -1.000000
Now compile it with -mp option, to run it parallel. The output in this case looks quite strange:
-0.5000000 -1.000000
-0.5000000 -1.000000
-0.5000000 -1.000000
-0.5000000 -1.000000
-0.5000000 -1.000000
:-(
Changing the values of ORTL in ORTR variables, we conclude, that the compiler considers ORTL=0 during first evaluation of (ORTL-ORTR), but everywhere else uses the correct value (ORTL=1.0 in this example)
Intel compiler doesn’t have this problem and generates correct output in both cases.