- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have made the following program to test how the Intel fortran compiler (10.0.*) catches fp exceptions. I am running fedora 7 on a intel pentium 4.
program test_ieee_fpe
use ifport
implicit none
real :: x, y, z
integer*4 :: ir
character*20 :: out
x=0.
y=1.
z=y/x ! Division by zero
ir=ieee_flags('get', 'exception', '', out)
print*,'Exception raised: ', out
end program test_ieee_fpe
When I compile and run the program, no exception is raised (that is, "out" is null) . However, if I try to print (either on the creen or to a file) the value of "z", the exception "division" is triggered.
Anyway, other operations leading to fp exceptions are not got by ieee_flags, for example invalid operations such as sqrt(-1.0) or overflows.
real x
x=sqrt(-1.0) ! Invalid operation
ir=ieee_flags('get', 'exception', '', out)
x is assigned to "NaN" but "out" is NULL. The same happens when an overflow occurs.
Has anybody else experienced these problems?
Best regards,
Rafa Gallego
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you don't use the result, the computation may be optimized away.
With the default -fpe3, there is no exception to raise. The operation simply results in a NaN or Inf, etc. Operations such as SQRT will directly assign a NaN to the result for out of range arguments - again, no exception is raised.
There isn't a straightforward way I know of to have the exception, catch it, and continue from the point of the error.
With the default -fpe3, there is no exception to raise. The operation simply results in a NaN or Inf, etc. Operations such as SQRT will directly assign a NaN to the result for out of range arguments - again, no exception is raised.
There isn't a straightforward way I know of to have the exception, catch it, and continue from the point of the error.

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