- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want my Fortran pgm to cause an exception, and have the debugger get control, when a real variable is set to NaN or infinity. I have fpe:0 in the command line, and I set the FP control word using
CALL GETCONTROLFPQQ (controlword)
controlword=IAND(controlword,INOT(FPCW$INVALID))
CALL SETCONTROLFPQQ (controlword)
testNaN=x'7FF8000000000001' ! signalling NaN
ftol=testNaN
xtol=testNaN+1d0
testNaN, ftol and xtol are declared REAL(8).
But I still don't get an exception on any of the last 3 lines.
What do I need to do to get these exceptions?
CALL GETCONTROLFPQQ (controlword)
controlword=IAND(controlword,INOT(FPCW$INVALID))
CALL SETCONTROLFPQQ (controlword)
testNaN=x'7FF8000000000001' ! signalling NaN
ftol=testNaN
xtol=testNaN+1d0
testNaN, ftol and xtol are declared REAL(8).
But I still don't get an exception on any of the last 3 lines.
What do I need to do to get these exceptions?
Link Copied
7 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you compile with /fpe:0 specified?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes. I both had fpe:0 in the command line, and the modification of the floating control word in the pgm.
FWIW, this is a mixed C++ - Fortran pgm, with the C++ the "main project" and the Fortran a library.
FWIW, this is a mixed C++ - Fortran pgm, with the C++ the "main project" and the Fortran a library.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Irrespective of /fpe:n, you're overriding it to allow NaN's to be generated and thenyou want the debugger to halt when one is produced. You'll have to place a breakpoint when one occurs for the debugger to catch this since it's not a bug by design. BTW, is controlword of type integer(2)?
HTH,
Gerry T.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
g.f.thomas wrote:You'll have to place a breakpoint when one occurs for the debugger to catch this since it's not a bug by design. BTW, is controlword of type integer(2)?HTH,Gerry T.
Yes, controlWord is declared INTEGER(2), though that should not matter as long as it's >=2 bytes in size.
I want the debugger to stop at the time the Nan or infinity is generated. Therefore I can't place a breakpoint, because I don't know where to put it. At the end of a long computation, a result is displayed as NaN; the question is, where in that computation was the initial NaN generated?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use /fpe:0 in conjunction with traceback.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
g.f.thomas wrote:Use /fpe:0 in conjunction with traceback.
As I said, I am using fpe:0. I also have traceback enabled. I do not get debugger control when a NaN appears.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the code snippet you posted, there is nothing to consume the result of the addition. If that is the real code you have, try adding a print statement to actually use the value. I'm just guessing the compiler may have thrown away the operation that would trip the exception since the result is never used.
Hope this is helpful...Bill

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