Is there a standard way to check for Infinite and NaN in Fortran 90/95?

前端 未结 8 1206
小鲜肉
小鲜肉 2020-12-06 15:59

I\'ve been trying to find a standards-compliant way to check for Infinite and NaN values in Fortran 90/95 but it proved harder than I thought.

  • I tried to manua
8条回答
  •  感动是毒
    2020-12-06 16:41

    for testing NaN none of the things worked eg.if testing real s2p to see if it is NaN then

    if(isnan(s2p)) 
    

    did not work in gfortran nor did

    if(s2p.ne.s2p). 
    

    The only thing that worked was

    if(.not.s2p<1.and..not.s2p>1)  
    

    though to make real sure u may want to add

    if(.not.s2p<1.and..not.s2p>1.and..not.s2p==1)    
    

提交回复
热议问题