CalculiX  2.13
A Free Software Three-Dimensional Structural Finite Element Program
dir.f File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine dir (N, B, X, NELT, IA, JA, A, ISYM, MATVEC, MSOLVE, ITOL, TOL, ITMAX, ITER, ERR, IERR, IUNIT, R, Z, DZ, RWORK, IWORK)
 
integer function isdir (N, B, X, NELT, IA, JA, A, ISYM, MSOLVE, ITOL, TOL, ITMAX, ITER, ERR, IERR, IUNIT, R, Z, DZ, RWORK, IWORK, BNRM, SOLNRM)
 

Function/Subroutine Documentation

◆ dir()

subroutine dir ( integer  N,
double precision, dimension(n)  B,
double precision, dimension(n)  X,
integer  NELT,
integer, dimension(nelt)  IA,
integer, dimension(nelt)  JA,
double precision, dimension(nelt)  A,
integer  ISYM,
external  MATVEC,
external  MSOLVE,
integer  ITOL,
double precision  TOL,
integer  ITMAX,
integer  ITER,
double precision  ERR,
integer  IERR,
integer  IUNIT,
double precision, dimension(n)  R,
double precision, dimension(n)  Z,
double precision, dimension(n)  DZ,
double precision, dimension(*)  RWORK,
integer, dimension(*)  IWORK 
)
5 C***BEGIN PROLOGUE DIR
6 C***PURPOSE Preconditioned Iterative Refinement Sparse Ax = b Solver.
7 C Routine to solve a general linear system Ax = b using
8 C iterative refinement with a matrix splitting.
9 C***LIBRARY SLATEC (SLAP)
10 C***CATEGORY D2A4, D2B4
11 C***TYPE DOUBLE PRECISION (SIR-S, DIR-D)
12 C***KEYWORDS ITERATIVE PRECONDITION, LINEAR SYSTEM, SLAP, SPARSE
13 C***AUTHOR Greenbaum, Anne, (Courant Institute)
14 C Seager, Mark K., (LLNL)
15 C Lawrence Livermore National Laboratory
16 C PO BOX 808, L-60
17 C Livermore, CA 94550 (510) 423-3141
18 C seager@llnl.gov
19 C***DESCRIPTION
20 C
21 C *Usage:
22 C INTEGER N, NELT, IA(NELT), JA(NELT), ISYM, ITOL, ITMAX
23 C INTEGER ITER, IERR, IUNIT, IWORK(USER DEFINED)
24 C DOUBLE PRECISION B(N), X(N), A(NELT), TOL, ERR, R(N), Z(N), DZ(N)
25 C DOUBLE PRECISION RWORK(USER DEFINED)
26 C EXTERNAL MATVEC, MSOLVE
27 C
28 C CALL DIR(N, B, X, NELT, IA, JA, A, ISYM, MATVEC, MSOLVE, ITOL,
29 C $ TOL, ITMAX, ITER, ERR, IERR, IUNIT, R, Z, DZ, RWORK, IWORK)
30 C
31 C *Arguments:
32 C N :IN Integer.
33 C Order of the Matrix.
34 C B :IN Double Precision B(N).
35 C Right-hand side vector.
36 C X :INOUT Double Precision X(N).
37 C On input X is your initial guess for solution vector.
38 C On output X is the final approximate solution.
39 C NELT :IN Integer.
40 C Number of Non-Zeros stored in A.
41 C IA :IN Integer IA(NELT).
42 C JA :IN Integer JA(NELT).
43 C A :IN Double Precision A(NELT).
44 C These arrays contain the matrix data structure for A.
45 C It could take any form. See "Description", below,
46 C for more details.
47 C ISYM :IN Integer.
48 C Flag to indicate symmetric storage format.
49 C If ISYM=0, all non-zero entries of the matrix are stored.
50 C If ISYM=1, the matrix is symmetric, and only the upper
51 C or lower triangle of the matrix is stored.
52 C MATVEC :EXT External.
53 C Name of a routine which performs the matrix vector multiply
54 C Y = A*X given A and X. The name of the MATVEC routine must
55 C be declared external in the calling program. The calling
56 C sequence to MATVEC is:
57 C CALL MATVEC( N, X, Y, NELT, IA, JA, A, ISYM )
58 C Where N is the number of unknowns, Y is the product A*X
59 C upon return, X is an input vector, NELT is the number of
60 C non-zeros in the SLAP IA, JA, A storage for the matrix A.
61 C ISYM is a flag which, if non-zero, denotes that A is
62 C symmetric and only the lower or upper triangle is stored.
63 C MSOLVE :EXT External.
64 C Name of a routine which solves a linear system MZ = R for
65 C Z given R with the preconditioning matrix M (M is supplied via
66 C RWORK and IWORK arrays). The name of the MSOLVE routine must
67 C be declared external in the calling program. The calling
68 C sequence to MSOLVE is:
69 C CALL MSOLVE(N, R, Z, NELT, IA, JA, A, ISYM, RWORK, IWORK)
70 C Where N is the number of unknowns, R is the right-hand side
71 C vector and Z is the solution upon return. NELT, IA, JA, A and
72 C ISYM are defined as above. RWORK is a double precision array
73 C that can be used to pass necessary preconditioning information
74 C and/or workspace to MSOLVE. IWORK is an integer work array
75 C for the same purpose as RWORK.
76 C ITOL :IN Integer.
77 C Flag to indicate type of convergence criterion.
78 C If ITOL=1, iteration stops when the 2-norm of the residual
79 C divided by the 2-norm of the right-hand side is less than TOL.
80 C If ITOL=2, iteration stops when the 2-norm of M-inv times the
81 C residual divided by the 2-norm of M-inv times the right hand
82 C side is less than TOL, where M-inv is the inverse of the
83 C diagonal of A.
84 C ITOL=11 is often useful for checking and comparing different
85 C routines. For this case, the user must supply the "exact"
86 C solution or a very accurate approximation (one with an error
87 C much less than TOL) through a common block,
88 C COMMON /DSLBLK/ SOLN( )
89 C If ITOL=11, iteration stops when the 2-norm of the difference
90 C between the iterative approximation and the user-supplied
91 C solution divided by the 2-norm of the user-supplied solution
92 C is less than TOL. Note that this requires the user to set up
93 C the "COMMON /DSLBLK/ SOLN(LENGTH)" in the calling routine.
94 C The routine with this declaration should be loaded before the
95 C stop test so that the correct length is used by the loader.
96 C This procedure is not standard Fortran and may not work
97 C correctly on your system (although it has worked on every
98 C system the authors have tried). If ITOL is not 11 then this
99 C common block is indeed standard Fortran.
100 C TOL :INOUT Double Precision.
101 C Convergence criterion, as described above. (Reset if IERR=4.)
102 C ITMAX :IN Integer.
103 C Maximum number of iterations.
104 C ITER :OUT Integer.
105 C Number of iterations required to reach convergence, or
106 C ITMAX+1 if convergence criterion could not be achieved in
107 C ITMAX iterations.
108 C ERR :OUT Double Precision.
109 C Error estimate of error in final approximate solution, as
110 C defined by ITOL.
111 C IERR :OUT Integer.
112 C Return error flag.
113 C IERR = 0 => All went well.
114 C IERR = 1 => Insufficient space allocated for WORK or IWORK.
115 C IERR = 2 => Method failed to converge in ITMAX steps.
116 C IERR = 3 => Error in user input.
117 C Check input values of N, ITOL.
118 C IERR = 4 => User error tolerance set too tight.
119 C Reset to 500*D1MACH(3). Iteration proceeded.
120 C IERR = 5 => Preconditioning matrix, M, is not positive
121 C definite. (r,z) < 0.
122 C IERR = 6 => Matrix A is not positive definite. (p,Ap) < 0.
123 C IUNIT :IN Integer.
124 C Unit number on which to write the error at each iteration,
125 C if this is desired for monitoring convergence. If unit
126 C number is 0, no writing will occur.
127 C R :WORK Double Precision R(N).
128 C Z :WORK Double Precision Z(N).
129 C DZ :WORK Double Precision DZ(N).
130 C Double Precision arrays used for workspace.
131 C RWORK :WORK Double Precision RWORK(USER DEFINED).
132 C Double Precision array that can be used by MSOLVE.
133 C IWORK :WORK Integer IWORK(USER DEFINED).
134 C Integer array that can be used by MSOLVE.
135 C
136 C *Description:
137 C The basic algorithm for iterative refinement (also known as
138 C iterative improvement) is:
139 C
140 C n+1 n -1 n
141 C X = X + M (B - AX ).
142 C
143 C -1 -1
144 C If M = A then this is the standard iterative refinement
145 C algorithm and the "subtraction" in the residual calculation
146 C should be done in double precision (which it is not in this
147 C routine).
148 C If M = DIAG(A), the diagonal of A, then iterative refinement
149 C is known as Jacobi's method. The SLAP routine DSJAC
150 C implements this iterative strategy.
151 C If M = L, the lower triangle of A, then iterative refinement
152 C is known as Gauss-Seidel. The SLAP routine DSGS implements
153 C this iterative strategy.
154 C
155 C This routine does not care what matrix data structure is
156 C used for A and M. It simply calls the MATVEC and MSOLVE
157 C routines, with the arguments as described above. The user
158 C could write any type of structure and the appropriate MATVEC
159 C and MSOLVE routines. It is assumed that A is stored in the
160 C IA, JA, A arrays in some fashion and that M (or INV(M)) is
161 C stored in IWORK and RWORK) in some fashion. The SLAP
162 C routines DSJAC and DSGS are examples of this procedure.
163 C
164 C Two examples of matrix data structures are the: 1) SLAP
165 C Triad format and 2) SLAP Column format.
166 C
167 C =================== S L A P Triad format ===================
168 C
169 C In this format only the non-zeros are stored. They may
170 C appear in *ANY* order. The user supplies three arrays of
171 C length NELT, where NELT is the number of non-zeros in the
172 C matrix: (IA(NELT), JA(NELT), A(NELT)). For each non-zero
173 C the user puts the row and column index of that matrix
174 C element in the IA and JA arrays. The value of the non-zero
175 C matrix element is placed in the corresponding location of
176 C the A array. This is an extremely easy data structure to
177 C generate. On the other hand it is not too efficient on
178 C vector computers for the iterative solution of linear
179 C systems. Hence, SLAP changes this input data structure to
180 C the SLAP Column format for the iteration (but does not
181 C change it back).
182 C
183 C Here is an example of the SLAP Triad storage format for a
184 C 5x5 Matrix. Recall that the entries may appear in any order.
185 C
186 C 5x5 Matrix SLAP Triad format for 5x5 matrix on left.
187 C 1 2 3 4 5 6 7 8 9 10 11
188 C |11 12 0 0 15| A: 51 12 11 33 15 53 55 22 35 44 21
189 C |21 22 0 0 0| IA: 5 1 1 3 1 5 5 2 3 4 2
190 C | 0 0 33 0 35| JA: 1 2 1 3 5 3 5 2 5 4 1
191 C | 0 0 0 44 0|
192 C |51 0 53 0 55|
193 C
194 C =================== S L A P Column format ==================
195 C
196 C In this format the non-zeros are stored counting down
197 C columns (except for the diagonal entry, which must appear
198 C first in each "column") and are stored in the double pre-
199 C cision array A. In other words, for each column in the
200 C matrix first put the diagonal entry in A. Then put in the
201 C other non-zero elements going down the column (except the
202 C diagonal) in order. The IA array holds the row index for
203 C each non-zero. The JA array holds the offsets into the IA,
204 C A arrays for the beginning of each column. That is,
205 C IA(JA(ICOL)),A(JA(ICOL)) are the first elements of the ICOL-
206 C th column in IA and A, and IA(JA(ICOL+1)-1), A(JA(ICOL+1)-1)
207 C are the last elements of the ICOL-th column. Note that we
208 C always have JA(N+1)=NELT+1, where N is the number of columns
209 C in the matrix and NELT is the number of non-zeros in the
210 C matrix.
211 C
212 C Here is an example of the SLAP Column storage format for a
213 C 5x5 Matrix (in the A and IA arrays '|' denotes the end of a
214 C column):
215 C
216 C 5x5 Matrix SLAP Column format for 5x5 matrix on left.
217 C 1 2 3 4 5 6 7 8 9 10 11
218 C |11 12 0 0 15| A: 11 21 51 | 22 12 | 33 53 | 44 | 55 15 35
219 C |21 22 0 0 0| IA: 1 2 5 | 2 1 | 3 5 | 4 | 5 1 3
220 C | 0 0 33 0 35| JA: 1 4 6 8 9 12
221 C | 0 0 0 44 0|
222 C |51 0 53 0 55|
223 C
224 C *Examples:
225 C See the SLAP routines DSJAC, DSGS
226 C
227 C *Cautions:
228 C This routine will attempt to write to the Fortran logical output
229 C unit IUNIT, if IUNIT .ne. 0. Thus, the user must make sure that
230 C this logical unit is attached to a file or terminal before calling
231 C this routine with a non-zero value for IUNIT. This routine does
232 C not check for the validity of a non-zero IUNIT unit number.
233 C
234 C***SEE ALSO DSJAC, DSGS
235 C***REFERENCES 1. Gene Golub and Charles Van Loan, Matrix Computations,
236 C Johns Hopkins University Press, Baltimore, Maryland,
237 C 1983.
238 C 2. Mark K. Seager, A SLAP for the Masses, in
239 C G. F. Carey, Ed., Parallel Supercomputing: Methods,
240 C Algorithms and Applications, Wiley, 1989, pp.135-155.
241 C***ROUTINES CALLED D1MACH, ISDIR
242 C***REVISION HISTORY (YYMMDD)
243 C 890404 DATE WRITTEN
244 C 890404 Previous REVISION DATE
245 C 890915 Made changes requested at July 1989 CML Meeting. (MKS)
246 C 890921 Removed TeX from comments. (FNF)
247 C 890922 Numerous changes to prologue to make closer to SLATEC
248 C standard. (FNF)
249 C 890929 Numerous changes to reduce SP/DP differences. (FNF)
250 C 891004 Added new reference.
251 C 910411 Prologue converted to Version 4.0 format. (BAB)
252 C 910502 Removed MATVEC and MSOLVE from ROUTINES CALLED list. (FNF)
253 C 920407 COMMON BLOCK renamed DSLBLK. (WRB)
254 C 920511 Added complete declaration section. (WRB)
255 C 920929 Corrected format of references. (FNF)
256 C 921019 Changed 500.0 to 500 to reduce SP/DP differences. (FNF)
257 C***END PROLOGUE DIR
258 C .. Scalar Arguments ..
259  DOUBLE PRECISION err, tol
260  INTEGER ierr, isym, iter, itmax, itol, iunit, n, nelt
261 C .. Array Arguments ..
262  DOUBLE PRECISION a(nelt), b(n), dz(n), r(n), rwork(*), x(n), z(n)
263  INTEGER ia(nelt), iwork(*), ja(nelt)
264 C .. Subroutine Arguments ..
265  EXTERNAL matvec, msolve
266 C .. Local Scalars ..
267  DOUBLE PRECISION bnrm, solnrm, tolmin
268  INTEGER i, k
269 C .. External Functions ..
270  DOUBLE PRECISION d1mach
271  INTEGER isdir
272  EXTERNAL d1mach, isdir
273 C***FIRST EXECUTABLE STATEMENT DIR
274 C
275 C Check some of the input data.
276 C
277  iter = 0
278  ierr = 0
279  IF( n.LT.1 ) THEN
280  ierr = 3
281  RETURN
282  ENDIF
283  tolmin = 500*d1mach(3)
284  IF( tol.LT.tolmin ) THEN
285  tol = tolmin
286  ierr = 4
287  ENDIF
288 C
289 C Calculate initial residual and pseudo-residual, and check
290 C stopping criterion.
291  CALL matvec(n, x, r, nelt, ia, ja, a, isym)
292  DO 10 i = 1, n
293  r(i) = b(i) - r(i)
294  10 CONTINUE
295  CALL msolve(n, r, z, nelt, ia, ja, a, isym, rwork, iwork)
296 C
297  IF( isdir(n, b, x, nelt, ia, ja, a, isym, msolve, itol, tol,
298  $ itmax, iter, err, ierr, iunit, r, z, dz, rwork,
299  $ iwork, bnrm, solnrm) .NE. 0 ) GO TO 200
300  IF( ierr.NE.0 ) RETURN
301 C
302 C ***** iteration loop *****
303 C
304  DO 100 k=1,itmax
305  iter = k
306 C
307 C Calculate new iterate x, new residual r, and new
308 C pseudo-residual z.
309  DO 20 i = 1, n
310  x(i) = x(i) + z(i)
311  20 CONTINUE
312  CALL matvec(n, x, r, nelt, ia, ja, a, isym)
313  DO 30 i = 1, n
314  r(i) = b(i) - r(i)
315  30 CONTINUE
316  CALL msolve(n, r, z, nelt, ia, ja, a, isym, rwork, iwork)
317 C
318 C check stopping criterion.
319  IF( isdir(n, b, x, nelt, ia, ja, a, isym, msolve, itol, tol,
320  $ itmax, iter, err, ierr, iunit, r, z, dz, rwork,
321  $ iwork, bnrm, solnrm) .NE. 0 ) GO TO 200
322 C
323  100 CONTINUE
324 C
325 C ***** end of loop *****
326 C Stopping criterion not satisfied.
327  iter = itmax + 1
328  ierr = 2
329 C
330  200 RETURN
331 C------------- LAST LINE OF DIR FOLLOWS -------------------------------
subroutine matvec(n, x, y, nelt, ia, ja, a, isym)
Definition: matvec.f:27
double precision function d1mach(I)
Definition: ddeabm.f:2012
integer function isdir(N, B, X, NELT, IA, JA, A, ISYM, MSOLVE, ITOL, TOL, ITMAX, ITER, ERR, IERR, IUNIT, R, Z, DZ, RWORK, IWORK, BNRM, SOLNRM)
Definition: dir.f:337
subroutine msolve(n, r, z, nelt, ia, ja, a, isym, rwork, iwork)
Definition: msolve.f:22

◆ isdir()

integer function isdir ( integer  N,
double precision, dimension(n)  B,
double precision, dimension(n)  X,
integer  NELT,
integer, dimension(nelt)  IA,
integer, dimension(nelt)  JA,
double precision, dimension(nelt)  A,
integer  ISYM,
external  MSOLVE,
integer  ITOL,
double precision  TOL,
integer  ITMAX,
integer  ITER,
double precision  ERR,
integer  IERR,
integer  IUNIT,
double precision, dimension(n)  R,
double precision, dimension(n)  Z,
double precision, dimension(n)  DZ,
double precision, dimension(*)  RWORK,
integer, dimension(*)  IWORK,
double precision  BNRM,
double precision  SOLNRM 
)
337 C***BEGIN PROLOGUE ISDIR
338 C***SUBSIDIARY
339 C***PURPOSE Preconditioned Iterative Refinement Stop Test.
340 C This routine calculates the stop test for the iterative
341 C refinement iteration scheme. It returns a non-zero if the
342 C error estimate (the type of which is determined by ITOL)
343 C is less than the user specified tolerance TOL.
344 C***LIBRARY SLATEC (SLAP)
345 C***CATEGORY D2A4, D2B4
346 C***TYPE DOUBLE PRECISION (ISSIR-S, ISDIR-D)
347 C***KEYWORDS LINEAR SYSTEM, SLAP, SPARSE, STOP TEST
348 C***AUTHOR Greenbaum, Anne, (Courant Institute)
349 C Seager, Mark K., (LLNL)
350 C Lawrence Livermore National Laboratory
351 C PO BOX 808, L-60
352 C Livermore, CA 94550 (510) 423-3141
353 C seager@llnl.gov
354 C***DESCRIPTION
355 C
356 C *Usage:
357 C INTEGER N, NELT, IA(NELT), JA(NELT), ISYM, ITOL, ITMAX, ITER
358 C INTEGER IERR, IUNIT, IWORK(USER DEFINED)
359 C DOUBLE PRECISION B(N), X(N), A(N), TOL, ERR, R(N), Z(N), DZ(N)
360 C DOUBLE PRECISION RWORK(USER DEFINED), BNRM, SOLNRM
361 C EXTERNAL MSOLVE
362 C
363 C IF( ISDIR(N, B, X, NELT, IA, JA, A, ISYM, MSOLVE, ITOL, TOL,
364 C $ ITMAX, ITER, ERR, IERR, IUNIT, R, Z, DZ, RWORK, IWORK,
365 C $ BNRM, SOLNRM) .NE. 0 ) THEN ITERATION DONE
366 C
367 C *Arguments:
368 C N :IN Integer.
369 C Order of the Matrix.
370 C B :IN Double Precision B(N).
371 C Right-hand side vector.
372 C X :IN Double Precision X(N).
373 C The current approximate solution vector.
374 C NELT :IN Integer.
375 C Number of Non-Zeros stored in A.
376 C IA :IN Integer IA(NELT).
377 C JA :IN Integer JA(NELT).
378 C A :IN Double Precision A(NELT).
379 C These arrays contain the matrix data structure for A.
380 C It could take any form. See "C *Description" in the
381 C DIR routine.
382 C ISYM :IN Integer.
383 C Flag to indicate symmetric storage format.
384 C If ISYM=0, all non-zero entries of the matrix are stored.
385 C If ISYM=1, the matrix is symmetric, and only the upper
386 C or lower triangle of the matrix is stored.
387 C MSOLVE :EXT External.
388 C Name of a routine which solves a linear system Mz = r for
389 C z given r with the preconditioning matrix M (M is supplied via
390 C RWORK and IWORK arrays. The name of the MSOLVE routine must
391 C be declared external in the calling program. The calling
392 C sequence to MSOLVE is:
393 C CALL MSOLVE(N, R, Z, NELT, IA, JA, A, ISYM, RWORK, IWORK)
394 C Where N is the number of unknowns, R is the right-hand side
395 C vector and Z is the solution upon return. NELT, IA, JA, A and
396 C ISYM are defined as above. RWORK is a double precision array
397 C that can be used to pass necessary preconditioning information
398 C and/or workspace to MSOLVE. IWORK is an integer work array
399 C for the same purpose as RWORK.
400 C ITOL :IN Integer.
401 C Flag to indicate type of convergence criterion.
402 C If ITOL=1, iteration stops when the 2-norm of the residual
403 C divided by the 2-norm of the right-hand side is less than TOL.
404 C If ITOL=2, iteration stops when the 2-norm of M-inv times the
405 C residual divided by the 2-norm of M-inv times the right hand
406 C side is less than TOL, where M-inv is the inverse of the
407 C diagonal of A.
408 C ITOL=11 is often useful for checking and comparing different
409 C routines. For this case, the user must supply the "exact"
410 C solution or a very accurate approximation (one with an error
411 C much less than TOL) through a common block,
412 C COMMON /DSLBLK/ SOLN( )
413 C If ITOL=11, iteration stops when the 2-norm of the difference
414 C between the iterative approximation and the user-supplied
415 C solution divided by the 2-norm of the user-supplied solution
416 C is less than TOL. Note that this requires the user to set up
417 C the "COMMON /DSLBLK/ SOLN(LENGTH)" in the calling routine.
418 C The routine with this declaration should be loaded before the
419 C stop test so that the correct length is used by the loader.
420 C This procedure is not standard Fortran and may not work
421 C correctly on your system (although it has worked on every
422 C system the authors have tried). If ITOL is not 11 then this
423 C common block is indeed standard Fortran.
424 C TOL :IN Double Precision.
425 C Convergence criterion, as described above.
426 C ITMAX :IN Integer.
427 C Maximum number of iterations.
428 C ITER :IN Integer.
429 C Current iteration count. (Must be zero on first call.)
430 C ERR :OUT Double Precision.
431 C Error estimate of error in the X(N) approximate solution, as
432 C defined by ITOL.
433 C IERR :OUT Integer.
434 C Error flag. IERR is set to 3 if ITOL is not one of the
435 C acceptable values, see above.
436 C IUNIT :IN Integer.
437 C Unit number on which to write the error at each iteration,
438 C if this is desired for monitoring convergence. If unit
439 C number is 0, no writing will occur.
440 C R :IN Double Precision R(N).
441 C The residual R = B-AX.
442 C Z :WORK Double Precision Z(N).
443 C Workspace used to hold the pseudo-residual M z = r.
444 C DZ :WORK Double Precision DZ(N).
445 C Workspace used to hold temporary vector(s).
446 C RWORK :WORK Double Precision RWORK(USER DEFINED).
447 C Double Precision array that can be used by MSOLVE.
448 C IWORK :WORK Integer IWORK(USER DEFINED).
449 C Integer array that can be used by MSOLVE.
450 C BNRM :INOUT Double Precision.
451 C Norm of the right hand side. Type of norm depends on ITOL.
452 C Calculated only on the first call.
453 C SOLNRM :INOUT Double Precision.
454 C 2-Norm of the true solution, SOLN. Only computed and used
455 C if ITOL = 11.
456 C
457 C *Function Return Values:
458 C 0 : Error estimate (determined by ITOL) is *NOT* less than the
459 C specified tolerance, TOL. The iteration must continue.
460 C 1 : Error estimate (determined by ITOL) is less than the
461 C specified tolerance, TOL. The iteration can be considered
462 C complete.
463 C
464 C *Cautions:
465 C This routine will attempt to write to the Fortran logical output
466 C unit IUNIT, if IUNIT .ne. 0. Thus, the user must make sure that
467 C this logical unit is attached to a file or terminal before calling
468 C this routine with a non-zero value for IUNIT. This routine does
469 C not check for the validity of a non-zero IUNIT unit number.
470 C
471 C***SEE ALSO DIR, DSJAC, DSGS
472 C***ROUTINES CALLED D1MACH, DNRM2
473 C***COMMON BLOCKS DSLBLK
474 C***REVISION HISTORY (YYMMDD)
475 C 871119 DATE WRITTEN
476 C 880320 Previous REVISION DATE
477 C 890915 Made changes requested at July 1989 CML Meeting. (MKS)
478 C 890922 Numerous changes to prologue to make closer to SLATEC
479 C standard. (FNF)
480 C 890929 Numerous changes to reduce SP/DP differences. (FNF)
481 C 891003 Removed C***REFER TO line, per MKS.
482 C 910411 Prologue converted to Version 4.0 format. (BAB)
483 C 910502 Removed MSOLVE from ROUTINES CALLED list. (FNF)
484 C 910506 Made subsidiary to DIR. (FNF)
485 C 920407 COMMON BLOCK renamed DSLBLK. (WRB)
486 C 920511 Added complete declaration section. (WRB)
487 C 921026 Changed 1.0E10 to D1MACH(2) and corrected E to D in
488 C output format. (FNF)
489 C***END PROLOGUE ISDIR
490 C .. Scalar Arguments ..
491  DOUBLE PRECISION bnrm, err, solnrm, tol
492  INTEGER ierr, isym, iter, itmax, itol, iunit, n, nelt
493 C .. Array Arguments ..
494  DOUBLE PRECISION a(nelt), b(n), dz(n), r(n), rwork(*), x(n), z(n)
495  INTEGER ia(nelt), iwork(*), ja(nelt)
496 C .. Subroutine Arguments ..
497  EXTERNAL msolve
498 C .. Arrays in Common ..
499  DOUBLE PRECISION soln(1)
500 C .. Local Scalars ..
501  INTEGER i
502 C .. External Functions ..
503  DOUBLE PRECISION d1mach, dnrm2
504  EXTERNAL d1mach, dnrm2
505 C .. Common blocks ..
506  COMMON /dslblk/ soln
507 C***FIRST EXECUTABLE STATEMENT ISDIR
508  isdir = 0
509  IF( itol.EQ.1 ) THEN
510 C err = ||Residual||/||RightHandSide|| (2-Norms).
511  IF(iter .EQ. 0) bnrm = dnrm2(n, b, 1)
512  err = dnrm2(n, r, 1)/bnrm
513  ELSE IF( itol.EQ.2 ) THEN
514 C -1 -1
515 C err = ||M Residual||/||M RightHandSide|| (2-Norms).
516  IF(iter .EQ. 0) THEN
517  CALL msolve(n, b, dz, nelt, ia, ja, a, isym, rwork, iwork)
518  bnrm = dnrm2(n, dz, 1)
519  ENDIF
520  err = dnrm2(n, z, 1)/bnrm
521  ELSE IF( itol.EQ.11 ) THEN
522 C err = ||x-TrueSolution||/||TrueSolution|| (2-Norms).
523  IF( iter.EQ.0 ) solnrm = dnrm2(n, soln, 1)
524  DO 10 i = 1, n
525  dz(i) = x(i) - soln(i)
526  10 CONTINUE
527  err = dnrm2(n, dz, 1)/solnrm
528  ELSE
529 C
530 C If we get here ITOL is not one of the acceptable values.
531  err = d1mach(2)
532  ierr = 3
533  ENDIF
534 C
535  IF( iunit.NE.0 ) THEN
536  WRITE(iunit,1000) iter,err
537  ENDIF
538 C
539  IF( err.LE.tol ) isdir = 1
540 C
541  RETURN
542  1000 FORMAT(5x,'ITER = ',i4,' Error Estimate = ',d16.7)
543 C------------- LAST LINE OF ISDIR FOLLOWS -----------------------------
double precision function d1mach(I)
Definition: ddeabm.f:2012
double precision function dnrm2(N, DX, INCX)
Definition: dgmres.f:559
integer function isdir(N, B, X, NELT, IA, JA, A, ISYM, MSOLVE, ITOL, TOL, ITMAX, ITER, ERR, IERR, IUNIT, R, Z, DZ, RWORK, IWORK, BNRM, SOLNRM)
Definition: dir.f:337
subroutine msolve(n, r, z, nelt, ia, ja, a, isym, rwork, iwork)
Definition: msolve.f:22
Hosted by OpenAircraft.com, (Michigan UAV, LLC)