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?

    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

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