program enshu14rkg1f                                                           
implicitnone
integer,parameter::kosuu=16
real,dimension(0:kosuu)::t,vrkg,xrkg
real::dt,k1v,k2v,k3v,k4v,k1x,k2x,k3x,k4x
real,parameter::t_kaishi=0.0,t_shuryo=2.0
integer::i
real,parameter::pi=4.0*atan(1.0),pi2jo=pi**2
dt=(t_shuryo-t_kaishi)/real(kosuu)
doi=0,kosuu
t(i)=t_kaishi+dt*real(i)
enddo
vrkg(0)=pi
xrkg(0)=0.0
doi=0,kosuu-1
k1v=dt*dvdt(xrkg(i))
k1x=dt*dxdt(vrkg(i))
k2v=dt*dvdt(xrkg(i)+0.5*k1x)
k2x=dt*dxdt(vrkg(i)+0.5*k1v)
k3v=dt*dvdt(xrkg(i)+(sqrt(0.5)-0.5)*k1x+(1.0-sqrt(0.5))*k2x)
k3x=dt*dxdt(vrkg(i)+(sqrt(0.5)-0.5)*k1v+(1.0-sqrt(0.5))*k2v)
k4v=dt*dvdt(xrkg(i)-sqrt(0.5)*k2x+(1.0+sqrt(0.5))*k3x)
k4x=dt*dxdt(vrkg(i)-sqrt(0.5)*k2v+(1.0+sqrt(0.5))*k3v)
vrkg(i+1)=vrkg(i)+(k1v+(2.0-sqrt(2.0))*k2v+(2.0+sqrt(2.0))*k3v+k4v)/6.0
xrkg(i+1)=xrkg(i)+(k1x+(2.0-sqrt(2.0))*k2x+(2.0+sqrt(2.0))*k3x+k4x)/6.0
enddo
doi=0,kosuu
write(*,*)t(i),vrkg(i),xrkg(i)
enddo
contains
functiondvdt(x)
real,intent(in)::x
real::dvdt
dvdt=-pi2jo*x
endfunctiondvdt
functiondxdt(v)
real,intent(in)::v
real::dxdt
dxdt=v
endfunctiondxdt
endprogramenshu14rkg1f