Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29383 Discussions

variable assigned to number has value NaN

Sirat_S_
Beginner
644 Views

Hello Fortran fraternity

I assign a real variable to zero. but when i debug the program, I see that variable value as NaN without any operation having taken place. what could be the reason and what is the remedy. i am using visual studio 8.

Advise please.

 

0 Kudos
2 Replies
NotThatItMatters
Beginner
644 Views

There must be more to this than what you say.  For example, if I create the following

PROGRAM MAIN

REAL :: A

A = 0

END PROGRAM MAIN

and run it in debug, I get 0 for A.  NaN is typically generated in REAL values as 0.0 / 0.0 or 0.0 times infinity.  There must be something along these lines generating the value.

0 Kudos
jimdempseyatthecove
Honored Contributor III
644 Views

Or you are debugging a program with optimizations and the variable may live in a register or in memory dependent upon where the break point is located. The debugger will display the memory location only. You will not see this behavior in Debug build (with no optimizations). Also optimization may eliminate statements deemed unnecessary

A=0.0
{ A not used between above statement and next statement }
A=1.0

Optimization, with the above qualification, can eliminate the A=0.0

Jim Dempsey

0 Kudos
Reply