stout.f 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. *DECK STOUT
  2. SUBROUTINE STOUT (N, NELT, IA, JA, A, ISYM, SOLN, RHS, IUNIT, JOB)
  3. C***BEGIN PROLOGUE STOUT
  4. C***PURPOSE Write out SLAP Triad Format Linear System.
  5. C Routine to write out a SLAP Triad format matrix and right
  6. C hand side and solution to the system, if known.
  7. C***LIBRARY SLATEC (SLAP)
  8. C***CATEGORY N1
  9. C***TYPE SINGLE PRECISION (STOUT-S, DTOUT-D)
  10. C***KEYWORDS DIAGNOSTICS, LINEAR SYSTEM, SLAP SPARSE
  11. C***AUTHOR Seager, Mark K., (LLNL)
  12. C Lawrence Livermore National Laboratory
  13. C PO BOX 808, L-60
  14. C Livermore, CA 94550 (510) 423-3141
  15. C seager@llnl.gov
  16. C***DESCRIPTION
  17. C
  18. C *Usage:
  19. C INTEGER N, NELT, IA(NELT), JA(NELT), ISYM, IUNIT, JOB
  20. C REAL A(NELT), SOLN(N), RHS(N)
  21. C
  22. C CALL STOUT( N, NELT, IA, JA, A, ISYM, SOLN, RHS, IUNIT, JOB )
  23. C
  24. C *Arguments:
  25. C N :IN Integer
  26. C Order of the Matrix.
  27. C NELT :IN Integer.
  28. C Number of non-zeros stored in A.
  29. C IA :IN Integer IA(NELT).
  30. C JA :IN Integer JA(NELT).
  31. C A :IN Real A(NELT).
  32. C These arrays should hold the matrix A in the SLAP
  33. C Triad format. See "Description", below.
  34. C ISYM :IN Integer.
  35. C Flag to indicate symmetric storage format.
  36. C If ISYM=0, all non-zero entries of the matrix are stored.
  37. C If ISYM=1, the matrix is symmetric, and only the lower
  38. C triangle of the matrix is stored.
  39. C SOLN :IN Real SOLN(N).
  40. C The solution to the linear system, if known. This array
  41. C is accessed if and only if JOB is set to print it out,
  42. C see below.
  43. C RHS :IN Real RHS(N).
  44. C The right hand side vector. This array is accessed if and
  45. C only if JOB is set to print it out, see below.
  46. C IUNIT :IN Integer.
  47. C Fortran logical I/O device unit number to write the matrix
  48. C to. This unit must be connected in a system dependent fashion
  49. C to a file or the console or you will get a nasty message
  50. C from the Fortran I/O libraries.
  51. C JOB :IN Integer.
  52. C Flag indicating what I/O operations to perform.
  53. C JOB = 0 => Print only the matrix.
  54. C = 1 => Print matrix and RHS.
  55. C = 2 => Print matrix and SOLN.
  56. C = 3 => Print matrix, RHS and SOLN.
  57. C
  58. C *Description:
  59. C The format for the output is as follows. On the first line
  60. C are counters and flags: N, NELT, ISYM, IRHS, ISOLN. N, NELT
  61. C and ISYM are described above. IRHS is a flag indicating if
  62. C the RHS was written out (1 is yes, 0 is no). ISOLN is a
  63. C flag indicating if the SOLN was written out (1 is yes, 0 is
  64. C no). The format for the fist line is: 5i10. Then comes the
  65. C NELT Triad's IA(I), JA(I) and A(I), I = 1, NELT. The format
  66. C for these lines is : 1X,I5,1X,I5,1X,E16.7. Then comes
  67. C RHS(I), I = 1, N, if IRHS = 1. Then comes SOLN(I), I = 1,
  68. C N, if ISOLN = 1. The format for these lines is: 1X,E16.7.
  69. C
  70. C =================== S L A P Triad format ===================
  71. C This routine requires that the matrix A be stored in the
  72. C SLAP Triad format. In this format only the non-zeros are
  73. C stored. They may appear in *ANY* order. The user supplies
  74. C three arrays of length NELT, where NELT is the number of
  75. C non-zeros in the matrix: (IA(NELT), JA(NELT), A(NELT)). For
  76. C each non-zero the user puts the row and column index of that
  77. C matrix element in the IA and JA arrays. The value of the
  78. C non-zero matrix element is placed in the corresponding
  79. C location of the A array. This is an extremely easy data
  80. C structure to generate. On the other hand it is not too
  81. C efficient on vector computers for the iterative solution of
  82. C linear systems. Hence, SLAP changes this input data
  83. C structure to the SLAP Column format for the iteration (but
  84. C does not change it back).
  85. C
  86. C Here is an example of the SLAP Triad storage format for a
  87. C 5x5 Matrix. Recall that the entries may appear in any order.
  88. C
  89. C 5x5 Matrix SLAP Triad format for 5x5 matrix on left.
  90. C 1 2 3 4 5 6 7 8 9 10 11
  91. C |11 12 0 0 15| A: 51 12 11 33 15 53 55 22 35 44 21
  92. C |21 22 0 0 0| IA: 5 1 1 3 1 5 5 2 3 4 2
  93. C | 0 0 33 0 35| JA: 1 2 1 3 5 3 5 2 5 4 1
  94. C | 0 0 0 44 0|
  95. C |51 0 53 0 55|
  96. C
  97. C *Cautions:
  98. C This routine will attempt to write to the Fortran logical output
  99. C unit IUNIT, if IUNIT .ne. 0. Thus, the user must make sure that
  100. C this logical unit is attached to a file or terminal before calling
  101. C this routine with a non-zero value for IUNIT. This routine does
  102. C not check for the validity of a non-zero IUNIT unit number.
  103. C***REFERENCES (NONE)
  104. C***ROUTINES CALLED (NONE)
  105. C***REVISION HISTORY (YYMMDD)
  106. C 871119 DATE WRITTEN
  107. C 881213 Previous REVISION DATE
  108. C 890915 Made changes requested at July 1989 CML Meeting. (MKS)
  109. C 890922 Numerous changes to prologue to make closer to SLATEC
  110. C standard. (FNF)
  111. C 890929 Numerous changes to reduce SP/DP differences. (FNF)
  112. C 910411 Prologue converted to Version 4.0 format. (BAB)
  113. C 920511 Added complete declaration section. (WRB)
  114. C 930701 Updated CATEGORY section. (FNF, WRB)
  115. C***END PROLOGUE STOUT
  116. C .. Scalar Arguments ..
  117. INTEGER ISYM, IUNIT, JOB, N, NELT
  118. C .. Array Arguments ..
  119. REAL A(NELT), RHS(N), SOLN(N)
  120. INTEGER IA(NELT), JA(NELT)
  121. C .. Local Scalars ..
  122. INTEGER I, IRHS, ISOLN
  123. C***FIRST EXECUTABLE STATEMENT STOUT
  124. C
  125. C If RHS and SOLN are to be printed also.
  126. C Write out the information heading.
  127. C
  128. IRHS = 0
  129. ISOLN = 0
  130. IF( JOB.EQ.1 .OR. JOB.EQ.3 ) IRHS = 1
  131. IF( JOB.GT.1 ) ISOLN = 1
  132. WRITE(IUNIT,1000) N, NELT, ISYM, IRHS, ISOLN
  133. C
  134. C Write out the matrix non-zeros in Triad format.
  135. DO 10 I = 1, NELT
  136. WRITE(IUNIT,1010) IA(I), JA(I), A(I)
  137. 10 CONTINUE
  138. C
  139. C If requested, write out the rhs.
  140. IF( IRHS.EQ.1 ) THEN
  141. WRITE(IUNIT,1020) (RHS(I),I=1,N)
  142. ENDIF
  143. C
  144. C If requested, write out the solution.
  145. IF( ISOLN.EQ.1 ) THEN
  146. WRITE(IUNIT,1020) (SOLN(I),I=1,N)
  147. ENDIF
  148. RETURN
  149. 1000 FORMAT(5I10)
  150. 1010 FORMAT(1X,I5,1X,I5,1X,E16.7)
  151. 1020 FORMAT(1X,E16.7)
  152. C------------- LAST LINE OF STOUT FOLLOWS ----------------------------
  153. END