dpmpar.F 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. DOUBLE PRECISION FUNCTION DPMPAR (I)
  2. C-----------------------------------------------------------------------
  3. C
  4. C DPMPAR PROVIDES THE DOUBLE PRECISION MACHINE CONSTANTS FOR
  5. C THE COMPUTER BEING USED. IT IS ASSUMED THAT THE ARGUMENT
  6. C I IS AN INTEGER HAVING ONE OF THE VALUES 1, 2, OR 3. IF THE
  7. C DOUBLE PRECISION ARITHMETIC BEING USED HAS M BASE B DIGITS AND
  8. C ITS SMALLEST AND LARGEST EXPONENTS ARE EMIN AND EMAX, THEN
  9. C
  10. C DPMPAR(1) = B**(1 - M), THE MACHINE PRECISION,
  11. C
  12. C DPMPAR(2) = B**(EMIN - 1), THE SMALLEST MAGNITUDE,
  13. C
  14. C DPMPAR(3) = B**EMAX*(1 - B**(-T)), THE LARGEST MAGNITUDE.
  15. C
  16. C-----------------------------------------------------------------------
  17. C WRITTEN BY
  18. C ALFRED H. MORRIS, JR.
  19. C NAVAL SURFACE WARFARE CENTER
  20. C DAHLGREN VIRGINIA
  21. C-----------------------------------------------------------------------
  22. INTEGER EMIN, EMAX
  23. DOUBLE PRECISION B, BINV, BM1, ONE, W, Z
  24. C
  25. IF (I .GT. 1) GO TO 10
  26. B = IPMPAR(4)
  27. M = IPMPAR(8)
  28. DPMPAR = B**(1 - M)
  29. RETURN
  30. C
  31. 10 IF (I .GT. 2) GO TO 20
  32. B = IPMPAR(4)
  33. EMIN = IPMPAR(9)
  34. ONE = FLOAT(1)
  35. BINV = ONE/B
  36. W = B**(EMIN + 2)
  37. DPMPAR = ((W * BINV) * BINV) * BINV
  38. RETURN
  39. C
  40. 20 IBETA = IPMPAR(4)
  41. M = IPMPAR(8)
  42. EMAX = IPMPAR(10)
  43. C
  44. B = IBETA
  45. BM1 = IBETA - 1
  46. ONE = FLOAT(1)
  47. Z = B**(M - 1)
  48. W = ((Z - ONE)*B + BM1)/(B*Z)
  49. C
  50. Z = B**(EMAX - 2)
  51. DPMPAR = ((W * Z) * B) * B
  52. RETURN
  53. END