I am using Intel(R) Visual Fortran Compiler XE 18.104.22.168.
Attached is a very simple program that sums up 1000 values. If I do not use OpenMP, I am always getting an expected output of x= 1000 .
If I compile with OpenMP (/Qopenmp) in Debug mode, the output is unpredictable. Sometimes it is x=1000, but many times it is completely different.
In Release mode, I get unpredictable output only if I disable inlining (/Ob0).
Does anyone know if I am doing something wrong? The only unusual thing is that the reduction variable x is incremented inside a contained subroutine. The program works if x is incremented inside the main loop.