CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

How to detect NaN's in Fortran

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 25, 2002, 22:40
Default How to detect NaN's in Fortran
  #1
Wen Long
Guest
 
Posts: n/a
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
  Reply With Quote

Old   July 26, 2002, 03:44
Default Re: How to detect NaN's in Fortran
  #2
andy
Guest
 
Posts: n/a
Look up "exception handling" in the documentation for your compiler. The implementation will vary from compiler to compiler.
  Reply With Quote

Old   July 27, 2002, 09:05
Default Re: How to detect NaN's in Fortran
  #3
Li Yang
Guest
 
Posts: n/a
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
  Reply With Quote

Old   July 28, 2002, 23:38
Default Re: How to detect NaN's in Fortran
  #4
peter.zhao
Guest
 
Posts: n/a
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!
  Reply With Quote

Old   July 30, 2002, 22:07
Default Re: How to detect NaN's in Fortran
  #5
x.zhang
Guest
 
Posts: n/a
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!
  Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fortran Compiler-CFX12.1 Araz CFX 13 March 27, 2017 05:37
Intrinsic Procedure 'ISNAN' in GNU FORTRAN 77 hawk Main CFD Forum 1 April 12, 2005 22:13
visual fortran Monica Main CFD Forum 1 August 28, 2004 20:45
Fortran77 or Fortran 90 Swapnil CFX 2 November 26, 2002 15:16
Why Favoring Fortran over C/C++? Zi-Wei Chiou Main CFD Forum 35 September 26, 2001 09:34


All times are GMT -4. The time now is 04:36.