mpcdm.f 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. *DECK MPCDM
  2. SUBROUTINE MPCDM (DX, Z)
  3. C***BEGIN PROLOGUE MPCDM
  4. C***SUBSIDIARY
  5. C***PURPOSE Subsidiary to DQDOTA and DQDOTI
  6. C***LIBRARY SLATEC
  7. C***TYPE ALL (MPCDM-A)
  8. C***AUTHOR (UNKNOWN)
  9. C***DESCRIPTION
  10. C
  11. C Converts double-precision number DX to multiple-precision Z.
  12. C Some numbers will not convert exactly on machines with base
  13. C other than two, four or sixteen. This routine is not called
  14. C by any other routine in 'mp', so may be omitted if double-
  15. C precision is not available.
  16. C
  17. C The argument Z(*) and the variable R in COMMON are both INTEGER
  18. C arrays of size 30. See the comments in the routine MPBLAS for the
  19. C for the reason for this choice.
  20. C
  21. C***SEE ALSO DQDOTA, DQDOTI, MPBLAS
  22. C***ROUTINES CALLED MPCHK, MPDIVI, MPMULI, MPNZR
  23. C***COMMON BLOCKS MPCOM
  24. C***REVISION HISTORY (YYMMDD)
  25. C 791001 DATE WRITTEN
  26. C ?????? Modified for use with BLAS. Blank COMMON changed to named
  27. C COMMON. R given dimension 12.
  28. C 890531 Changed all specific intrinsics to generic. (WRB)
  29. C 890831 Modified array declarations. (WRB)
  30. C 891214 Prologue converted to Version 4.0 format. (BAB)
  31. C 900402 Added TYPE section. (WRB)
  32. C 930124 Increased Array size in MPCON for SUN -r8. (RWC)
  33. C***END PROLOGUE MPCDM
  34. DOUBLE PRECISION DB, DJ, DX
  35. COMMON /MPCOM/ B, T, M, LUN, MXR, R(30)
  36. INTEGER B, T, R, Z(*), RS, RE, TP
  37. C***FIRST EXECUTABLE STATEMENT MPCDM
  38. CALL MPCHK (1, 4)
  39. I2 = T + 4
  40. C CHECK SIGN
  41. IF (DX) 20, 10, 30
  42. C IF DX = 0D0 RETURN 0
  43. 10 Z(1) = 0
  44. RETURN
  45. C DX .LT. 0D0
  46. 20 RS = -1
  47. DJ = -DX
  48. GO TO 40
  49. C DX .GT. 0D0
  50. 30 RS = 1
  51. DJ = DX
  52. 40 IE = 0
  53. 50 IF (DJ.LT.1D0) GO TO 60
  54. C INCREASE IE AND DIVIDE DJ BY 16.
  55. IE = IE + 1
  56. DJ = 0.0625D0*DJ
  57. GO TO 50
  58. 60 IF (DJ.GE.0.0625D0) GO TO 70
  59. IE = IE - 1
  60. DJ = 16D0*DJ
  61. GO TO 60
  62. C NOW DJ IS DY DIVIDED BY SUITABLE POWER OF 16
  63. C SET EXPONENT TO 0
  64. 70 RE = 0
  65. DB = DBLE(B)
  66. C CONVERSION LOOP (ASSUME DOUBLE-PRECISION OPS. EXACT)
  67. DO 80 I = 1, I2
  68. DJ = DB*DJ
  69. R(I) = INT(DJ)
  70. 80 DJ = DJ - DBLE(R(I))
  71. C NORMALIZE RESULT
  72. CALL MPNZR (RS, RE, Z, 0)
  73. IB = MAX(7*B*B, 32767)/16
  74. TP = 1
  75. C NOW MULTIPLY BY 16**IE
  76. IF (IE) 90, 130, 110
  77. 90 K = -IE
  78. DO 100 I = 1, K
  79. TP = 16*TP
  80. IF ((TP.LE.IB).AND.(TP.NE.B).AND.(I.LT.K)) GO TO 100
  81. CALL MPDIVI (Z, TP, Z)
  82. TP = 1
  83. 100 CONTINUE
  84. RETURN
  85. 110 DO 120 I = 1, IE
  86. TP = 16*TP
  87. IF ((TP.LE.IB).AND.(TP.NE.B).AND.(I.LT.IE)) GO TO 120
  88. CALL MPMULI (Z, TP, Z)
  89. TP = 1
  90. 120 CONTINUE
  91. 130 RETURN
  92. END