Fehlberg's 7(8) algorithm.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(rkf78_class), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | t | |||
real(kind=wp), | intent(in), | dimension(me%n) | :: | x | ||
real(kind=wp), | intent(in) | :: | h | |||
real(kind=wp), | intent(out), | dimension(me%n) | :: | xf | ||
real(kind=wp), | intent(out), | dimension(me%n) | :: | terr |
subroutine rkf78(me,t,x,h,xf,terr) implicit none class(rkf78_class),intent(inout) :: me real(wp),intent(in) :: t real(wp),dimension(me%n),intent(in) :: x real(wp),intent(in) :: h real(wp),dimension(me%n),intent(out) :: xf real(wp),dimension(me%n),intent(out) :: terr real(wp),parameter :: a1 = 2.0_wp/27.0_wp real(wp),parameter :: a2 = 1.0_wp/9.0_wp real(wp),parameter :: a3 = 1.0_wp/6.0_wp real(wp),parameter :: a4 = 5.0_wp/12.0_wp real(wp),parameter :: a5 = 1.0_wp/2.0_wp real(wp),parameter :: a6 = 5.0_wp/6.0_wp real(wp),parameter :: a7 = 1.0_wp/6.0_wp real(wp),parameter :: a8 = 2.0_wp/3.0_wp real(wp),parameter :: a9 = 1.0_wp/3.0_wp !real(wp),parameter :: a10 = 1.0_wp !real(wp),parameter :: a12 = 1.0_wp real(wp),parameter :: b10 = 2.0_wp/27.0_wp real(wp),parameter :: b20 = 1.0_wp/36.0_wp real(wp),parameter :: b21 = 1.0_wp/12.0_wp real(wp),parameter :: b30 = 1.0_wp/24.0_wp real(wp),parameter :: b32 = 1.0_wp/8.0_wp real(wp),parameter :: b40 = 5.0_wp/12.0_wp real(wp),parameter :: b42 = -25.0_wp/16.0_wp real(wp),parameter :: b43 = 25.0_wp/16.0_wp real(wp),parameter :: b50 = 1.0_wp/20.0_wp real(wp),parameter :: b53 = 1.0_wp/4.0_wp real(wp),parameter :: b54 = 1.0_wp/5.0_wp real(wp),parameter :: b60 = -25.0_wp/108.0_wp real(wp),parameter :: b63 = 125.0_wp/108.0_wp real(wp),parameter :: b64 = -65.0_wp/27.0_wp real(wp),parameter :: b65 = 125.0_wp/54.0_wp real(wp),parameter :: b70 = 31.0_wp/300.0_wp real(wp),parameter :: b74 = 61.0_wp/225.0_wp real(wp),parameter :: b75 = -2.0_wp/9.0_wp real(wp),parameter :: b76 = 13.0_wp/900.0_wp real(wp),parameter :: b80 = 2.0_wp real(wp),parameter :: b83 = -53.0_wp/6.0_wp real(wp),parameter :: b84 = 704.0_wp/45.0_wp real(wp),parameter :: b85 = -107.0_wp/9.0_wp real(wp),parameter :: b86 = 67.0_wp/90.0_wp real(wp),parameter :: b87 = 3.0_wp real(wp),parameter :: b90 = -91.0_wp/108.0_wp real(wp),parameter :: b93 = 23.0_wp/108.0_wp real(wp),parameter :: b94 = -976.0_wp/135.0_wp real(wp),parameter :: b95 = 311.0_wp/54.0_wp real(wp),parameter :: b96 = -19.0_wp/60.0_wp real(wp),parameter :: b97 = 17.0_wp/6.0_wp real(wp),parameter :: b98 = -1.0_wp/12.0_wp real(wp),parameter :: b100 = 2383.0_wp/4100.0_wp real(wp),parameter :: b103 = -341.0_wp/164.0_wp real(wp),parameter :: b104 = 4496.0_wp/1025.0_wp real(wp),parameter :: b105 = -301.0_wp/82.0_wp real(wp),parameter :: b106 = 2133.0_wp/4100.0_wp real(wp),parameter :: b107 = 45.0_wp/82.0_wp real(wp),parameter :: b108 = 45.0_wp/164.0_wp real(wp),parameter :: b109 = 18.0_wp/41.0_wp real(wp),parameter :: b110 = 3.0_wp/205.0_wp real(wp),parameter :: b115 = -6.0_wp/41.0_wp real(wp),parameter :: b116 = -3.0_wp/205.0_wp real(wp),parameter :: b117 = -3.0_wp/41.0_wp real(wp),parameter :: b118 = 3.0_wp/41.0_wp real(wp),parameter :: b119 = 6.0_wp/41.0_wp real(wp),parameter :: b120 = -1777.0_wp/4100.0_wp real(wp),parameter :: b123 = -341.0_wp/164.0_wp real(wp),parameter :: b124 = 4496.0_wp/1025.0_wp real(wp),parameter :: b125 = -289.0_wp/82.0_wp real(wp),parameter :: b126 = 2193.0_wp/4100.0_wp real(wp),parameter :: b127 = 51.0_wp/82.0_wp real(wp),parameter :: b128 = 33.0_wp/164.0_wp real(wp),parameter :: b129 = 12.0_wp/41.0_wp !real(wp),parameter :: b1211 = 1.0_wp real(wp),parameter :: c5 = 34.0_wp/105.0_wp real(wp),parameter :: c6 = 9.0_wp/35.0_wp real(wp),parameter :: c7 = 9.0_wp/35.0_wp real(wp),parameter :: c8 = 9.0_wp/280.0_wp real(wp),parameter :: c9 = 9.0_wp/280.0_wp real(wp),parameter :: c11 = 41.0_wp/840.0_wp real(wp),parameter :: c12 = 41.0_wp/840.0_wp real(wp),dimension(me%n) :: f0,f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12 if (h==zero) then xf = x terr = zero return end if call me%f(t,x,f0) call me%f(t+h*a1,x+f0*b10*h,f1) call me%f(t+h*a2,x+(f0*b20+f1*b21)*h,f2) call me%f(t+h*a3,x+(f0*b30+f2*b32)*h,f3) call me%f(t+h*a4,x+(f0*b40+f2*b42+f3*b43)*h,f4) call me%f(t+h*a5,x+(f0*b50+f3*b53+f4*b54)*h,f5) call me%f(t+h*a6,x+(f0*b60+f3*b63+f4*b64+f5*b65)*h,f6) call me%f(t+h*a7,x+(f0*b70+f4*b74+f5*b75+f6*b76)*h,f7) call me%f(t+h*a8,x+(f0*b80+f3*b83+f4*b84+f5*b85+f6*b86+& f7*b87)*h,f8) call me%f(t+h*a9,x+(f0*b90+f3*b93+f4*b94+f5*b95+f6*b96+& f7*b97+f8*b98)*h,f9) call me%f(t+h,x+(f0*b100+f3*b103+f4*b104+f5*b105+& f6*b106+f7*b107+f8*b108+f9*b109)*h,f10) call me%f(t,x+(f0*b110+f5*b115+f6*b116+f7*b117+f8*b118+& f9*b119)*h,f11) call me%f(t+h,x+(f0*b120+f3*b123+f4*b124+f5*b125+f6*b126+& f7*b127+f8*b128+f9*b129+f11)*h,f12) xf = x + h*(f5*c5+f6*c6+f7*c7+f8*c8+f9*c9+f11*c11+f12*c12) terr = (41.0_wp/840.0_wp)*(f0+f10-f11-f12) end subroutine rkf78