Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!ucsd!swrinde!elroy.jpl.nasa.gov!freedom!xanth!mcdowell From: mcdowell@xanth.msfc.nasa.gov (Jonathan McDowell) Newsgroups: comp.lang.fortran Subject: Re: IEEE exceptions Message-ID: Date: 26 Feb 91 14:50:08 GMT References: <91963@lll-winken.LLNL.GOV> Sender: root@freedom.msfc.nasa.gov (Super-User) Distribution: usa Organization: NASA/MSFC Lines: 68 macq@miguel.llnl.gov (Don MacQueen) writes: [ Gets an error message due to IEEE exceptions in Sun fortran, integrating a normal distribution]. Sun fortran lets you divide by zero and other fun things during your program and only lets you know at the end. I actually find this quite useful as I use the NaN (Not a Number) value (obtained by y=0./0.) as a null value for missing data, to avoid the nastiness of using -999.9 etc. But not letting you know until the end of the program is silly. I generated Don's error with the following simple program: xanth{mcdowell}[59]t% cat test.f y=exp(-400.0) write (*,*) y end xanth{mcdowell}[60]t% a.out 0. Warning: the following IEEE floating-point arithmetic exceptions occurred in this program and were never cleared: Inexact; Underflow; >Can I assume that 'Inexact' is occurring for the same reason that underflow is occurring? >What exactly (or inexactly?) does inexact mean? It would appear so; I guess that inexact means 'some exception that loses preci sion' (as opposed to 'Invalid Operand' which you get when you replace the exp above wi th a sqrt) and is followed by the name of the specific exception that has occurred. >What does it mean to 'clear an exception?' I remove the annoying error message from the above program with xanth{mcdowell}[66]t% cat test.f y=exp(-400.0) write (*,*) y call sys_exit END c------------------------------------------- subroutine sys_exit c Avoid nasty error message on exit integer ierr,ieee_flags character out*16 ierr=ieee_flags ('clear','exception','all',out) end xanth{mcdowell}[67]t% a.out 0. Of course, this also stops any 'Invalid Operand' warnings that you may incur. .-----------------------------------------------------------------------------. | Jonathan McDowell | phone : (205)544-???? | | Space Science Lab ES65 | uucp: | | NASA Marshall Space Flight Center | bitnet : | | Huntsville AL 35812 | inter : mcdowell@xanth.msfc.nasa.gov | | USA | span : ssl::mcdowell | '-----------------------------------------------------------------------------'