program rkdumb_main_simple implicit none integer nstep,NMAX,NSTPMX,i,j,pgopen parameter (NMAX=50,NSTPMX=200) real xx(NSTPMX),y(NMAX,NSTPMX),x1,x2,vstart(1),yy(NSTPMX) real y_min, y_max common /path/xx,y external derivs write(*,*) 'Type in initial and final values of x :' read(*,*) x1,x2 c Be careful the max value of nstep is 199, not 200, see rkdumb. 100 write(*,*) 'How many steps to integrate the solution ? (<= 199)' read(*,*) nstep if (nstep.gt.199) goto 100 if (nstep.lt.0) goto 100 write(*,*) 'Give the initial value y1(x0) :' read (*,*) vstart(1) c This is a first-order ODE, so nvar = 1 call rkdumb(vstart,1,x1,x2,nstep,derivs) write(*,*) 'RK routine has completed.' c Find Max and min values of y1(x), but here we will use only y1(x). y_max= y(1,1) y_min= y(1,1) do j=1,nstep if (y(1,j).gt.y_max) y_max = y(1,j) if (y(1,j).lt.y_min) y_min = y(1,j) end do c Copy y(1,1:nstep) to yy(1:nstep) for PGLINE plotting do i=1,nstep yy(i) = y(1,i) end do c Start plotting if (pgopen('/xwin').le.0) stop call pgpap(6.0,0.75) call pgenv (x1,x2,y_min,y_max,0,0) call pgline(nstep,xx,yy) call pgclos end subroutine derivs(x,y,dy) c The reason need to pass y is because y' can be explicit function of both c x and y, like y'(x,y). real x,y,dy dy = 2*x end