-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NaN processing in adaptive_inflate_mod.f90 #176
Comments
i think (var /= var) is an ok test. the duplicates aren't needed but they don't hurt anything. that other line is not quite the right test in your note above. if (.false. .and. .false.) then nan ! which will never be true. it would have to be: if ((.not. var <= 0.0_r8 ).and. ( .not. var > 0.0_r8)) then nan which isn't the most direct thing to read but works. |
something about this issue was bugging me but i couldn't figure out what it was. i finally figured it out. regular code should try very hard to never generate NaNs ever. it shouldn't then need to test for them. if you do suspect nans are being generated, you should test for them and then error out immediately. then figure out how to avoid the case that led to the nan. here's why. there are compile-time flags that will trap when a nan is used as an operand. this is a very helpful way to debug an unexpected nan. but if we have code that routinely generates nans and then replaces the bad values with good, the program will stop on this nan if it happens before the unexpected nan. it makes debugging very much harder. |
@nancycollins (sanity) check this out: (NaN /= NaN) is false for pgi/nvfortran unless you compile with the flag -Kieee
|
my understanding was always that any kind of test that included a NaN as at least one of the operations returned false. but the test (a /= a) is like asking is "a" Not Not equal to "a"? so maybe returning true in that case is ok and i could live with gfortran's choices. (ifort is the same - see below) but nvfortran? i really don't like nvfortran saying (a == a) is true even if a is NaN. i wonder what the performance penalty for always compiling with -Kieee would be? for completeness, ifort on cheyenne gives: cheyenne1> ifort -o bob bob.f90 |
me too, that is IEEE 754. But the nvidia default is not to use IEEE 754 ( I think other compilers you would have to set -fastmath to do this). Anyway my brain just dribbled out of my ears running this test. It makes moving to Derecho a lot more interesting. |
i heard in irfan's talk this morning that they're trying to get derecho up and running by the end of this year, with early adopters getting access in spring 2023. maybe the compiler defaults will change by then? |
See NCAR#176 for discussion
Added -Kieee to pgi mkmf.template in 52a7056 |
We employ several different methods to test for NaNs, not sure which one is best, or if we need to be consistent.
In adaptive_inflate_mod.f90 there is code:
This code does the same test on density_1 - twice - and density_2 - twice - but before changing the code, I want to know what method to use. In other codes, we have employed the test
if (var < 0.0_r8 .and. var > 0.0_r8)
to test for NaNs.The text was updated successfully, but these errors were encountered: