I am trying to compile a complex model in Fortran mixed with .f and .f90. The debug version work fine and printed valid numbers into text files. However and release version printed some corrupted values as "NaN". As the debug version does not have problems, I could not debug the code. Are there any ways to diagnose what may have caused the difference between the debug and release version of the code?
BTW. I am using Intel Fortran 11.1 with VS 2008.
Any comments are greatly appreciated!
The primary difference is optimization level. Sometimes optimization can reveal coding errors. There are other debugging options enabled that change the code. I suggest trying the following one at a time (NOT all at once!). In your debug configuration:
- Turn off options under Fortran > Run-Time > Run-Time Error Checking
- Under Fortran > Optimization, gradually increase the optimization level through "Minimize Size" to "Maximize Speed"
If one of these settings changes brings out the bad behavior, then try reverting selected sources to the Debug defaults and see if the behavior persists. If your project has lots of sources, use a "binary search" technique, changing half the sources and see if the behavior changes. If not, then change half of the others, narrowing it down until you find (hopefully) the one source where changing the settings brings out the bad behavior.
This will give you a place to start looking.
For a NaN problem it may also be helpful to set Fortran > Floating Point > Floating Point Exception Handling to /fpe0 and seeing if you get any runtime exceptions, and if so, where.
You should also try building with a more recent compiler. 19,0 is current.
Thank you Steve, the suggestions are very helpful. The Floating Point Exception Handling helped us find one error, but other errors still exists. Will follow the binary search method to pinpoint other errors.