      SUBROUTINE ODEINT(YSTART,NVAR,T1,T2,EPS,H1,HMIN,NOK,NBAD,
     &                  DERIVS,RKQC)
      PARAMETER (MAXSTP=10000,NMAX=10,ZERO=0.0,TINY=1.E-30)
      DIMENSION YSTART(NMAX),YSCAL(NMAX),Y(NMAX),DYDT(NMAX)
      IF (NMAX.LT.NVAR) STOP 'NMAX LESS THAN NVAR'
      T=T1
      H=SIGN(H1,T2-T1)
      NOK=0
      NBAD=0
      DO 11 I=1,NVAR
       Y(I)=YSTART(I)
11    CONTINUE
      DO 16 NSTP=1,MAXSTP
        CALL DERIVS(T,Y,DYDT)
        DO 12 I=1,NVAR
          YSCAL(I)=ABS(Y(I))+ABS(H*DYDT(I))+TINY
12      CONTINUE
        IF((T+H-T2)*(T+H-T1).GT.ZERO) H=T2-T
        CALL RKQC(Y,DYDT,NVAR,T,H,EPS,YSCAL,HDID,HNEXT,DERIVS)
        IF(HDID.EQ.H)THEN
          NOK=NOK+1
        ELSE
          NBAD=NBAD+1
        ENDIF
        IF((T-T2)*(T2-T1).GE.ZERO)THEN
          DO 14 I=1,NVAR
            YSTART(I)=Y(I)
14        CONTINUE
          RETURN
        ENDIF
16    CONTINUE
      STOP ' Too many steps.'
18    RETURN
      END
