So, for an operation "a/b" where "b" is may be 0 at some point, a limiter can be applied such that a minimum threshold, dictated by parameter "SMALL", forces the value to be higher than zero and also to avoid underflows.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REAL, PARAMETER :: SMALL = 1.E-18 | |
!! for a divisor b>0 | |
c = a/MAX(b, SMALL) | |
!! for a divisor b with an arbitrary sign | |
c = a/SIGN(MAX(ABS(b), SMALL), b) |
No comments:
Post a Comment