      subroutine ADMINT(NEQN,Y,W,TINIT,TFINAL,TINCR,RELERR,
     &  ABSERR,IUNIT,TT,IIFLAG,TPRINT,TTYOUT,FOURU,NPRINT)
      double precision ABSER,ABSERR,DT,DTSGN,
     &                 EPSDT,RELER,RELERR,T,TFINAL,
     &                 TINCR,TINIT,TMAXIN,TOUT,Y,W
      double precision TT, TPRINT, FOURU
      integer TTYOUT, NPRINT, MAXERR
      integer NEQN,IER,IUNIT,K1,K2,K3,NEQ,IFLAG,JFLAG,IIFLAG
      integer IOLD,KLE4,INIT,KOP
      dimension Y(NEQN),W(19*NEQN)
      common/ADDATA/ T,TOUT,RELER,ABSER,DTSGN,NEQ,IFLAG
     &,IOLD,KLE4,INIT,KOP
        data MAXERR/8/
      IER = 0
      if (IUNIT.gt.0) call ADMESS (TTYOUT,10,NEQN,TINIT,TFINAL,TINCR,
     &   RELERR,ABSERR)
      K1 = NEQN+1
      K2 = K1+NEQN
      K3 = K2+NEQN
      NEQ = NEQN
      RELER = RELERR
      ABSER = ABSERR
      IFLAG = 1
      JFLAG = 1
      T = TINIT
      TOUT = TINIT
      TMAXIN = dabs(TFINAL-TINIT)
      EPSDT = 0.001*dabs(TINCR)
      DT = dsign(TINCR,TFINAL-TINIT)
100   continue
      call ADAM (Y,W(1),W(K1),W(K2),W(K3),FOURU)
      if (IFLAG.ne.2) go to 110
      call OUTP (T,Y,W,JFLAG)
      JFLAG = IFLAG
      NPRINT = NPRINT+1
      if (dabs(T-TINIT).ge.TMAXIN) go to 210
      TOUT = T+DT
      if (dabs(TFINAL-TOUT).lt.EPSDT) TOUT = TFINAL
      go to 100
110   continue
      IER = IER+1
      go to (120,120,130,140,150,160,170,180,190), IFLAG
120   continue
      if (IUNIT.gt.0) call ADMESS (TTYOUT,25,NEQN,TINIT,TFINAL,TINCR,
     &   RELERR,ABSERR)
      IFLAG = 9
      go to 220
130   continue
      if (IUNIT.gt.0) call ADMESS (TTYOUT,30,NEQN,TINIT,TFINAL,TINCR,
     &   RELERR,ABSERR)
      if (IER.gt.MAXERR) go to 200
      go to 100
140   continue
      if (IUNIT.gt.0) call ADMESS (TTYOUT,40,NEQN,TINIT,TFINAL,TINCR,
     &   RELERR,ABSERR)
      if (IER.gt.MAXERR) go to 200
      go to 100
150   continue
      if (IUNIT.gt.0) call ADMESS (TTYOUT,50,NEQN,TINIT,TFINAL,TINCR,
     &   RELERR,ABSERR)
      if (IUNIT.eq.0) write (TTYOUT,5000)
5000  format (/'     Simulation RUN/CONTINUE in progress...')
      if (IER.gt.MAXERR) go to 200
      go to 100
160   continue
      if (IUNIT.gt.0) call ADMESS (TTYOUT,60,NEQN,TINIT,TFINAL,TINCR,
     &   RELERR,ABSERR)
      if (IUNIT.eq.0) write (TTYOUT,5000)
      go to 220
170   continue
      if (IUNIT.gt.0) call ADMESS (TTYOUT,70,NEQN,TINIT,TFINAL,TINCR,
     &   RELERR,ABSERR)
      if (IER.gt.MAXERR) go to 200
      go to 100
180   continue
      if (IUNIT.gt.0) call ADMESS (TTYOUT,80,NEQN,TINIT,TFINAL,TINCR,
     &   RELERR,ABSERR)
      go to 220
190   continue
      if (IUNIT.gt.0) call ADMESS (TTYOUT,90,NEQN,TINIT,TFINAL,TINCR,
     &   RELERR,ABSERR)
      go to 220
200   continue
      if (IUNIT.gt.0) call ADMESS (TTYOUT,92,NEQN,TINIT,TFINAL,TINCR,
     &   RELERR,ABSERR)
      go to 220
210   continue
      if (IUNIT.gt.0) call ADMESS (TTYOUT,20,NEQN,TINIT,TFINAL,TINCR,
     &   RELERR,ABSERR)
220   continue
      TT = T
      IIFLAG = IFLAG
      TPRINT = TOUT
      return
      end
