Replies: 4 comments 10 replies
-
|
LFRic uses the ieee_arithmetic module to control how NaN values are handled, and it has commands for detecting NaN values. https://fortranwiki.org/fortran/show/ieee_arithmetic use, intrinsic :: ieee_arithmetic, only: ieee_is_nan if (ieee_is_nan(x)) print *,'x is NaN' I just checked it and it works as expected, returning true for both signalling and quiet NaN values. |
Beta Was this translation helpful? Give feedback.
-
|
Hi folks, I didn't know about the shumlib "is this number NaN" function, but I've always checked for bad values by just writing something like: I reckon this reliably flags NaNs in a portable way (and as a bonus, it also flags "Inf" values which are distinct from NaN with some compilers). The relational comparisons will always evaluate to false if x is not a valid number; then the .NOT. flips it to true... You can also easily change the min-allowed lower bound to zero instead of -HUGE, if you want to also flag negative values of things that should never be negative. Cheers! |
Beta Was this translation helpful? Give feedback.
-
|
A follow up to this - does anyone know how to get a useful traceback out of the ex1a CCE compiler? Having been unable to track down where the NaN is coming from by printing input/output fields to the failing scheme (inputs look fine, outputs contain a NaN), I've switched to compiling with full-debug in the hope of getting the model to fail at the point of generating the NaN. Sure enough it does fail where I expect it to, but the only output is: which is no real use. Is there a way to get routines/line-numbers of where the failure happens? Thanks! |
Beta Was this translation helpful? Give feedback.
-
|
As a followup for those interested, the shumlib code is now being included in lfric_atm as a library. Use of functions such as This change has just gone on trunk so should be available from lfric_apps vn2.2. Note that to It would be relatively easy to copy functionality to use in |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to track down where/how a NaN is generated in lfric_atm, but it would appear "f_shum_is_nan" doesn't work on the ex1a - is this known, and does anyone have any suggestions of how we can trap NaNs on the ex1a CCE compiler?
To be more specific, I have the following code:
which returns the following output:
so the sum over the field is clearly showing a NaN is present, but f_shum_is_nan has never returned true, making it hard to track down exactly which l & k index the NaN exists at.
Does anyone have any clever ideas on how else to find where it is?
Beta Was this translation helpful? Give feedback.
All reactions