exception handling in FORTRAN

Ralph Noack texbell!killer!utacfd!rwn at cs.utexas.edu
Mon Dec 12 07:52:33 AEST 1988


We too were shocked that flt pt exceptions were not being taken. Took me a
while to figure it out and longer to figure out how to turn it on. Here is
what we do under SunOS 4.0(I can send similiar for 3.x, they are
different.

We either link in a subroutine or include the code from a file such as

      include '/usr/local/trap.i'

where /usr/local/trap.i contains

      external abort
      ieeer= ieee_handler('set','common',abort)
      if (ieeer .ne. 0) then
        write (0,'(''ieee_flags returned status='',i5)') ieeer
        stop 'ieee_flags'
      endif

The difficulty is that 4.0 has lots of problems and debugging is one of
them. With this include as the first executable statement in the main,
tracebacks are incorrect. To alleviate this I created a subroutine which I
added to /usr/lib/libF77.a I think. Replace the include above by the call

      call trapfltpt

with the subroutine being:

      subroutine trapfltpt
      external abort
      ieeer= ieee_handler('set','common',abort)
      if (ieeer .ne. 0) then
        write (0,'(''ieee_flags returned status='',i5)') ieeer
        stop 'ieee_flags'
      endif
      return 
      end

either works fine regardless of floating pt hardware.

-- 
Ralph W. Noack (817)-273-2860
Univ. of Tx at Arlington, Aerospace Eng. Dept. Box 19018 Arlington, Tx 76019
..!{killer,texsun}!utacfd!rwn



More information about the Comp.sys.sun mailing list