- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I played around a little bit with the IEEE_HANDLER() function from the Intel Fortran Library. I managed to produce a defind overflow exception behaviour as described in for_lib.pdf, pp. 2-108 ...2-110 So far so good.
But I was not able to get the handler working for integer overflow with the byte datatype. How can I enable integer overflow exception handling with ifc? Is this possible at all?
Regards,
Michael
But I was not able to get the handler working for integer overflow with the byte datatype. How can I enable integer overflow exception handling with ifc? Is this possible at all?
Regards,
Michael
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I too have been trying to get sensible exception handling
behavior out of ifc but I feel like I'm stumbling around
in the dark. What I really want is a compiler flag like
-ftrap=common, as found in the NAG compiler, that will
cause execution to be aborted on overflow, divide-by-zero,
or invalid operation.
Having failed to find one, I resorted to trying some of the routines described in the Intel Fortran Library,
namely setcontrolfpqq and ieee_flags but I can't claim
to understand what I'm doing.
In particular, what exactly is the difference in
functionalty between setcontrolfpqq() and ieee_flags()?
The only way I got an FP exception to abort execution
was by using _both_ of them (see example code below).
I found the descriptions in for_lib.pdf to be
very opaque and confusing. Also, the example code
snippets are in very non-standard fortran.
Any help or general enlightenment on the topic
would be much appreciated
Will
behavior out of ifc but I feel like I'm stumbling around
in the dark. What I really want is a compiler flag like
-ftrap=common, as found in the NAG compiler, that will
cause execution to be aborted on overflow, divide-by-zero,
or invalid operation.
Having failed to find one, I resorted to trying some of the routines described in the Intel Fortran Library,
namely setcontrolfpqq and ieee_flags but I can't claim
to understand what I'm doing.
In particular, what exactly is the difference in
functionalty between setcontrolfpqq() and ieee_flags()?
The only way I got an FP exception to abort execution
was by using _both_ of them (see example code below).
I found the descriptions in for_lib.pdf to be
very opaque and confusing. Also, the example code
snippets are in very non-standard fortran.
Any help or general enlightenment on the topic
would be much appreciated
Will
program fpetest use iflport implicit none integer :: iflag real :: x integer, parameter :: i2b = selected_int_kind(3) integer(i2b) :: control character(len=9) :: out ! find floating point processor control word call getcontrolfpqq(control) print '(b16.16)', control ! unmask common exceptions control = ibclr( control, 0 ) ! FPCW$INVALID control = ibclr( control, 2 ) ! FPCW$ZERODIVIDE control = ibclr( control, 3 ) ! FPCW$OVERFLOW call setcontrolfpqq(control) print '(b16.16)', control ! set the IEEE flags iflag = ieee_flags('set', 'exception', 'common', out) ! try to trigger an overflow x = 1.e30 x = x/1.e-30 end program fpetest
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please excuse my previous post, which was full of
errors.
I've now got this to work with the getcontrolfpqq()
routine. The ieee_flags('set',...) function was a red herring - it seems to cause the next floating point operation, however innocuous, to raise an exception.
I append a revised demo program. By uncommenting each
of the three ibclr calls it falls over on a different
exception.
So I now have the -ftrap=XXX behavior that I wanted. Hopefully this will be of use to someone else. Doesn't help the OP with the integer exception problem though
(there is no SETCONTROLINTQQ routine....)
Will
errors.
I've now got this to work with the getcontrolfpqq()
routine. The ieee_flags('set',...) function was a red herring - it seems to cause the next floating point operation, however innocuous, to raise an exception.
I append a revised demo program. By uncommenting each
of the three ibclr calls it falls over on a different
exception.
So I now have the -ftrap=XXX behavior that I wanted. Hopefully this will be of use to someone else. Doesn't help the OP with the integer exception problem though
(there is no SETCONTROLINTQQ routine....)
Will
yprogram fpetest use iflport implicit none integer :: iflag real :: x integer, parameter :: i2b = selected_int_kind(3) integer(i2b) :: control character(len=9) :: out ! find floating point processor control word call getcontrolfpqq(control) print '(b16.16)', control ! unmask common exceptions control = ibclr( control, 0 ) ! FPCW$INVALID ! control = ibclr( control, 2 ) ! FPCW$ZERODIVIDE ! control = ibclr( control, 3 ) ! FPCW$OVERFLOW call setcontrolfpqq(control) print '(b16.16)', control ! test of OVERFLOW x = 1.e30 x = (x/1.e-30)**2 ! test of ZERODIVIDE x = 0.0 x = 1./x ! test of INVALID x = 0.0 x = 0.0/x end program fpetest

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