PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Alternatives to isnanf & isinff

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
dcwarren



Joined: 18 Jun 2012
Posts: 29

PostPosted: Thu May 16, 2013 7:19 am    Post subject: Alternatives to isnanf & isinff Reply with quote

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
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6122
Location: The Portland Group Inc.

PostPosted: Thu May 16, 2013 10:26 am    Post subject: Reply with quote

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
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group