Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
1 View

debug mode have results, but the release mode get NaN

It's a large code. When I applied the debugging mode to debug the code, I can obtain a reasonable number. However, when I applied the releasing mode, the numbers are NaN. Does anyone know why for the same code, these two mode would reach two totally different results? What are the probable reasons? If you need some part of the code, I can post. Thanks!

0 Kudos
3 Replies
Highlighted
Valued Contributor II
1 View

This could be a symptom of

This could be a symptom of variables that are not properly initialised. Then their value can be anything - under the debugger it is (in my experience) more likely that the value is zero, whereas outside the debugger such values are much more likely to be rubbish.

You should check that all the variables have a proper value before they are used. Unfortunately that is a lot of work if you have a large program. the option /Qtrapuv  (trap uninitialized variables) might help, though I have no experience with it. Another one you can try is: /check:all

 

0 Kudos
Highlighted
1 View

The usual source of this

The usual source of this symptom is your the coding error of using uninitialized variables. Debug mode may (stressed) initialize (your code's unitialized) variables to 0.0, whereas release mode does not. GIGO (garbage in - garbage out)

To rectify, first start using IMPLICIT NONE.

Then after you correct for potential implicit variable errors, run a Debug run with all runtime checks enabled (including use of uninitialized variables).

Note, the runtime check for use of uninitialized variables will catch many, but not all, instances of referencing uninitialized variables.

Jim Dempsey

0 Kudos
Highlighted
Black Belt
1 View

If the suggestions about

If the suggestions about finding undefined variables don't pan out, you may need to explore some of the compiler options which default differently in debug and release mode.  Note that you can add release optimizations to your debug build and run under debug in an attempt to locate the difference.

I had a project recently where it was necessary to set gradual underflow explicitly under recent ifort (e.g. USE IEEE_arithmetic, call ieee_set_underflow_mode(gradual)...) to avoid generating NaN under optimization.  Note that ifort /Qftz- (in main program) should (but may not) over-ride the Windows OS setting, which differs between 32-bit and X64 OS.

0 Kudos