1
subroutine rksimp(fydot2,neqn,y,t,tout,itol,rerr,aerr,
2
1 itask,iflag,iopt,work,lrw,iwork,liw,bjac,mf)
4
c fehlberg fourth-fifth order runge-kutta method
7
integer neqn,iflag,iwork(*)
8
double precision y(*),t,tout,rerr,aerr,work(*),h
10
double precision ae,scale,eeoet,et,esttol,ee
14
integer k1,k2,k3,k4,k5,k6
17
c compute indices for the splitting of the work array
28
c this interfacing routine merely relieves the user of a long
29
c calling list via the splitting apart of two working storage
30
c arrays. if this is not compatible with the users compiler,
31
c he must use rkfs directly.
37
call fehl2(fydot2,neqn,y,t,h,work(1),
38
1 work(k1),work(k2),work(k3),work(k4),work(k5),
43
et=dabs(work(k6+k-1))+dabs(work(k1-1+k))+ae
44
if (et .gt. 0.0d0) go to 240
46
c inappropriate error tolerance
51
ee=dabs((-2090.0d0*work(k)+(21970.0d0*
52
1 work(k3-1+k)-15048.0d0*work(k4-1+k)))+
53
2 (22528.0d0*work(k2-1+k)-27360.0d0*work(k5-1+k)))
54
250 eeoet=dmax1(eeoet,ee/et)
56
esttol=dabs(h)*eeoet*scale/752400.0d0
58
if (esttol .le. 1.0d0) then
62
c write(6,*) esttol,scale,eeoet,ee,et
70
subroutine fehl2(fydot2,neqn,y,t,h,yp,f1,f2,f3,f4,f5,s)
72
c fehlberg fourth-fifth order runge-kutta method
76
double precision y(*),t,h,yp(neqn),f1(neqn),f2(neqn),
77
1 f3(neqn),f4(neqn),f5(neqn),s(neqn)
84
c write(6,*) 'inputfelh2:',y(1),y(2)
85
call fydot2(neqn,t,y,yp)
89
221 y(k)=y(k)+ch*yp(k)
90
call fydot2(neqn,t+ch,y,f1)
95
222 y(k)=s(k)+ch*(yp(k)+3.0d0*f1(k))
96
call fydot2(neqn,t+3.0d0*h/8.0d0,y,f2)
101
223 y(k)=s(k)+ch*(1932.0d0*yp(k)+(7296.0d0*f2(k)-7200.0d0*f1(k)))
102
call fydot2(neqn,t+12.0d0*h/13.0d0,y,f3)
107
224 y(k)=s(k)+ch*((8341.0d0*yp(k)-845.0d0*f3(k))+
108
1 (29440.0d0*f2(k)-32832.0d0*f1(k)))
109
call fydot2(neqn,t+h,y,f4)
114
225 y(k)=s(k)+ch*((-6080.0d0*yp(k)+(9295.0d0*f3(k)-
115
1 5643.0d0*f4(k)))+(41040.0d0*f1(k)-28352.0d0*f2(k)))
116
call fydot2(neqn,t+h/2.0d0,y,f5)
119
c compute approximate solution at t+h
123
y(k)=s(k)+ch*((902880.0d0*yp(k)+(3855735.0d0*f3(k)-
124
1 1371249.0d0*f4(k)))+(3953664.0d0*f2(k)+
128
c write(6,*) 'endfelh2:',y(1),y(2)