1
C/MEMBR ADD NAME=PRJA,SSI=0
2
subroutine prja (neq, y, yh, nyh, ewt, ftem, savf, wm, iwm,
8
1 icf, ierpj, iersl, jcur, jstart, kflag, l, meth, miter,
9
2 maxord, maxcor, msbp, mxncf, n, nq, nst, nfe, nje, nqu
10
integer iownd2, iowns2, jtyp, mused, mxordn, mxords
11
integer i, i1, i2, ier, ii, j, j1, jj, lenp,
12
1 mba, mband, meb1, meband, ml, ml3, mu
13
double precision y, yh, ewt, ftem, savf, wm
14
double precision rownd, rowns,
15
1 ccmax, el0, h, hmin, hmxi, hu, rc, tn, uround
16
double precision rownd2, rowns2, pdnorm
17
double precision con, fac, hl0, r, r0, srur, yi, yj, yjj,
18
1 vmnorm, fnorm, bnorm
19
dimension neq(*), y(*), yh(nyh,*), ewt(*), ftem(*), savf(*),
23
common /ls0001/ rownd, rowns(209),
24
2 ccmax, el0, h, hmin, hmxi, hu, rc, tn, uround,
25
3 iownd(14), iowns(6),
26
4 icf, ierpj, iersl, jcur, jstart, kflag, l, meth, miter,
27
5 maxord, maxcor, msbp, mxncf, n, nq, nst, nfe, nje, nqu
28
common /lsa001/ rownd2, rowns2(20), pdnorm,
29
1 iownd2(3), iowns2(2), jtyp, mused, mxordn, mxords
30
c-----------------------------------------------------------------------
32
c prja is called by stoda to compute and process the matrix
33
c p = i - h*el(1)*j , where j is an approximation to the jacobian.
34
c here j is computed by the user-supplied routine jac if
35
c miter = 1 or 4 or by finite differencing if miter = 2 or 5.
36
c j, scaled by -h*el(1), is stored in wm. then the norm of j (the
37
c matrix norm consistent with the weighted max-norm on vectors given
38
c by vmnorm) is computed, and j is overwritten by p. p is then
39
c subjected to lu decomposition in preparation for later solution
40
c of linear systems with p as coefficient matrix. this is done
41
c by dgefa if miter = 1 or 2, and by dgbfa if miter = 4 or 5.
43
c%additional parameters
44
c in addition to variables described previously, communication
45
c with prja uses the following..
46
c y = array containing predicted values on entry.
47
c ftem = work array of length n (acor in stoda).
48
c savf = array containing f evaluated at predicted y.
49
c wm = real work space for matrices. on output it contains the
50
c lu decomposition of p.
51
c storage of matrix elements starts at wm(3).
52
c wm also contains the following matrix-related data..
53
c wm(1) = sqrt(uround), used in numerical jacobian increments.
54
c iwm = integer work space containing pivot information, starting at
55
c iwm(21). iwm also contains the band parameters
56
c ml = iwm(1) and mu = iwm(2) if miter is 4 or 5.
57
c el0 = el(1) (input).
58
c pdnorm= norm of jacobian matrix. (output).
59
c ierpj = output error flag, = 0 if no trouble, .gt. 0 if
60
c p matrix found to be singular.
61
c jcur = output flag = 1 to indicate that the jacobian matrix
62
c (or approximation) is now current.
63
c this routine also uses the common variables el0, h, tn, uround,
64
c miter, n, nfe, and nje.
66
c-----------------------------------------------------------------------
71
go to (100, 200, 300, 400, 500), miter
72
c if miter = 1, call jac and multiply by scalar. -----------------------
76
call jac (neq, tn, y, 0, 0, wm(3), n)
80
120 wm(i+2) = wm(i+2)*con
82
c if miter = 2, make n calls to f to approximate j. --------------------
83
200 fac = vmnorm (n, savf, ewt)
84
r0 = 1000.0d+0*abs(h)*uround*dble(n)*fac
85
if (r0 .eq. 0.0d+0) r0 = 1.0d+0
90
r = max(srur*abs(yj),r0/ewt(j))
93
call f (neq, tn, y, ftem)
96
220 wm(i+j1) = (ftem(i) - savf(i))*fac
102
c compute norm of jacobian. --------------------------------------------
103
pdnorm = fnorm (n, wm(3), ewt)/abs(hl0)
104
c add identity matrix. -------------------------------------------------
107
wm(j) = wm(j) + 1.0d+0
109
c do lu decomposition on p. --------------------------------------------
110
call dgefa (wm(3), n, n, iwm(21), ier)
111
if (ier .ne. 0) ierpj = 1
113
c dummy block only, since miter is never 3 in this routine. ------------
115
c if miter = 4, call jac and multiply by scalar. -----------------------
124
call jac (neq, tn, y, ml, mu, wm(ml3), meband)
128
420 wm(i+2) = wm(i+2)*con
130
c if miter = 5, make mband calls to f to approximate j. ----------------
138
fac = vmnorm (n, savf, ewt)
139
r0 = 1000.0d+0*abs(h)*uround*dble(n)*fac
140
if (r0 .eq. 0.0d+0) r0 = 1.0d+0
144
r = max(srur*abs(yi),r0/ewt(i))
146
call f (neq, tn, y, ftem)
148
do 550 jj = j,n,mband
151
r = max(srur*abs(yjj),r0/ewt(jj))
155
ii = jj*meb1 - ml + 2
157
540 wm(ii+i) = (ftem(i) - savf(i))*fac
162
c compute norm of jacobian. --------------------------------------------
163
pdnorm = bnorm (n, wm(3), meband, ml, mu, ewt)/abs(hl0)
164
c add identity matrix. -------------------------------------------------
167
wm(ii) = wm(ii) + 1.0d+0
169
c do lu decomposition of p. --------------------------------------------
170
call dgbfa (wm(3), meband, n, ml, mu, iwm(21), ier)
171
if (ier .ne. 0) ierpj = 1
173
c----------------------- end of subroutine prja ------------------------