      subroutine odeint(ystart,nvar,x1,x2,eps,h1,hmin,nok,nbad,nd,derivs,rkqc)
      parameter (maxstp=10000,nmax=100,two=2.0,zero=0.0,tiny=1.d-30)
      parameter (nd1=100)
      common /path/ kmax,kount,dxsav      
      dimension ystart(nd),yscal(nd1),y(nd1),dydx(nd1)
      external derivs,rkqc
      x=x1
      h=sign(h1,x2-x1)
      nok=0
      nbad=0
      kount=0
      do 11 i=1,nvar
         y(i)=ystart(i)
 11   continue
      if (kmax.gt.0) xsav=x-dxsav*two
      do 16 nstp=1,maxstp
         call derivs(nvar,x,y,dydx,nd)
         do 12 i=1,nvar
            yscal(i)=abs(y(i))+abs(h*dydx(i))+tiny
 12      continue
         if ((x+h-x2)*(x+h-x1).gt.zero) h=x2-x
         call rkqc(y,dydx,nvar,x,h,eps,yscal,hdid,hnext,derivs,nd)
         if (hdid.eq.h) then
            nok=nok+1
         else
            nbad=nbad+1
         endif
         if ((x-x2)*(x2-x1).ge.zero) then
            do 14 i=1,nvar
               ystart(i)=y(i)
 14         continue
            return
         endif
         if (abs(hnext).lt.hmin) then
	    write(*,*) 'stepsize small',hmin
            stop
         endif
         h=hnext
 16   continue
      write(*,*) 'too many steps',nstp
      stop
      end
!234567890123456789012345678901234567890123456789012345678901234567890

