lilian@mips.COM (Lilian Leung) (05/26/90)
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 We have implemented a function called "setfpe" that would trap the following 4 conditions: 1 - Invalid Operation Condition 2 - Divide by Zero Condition 3 - Inexact Result Condition 4 - Overflow Condition Here is an example of the use of the "setfpe" 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 Of course, you can have your own "fperror" function written. Also, we have a command line flag called "-trapuv" that would initialize all local and stack variables to NaN and take exception whenever an operation involving NaN occurs. Please check with Mips's customer support for more details on the above. -- 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
lilian@mips.COM (Lilian Leung) (05/26/90)
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