- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How can I create a breakpoint that tests for NaN?
I am using Visual Studio 2005 and Intel Fortran 10to debug a legacy Fortran77 program in which elements in a large array (~100000 elements) inexplicably take on NaN values.
If I create a watchpoint conditionsuch as ISNAN(x) to test whether the variable x is NaN, the message in the watch window is "Undefinded variable isnan."
Thanks.
Glenn
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your quick response.
The debugger doesn't stop at abreakpoint testing for NaN with a condition x/=x nor isnan(x) Consider this code snippet --
logical isxnan1,isxnan2
x=sqrt(-1.)
isxnan1=isnan(x)
isxnan2=x/=x
As shown in the watch window, the returned values are
x = NaN
isxnan1 = .TRUE.
isxnan2 = .TRUE.
But if I enter x/=x directly into the watch window, the returned value is .FALSE.
Apparently the debugger --
1. Doesn't recognize the function ISNAN() and,
2. For x = NaN, evaluates x/=x exactly opposite (!?!) to the compiled code.
Setting a breakpoint that tests for '.not. x/=x' won't work since '.not. x/=x' is also true whenx is any number.
The only solution seems to be to modify the code to assign the result of isnan(x) to some new logical variable and to test for whether that variable is true.
logical isxnan
x=sqrt(-1.)
isxnan=isnan(x)
... ! set breakpoint to test whether isxnan = .true.
Not very elegant, but it works.
I'm open to other suggestions.
Thanks again.
Glenn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How can I create a breakpoint that tests for NaN?
I am using Visual Studio 2005 and Intel Fortran 10to debug a legacy Fortran77 program in which elements in a large array (~100000 elements) inexplicably take on NaN values.
If I create a watchpoint conditionsuch as ISNAN(x) to test whether the variable x is NaN, the message in the watch window is "Undefinded variable isnan."
Thanks.
Glenn
I had code of the form
IF (IsNan(x)) THEN
x = 0.0 ! Place breakpoint here
END IF
and
IF (ANY(IsNan(x))) THEN
WHERE (IsNan(x)) ! Breakpoint here
x = 0.0
END WHERE
END IF
Replace assignment of 0.0 with whatever makes most sense for your program - PRINT *, for example.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page