1 SUBROUTINE stode (NEQ, Y, YH, NYH, YH1, EWT, SAVF, ACOR,
2 1 wm, iwm,
f, jac, pjac, slvs,
ierr)
4 EXTERNAL f, jac, pjac, slvs
6 INTEGER iownd, ialth, ipup, lmax, meo, nqnyh, nslp,
7 1 icf, ierpj, iersl, jcur, jstart, kflag, l, meth, miter,
8 2 maxord, maxcor, msbp, mxncf, n, nq, nst, nfe, nje, nqu
9 INTEGER i, i1, iredo, iret, j, jb, m, ncf, newq
10 DOUBLE PRECISION y, yh, yh1, ewt, savf, acor, wm
11 DOUBLE PRECISION conit, crate, el, elco, hold, rmax, tesco,
12 2 ccmax, el0, h, hmin, hmxi, hu, rc, tn, uround
13 DOUBLE PRECISION dcon, ddn,
del, delp, dsm,
dup, exdn, exsm, exup,
14 1 r, rh, rhdn, rhsm, rhup, told,
vnorm
15 dimension neq(*), y(*), yh(nyh,*), yh1(*), ewt(*), savf(*),
16 1 acor(*), wm(*), iwm(*)
17 COMMON /ls0001/ conit, crate, el(13), elco(13,12),
18 1 hold, rmax, tesco(3,12),
19 2 ccmax, el0, h, hmin, hmxi, hu, rc, tn, uround, iownd(14),
20 3 ialth, ipup, lmax, meo, nqnyh, nslp,
21 4 icf, ierpj, iersl, jcur, jstart, kflag, l, meth, miter,
22 5 maxord, maxcor, msbp, mxncf, n, nq, nst, nfe, nje, nqu
103 IF (jstart .GT. 0) go to 200
104 IF (jstart .EQ. -1) go to 100
105 IF (jstart .EQ. -2) go to 160
143 IF (ialth .EQ. 1) ialth = 2
144 IF (meth .EQ. meo) go to 110
145 CALL
cfode(meth, elco, tesco)
147 IF (nq .GT. maxord) go to 120
151 110
IF (nq .LE. maxord) go to 160
155 125 el(i) = elco(i,nq)
159 conit = 0.5d0/dble(nq+2)
160 ddn =
vnorm(n, savf, ewt)/tesco(1,l)
162 rhdn = 1.0d0/(1.3d0*ddn**exdn + 0.0000013d0)
163 rh = dmin1(rhdn,1.0d0)
165 IF (h .EQ. hold) go to 170
166 rh = dmin1(rh,dabs(h/hold))
174 140 CALL
cfode(meth, elco, tesco)
176 155 el(i) = elco(i,nq)
180 conit = 0.5d0/dble(nq+2)
181 go to(160, 170, 200), iret
188 160
IF (h .EQ. hold) go to 200
193 170 rh = dmax1(rh,hmin/dabs(h))
194 175 rh = dmin1(rh,rmax)
195 rh = rh/dmax1(1.0d0,dabs(h)*hmxi*rh)
200 180 yh(i,j) = yh(i,j)*r
204 IF (iredo .EQ. 0) go to 690
213 200
IF (dabs(rc-1.0d0) .GT. ccmax) ipup = miter
214 IF (nst .GE. nslp+msbp) ipup = miter
221 210 yh1(i) = yh1(i) + yh1(i+nyh)
233 CALL
f(neq, tn, y, savf,
ierr)
234 IF (
ierr .LT. 0)
RETURN
236 IF (ipup .LE. 0) go to 250
243 CALL pjac(neq, y, yh, nyh, ewt, acor, savf, wm, iwm,
f, jac,
245 IF (
ierr .LT. 0)
RETURN
250 IF (ierpj .NE. 0) go to 430
253 270
IF (miter .NE. 0) go to 350
259 savf(i) = h*savf(i) - yh(i,2)
260 290 y(i) = savf(i) - acor(i)
263 y(i) = yh(i,1) + el(1)*savf(i)
264 300 acor(i) = savf(i)
272 360 y(i) = h*savf(i) - (yh(i,2) + acor(i))
273 CALL slvs(wm, iwm, y, savf)
274 IF (iersl .LT. 0) go to 430
275 IF (iersl .GT. 0) go to 410
278 acor(i) = acor(i) + y(i)
279 380 y(i) = yh(i,1) + el(1)*acor(i)
284 400
IF (m .NE. 0) crate = dmax1(0.2d0*crate,
del/delp)
285 dcon =
del*dmin1(1.0d0,1.5d0*crate)/(tesco(2,nq)*conit)
286 IF (dcon .LE. 1.0d0) go to 450
288 IF (m .EQ. maxcor) go to 410
289 IF (m .GE. 2 .AND.
del .GT. 2.0d0*delp) go to 410
292 CALL
f(neq, tn, y, savf,
ierr)
293 IF (
ierr .LT. 0)
RETURN
303 410
IF (miter .EQ. 0 .OR. jcur .EQ. 1) go to 430
316 440 yh1(i) = yh1(i) - yh1(i+nyh)
318 IF (ierpj .LT. 0 .OR. iersl .LT. 0) go to 680
319 IF (dabs(h) .LE. hmin*1.00001d0) go to 670
320 IF (ncf .EQ. mxncf) go to 670
332 IF (m .EQ. 0) dsm =
del/tesco(2,nq)
333 IF (m .GT. 0) dsm =
vnorm(n, acor, ewt)/tesco(2,nq)
334 IF (dsm .GT. 1.0d0) go to 500
352 470 yh(i,j) = yh(i,j) + el(j)*acor(i)
354 IF (ialth .EQ. 0) go to 520
355 IF (ialth .GT. 1) go to 700
356 IF (l .EQ. lmax) go to 700
358 490 yh(i,lmax) = acor(i)
367 500 kflag = kflag - 1
374 510 yh1(i) = yh1(i) - yh1(i+nyh)
377 IF (dabs(h) .LE. hmin*1.00001d0) go to 660
378 IF (kflag .LE. -3) go to 640
392 IF (l .EQ. lmax) go to 540
394 530 savf(i) = acor(i) - yh(i,lmax)
395 dup =
vnorm(n, savf, ewt)/tesco(3,nq)
396 exup = 1.0d0/dble(l+1)
397 rhup = 1.0d0/(1.4d0*
dup**exup + 0.0000014d0)
398 540 exsm = 1.0d0/dble(l)
399 rhsm = 1.0d0/(1.2d0*dsm**exsm + 0.0000012d0)
401 IF (nq .EQ. 1) go to 560
402 ddn =
vnorm(n, yh(1,l), ewt)/tesco(1,nq)
403 exdn = 1.0d0/dble(nq)
404 rhdn = 1.0d0/(1.3d0*ddn**exdn + 0.0000013d0)
405 560
IF (rhsm .GE. rhup) go to 570
406 IF (rhup .GT. rhdn) go to 590
408 570
IF (rhsm .LT. rhdn) go to 580
414 IF (kflag .LT. 0 .AND. rh .GT. 1.0d0) rh = 1.0d0
418 IF (rh .LT. 1.1d0) go to 610
421 600 yh(i,newq+1) = acor(i)*r
425 620
IF ((kflag .EQ. 0) .AND. (rh .LT. 1.1d0)) go to 610
426 IF (kflag .LE. -2) rh = dmin1(rh,0.2d0)
432 IF (newq .EQ. nq) go to 170
446 640
IF (kflag .EQ. -10) go to 660
448 rh = dmax1(hmin/dabs(h),rh)
453 CALL
f(neq, tn, y, savf,
ierr)
454 IF (
ierr .LT. 0)
RETURN
457 650 yh(i,2) = h*savf(i)
460 IF (nq .EQ. 1) go to 200
476 700 r = 1.0d0/tesco(2,nqu)
478 710 acor(i) = acor(i)*r