Software Archive
Read-only legacy content
17061 Discussions

FP Exception Handler in CVF

Intel_C_Intel
Employee
340 Views
I have taken the example in the documentation and changed the RAISEQQ call into a real divide by zero, but it does not enter the h_fpe code when I enter 0.0 for x.

Can you point me at what I'm doing wrong?

Adrian Ferramosca
Baker Jardine



! This program shows a signal handler for
! SIG$FPE
USE DFLIB
INTERFACE
FUNCTION h_fpe (signum, except)
!DEC$ATTRIBUTES C :: h_fpe
INTEGER(4) h_fpe
INTEGER(2) signum, except
END FUNCTION
END INTERFACE

INTEGER(2) i2ret
INTEGER(4) i4ret
real(8) x
real(8) y

i4ret = SIGNALQQ(SIG$FPE, h_fpe)
WRITE(6,*) 'Set signal handler. Return = ', i4ret

read(5,*) x
y = 1.0d0 / x
y = dlog(x)
! i2ret = RAISEQQ(SIG$FPE)
! WRITE(6,*) 'Raised signal. Return = ', i2ret
END
!
! Signal handler routine
!
INTEGER(4) FUNCTION h_fpe (signum,except)
!DEC$ATTRIBUTES C :: h_fpe
INTEGER(2) signum, except
WRITE(6,*) 'In signal handler for SIG$fpe'
WRITE(6,*) 'signum = ', signum
WRITE(6,*) 'signum = ', except
h_fpe = 1
END
0 Kudos
0 Replies
Reply