One thing that -openmp does is cause all local variables to be "automatic", that is, allocated on the stack. If you have any variables that are not initialized, they will have "random" values when you run the program. Make sure all your variables are initialized.
numerical result is changed by compiling fortran code with "-openmp"
如需更全面地了解编译器优化,请参阅优化注意事项.



numerical result is changed by compiling fortran code with "-openmp"
All
I am writting a Monte Carlo code to simulate particle collisions,
and I use my own random number genertoion subroutine in my code.
Before I parallelize the code, the simulation result can be exactly reproduced if i use the same seed number.
(all the numerical results are exactly the same).
If I compile the code with a flag (-openmp), the numerical results are changed even if I do nothing to the code.
Does anyone know how it happens and how can I avoid this problem?
Thank you.