- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm getting NaN as answer for expressions like below
MN1=WTAP/( SQRT(GC*GAMA1/R1)*(1.0+(GAMA1-1.0)/2.0*
& MN1**2.0)**((GAMA1+1.0)/(2.0*(1.0-GAMA1))) )
All are real variables and they have real values.
When I simplify the expression , it gives the correct answer. But then I am getting Nan as answer for a another expression. Then I have to simplify it also.
Please help me.
Thank you.
Intel visual Fortran Compiler
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well if you get NAN for that expression i would expect you will have:
a) sqrt of a negative number
b) division by zero
c) or maybe a real underflow/overflow
If you simplified it correctly and used the same values you would still get a NAN at some intermediate step for the first 2 cases so I would check that carefully. Maybe the order of the expression gives and overflow at some intermediate step in the evaluation? I would suggest you examine the value in your test case in the sequence the brackets dictate the evaluation.
GC, R1 or Gamma being zero will give a NAN as will Gamma=1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Without a working reproducer, I don't think a definitive comment can be made, with or without the background of a former aerodynamicist.
To begin with, we would need to see data types, initial values, ....
Among the unnecessary opportunities you leave for varying compiler translations are the use of **2.0 where you may mean **2 (ifort will assume that) and /2.0 in place of *.5 (ifort will not do that when safe options are used, even though this is a safe replacement).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You cannot expect a definite resolution of the problem when you have displayed only one line of code, and you say that changing that line of code causes "another expression", which you have not shown, to give an incorrect answer. Nor have you stated what your "simplification" involved.
I note that MN1 (Mach number?) appears on both sides of the assignment statement. Is this statement placed inside an iteration block? How is MN1 initialized? What compiler options did you use? Could the value of MN1 be zero when it got used on the right hand side?
As was suggested, examine all the variables used in each expression using a debugger, or insert PRINT statements just before the statement(s) that give you NaNs.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page