NaN's

Hi,

is there any option in pgf90 to stop the execution when a NaN occurs ?

thanks,
sam

Hi sbuis,

There is a flag “-Ktrap=fp” which traps floating-point exceptions but not one that traps NaN. Instead, you can use the functions “isnanf” for real and “isnand” for double precision. Also, there are to functions to detect INF, “isinff” and “isinfd”.

Example:

% cat inf2.f90
program test
real a,b
logical isnanf
logical isinff

b=3
a=0
b=b/a

print *, b
if (isnanf(b)) then
print *, "Its a NaN"
else if (isinff(b)) then
print *, "Its a Inf"
else
print *, "Its not a NaN or Inf"
end if

end
% pgf90 inf2.f90
% a.out
             inf
 Its a Inf

Hope this helps,
Mat