Skip to content

Commit c7400e5

Browse files
Improve documentation of the new routines. Force roundup only if it is necessary
1 parent cea9568 commit c7400e5

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

INSTALL/droundup_lwork.f

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@
2121
*> \verbatim
2222
*>
2323
*> DROUNDUP_LWORK deals with a subtle bug with returning LWORK as a Float.
24-
*> If LWORK > 2**24, then it will get rounded as a Float.
2524
*> This routine guarantees it is rounded up instead of down by
26-
*> multiplying LWORK by 1+eps, where eps is the relative machine precision.
25+
*> multiplying LWORK by 1+eps when it is necessary, where eps is the relative machine precision.
26+
*> E.g.,
27+
*>
28+
*> float( 9007199254740993 ) == 9007199254740992
29+
*> float( 9007199254740993 ) * (1.+eps) == 9007199254740994
2730
*>
2831
*> \return DROUNDUP_LWORK
2932
*> \verbatim
3033
*> DROUNDUP_LWORK >= LWORK.
34+
*> DROUNDUP_LWORK is guaranteed to have zero decimal part.
3135
*> \endverbatim
3236
*
3337
* Arguments:
@@ -64,14 +68,14 @@ DOUBLE PRECISION FUNCTION DROUNDUP_LWORK( LWORK )
6468
* =====================================================================
6569
* ..
6670
* .. Intrinsic Functions ..
67-
INTRINSIC DIGITS, RADIX, EPSILON
71+
INTRINSIC EPSILON, DBLE, INT
6872
* ..
6973
* .. Executable Statements ..
7074
* ..
71-
DROUNDUP_LWORK = LWORK
75+
DROUNDUP_LWORK = DBLE( LWORK )
7276
*
73-
IF( DROUNDUP_LWORK .GE. DBLE(RADIX(0.0D+0))**DIGITS(0.0D+0) ) THEN
74-
* If LWORK can't be represented exactly in double precision
77+
IF( INT( DROUNDUP_LWORK ) .LT. LWORK ) THEN
78+
* Force round up of LWORK
7579
DROUNDUP_LWORK = DROUNDUP_LWORK * ( 1.0D+0 + EPSILON(0.0D+0) )
7680
ENDIF
7781
*

INSTALL/sroundup_lwork.f

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,17 @@
2121
*> \verbatim
2222
*>
2323
*> SROUNDUP_LWORK deals with a subtle bug with returning LWORK as a Float.
24-
*> If LWORK > 2**24, then it will get rounded as a Float.
2524
*> This routine guarantees it is rounded up instead of down by
26-
*> multiplying LWORK by 1+eps, where eps is the relative machine precision.
25+
*> multiplying LWORK by 1+eps when it is necessary, where eps is the relative machine precision.
26+
*> E.g.,
2727
*>
2828
*> float( 16777217 ) == 16777216
29-
*> float( 16777217 * (1.+eps) ) == 16777218
29+
*> float( 16777217 ) * (1.+eps) == 16777218
3030
*>
3131
*> \return SROUNDUP_LWORK
3232
*> \verbatim
3333
*> SROUNDUP_LWORK >= LWORK.
34+
*> SROUNDUP_LWORK is guaranteed to have zero decimal part.
3435
*> \endverbatim
3536
*
3637
* Arguments:
@@ -67,14 +68,14 @@ REAL FUNCTION SROUNDUP_LWORK( LWORK )
6768
* =====================================================================
6869
* ..
6970
* .. Intrinsic Functions ..
70-
INTRINSIC DIGITS, RADIX, EPSILON
71+
INTRINSIC EPSILON, REAL, INT
7172
* ..
7273
* .. Executable Statements ..
7374
* ..
74-
SROUNDUP_LWORK = LWORK
75+
SROUNDUP_LWORK = REAL( LWORK )
7576
*
76-
IF( SROUNDUP_LWORK .GE. REAL(RADIX(0.0E+0))**DIGITS(0.0E+0) ) THEN
77-
* If LWORK can't be represented exactly in single precision
77+
IF( INT( SROUNDUP_LWORK ) .LT. LWORK ) THEN
78+
* Force round up of LWORK
7879
SROUNDUP_LWORK = SROUNDUP_LWORK * ( 1.0E+0 + EPSILON(0.0E+0) )
7980
ENDIF
8081
*

0 commit comments

Comments
 (0)