*DECK SSDOMN SUBROUTINE SSDOMN (N, B, X, NELT, IA, JA, A, ISYM, NSAVE, ITOL, + TOL, ITMAX, ITER, ERR, IERR, IUNIT, RWORK, LENW, IWORK, LENIW) C***BEGIN PROLOGUE SSDOMN C***PURPOSE Diagonally Scaled Orthomin Sparse Iterative Ax=b Solver. C Routine to solve a general linear system Ax = b using C the Orthomin method with diagonal scaling. C***LIBRARY SLATEC (SLAP) C***CATEGORY D2A4, D2B4 C***TYPE SINGLE PRECISION (SSDOMN-S, DSDOMN-D) C***KEYWORDS ITERATIVE PRECONDITION, NON-SYMMETRIC LINEAR SYSTEM SOLVE, C SLAP, SPARSE C***AUTHOR Greenbaum, Anne, (Courant Institute) C Seager, Mark K., (LLNL) C Lawrence Livermore National Laboratory C PO BOX 808, L-60 C Livermore, CA 94550 (510) 423-3141 C seager@llnl.gov C***DESCRIPTION C C *Usage: C INTEGER N, NELT, IA(NELT), JA(NELT), ISYM, NSAVE, ITOL, ITMAX C INTEGER ITER, IERR, IUNIT, LENW, IWORK(10), LENIW C REAL B(N), X(N), A(NELT), TOL, ERR C REAL RWORK(7*N+3*N*NSAVE+NSAVE) C C CALL SSDOMN(N, B, X, NELT, IA, JA, A, ISYM, NSAVE, ITOL, TOL, C $ ITMAX, ITER, ERR, IERR, IUNIT, RWORK, LENW, IWORK, LENIW ) C C *Arguments: C N :IN Integer. C Order of the Matrix. C B :IN Real B(N). C Right-hand side vector. C X :INOUT Real X(N). C On input X is your initial guess for solution vector. C On output X is the final approximate solution. C NELT :IN Integer. C Number of Non-Zeros stored in A. C IA :IN Integer IA(NELT). C JA :IN Integer JA(NELT). C A :IN Real A(NELT). C These arrays should hold the matrix A in either the SLAP C Triad format or the SLAP Column format. See "Description", C below. If the SLAP Triad format is chosen, it is changed C internally to the SLAP Column format. C ISYM :IN Integer. C Flag to indicate symmetric storage format. C If ISYM=0, all non-zero entries of the matrix are stored. C If ISYM=1, the matrix is symmetric, and only the upper C or lower triangle of the matrix is stored. C NSAVE :IN Integer. C Number of direction vectors to save and orthogonalize against. C ITOL :IN Integer. C Flag to indicate type of convergence criterion. C If ITOL=1, iteration stops when the 2-norm of the residual C divided by the 2-norm of the right-hand side is less than TOL. C If ITOL=2, iteration stops when the 2-norm of M-inv times the C residual divided by the 2-norm of M-inv times the right hand C side is less than TOL, where M-inv is the inverse of the C diagonal of A. C ITOL=11 is often useful for checking and comparing different C routines. For this case, the user must supply the "exact" C solution or a very accurate approximation (one with an error C much less than TOL) through a common block, C COMMON /SSLBLK/ SOLN( ) C If ITOL=11, iteration stops when the 2-norm of the difference C between the iterative approximation and the user-supplied C solution divided by the 2-norm of the user-supplied solution C is less than TOL. C TOL :INOUT Real. C Convergence criterion, as described above. (Reset if IERR=4.) C ITMAX :IN Integer. C Maximum number of iterations. C ITER :OUT Integer. C Number of iterations required to reach convergence, or C ITMAX+1 if convergence criterion could not be achieved in C ITMAX iterations. C ERR :OUT Real. C Error estimate of error in final approximate solution, as C defined by ITOL. C IERR :OUT Integer. C Return error flag. C IERR = 0 => All went well. C IERR = 1 => Insufficient space allocated for WORK or IWORK. C IERR = 2 => Method failed to converge in ITMAX steps. C IERR = 3 => Error in user input. C Check input values of N, ITOL. C IERR = 4 => User error tolerance set too tight. C Reset to 500*R1MACH(3). Iteration proceeded. C IERR = 5 => Preconditioning matrix, M, is not positive C definite. (r,z) < 0. C IERR = 6 => Breakdown of method detected. C (p,Ap) < epsilon**2. C IUNIT :IN Integer. C Unit number on which to write the error at each iteration, C if this is desired for monitoring convergence. If unit C number is 0, no writing will occur. C RWORK :WORK Real RWORK(LENW). C Real array used for workspace. C LENW :IN Integer. C Length of the real workspace, RWORK. C LENW >= 7*N+NSAVE*(3*N+1). C IWORK :WORK Integer IWORK(LENIW). C Used to hold pointers into the RWORK array. C LENIW :IN Integer. C Length of the integer workspace, IWORK. LENIW >= 10. C C *Description: C This routine is simply a driver for the SOMN routine. It C calls the SSDS routine to set up the preconditioning and C then calls SOMN with the appropriate MATVEC and MSOLVE C routines. C C The Sparse Linear Algebra Package (SLAP) utilizes two matrix C data structures: 1) the SLAP Triad format or 2) the SLAP C Column format. The user can hand this routine either of the C of these data structures and SLAP will figure out which on C is being used and act accordingly. C C =================== S L A P Triad format =================== C C In this format only the non-zeros are stored. They may C appear in *ANY* order. The user supplies three arrays of C length NELT, where NELT is the number of non-zeros in the C matrix: (IA(NELT), JA(NELT), A(NELT)). For each non-zero C the user puts the row and column index of that matrix C element in the IA and JA arrays. The value of the non-zero C matrix element is placed in the corresponding location of C the A array. This is an extremely easy data structure to C generate. On the other hand it is not too efficient on C vector computers for the iterative solution of linear C systems. Hence, SLAP changes this input data structure to C the SLAP Column format for the iteration (but does not C change it back). C C Here is an example of the SLAP Triad storage format for a C 5x5 Matrix. Recall that the entries may appear in any order. C C 5x5 Matrix SLAP Triad format for 5x5 matrix on left. C 1 2 3 4 5 6 7 8 9 10 11 C |11 12 0 0 15| A: 51 12 11 33 15 53 55 22 35 44 21 C |21 22 0 0 0| IA: 5 1 1 3 1 5 5 2 3 4 2 C | 0 0 33 0 35| JA: 1 2 1 3 5 3 5 2 5 4 1 C | 0 0 0 44 0| C |51 0 53 0 55| C C =================== S L A P Column format ================== C C In this format the non-zeros are stored counting down C columns (except for the diagonal entry, which must appear C first in each "column") and are stored in the real array A. C In other words, for each column in the matrix put the C diagonal entry in A. Then put in the other non-zero C elements going down the column (except the diagonal) in C order. The IA array holds the row index for each non-zero. C The JA array holds the offsets into the IA, A arrays for the C beginning of each column. That is, IA(JA(ICOL)), C A(JA(ICOL)) points to the beginning of the ICOL-th column in C IA and A. IA(JA(ICOL+1)-1), A(JA(ICOL+1)-1) points to the C end of the ICOL-th column. Note that we always have JA(N+1) C = NELT+1, where N is the number of columns in the matrix and C NELT is the number of non-zeros in the matrix. C C Here is an example of the SLAP Column storage format for a C 5x5 Matrix (in the A and IA arrays '|' denotes the end of a C column): C C 5x5 Matrix SLAP Column format for 5x5 matrix on left. C 1 2 3 4 5 6 7 8 9 10 11 C |11 12 0 0 15| A: 11 21 51 | 22 12 | 33 53 | 44 | 55 15 35 C |21 22 0 0 0| IA: 1 2 5 | 2 1 | 3 5 | 4 | 5 1 3 C | 0 0 33 0 35| JA: 1 4 6 8 9 12 C | 0 0 0 44 0| C |51 0 53 0 55| C C *Side Effects: C The SLAP Triad format (IA, JA, A) is modified internally to C be the SLAP Column format. See above. C C *Cautions: C This routine will attempt to write to the Fortran logical output C unit IUNIT, if IUNIT .ne. 0. Thus, the user must make sure that C this logical unit is attached to a file or terminal before calling C this routine with a non-zero value for IUNIT. This routine does C not check for the validity of a non-zero IUNIT unit number. C C***SEE ALSO SOMN, SSLUOM C***REFERENCES (NONE) C***ROUTINES CALLED SCHKW, SOMN, SS2Y, SSDI, SSDS, SSMV C***REVISION HISTORY (YYMMDD) C 871119 DATE WRITTEN C 881213 Previous REVISION DATE C 890915 Made changes requested at July 1989 CML Meeting. (MKS) C 890921 Removed TeX from comments. (FNF) C 890922 Numerous changes to prologue to make closer to SLATEC C standard. (FNF) C 890929 Numerous changes to reduce SP/DP differences. (FNF) C 910411 Prologue converted to Version 4.0 format. (BAB) C 920407 COMMON BLOCK renamed SSLBLK. (WRB) C 920511 Added complete declaration section. (WRB) C 921113 Corrected C***CATEGORY line. (FNF) C***END PROLOGUE SSDOMN