home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cis.ohio-state.edu!pacific.mps.ohio-state.edu!ohstpy!sidwell
- From: sidwell@ohstpy.mps.ohio-state.edu
- Newsgroups: comp.unix.ultrix
- Subject: help requested: f77 and ERRSNS error trapping
- Message-ID: <13431.2a938586@ohstpy.mps.ohio-state.edu>
- Date: 20 Aug 92 11:44:06 EDT
- Lines: 62
-
- I am trying (very unsuccessfully) to use the ERRSNS subroutine
- to spot arithmetic faults. I would like to 1)keep my program running
- even in case of an arithmetic fault and 2)keep track of what kind of
- fault occurred and how often (it is important for me to distinguish
- between underflow and overflow). My program is in DEC Fortran 3.1
- under ULTRIX 4.2.
- To try to do the above two things I wrote the small program
- below so I can learn how to use ERRSNS. Something is wrong with that
- small program because ERRSNS always returned zero for all of its
- arguments, so that there is no way for me to achieve goal 2) above.
- I would very much appreciate answers for:
- - what is wrong with the small program below?
- - are there other ways to do the same thing?
- or any hints on where to get those answers.
- Harried and Hopeless,
- Ai Nguyen
- P.S. I've also tried to set the fpe at compile time (as opposed to
- calling for_set_fpe) and the ERRSNS results are the same.
-
- small test program=================================================
- implicit none
- include '/usr/include/for_fpe_flags.f'
- include '/usr/include/foriosdef.f'
- integer fnum,stat1,stat2,lun,cval
- integer for_get_fpe,for_set_fpe,old_fpe_flags,new_fpe_flags
- external for_get_fpe
- integer i,j,k
- real x,y,z
- c
- old_fpe_flags=for_get_fpe()
- write(6,*)' old fpe=',old_fpe_flags
- new_fpe_flags=986895
- old_fpe_flags=for_set_fpe(new_fpe_flags)
- old_fpe_flags=for_get_fpe()
- c integer divide by zero
- write(6,*)' '
- i=1
- j=0
- k=i/j
- write(6,*)i,'/',j,'=',k
- call errsns(fnum,stat1,stat2,lun,cval)
- write(6,*)fnum,stat1,stat2,lun,cval
- c exponentiation of small number
- write(6,*)' '
- x=-1.e-99
- y=exp(x)
- write(6,*)' exp(',x,')=',y
- call errsns(fnum,stat1,stat2,lun,cval)
- write(6,*)fnum,stat1,stat2,lun,cval
- c floating divide by zero
- write(6,*)' '
- x=1.0
- y=0.0
- z=x/y
- write(6,*)x,'/',y,'=',z
- call errsns(fnum,stat1,stat2,lun,cval)
- write(6,*)fnum,stat1,stat2,lun,cval
- c
- write(6,*)' Bye'
- stop
- end
- ===================================================================
-