2 SUBROUTINE DPJIBT
(NEQ
, Y
, YH
, NYH
, EWT
, RTEM
, SAVR
, S
, WM
, IWM
,
4 EXTERNAL RES
, JAC
, ADDA
6 DOUBLE PRECISION Y
, YH
, EWT
, RTEM
, SAVR
, S
, WM
7 DIMENSION NEQ
(*), Y
(*), YH
(NYH
,*), EWT
(*), RTEM
(*),
8 1 S
(*), SAVR
(*), WM
(*), IWM
(*)
10 1 ICF
, IERPJ
, IERSL
, JCUR
, JSTART
, KFLAG
, L
,
11 2 LYH
, LEWT
, LACOR
, LSAVF
, LWM
, LIWM
, METH
, MITER
,
12 3 MAXORD
, MAXCOR
, MSBP
, MXNCF
, N
, NQ
, NST
, NFE
, NJE
, NQU
13 DOUBLE PRECISION ROWNS
,
14 1 CCMAX
, EL0
, H
, HMIN
, HMXI
, HU
, RC
, TN
, UROUND
15 COMMON /DLS001
/ ROWNS
(209),
16 1 CCMAX
, EL0
, H
, HMIN
, HMXI
, HU
, RC
, TN
, UROUND
,
18 3 ICF
, IERPJ
, IERSL
, JCUR
, JSTART
, KFLAG
, L
,
19 4 LYH
, LEWT
, LACOR
, LSAVF
, LWM
, LIWM
, METH
, MITER
,
20 5 MAXORD
, MAXCOR
, MSBP
, MXNCF
, N
, NQ
, NST
, NFE
, NJE
, NQU
21 INTEGER I
, IER
, IIA
, IIB
, IIC
, IPA
, IPB
, IPC
, IRES
, J
, J1
, J2
,
22 1 K
, K1
, LENP
, LBLOX
, LPB
, LPC
, MB
, MBSQ
, MWID
, NB
23 DOUBLE PRECISION CON
, FAC
, HL0
, R
, SRUR
24 C-----------------------------------------------------------------------
25 C DPJIBT is called by DSTODI to compute and process the matrix
26 C P = A - H*EL(1)*J , where J is an approximation to the Jacobian dr/dy,
27 C and r = g(t,y) - A(t,y)*s. Here J is computed by the user-supplied
28 C routine JAC if MITER = 1, or by finite differencing if MITER = 2.
29 C J is stored in WM, rescaled, and ADDA is called to generate P.
30 C P is then subjected to LU decomposition by DDECBT in preparation
31 C for later solution of linear systems with P as coefficient matrix.
33 C In addition to variables described previously, communication
34 C with DPJIBT uses the following:
35 C Y = array containing predicted values on entry.
36 C RTEM = work array of length N (ACOR in DSTODI).
37 C SAVR = array used for output only. On output it contains the
38 C residual evaluated at current values of t and y.
39 C S = array containing predicted values of dy/dt (SAVF in DSTODI).
40 C WM = real work space for matrices. On output it contains the
41 C LU decomposition of P.
42 C Storage of matrix elements starts at WM(3).
43 C WM also contains the following matrix-related data:
44 C WM(1) = SQRT(UROUND), used in numerical Jacobian increments.
45 C IWM = integer work space containing pivot information, starting at
46 C IWM(21). IWM also contains block structure parameters
47 C MB = IWM(1) and NB = IWM(2).
48 C EL0 = EL(1) (input).
49 C IERPJ = output error flag.
50 C = 0 if no trouble occurred,
51 C = 1 if the P matrix was found to be unfactorable,
52 C = IRES (= 2 or 3) if RES returned IRES = 2 or 3.
53 C JCUR = output flag = 1 to indicate that the Jacobian matrix
54 C (or approximation) is now current.
55 C This routine also uses the Common variables EL0, H, TN, UROUND,
56 C MITER, N, NFE, and NJE.
57 C-----------------------------------------------------------------------
69 GO TO (100, 200), MITER
70 C If MITER = 1, call RES, then JAC, and multiply by scalar. ------------
72 CALL RES
(NEQ
, TN
, Y
, S
, SAVR
, IRES
)
74 IF (IRES
.GT
. 1) GO TO 600
77 CALL JAC
(NEQ
, TN
, Y
, S
, MB
, NB
, WM
(3), WM
(LPB
), WM
(LPC
))
80 120 WM
(I
+2) = WM
(I
+2)*CON
83 C If MITER = 2, make 3*MB + 1 calls to RES to approximate J. -----------
86 CALL RES
(NEQ
, TN
, Y
, S
, SAVR
, IRES
)
88 IF (IRES
.GT
. 1) GO TO 600
95 C Increment Y(I) for group of column indices, and call RES. ----
98 R
= MAX
(SRUR*ABS
(Y
(I
)),0.01D0
/EWT
(I
))
101 CALL RES
(NEQ
, TN
, Y
, S
, RTEM
, IRES
)
103 IF (IRES
.GT
. 1) GO TO 600
105 215 RTEM
(I
) = RTEM
(I
) - SAVR
(I
)
108 C Get Jacobian elements in column I (block-column K1). -------
110 R
= MAX
(SRUR*ABS
(Y
(I
)),0.01D0
/EWT
(I
))
112 C Compute and load elements PA(*,J,K1). ----------------------
114 IPA
= 2 + (J
-1)*MB
+ (K1
-1)*MBSQ
116 221 WM
(IPA
+J2
) = RTEM
(IIA
+J2
)*FAC
117 IF (K1
.LE
. 1) GO TO 223
118 C Compute and load elements PB(*,J,K1-1). --------------------
120 IPB
= IPA
+ LBLOX
- MBSQ
122 222 WM
(IPB
+J2
) = RTEM
(IIB
+J2
)*FAC
124 IF (K1
.GE
. NB
) GO TO 225
125 C Compute and load elements PC(*,J,K1+1). --------------------
127 IPC
= IPA
+ 2*LBLOX
+ MBSQ
129 224 WM
(IPC
+J2
) = RTEM
(IIC
+J2
)*FAC
131 IF (K1
.NE
. 3) GO TO 227
132 C Compute and load elements PC(*,J,1). -----------------------
133 IPC
= IPA
- 2*MBSQ
+ 2*LBLOX
135 226 WM
(IPC
+J2
) = RTEM
(J2
)*FAC
137 IF (K1
.NE
. NB
-2) GO TO 229
138 C Compute and load elements PB(*,J,NB). ----------------------
140 IPB
= IPA
+ 2*MBSQ
+ LBLOX
142 228 WM
(IPB
+J2
) = RTEM
(IIB
+J2
)*FAC
147 C RES call for first corrector iteration. ------------------------------
149 CALL RES
(NEQ
, TN
, Y
, S
, SAVR
, IRES
)
151 IF (IRES
.GT
. 1) GO TO 600
152 C Add matrix A. --------------------------------------------------------
154 CALL ADDA
(NEQ
, TN
, Y
, MB
, NB
, WM
(3), WM
(LPB
), WM
(LPC
))
155 C Do LU decomposition on P. --------------------------------------------
156 CALL DDECBT
(MB
, NB
, WM
(3), WM
(LPB
), WM
(LPC
), IWM
(21), IER
)
157 IF (IER
.NE
. 0) IERPJ
= 1
159 C Error return for IRES = 2 or IRES = 3 return from RES. ---------------
162 C----------------------- End of Subroutine DPJIBT ----------------------