2 SUBROUTINE DPRJS
(NEQ
,Y
,YH
,NYH
,EWT
,FTEM
,SAVF
,WK
,IWK
,F
,JAC
)
5 DOUBLE PRECISION Y
, YH
, EWT
, FTEM
, SAVF
, WK
6 DIMENSION NEQ
(*), Y
(*), YH
(NYH
,*), EWT
(*), FTEM
(*), SAVF
(*),
9 1 ICF
, IERPJ
, IERSL
, JCUR
, JSTART
, KFLAG
, L
,
10 2 LYH
, LEWT
, LACOR
, LSAVF
, LWM
, LIWM
, METH
, MITER
,
11 3 MAXORD
, MAXCOR
, MSBP
, MXNCF
, N
, NQ
, NST
, NFE
, NJE
, NQU
12 INTEGER IPLOST
, IESP
, ISTATC
, IYS
, IBA
, IBIAN
, IBJAN
, IBJGP
,
13 1 IPIAN
, IPJAN
, IPJGP
, IPIGP
, IPR
, IPC
, IPIC
, IPISP
, IPRSP
, IPA
,
14 2 LENYH
, LENYHM
, LENWK
, LREQ
, LRAT
, LREST
, LWMIN
, MOSS
, MSBJ
,
15 3 NSLJ
, NGP
, NLU
, NNZ
, NSP
, NZL
, NZU
16 DOUBLE PRECISION ROWNS
,
17 1 CCMAX
, EL0
, H
, HMIN
, HMXI
, HU
, RC
, TN
, UROUND
18 DOUBLE PRECISION CON0
, CONMIN
, CCMXJ
, PSMALL
, RBIG
, SETH
19 COMMON /DLS001
/ ROWNS
(209),
20 1 CCMAX
, EL0
, H
, HMIN
, HMXI
, HU
, RC
, TN
, UROUND
,
22 3 ICF
, IERPJ
, IERSL
, JCUR
, JSTART
, KFLAG
, L
,
23 4 LYH
, LEWT
, LACOR
, LSAVF
, LWM
, LIWM
, METH
, MITER
,
24 5 MAXORD
, MAXCOR
, MSBP
, MXNCF
, N
, NQ
, NST
, NFE
, NJE
, NQU
25 COMMON /DLSS01
/ CON0
, CONMIN
, CCMXJ
, PSMALL
, RBIG
, SETH
,
26 1 IPLOST
, IESP
, ISTATC
, IYS
, IBA
, IBIAN
, IBJAN
, IBJGP
,
27 2 IPIAN
, IPJAN
, IPJGP
, IPIGP
, IPR
, IPC
, IPIC
, IPISP
, IPRSP
, IPA
,
28 3 LENYH
, LENYHM
, LENWK
, LREQ
, LRAT
, LREST
, LWMIN
, MOSS
, MSBJ
,
29 4 NSLJ
, NGP
, NLU
, NNZ
, NSP
, NZL
, NZU
30 INTEGER I
, IMUL
, J
, JJ
, JOK
, JMAX
, JMIN
, K
, KMAX
, KMIN
, NG
31 DOUBLE PRECISION CON
, DI
, FAC
, HL0
, PIJ
, R
, R0
, RCON
, RCONT
,
33 C-----------------------------------------------------------------------
34 C DPRJS is called to compute and process the matrix
35 C P = I - H*EL(1)*J , where J is an approximation to the Jacobian.
36 C J is computed by columns, either by the user-supplied routine JAC
37 C if MITER = 1, or by finite differencing if MITER = 2.
38 C if MITER = 3, a diagonal approximation to J is used.
39 C if MITER = 1 or 2, and if the existing value of the Jacobian
40 C (as contained in P) is considered acceptable, then a new value of
41 C P is reconstructed from the old value. In any case, when MITER
42 C is 1 or 2, the P matrix is subjected to LU decomposition in CDRV.
43 C P and its LU decomposition are stored (separately) in WK.
45 C In addition to variables described previously, communication
46 C with DPRJS uses the following:
47 C Y = array containing predicted values on entry.
48 C FTEM = work array of length N (ACOR in DSTODE).
49 C SAVF = array containing f evaluated at predicted y.
50 C WK = real work space for matrices. On output it contains the
51 C inverse diagonal matrix if MITER = 3, and P and its sparse
52 C LU decomposition if MITER is 1 or 2.
53 C Storage of matrix elements starts at WK(3).
54 C WK also contains the following matrix-related data:
55 C WK(1) = SQRT(UROUND), used in numerical Jacobian increments.
56 C WK(2) = H*EL0, saved for later use if MITER = 3.
57 C IWK = integer work space for matrix-related data, assumed to
58 C be equivalenced to WK. In addition, WK(IPRSP) and IWK(IPISP)
59 C are assumed to have identical locations.
60 C EL0 = EL(1) (input).
61 C IERPJ = output error flag (in Common).
63 C = 1 if zero pivot found in CDRV.
64 C = 2 if a singular matrix arose with MITER = 3.
65 C = -1 if insufficient storage for CDRV (should not occur here).
66 C = -2 if other error found in CDRV (should not occur here).
67 C JCUR = output flag showing status of (approximate) Jacobian matrix:
68 C = 1 to indicate that the Jacobian is now current, or
69 C = 0 to indicate that a saved value was used.
70 C This routine also uses other variables in Common.
71 C-----------------------------------------------------------------------
74 IF (MITER
.EQ
. 3) GO TO 300
75 C See whether J should be reevaluated (JOK = 0) or not (JOK = 1). ------
77 IF (NST
.EQ
. 0 .OR
. NST
.GE
. NSLJ
+MSBJ
) JOK
= 0
78 IF (ICF
.EQ
. 1 .AND
. ABS
(RC
- 1.0D0
) .LT
. CCMXJ
) JOK
= 0
79 IF (ICF
.EQ
. 2) JOK
= 0
80 IF (JOK
.EQ
. 1) GO TO 250
82 C MITER = 1 or 2, and the Jacobian is to be reevaluated. ---------------
88 GO TO (100, 200), MITER
90 C If MITER = 1, call JAC, multiply by scalar, and add identity. --------
94 KMAX
= IWK
(IPIAN
+J
) - 1
97 CALL JAC
(NEQ
, TN
, Y
, J
, IWK
(IPIAN
), IWK
(IPJAN
), FTEM
)
100 WK
(IBA
+K
) = FTEM
(I
)*CON
101 IF (I
.EQ
. J
) WK
(IBA
+K
) = WK
(IBA
+K
) + 1.0D0
107 C If MITER = 2, make NGP calls to F to approximate J and P. ------------
109 FAC
= DVNORM
(N
, SAVF
, EWT
)
110 R0
= 1000.0D0
* ABS
(H
) * UROUND
* N
* FAC
111 IF (R0
.EQ
. 0.0D0
) R0
= 1.0D0
115 JMAX
= IWK
(IPIGP
+NG
) - 1
118 R
= MAX
(SRUR*ABS
(Y
(JJ
)),R0
/EWT
(JJ
))
119 210 Y
(JJ
) = Y
(JJ
) + R
120 CALL F
(NEQ
, TN
, Y
, FTEM
)
124 R
= MAX
(SRUR*ABS
(Y
(JJ
)),R0
/EWT
(JJ
))
127 KMAX
=IWK
(IBIAN
+JJ
+1) - 1
130 WK
(IBA
+K
) = (FTEM
(I
) - SAVF
(I
))*FAC
131 IF (I
.EQ
. JJ
) WK
(IBA
+K
) = WK
(IBA
+K
) + 1.0D0
139 C If JOK = 1, reconstruct new P from old P. ----------------------------
142 RCONT
= ABS
(CON
)/CONMIN
143 IF (RCONT
.GT
. RBIG
.AND
. IPLOST
.EQ
. 1) GO TO 20
146 KMAX
= IWK
(IPIAN
+J
) - 1
150 IF (I
.NE
. J
) GO TO 260
152 IF (ABS
(PIJ
) .GE
. PSMALL
) GO TO 260
154 CONMIN
= MIN
(ABS
(CON0
),CONMIN
)
156 IF (I
.EQ
. J
) PIJ
= PIJ
+ 1.0D0
162 C Do numerical factorization of P matrix. ------------------------------
168 CALL CDRV
(N
,IWK
(IPR
),IWK
(IPC
),IWK
(IPIC
),IWK
(IPIAN
),IWK
(IPJAN
),
169 1 WK
(IPA
),FTEM
,FTEM
,NSP
,IWK
(IPISP
),WK
(IPRSP
),IESP
,2,IYS
)
170 IF (IYS
.EQ
. 0) RETURN
173 IF (IMUL
.EQ
. 8) IERPJ
= 1
174 IF (IMUL
.EQ
. 10) IERPJ
= -1
177 C If MITER = 3, construct a diagonal approximation to J and P. ---------
185 310 Y
(I
) = Y
(I
) + R*
(H*SAVF
(I
) - YH
(I
,2))
186 CALL F
(NEQ
, TN
, Y
, WK
(3))
189 R0
= H*SAVF
(I
) - YH
(I
,2)
190 DI
= 0.1D0*R0
- H*
(WK
(I
+2) - SAVF
(I
))
192 IF (ABS
(R0
) .LT
. UROUND
/EWT
(I
)) GO TO 320
193 IF (ABS
(DI
) .EQ
. 0.0D0
) GO TO 330
194 WK
(I
+2) = 0.1D0*R0
/DI
199 C----------------------- End of Subroutine DPRJS -----------------------