sample 5
c —ÍŠw‰‰K2 ”’lŒvŽZ(1)
c U‚èŽq‚̉^“®•û’öŽ®‚ðEuler–@‚ð—p‚¢‚ĉð‚ 2002-10-28
c-------------------------------------------------------
implicit none
integer j,jmax
parameter (jmax=1000)
real x0,v0,xh,vh,ah
real x(0:jmax),v(0:jmax),a(0:jmax)
real t(0:jmax),dt,tmax
c ‰ŠúðŒ
call getinit(x0,v0,dt,tmax)
x(0)=x0; v(0)=v0;
t(0)=0.0
c ‰^“®•û’öŽ®‚ð‰ð‚
do j=0,jmax-1
a(j)=-sin(x(j)) !‰^“®•û’öŽ®:a=-sinx
xh=x(j)+v(j)*(dt/2)
vh=v(j)+a(j)*(dt/2)
ah=-sin(xh)
x(j+1)=x(j)+vh*dt
v(j+1)=v(j)+ah*dt
t(j+1)=t(j)+dt
if (t(j).gt.tmax) exit
end do
open(1,file="rikigaku3a.dat")
c Œ‹‰Ê‚ðo—Í‚·‚é
do j=0,jmax-1
write(1,*) t(j),x(j)
if (t(j).gt.tmax) exit
end do
stop
end
c ‰ŠúðŒ‚Ì“ü—Í
subroutine getinit(xinit,vinit,dt,tmax)
write(0,*) 'initial condition: x,v='
read(*,*) xinit,vinit
write(0,*) 'dt,tmax='
read(*,*) dt,tmax
return
end
[–ß‚é]