Skip to content

Commit

Permalink
Improve documentation of the new routines. Force roundup only if it i…
Browse files Browse the repository at this point in the history
…s necessary
  • Loading branch information
weslleyspereira committed Aug 4, 2021
1 parent cea9568 commit 51eee01
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
16 changes: 10 additions & 6 deletions INSTALL/droundup_lwork.f
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@
*> \verbatim
*>
*> DROUNDUP_LWORK deals with a subtle bug with returning LWORK as a Float.
*> If LWORK > 2**24, then it will get rounded as a Float.
*> This routine guarantees it is rounded up instead of down by
*> multiplying LWORK by 1+eps, where eps is the relative machine precision.
*> multiplying LWORK by 1+eps when it is necessary, where eps is the relative machine precision.
*> E.g.,
*>
*> float( 9007199254740993 ) == 9007199254740992
*> float( 9007199254740993 ) * (1.+eps) == 9007199254740994
*>
*> \return DROUNDUP_LWORK
*> \verbatim
*> DROUNDUP_LWORK >= LWORK.
*> DROUNDUP_LWORK is guaranteed to have zero decimal part.
*> \endverbatim
*
* Arguments:
Expand Down Expand Up @@ -64,14 +68,14 @@ DOUBLE PRECISION FUNCTION DROUNDUP_LWORK( LWORK )
* =====================================================================
* ..
* .. Intrinsic Functions ..
INTRINSIC DIGITS, RADIX, EPSILON
INTRINSIC EPSILON, DBLE, INT
* ..
* .. Executable Statements ..
* ..
DROUNDUP_LWORK = LWORK
DROUNDUP_LWORK = DBLE( LWORK )
*
IF( DROUNDUP_LWORK .GE. DBLE(RADIX(0.0D+0))**DIGITS(0.0D+0) ) THEN
* If LWORK can't be represented exactly in double precision
IF( INT( DROUNDUP_LWORK ) .LT. LWORK ) THEN
* Force round up of LWORK
DROUNDUP_LWORK = DROUNDUP_LWORK * ( 1.0D+0 + EPSILON(0.0D+0) )
ENDIF
*
Expand Down
15 changes: 8 additions & 7 deletions INSTALL/sroundup_lwork.f
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@
*> \verbatim
*>
*> SROUNDUP_LWORK deals with a subtle bug with returning LWORK as a Float.
*> If LWORK > 2**24, then it will get rounded as a Float.
*> This routine guarantees it is rounded up instead of down by
*> multiplying LWORK by 1+eps, where eps is the relative machine precision.
*> multiplying LWORK by 1+eps when it is necessary, where eps is the relative machine precision.
*> E.g.,
*>
*> float( 16777217 ) == 16777216
*> float( 16777217 * (1.+eps) ) == 16777218
*> float( 16777217 ) * (1.+eps) == 16777218
*>
*> \return SROUNDUP_LWORK
*> \verbatim
*> SROUNDUP_LWORK >= LWORK.
*> SROUNDUP_LWORK is guaranteed to have zero decimal part.
*> \endverbatim
*
* Arguments:
Expand Down Expand Up @@ -67,14 +68,14 @@ REAL FUNCTION SROUNDUP_LWORK( LWORK )
* =====================================================================
* ..
* .. Intrinsic Functions ..
INTRINSIC DIGITS, RADIX, EPSILON
INTRINSIC EPSILON, REAL, INT
* ..
* .. Executable Statements ..
* ..
SROUNDUP_LWORK = LWORK
SROUNDUP_LWORK = REAL( LWORK )
*
IF( SROUNDUP_LWORK .GE. REAL(RADIX(0.0E+0))**DIGITS(0.0E+0) ) THEN
* If LWORK can't be represented exactly in single precision
IF( INT( SROUNDUP_LWORK ) .LT. LWORK ) THEN
* Force round up of LWORK
SROUNDUP_LWORK = SROUNDUP_LWORK * ( 1.0E+0 + EPSILON(0.0E+0) )
ENDIF
*
Expand Down

0 comments on commit 51eee01

Please sign in to comment.