home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / ultrix / 6356 < prev    next >
Encoding:
Internet Message Format  |  1992-08-20  |  2.3 KB

  1. Path: sparky!uunet!cis.ohio-state.edu!pacific.mps.ohio-state.edu!ohstpy!sidwell
  2. From: sidwell@ohstpy.mps.ohio-state.edu
  3. Newsgroups: comp.unix.ultrix
  4. Subject: help requested: f77 and ERRSNS error trapping
  5. Message-ID: <13431.2a938586@ohstpy.mps.ohio-state.edu>
  6. Date: 20 Aug 92 11:44:06 EDT
  7. Lines: 62
  8.  
  9.     I am trying (very unsuccessfully) to use the ERRSNS subroutine
  10. to spot arithmetic faults.  I would like to 1)keep my program running
  11. even in case of an arithmetic fault and 2)keep track of what kind of
  12. fault occurred and how often (it is important for me to distinguish
  13. between underflow and overflow).  My program is in DEC Fortran 3.1
  14. under ULTRIX 4.2.
  15.     To try to do the above two things I wrote the small program
  16. below so I can learn how to use ERRSNS.  Something is wrong with that
  17. small program because ERRSNS always returned zero for all of its
  18. arguments, so that there is no way for me to achieve goal 2) above.
  19.     I would very much appreciate answers for:
  20.  - what is wrong with the small program below?
  21.  - are there other ways to do the same thing?
  22. or any hints on where to get those answers.
  23.                 Harried and Hopeless,
  24.                      Ai Nguyen
  25. P.S. I've also tried to set the fpe at compile time (as opposed to
  26.      calling for_set_fpe) and the ERRSNS results are the same.
  27.  
  28. small test program=================================================
  29.     implicit none
  30.     include '/usr/include/for_fpe_flags.f'
  31.     include '/usr/include/foriosdef.f'
  32.     integer fnum,stat1,stat2,lun,cval
  33.     integer for_get_fpe,for_set_fpe,old_fpe_flags,new_fpe_flags
  34.     external for_get_fpe
  35.     integer i,j,k
  36.     real x,y,z
  37. c
  38.     old_fpe_flags=for_get_fpe()
  39.     write(6,*)' old fpe=',old_fpe_flags
  40.     new_fpe_flags=986895
  41.     old_fpe_flags=for_set_fpe(new_fpe_flags)
  42.     old_fpe_flags=for_get_fpe()
  43. c integer divide by zero
  44.     write(6,*)' '
  45.     i=1
  46.     j=0
  47.     k=i/j
  48.     write(6,*)i,'/',j,'=',k
  49.     call errsns(fnum,stat1,stat2,lun,cval)
  50.     write(6,*)fnum,stat1,stat2,lun,cval
  51. c exponentiation of small number
  52.     write(6,*)' '
  53.     x=-1.e-99
  54.     y=exp(x)
  55.     write(6,*)' exp(',x,')=',y
  56.     call errsns(fnum,stat1,stat2,lun,cval)
  57.     write(6,*)fnum,stat1,stat2,lun,cval
  58. c floating divide by zero
  59.     write(6,*)' '
  60.     x=1.0
  61.     y=0.0
  62.     z=x/y
  63.     write(6,*)x,'/',y,'=',z
  64.     call errsns(fnum,stat1,stat2,lun,cval)
  65.     write(6,*)fnum,stat1,stat2,lun,cval
  66. c
  67.     write(6,*)' Bye'
  68.     stop
  69.     end
  70. ===================================================================
  71.