      SUBROUTINE ADJUST (Y, N0)
C-----------------------------------------------------------------------
C THIS SUBROUTINE ADJUSTS THE Y ARRAY ON REDUCTION OF ORDER.
C SEE REFERENCE 1 FOR DETAILS.
C-----------------------------------------------------------------------
C CAUTION   NOT ALL MEMBERS OF EPCOM1 ARE USED IN THIS SUBROUTINE.
C-----------------------------------------------------------------------
      INTEGER N0
      INTEGER JSTART, KFLAG, L, LMAX, METH, MF, N, NQ, NQINDX
      INTEGER I, IBACK, J, JP1, NQM1, NQM2
      REAL Y
      REAL EL, EPS, H, HMAX, HMIN, SS, T, TAU, TQ, UROUND
      REAL HSUM, XI
      REAL ONE, ZERO
      DIMENSION Y(N0,13)
C
      COMMON /EPCOM1/ T,H,HMIN,HMAX,EPS,SS,UROUND,N,MF,KFLAG,JSTART
      COMMON /EPCM10/ TAU(13),EL(13),TQ(5),LMAX,METH,NQ,L,NQINDX
      DATA ONE /1.0E0/, ZERO /0.0E0/
C
      IF (NQ .EQ. 2) RETURN
      NQM1 = NQ - 1
      NQM2 = NQ - 2
      GO TO (100, 200), METH
C
 100  DO 110 J = 1,LMAX
 110    EL(J) = ZERO
      EL(2) = ONE
      HSUM = ZERO
      DO 130 J = 1,NQM2
C CONSTRUCT COEFFICIENTS OF X*(X+XI(1))*...*(X+XI(J)). -----------------
        HSUM = HSUM + TAU(J)
        XI = HSUM/H
        JP1 = J + 1
        DO 120 IBACK = 1,JP1
          I = (J + 3) - IBACK
 120      EL(I) = EL(I)*XI + EL(I-1)
 130    CONTINUE
C CONSTRUCT COEFFICIENTS OF INTEGRATED POLYNOMIAL. ---------------------
      DO 140 J = 2,NQM1
  140   EL(J+1) = FLOAT(NQ)*EL(J)/FLOAT(J)
      GO TO 300
C
 200  DO 210 J = 1,LMAX
 210    EL(J) = ZERO
      EL(3) = ONE
      HSUM = ZERO
      DO 230 J = 1,NQM2
C CONSTRUCT COEFFICIENTS OF X*X*(X+XI(1))*...*(X+XI(J)). ---------------
        HSUM = HSUM + TAU(J)
        XI = HSUM/H
        JP1 = J + 1
        DO 220 IBACK = 1,JP1
          I = (J + 4) - IBACK
 220      EL(I) = EL(I)*XI + EL(I-1)
 230    CONTINUE
C
C SUBTRACT CORRECTION TERMS FROM Y ARRAY. ------------------------------
 300  DO 320 J = 3,NQ
        DO 310 I = 1,N
 310      Y(I,J) = Y(I,J) - Y(I,L)*EL(J)
 320    CONTINUE
      RETURN
C-----------------------  END OF SUBROUTINE ADJUST  --------------------
      END
