;+ ; NAME: ; SILENCE_MATH_ERRORS ; ; PURPOSE: ; ; The purpose of this procedure is to silence ; any math error that you know about, but ; don't need reminding about again. For ; instance, the dreaded floating underflow. ; ; AUTHOR: ; ; Nathan Johnson ; University of Arizona ; Department of Atmospheric Sciences ; johnson AT atmo DOT arizona DOT edu ; ; CATEGORY: ; ; Math. ; ; CALLING SEQUENCE (WITH REQUIRED INPUT PARAMETERS): ; ; SILENCE_MATH_ERRORS ; ; OPTIONAL INPUT PARAMETERS: ; ; currentexcept: Used only if the unsilence keyword is set. ; This will be used as the future !except. Should ; usually be set to 1. ; ; INPUT KEYWORD PARAMETERS: ; ; unsilence: Undo the silencing. Math error will again be reported. ; ; OUTPUT KEYWORD PARAMETERS: ; ; None. ; ; COMMON BLOCKS: ; None. ; ; SIDE EFFECTS: ; None known. ; ; RESTRICTIONS: ; None. ; ; EXAMPLE: ; ; SILENCE_MATH_ERRORS ; This command will silence the math errors. ; ; SILENCE_MATH_ERRORS, 1, /unsilence ; This command will unsilence the math errors. ; ; MODIFICATION HISTORY: ; ; Written by: Nathan Johnson, 17 January 2008. ;- PRO silence_math_errors, currentexcept, unsilence=unsilence ON_ERROR, 2 IF NOT KEYWORD_SET(unsilence) THEN BEGIN currentExcept = !Except !Except = 0 void = Check_Math() ENDIF ELSE BEGIN floating_point_underflow = 32 status = Check_Math() ; Get status and reset accumulated math error register. ;IF(status AND NOT floating_point_underflow) NE 0 THEN $ ; Message, 'IDL Check_Math() error: ' + StrTrim(status, 2) IF NOT KEYWORD_SET(currentExcept) THEN currentExcept = 1 !Except = currentExcept ENDELSE END