| View previous topic :: View next topic |
| Author |
Message |
dcwarren
Joined: 18 Jun 2012 Posts: 29
|
Posted: Thu May 16, 2013 7:19 am Post subject: Alternatives to isnanf & isinff |
|
|
Hello,
I've been using isnanf and isinff (both PGI intrinsics, I think) to catch floating point errors in some code I'm using. But since they are PGI-specific, I can't port the code over to other compilers.
Are the following tests correct, compiler-agnostic, equivalents to isnanf and isinff?
| Code: | isnanf(foo) --> foo .ne. foo ! NaNs are not equal to themselves
isinff(foo) --> (foo*0.d0) .ne. 0.d0 ! Infs are nonzero when
! multiplied by zero |
|
|
| Back to top |
|
 |
mkcolg
Joined: 30 Jun 2004 Posts: 4996 Location: The Portland Group Inc.
|
Posted: Thu May 16, 2013 10:26 am Post subject: |
|
|
Hi dcwarren,
These were standardized in under the F2003 "ieee_arithmetic" module. Use this module in your code and then change "isnanf" to "ieee_is_nan" and "isinff" to "ieee_is_finite" (.false. is infinite)
The caveat being not all compilers fully support F2003 yet.
- Mat |
|
| Back to top |
|
 |
|