dsds.f 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. *DECK DSDS
  2. SUBROUTINE DSDS (N, NELT, IA, JA, A, ISYM, DINV)
  3. C***BEGIN PROLOGUE DSDS
  4. C***PURPOSE Diagonal Scaling Preconditioner SLAP Set Up.
  5. C Routine to compute the inverse of the diagonal of a matrix
  6. C stored in the SLAP Column format.
  7. C***LIBRARY SLATEC (SLAP)
  8. C***CATEGORY D2E
  9. C***TYPE DOUBLE PRECISION (SSDS-S, DSDS-D)
  10. C***KEYWORDS DIAGONAL, SLAP SPARSE
  11. C***AUTHOR Greenbaum, Anne, (Courant Institute)
  12. C Seager, Mark K., (LLNL)
  13. C Lawrence Livermore National Laboratory
  14. C PO BOX 808, L-60
  15. C Livermore, CA 94550 (510) 423-3141
  16. C seager@llnl.gov
  17. C***DESCRIPTION
  18. C
  19. C *Usage:
  20. C INTEGER N, NELT, IA(NELT), JA(NELT), ISYM
  21. C DOUBLE PRECISION A(NELT), DINV(N)
  22. C
  23. C CALL DSDS( N, NELT, IA, JA, A, ISYM, DINV )
  24. C
  25. C *Arguments:
  26. C N :IN Integer.
  27. C Order of the Matrix.
  28. C NELT :IN Integer.
  29. C Number of elements in arrays IA, JA, and A.
  30. C IA :INOUT Integer IA(NELT).
  31. C JA :INOUT Integer JA(NELT).
  32. C A :INOUT Double Precision A(NELT).
  33. C These arrays should hold the matrix A in the SLAP Column
  34. C format. See "Description", below.
  35. C ISYM :IN Integer.
  36. C Flag to indicate symmetric storage format.
  37. C If ISYM=0, all non-zero entries of the matrix are stored.
  38. C If ISYM=1, the matrix is symmetric, and only the upper
  39. C or lower triangle of the matrix is stored.
  40. C DINV :OUT Double Precision DINV(N).
  41. C Upon return this array holds 1./DIAG(A).
  42. C
  43. C *Description
  44. C =================== S L A P Column format ==================
  45. C This routine requires that the matrix A be stored in the
  46. C SLAP Column format. In this format the non-zeros are stored
  47. C counting down columns (except for the diagonal entry, which
  48. C must appear first in each "column") and are stored in the
  49. C double precision array A. In other words, for each column
  50. C in the matrix put the diagonal entry in A. Then put in the
  51. C other non-zero elements going down the column (except the
  52. C diagonal) in order. The IA array holds the row index for
  53. C each non-zero. The JA array holds the offsets into the IA,
  54. C A arrays for the beginning of each column. That is,
  55. C IA(JA(ICOL)), A(JA(ICOL)) points to the beginning of the
  56. C ICOL-th column in IA and A. IA(JA(ICOL+1)-1),
  57. C A(JA(ICOL+1)-1) points to the end of the ICOL-th column.
  58. C Note that we always have JA(N+1) = NELT+1, where N is the
  59. C number of columns in the matrix and NELT is the number of
  60. C non-zeros in the matrix.
  61. C
  62. C Here is an example of the SLAP Column storage format for a
  63. C 5x5 Matrix (in the A and IA arrays '|' denotes the end of a
  64. C column):
  65. C
  66. C 5x5 Matrix SLAP Column format for 5x5 matrix on left.
  67. C 1 2 3 4 5 6 7 8 9 10 11
  68. C |11 12 0 0 15| A: 11 21 51 | 22 12 | 33 53 | 44 | 55 15 35
  69. C |21 22 0 0 0| IA: 1 2 5 | 2 1 | 3 5 | 4 | 5 1 3
  70. C | 0 0 33 0 35| JA: 1 4 6 8 9 12
  71. C | 0 0 0 44 0|
  72. C |51 0 53 0 55|
  73. C
  74. C With the SLAP format all of the "inner loops" of this
  75. C routine should vectorize on machines with hardware support
  76. C for vector gather/scatter operations. Your compiler may
  77. C require a compiler directive to convince it that there are
  78. C no implicit vector dependencies. Compiler directives for
  79. C the Alliant FX/Fortran and CRI CFT/CFT77 compilers are
  80. C supplied with the standard SLAP distribution.
  81. C
  82. C
  83. C *Cautions:
  84. C This routine assumes that the diagonal of A is all non-zero
  85. C and that the operation DINV = 1.0/DIAG(A) will not underflow
  86. C or overflow. This is done so that the loop vectorizes.
  87. C Matrices with zero or near zero or very large entries will
  88. C have numerical difficulties and must be fixed before this
  89. C routine is called.
  90. C***REFERENCES (NONE)
  91. C***ROUTINES CALLED (NONE)
  92. C***REVISION HISTORY (YYMMDD)
  93. C 890404 DATE WRITTEN
  94. C 890404 Previous REVISION DATE
  95. C 890915 Made changes requested at July 1989 CML Meeting. (MKS)
  96. C 890922 Numerous changes to prologue to make closer to SLATEC
  97. C standard. (FNF)
  98. C 890929 Numerous changes to reduce SP/DP differences. (FNF)
  99. C 910411 Prologue converted to Version 4.0 format. (BAB)
  100. C 920511 Added complete declaration section. (WRB)
  101. C 930701 Updated CATEGORY section. (FNF, WRB)
  102. C***END PROLOGUE DSDS
  103. C .. Scalar Arguments ..
  104. INTEGER ISYM, N, NELT
  105. C .. Array Arguments ..
  106. DOUBLE PRECISION A(NELT), DINV(N)
  107. INTEGER IA(NELT), JA(NELT)
  108. C .. Local Scalars ..
  109. INTEGER ICOL
  110. C***FIRST EXECUTABLE STATEMENT DSDS
  111. C
  112. C Assume the Diagonal elements are the first in each column.
  113. C This loop should *VECTORIZE*. If it does not you may have
  114. C to add a compiler directive. We do not check for a zero
  115. C (or near zero) diagonal element since this would interfere
  116. C with vectorization. If this makes you nervous put a check
  117. C in! It will run much slower.
  118. C
  119. DO 10 ICOL = 1, N
  120. DINV(ICOL) = 1.0D0/A(JA(ICOL))
  121. 10 CONTINUE
  122. C
  123. RETURN
  124. C------------- LAST LINE OF DSDS FOLLOWS ----------------------------
  125. END