Compile with debug on and optimization 0 is not the same

I have compiled some Fortran code with the pgf77 compiler (version 7.2-1). If I compile with debug on I get one set of results with the executable. If I compile with optimization level 0, I get different results which are incorrect.

In the User’s Guide, it states the compiling with the -g option sets the optimization level to zero (-O0). However, this does not seem to be the case for me.

Has anyone else had this experience?


Hi Khali,

The only thing that I think off is if your program is reading un-initialized memory (UMR). “-g” can initialize memory to zero, while “-O0” does not. If you’re on Linux, a good utility to find UMRs is Valgrind (

Hope this helps,