      SUBROUTINE CERR (T, FT, GT, PHIT, DEL, IERR, L, LP1, M, NP1, D)
C     ------------------------------------------------------------------
C     COMPUTE THE APPROXIMATION ERROR AT POINT T
C     ------------------------------------------------------------------
      DOUBLE PRECISION T, FT, GT, PHIT, DEL, D(NP1)
      DOUBLE PRECISION P, Q, R, ZERO, ONE
      DATA ZERO/0.D0/, ONE/1.D0/
C     -------------------
      P = D(LP1)
      IF (L .LE. 0) GO TO 20
      DO 10 I = 1,L
      II = LP1 - I
   10 P = P*PHIT + D(II)
C
   20 Q = ZERO
      IF (M .LE. 0) GO TO 22
      DO 21 I = 1,M
      II = NP1 - I
   21 Q = (Q + D(II))*PHIT
   22 Q = Q + ONE
C
      IF (Q .EQ. ZERO) GO TO 110
      IF (GT .EQ. ZERO) GO TO 100
      R = P/Q
      DEL = (R - FT)/GT
      RETURN
C     ------------------------------------------------------------------
C     ERROR RETURN
C     ------------------------------------------------------------------
C     THE FUNCTION G IS ZERO AT POINT T
C
  100 IERR = 1
      RETURN
C
C     THE ROUTINE HAS COMPLETELY FAILED - THE RESULTS SHOULD BE IGNORED
C
  110 IERR = 6
      RETURN
      END
