# Appendix DProblem 5.7 Local Solvers

## D.1 DTD3M,DTD3N,DCG (problem57.f)

````- - - - - - DTD3M - - - - - - - - - - - -`

`      SUBROUTINE DTD3M(N,NZ,IR,IC,A,B,JOB,SPD)`
`      IMPLICIT DOUBLE PRECISION (A-H,O-Z)`
`      DIMENSION IR(NZ),IC(NZ),A(NZ),B(N)`
`      LOGICAL SPD`
`      COMMON /DTDP27/ ITASK,NPES,ICOMM`
`C`
`C  DTD3M IS A LOCALLY-WRITTEN CODE WHICH SOLVES A SPARSE SYMMETRIC`
`C  LINEAR SYSTEM A*X=B.  IT WILL BE CALLED WHEN ISOLVE=5 FOR A SYMMETRIC`
`C  2D GALERKIN PROBLEM, AND WHEN ISOLVE=4 FOR A 2D OR 3D COLLOCATION PROBLEM.`
`C  IF YOU ACTIVATE DTD3M,DTD3N, YOU SHOULD ALSO INCREASE ISMX2D AND ISMX3D TO`
`C  AT LEAST 5 IN THE FILE 'pde2d.f'.`
`C`
`C  N  - NUMBER OF EQUATIONS AND UNKNOWNS (INPUT)`
`C  NZ - NUMBER OF NONZEROS IN THE UPPER TRIANGLE OF A (INPUT)`
`C  IR - ROW NUMBERS OF THE NONZEROS IN THE UPPER TRIANGLE OF A (INPUT)`
`C  IC - COLUMN NUMBERS OF THE NONZEROS IN THE UPPER TRIANGLE OF A (INPUT)`
`C  A  - NONZERO ELEMENTS OF THE UPPER TRIANGLE OF A (INPUT).  A(J)`
`C         CONTAINS ELEMENT (IR(J),IC(J)), J=1,...,NZ, OF THE MATRIX,`
`C         WHERE IC(J).GE.IR(J).`
`C  B  - ON INPUT, B WILL CONTAIN THE RIGHT HAND SIDE OF THE LINEAR`
`C         SYSTEM.  ON OUTPUT, B SHOULD CONTAIN THE SOLUTION, X.`
`C  JOB- JOB PARAMETER (INPUT).  IF JOB=2, THIS MEANS THAT THE MATRIX`
`C         A HAS CHANGED SINCE THE LAST CALL TO DTD3M, WHILE JOB=3 MEANS`
`C         A HAS NOT CHANGED.  THUS, IF YOU WISH, YOU CAN COMPUTE AN LU`
`C         DECOMPOSITION OF A WHEN JOB=2 AND SAVE IT, AND USE THIS`
`C         DECOMPOSITION TO SOLVE THE SYSTEM MORE RAPIDLY, WHEN JOB=3.`
`C SPD- .TRUE. IF LINEAR SYSTEM IS POSITIVE DEFINITE. (INPUT) ...````

Get Solving Partial Differential Equation Applications with PDE2D now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.