drlcal.f 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. *DECK DRLCAL
  2. SUBROUTINE DRLCAL (N, KMP, LL, MAXL, V, Q, RL, SNORMW, PROD,
  3. + R0NRM)
  4. C***BEGIN PROLOGUE DRLCAL
  5. C***SUBSIDIARY
  6. C***PURPOSE Internal routine for DGMRES.
  7. C***LIBRARY SLATEC (SLAP)
  8. C***CATEGORY D2A4, D2B4
  9. C***TYPE DOUBLE PRECISION (SRLCAL-S, DRLCAL-D)
  10. C***KEYWORDS GENERALIZED MINIMUM RESIDUAL, ITERATIVE PRECONDITION,
  11. C NON-SYMMETRIC LINEAR SYSTEM, SLAP, SPARSE
  12. C***AUTHOR Brown, Peter, (LLNL), pnbrown@llnl.gov
  13. C Hindmarsh, Alan, (LLNL), alanh@llnl.gov
  14. C Seager, Mark K., (LLNL), seager@llnl.gov
  15. C Lawrence Livermore National Laboratory
  16. C PO Box 808, L-60
  17. C Livermore, CA 94550 (510) 423-3141
  18. C***DESCRIPTION
  19. C This routine calculates the scaled residual RL from the
  20. C V(I)'s.
  21. C *Usage:
  22. C INTEGER N, KMP, LL, MAXL
  23. C DOUBLE PRECISION V(N,LL), Q(2*MAXL), RL(N), SNORMW, PROD, R0NORM
  24. C
  25. C CALL DRLCAL(N, KMP, LL, MAXL, V, Q, RL, SNORMW, PROD, R0NRM)
  26. C
  27. C *Arguments:
  28. C N :IN Integer
  29. C The order of the matrix A, and the lengths
  30. C of the vectors SR, SZ, R0 and Z.
  31. C KMP :IN Integer
  32. C The number of previous V vectors the new vector VNEW
  33. C must be made orthogonal to. (KMP .le. MAXL)
  34. C LL :IN Integer
  35. C The current dimension of the Krylov subspace.
  36. C MAXL :IN Integer
  37. C The maximum dimension of the Krylov subspace.
  38. C V :IN Double Precision V(N,LL)
  39. C The N x LL array containing the orthogonal vectors
  40. C V(*,1) to V(*,LL).
  41. C Q :IN Double Precision Q(2*MAXL)
  42. C A double precision array of length 2*MAXL containing the
  43. C components of the Givens rotations used in the QR
  44. C decomposition of HES. It is loaded in DHEQR and used in
  45. C DHELS.
  46. C RL :OUT Double Precision RL(N)
  47. C The residual vector RL. This is either SB*(B-A*XL) if
  48. C not preconditioning or preconditioning on the right,
  49. C or SB*(M-inverse)*(B-A*XL) if preconditioning on the
  50. C left.
  51. C SNORMW :IN Double Precision
  52. C Scale factor.
  53. C PROD :IN Double Precision
  54. C The product s1*s2*...*sl = the product of the sines of the
  55. C Givens rotations used in the QR factorization of
  56. C the Hessenberg matrix HES.
  57. C R0NRM :IN Double Precision
  58. C The scaled norm of initial residual R0.
  59. C
  60. C***SEE ALSO DGMRES
  61. C***ROUTINES CALLED DCOPY, DSCAL
  62. C***REVISION HISTORY (YYMMDD)
  63. C 890404 DATE WRITTEN
  64. C 890404 Previous REVISION DATE
  65. C 890915 Made changes requested at July 1989 CML Meeting. (MKS)
  66. C 890922 Numerous changes to prologue to make closer to SLATEC
  67. C standard. (FNF)
  68. C 890929 Numerous changes to reduce SP/DP differences. (FNF)
  69. C 910411 Prologue converted to Version 4.0 format. (BAB)
  70. C 910506 Made subsidiary to DGMRES. (FNF)
  71. C 920511 Added complete declaration section. (WRB)
  72. C***END PROLOGUE DRLCAL
  73. C The following is for optimized compilation on LLNL/LTSS Crays.
  74. CLLL. OPTIMIZE
  75. C .. Scalar Arguments ..
  76. DOUBLE PRECISION PROD, R0NRM, SNORMW
  77. INTEGER KMP, LL, MAXL, N
  78. C .. Array Arguments ..
  79. DOUBLE PRECISION Q(*), RL(N), V(N,*)
  80. C .. Local Scalars ..
  81. DOUBLE PRECISION C, S, TEM
  82. INTEGER I, I2, IP1, K, LLM1, LLP1
  83. C .. External Subroutines ..
  84. EXTERNAL DCOPY, DSCAL
  85. C***FIRST EXECUTABLE STATEMENT DRLCAL
  86. IF (KMP .EQ. MAXL) THEN
  87. C
  88. C calculate RL. Start by copying V(*,1) into RL.
  89. C
  90. CALL DCOPY(N, V(1,1), 1, RL, 1)
  91. LLM1 = LL - 1
  92. DO 20 I = 1,LLM1
  93. IP1 = I + 1
  94. I2 = I*2
  95. S = Q(I2)
  96. C = Q(I2-1)
  97. DO 10 K = 1,N
  98. RL(K) = S*RL(K) + C*V(K,IP1)
  99. 10 CONTINUE
  100. 20 CONTINUE
  101. S = Q(2*LL)
  102. C = Q(2*LL-1)/SNORMW
  103. LLP1 = LL + 1
  104. DO 30 K = 1,N
  105. RL(K) = S*RL(K) + C*V(K,LLP1)
  106. 30 CONTINUE
  107. ENDIF
  108. C
  109. C When KMP < MAXL, RL vector already partially calculated.
  110. C Scale RL by R0NRM*PROD to obtain the residual RL.
  111. C
  112. TEM = R0NRM*PROD
  113. CALL DSCAL(N, TEM, RL, 1)
  114. RETURN
  115. C------------- LAST LINE OF DRLCAL FOLLOWS ----------------------------
  116. END