Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!mips!gumby!lilian From: lilian@mips.COM (Lilian Leung) Newsgroups: comp.sys.mips Subject: Re: How can you trap floating point errors in MIPS FORTRAN? Message-ID: <39088@mips.mips.COM> Date: 25 May 90 23:15:40 GMT References: <1990May15.011508.16295@portia.Stanford.EDU> Sender: news@mips.COM Reply-To: lilian@mips.COM (Lilian Leung) Organization: MIPS Computer Systems, Sunnyvale, CA Lines: 48 In article <1990May15.011508.16295@portia.Stanford.EDU> dhinds@portia.Stanford.EDU (David Hinds) writes: >There may be an obvious answer to this, but I can't find it in any of our >manuals. In MIPS FORTRAN, how can you test a real variable to see if it >holds a valid real number? I get very annoyed when my programs run for a >long time only to tell me the answer is "NaN.000". > > -David Hinds > dhinds@popserver.stanford.edu I have sent the following response before. In case it got lost, here it is again: We have implemented a function called "setfpe" which traps the following conditions for floating point operations: 1 - Invalid Operation Condition 2 - Divide By Zero Condition 3 - Inexact Result Condition 4 - Overflow Condition Here is an example for using that function: integer SIGFPE,DIVIDE0 parameter (SIGFPE=8,DIVIDE0=2) logical old,setfpe external fperror data a/0.0/ old = setfpe(DIVIDE0,.true.) isig = signal(SIGFPE,fperror,-1) b = 1.0/a print *,b end A user can specify his/her own "fperror" function. We have also implemented a command-line flag called "-trapuv" for initializing all local and stack variables to NaNs. When a floating point operation on a NaN operand occurs, the compiler takes a floating pointing exception and dumps core. Please contact our techical support for more details on the above functions. -- UUCP: {ames,decwrl,prls,pyramid}!mips!lilian (or lilian@mips.com) DDD: 408-991-7848 Lilian Leung (or 408-720-1700, Ext. 848) USPS: MIPS Computer Systems, 930 Arques, Sunnyvale, CA 94086-3650