CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Main CFD Forum (http://www.cfd-online.com/Forums/main/)
-   -   How to detect NaN's in Fortran (http://www.cfd-online.com/Forums/main/4972-how-detect-nans-fortran.html)

Wen Long July 25, 2002 22:40

How to detect NaN's in Fortran
 
Hi,friends

I would like to know how to detect NaN's in Fortran code. I want the code to stop at the first NaN when something gets weird and then step into.

Thanks,

Wen

andy July 26, 2002 03:44

Re: How to detect NaN's in Fortran
 
Look up "exception handling" in the documentation for your compiler. The implementation will vary from compiler to compiler.

Li Yang July 27, 2002 09:05

Re: How to detect NaN's in Fortran
 
Hi, if you are using F77, the following would be useful for debugging:

f77 -g -ftrap=common -O3 file.f -o file.e

dbx file.e

catch fpe

run

You will find out which value is zero !

Regards

Li

peter.zhao July 28, 2002 23:38

Re: How to detect NaN's in Fortran
 
If you use digital Visual Fortran, you can set the entry of floating point exception to 1 instead of 3 on project/setting/fortran/floating point.

Good luck!

x.zhang July 30, 2002 22:07

Re: How to detect NaN's in Fortran
 
Hi, there:

I have 2 methods:

1. To use Function IsNaN(*)

* real

it gives you a logical type

2. Do it my own way

Check if (a + 1.0) .eq. a , only NaNs will give

you a .true. answer

Good luck!


All times are GMT -4. The time now is 15:16.