I am trying to run a 64 bit application built using PGI fortran compiler.
Initially the application was not displaying the expected output on screen. So I added some debug ‘write’ statements in the code and tried after building again. Now the expected output got displayed along with my debug write statements.
Ah, the Heisenberg debugging problem. The most likely reasons for this is that the compiler is performing an optimization which gets inhibited when you insert in the WRITE statements. To test this theory, compile your original program (no WRITEs) without optimization, “-O0”. Do you now get the expected answer? Is so, then the next step to narrow down which optimization is causing the problem and exactly where in the code the problem occurs.
For problem 1, the optimization, start by compiling at “-O1” then “-O2”, “-fast”, etc. until you’ve found the optimization that’s causing the problem. Once there, reinsert the WRITE statements, either in a binary search or serially, until the problem disappears again. While doing this keep a log of the “-Minfo” messages (add this flag to the compilation to have the compiler display which optimizations it’s performing). Compare the passing and failing Minfo logs to determine what optimizations were inhibited and where in the source they occur. The final step is to compile again with the problem optimization and"-gopt". Then use the PGI debugger, PGDBG, to determine the exact cause.
If you’re still failing at “-O0”, then look for UMRs (uninitialized memory reads) or porting problems. The same method I described above, except for the optimization hunting, will apply to these types of errors as well.
While this does seem like a lot of work and you may be tempted to simply use Intel or the lowest passing optimization, if this is a bug in your program then you may have problems in the future, or if it’s a problem with the PGI compilers, we would very much appreciate a report sent to firstname.lastname@example.org so we can fix the issue.