      SUBROUTINE A10DEX(TSTART, TSTOP, XA, F, DA, D, BETA, GAMMA
     1   , DELTA, X, NX, DT, N, KMAX, MMAX, XPOLY, SERROR, ERROR,
     2   ERRPAR, INMI, SOUT, OUTPUT, PESPAR, HFRACT, KINIT)
      INTEGER MMAX, NX
      EXTERNAL XA, F, DA, D, SERROR, ERROR
      EXTERNAL INMI, SOUT, OUTPUT
      INTEGER N(MMAX), KMAX, KINIT
      REAL TSTART, TSTOP, BETA, GAMMA, DELTA, X(NX)
      REAL DT, ERRPAR(2), PESPAR, HFRACT
      LOGICAL XPOLY, SERROR
      COMMON /CSTAK/ DS
      DOUBLE PRECISION DS(500)
      COMMON /A10DEY/ WV, RV, IV, LV
      INTEGER IV(40)
      REAL WV(30), RV(30)
      LOGICAL LV(20)
      COMMON /A1ODEG/ TJ, DTJ, GETJAC, SEPATE, USENGJ, USENNS, USENFD
      REAL TJ, DTJ
      LOGICAL GETJAC, SEPATE, USENGJ, USENNS, USENFD
      COMMON /A1ODEM/ THETA, EGIVE, MINIT, MAXIT, KEEJAC, IRCS
      INTEGER MINIT, MAXIT, KEEJAC, IRCS
      REAL THETA, EGIVE
      INTEGER NERROR, M, NERR, IE, IS(1000), IX1
      REAL T0, T1, RS(1000), WS(1000)
      LOGICAL A4SSOR, A4SSOX, DONE, OK, LS(1000), A4SSOE
      LOGICAL A4SSOI, A4SSOM
      EQUIVALENCE (DS(1), WS(1), RS(1), IS(1), LS(1))
      EQUIVALENCE (WV(10), T0)
      EQUIVALENCE (WV(11), T1)
      EQUIVALENCE (IV(12), IX1)
      EQUIVALENCE (IV(22), IE)
      EQUIVALENCE (LV(2), OK)
      EQUIVALENCE (LV(7), DONE)
C SCRATCH SPACE ALLOCATED -
C     S(A10DEX) <= 2*MMAX + 1 + NX*(KMAX+1) +
C     ( 5*KMAX + 2*MMAX + 3 ) INTEGER +
C     MAX ( S(XA), NX*(KMAX+1) REAL +
C           MAX ( KMAX + KMAX INTEGER, S(SERROR) ),
C           NX REAL + S(SOUT) )
C REAL.
C THE PORT LIBRARY STACK AND ITS ALIASES.
      CALL ENTER(1)
      IF (.NOT. A4SSOI(WV, RV, IV, LV, TSTART, TSTOP, BETA, GAMMA,
     1   DELTA, NX, DT, N, KMAX, MMAX, XPOLY, ERRPAR, PESPAR, HFRACT,
     2   KINIT)) GOTO 1
         CALL LEAVE
         RETURN
   1  IF (T0 .EQ. TSTOP) GOTO  7
C TAKE THE TIME-STEPS.
         IF (KEEJAC .NE. 2) GOTO 2
            GETJAC = T0 .NE. TJ
            TJ = T0
C BUILD THE EXTRAPLOATION LOZENGE.
   2     DO  5 M = 1, MMAX
C GET XA((T1-T0)/N(M)).
            OK = .TRUE.
            CALL XA(T0, X, T1, WS(IX1), NX, N(M), F, D, DA, OK, ERROR,
     1         ERRPAR, INMI)
            IF (OK) GOTO 4
               IF (NERROR(NERR) .EQ. 0) GOTO 3
                  CALL LEAVE
                  RETURN
   3           CONTINUE
C     EXTRAPOLATE THE RESULTS.
   4        IF (A4SSOX(WV, RV, IV, LV, N, M)) GOTO  6
            IF (M .GT. 1) DONE = SERROR(WS(IX1), NX, T1, DT, ERRPAR,
     1         DELTA, RS(IE), ERROR)
C CHECK FOR CONVERGENCE.
C     CHECK FOR A RESTART.
            IF (A4SSOR(WV, RV, IV, LV, ERRPAR)) GOTO  6
   5        CONTINUE
C   GET OPTIMAL DT AND ORDER ( LOZENGE SIZE ).
   6     IF (A4SSOM(WV, RV, IV, LV, DT)) GOTO  7
C   OUTPUT THE RESULTS FOR THIS TIME-STEP.
         CALL SOUT(T0, X, T1, WS(IX1), NX, DT, TSTOP, RS(IE), OK,
     1      OUTPUT)
C   WIND-UP THIS TIME-STEP.
         IF (A4SSOE(WV, RV, IV, LV, X, TSTOP, DT)) GOTO  7
         GOTO  1
   7  CALL LEAVE
      RETURN
      END
