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 ILLIN, INIT, LYH, LEWT, LACOR, LSAVF, LWM, LIWM,
7 1 mxstep, mxhnil, nhnil, ntrep, nslast, cnyh,
8 2 ialth, ipup, lmax, meo, nqnyh, nslp
9 INTEGER ICF, IERPJ, IERSL, JCUR, JSTART, KFLAG, L, METH, MITER,
10 1 maxord, maxcor, msbp, mxncf, n, nq, nst, nfe, nje, nqu
11 INTEGER I, I1, IREDO, IRET, J, JB, M, NCF, NEWQ
12 DOUBLE PRECISION Y, YH, YH1, EWT, SAVF, ACOR, WM
13 DOUBLE PRECISION CONIT, CRATE, EL, ELCO, HOLD, RMAX, TESCO,
14 2 ccmax, el0, h, hmin, hmxi, hu, rc, tn, uround
15 DOUBLE PRECISION DCON, DDN, DEL, DELP, DSM, DUP, EXDN, EXSM, EXUP,
16 1 r, rh, rhdn, rhsm, rhup, told,
vnorm
17 dimension neq(*), y(*), yh(nyh,*), yh1(*), ewt(*), savf(*),
18 1 acor(*), wm(*), iwm(*)
19 COMMON /ls0001/ conit, crate, el(13), elco(13,12),
20 1 hold, rmax, tesco(3,12),
21 2 ccmax, el0, h, hmin, hmxi, hu, rc, tn, uround,
22 2 illin, init, lyh, lewt, lacor, lsavf, lwm, liwm,
23 3 mxstep, mxhnil, nhnil, ntrep, nslast, cnyh,
24 3 ialth, ipup, lmax, meo, nqnyh, nslp,
25 4 icf, ierpj, iersl, jcur, jstart, kflag, l, meth, miter,
26 5 maxord, maxcor, msbp, mxncf, n, nq, nst, nfe, nje, nqu
107 IF (jstart .GT. 0)
GO TO 200
108 IF (jstart .EQ. -1)
GO TO 100
109 IF (jstart .EQ. -2)
GO TO 160
147 IF (ialth .EQ. 1) ialth = 2
148 IF (meth .EQ. meo)
GO TO 110
149 CALL cfode (meth, elco, tesco)
151 IF (nq .GT. maxord)
GO TO 120
155 110
IF (nq .LE. maxord)
GO TO 160
159 125 el(i) = elco(i,nq)
163 conit = 0.5d0/dble(nq+2)
164 ddn =
vnorm(n, savf, ewt)/tesco(1,l)
166 rhdn = 1.0d0/(1.3d0*ddn**exdn + 0.0000013d0)
167 rh = dmin1(rhdn,1.0d0)
169 IF (h .EQ. hold)
GO TO 170
170 rh = dmin1(rh,dabs(h/hold))
178 140
CALL cfode (meth, elco, tesco)
180 155 el(i) = elco(i,nq)
184 conit = 0.5d0/dble(nq+2)
185 GO TO (160, 170, 200), iret
192 160
IF (h .EQ. hold)
GO TO 200
197 170 rh = dmax1(rh,hmin/dabs(h))
198 175 rh = dmin1(rh,rmax)
199 rh = rh/dmax1(1.0d0,dabs(h)*hmxi*rh)
204 180 yh(i,j) = yh(i,j)*r
208 IF (iredo .EQ. 0)
GO TO 690
217 200
IF (dabs(rc-1.0d0) .GT. ccmax) ipup = miter
218 IF (nst .GE. nslp+msbp) ipup = miter
225 210 yh1(i) = yh1(i) + yh1(i+nyh)
237 CALL f (neq, tn, y, savf, ierr)
238 IF (ierr .LT. 0)
RETURN
240 IF (ipup .LE. 0)
GO TO 250
247 CALL pjac (neq, y, yh, nyh, ewt, acor, savf, wm, iwm, f, jac,
249 IF (ierr .LT. 0)
RETURN
254 IF (ierpj .NE. 0)
GO TO 430
257 270
IF (miter .NE. 0)
GO TO 350
263 savf(i) = h*savf(i) - yh(i,2)
264 290 y(i) = savf(i) - acor(i)
265 del =
vnorm(n, y, ewt)
267 y(i) = yh(i,1) + el(1)*savf(i)
268 300 acor(i) = savf(i)
276 360 y(i) = h*savf(i) - (yh(i,2) + acor(i))
277 CALL slvs (wm, iwm, y, savf)
278 IF (iersl .LT. 0)
GO TO 430
279 IF (iersl .GT. 0)
GO TO 410
280 del =
vnorm(n, y, ewt)
282 acor(i) = acor(i) + y(i)
283 380 y(i) = yh(i,1) + el(1)*acor(i)
288 400
IF (m .NE. 0) crate = dmax1(0.2d0*crate,del/delp)
289 dcon = del*dmin1(1.0d0,1.5d0*crate)/(tesco(2,nq)*conit)
290 IF (dcon .LE. 1.0d0)
GO TO 450
292 IF (m .EQ. maxcor)
GO TO 410
293 IF (m .GE. 2 .AND. del .GT. 2.0d0*delp)
GO TO 410
296 CALL f (neq, tn, y, savf, ierr)
297 IF (ierr .LT. 0)
RETURN
307 410
IF (miter .EQ. 0 .OR. jcur .EQ. 1)
GO TO 430
320 440 yh1(i) = yh1(i) - yh1(i+nyh)
322 IF (ierpj .LT. 0 .OR. iersl .LT. 0)
GO TO 680
323 IF (dabs(h) .LE. hmin*1.00001d0)
GO TO 670
324 IF (ncf .EQ. mxncf)
GO TO 670
336 IF (m .EQ. 0) dsm = del/tesco(2,nq)
337 IF (m .GT. 0) dsm =
vnorm(n, acor, ewt)/tesco(2,nq)
338 IF (dsm .GT. 1.0d0)
GO TO 500
356 470 yh(i,j) = yh(i,j) + el(j)*acor(i)
358 IF (ialth .EQ. 0)
GO TO 520
359 IF (ialth .GT. 1)
GO TO 700
360 IF (l .EQ. lmax)
GO TO 700
362 490 yh(i,lmax) = acor(i)
371 500 kflag = kflag - 1
378 510 yh1(i) = yh1(i) - yh1(i+nyh)
381 IF (dabs(h) .LE. hmin*1.00001d0)
GO TO 660
382 IF (kflag .LE. -3)
GO TO 640
396 IF (l .EQ. lmax)
GO TO 540
398 530 savf(i) = acor(i) - yh(i,lmax)
399 dup =
vnorm(n, savf, ewt)/tesco(3,nq)
400 exup = 1.0d0/dble(l+1)
401 rhup = 1.0d0/(1.4d0*dup**exup + 0.0000014d0)
402 540 exsm = 1.0d0/dble(l)
403 rhsm = 1.0d0/(1.2d0*dsm**exsm + 0.0000012d0)
405 IF (nq .EQ. 1)
GO TO 560
406 ddn =
vnorm(n, yh(1,l), ewt)/tesco(1,nq)
407 exdn = 1.0d0/dble(nq)
408 rhdn = 1.0d0/(1.3d0*ddn**exdn + 0.0000013d0)
409 560
IF (rhsm .GE. rhup)
GO TO 570
410 IF (rhup .GT. rhdn)
GO TO 590
412 570
IF (rhsm .LT. rhdn)
GO TO 580
418 IF (kflag .LT. 0 .AND. rh .GT. 1.0d0) rh = 1.0d0
422 IF (rh .LT. 1.1d0)
GO TO 610
425 600 yh(i,newq+1) = acor(i)*r
429 620
IF ((kflag .EQ. 0) .AND. (rh .LT. 1.1d0))
GO TO 610
430 IF (kflag .LE. -2) rh = dmin1(rh,0.2d0)
436 IF (newq .EQ. nq)
GO TO 170
450 640
IF (kflag .EQ. -10)
GO TO 660
452 rh = dmax1(hmin/dabs(h),rh)
457 CALL f (neq, tn, y, savf, ierr)
458 IF (ierr .LT. 0)
RETURN
461 650 yh(i,2) = h*savf(i)
464 IF (nq .EQ. 1)
GO TO 200
480 700 r = 1.0d0/tesco(2,nqu)
482 710 acor(i) = acor(i)*r
subroutine cfode(METH, ELCO, TESCO)
subroutine stode(NEQ, Y, YH, NYH, YH1, EWT, SAVF, ACOR, WM, IWM, F, JAC, PJAC, SLVS, IERR)
double precision function vnorm(N, V, W)