c***Euler program from Koonin, Chapter 2 c***modified to take Runge-Kutta step using rk4.f from Numerical Recipes dimension y(1),dydx(1) external derivs n=1 20 print *, 'Enter step size ( .le. 0 to stop)' read *,h if(h. le. 0.) stop nstep=3./h !number of steps to reach x=3 y(1)=1. !y(0)=1 do ix=0,nstep-1 !loop over steps x=ix*h !last x value c y=y+h*func(x,y) call derivs(x,y,dydx) call rk4(y,dydx,n,x,h,y,derivs) yexact = exp(-0.5*(x+h)**2) diff=yexact-y(1) !compare with exact value print *, ix,x+h,y,yexact,diff enddo goto 20 !start again with new value of h end c****************************************************************** subroutine derivs(x,y,dydx) dimension y(1),dydx(1) dydx(1) = -x*y(1) return end c******************************************************************