      SUBROUTINE HTRP (N,X,Y,A,T,IERR)
C     ******************************************************************
C     HERMITE INTERPOLATION
C     ******************************************************************
      DIMENSION X(N),Y(N),A(N),T(N)
      IF (N.LE.0) GO TO 30
      IERR = 0
      A(1) = Y(1)
      IF (N.EQ.1) RETURN
      F = 1.0
      R = 0.0
      IEND = 0
      IBEG = 1
C
      DO 22 K=2,N
      IF (X(K)-X(K-1)) 10,20,10
C
   10 F = 1.0
      R = 0.0
      IEND = K-1
      IBEG = K
      T(1) = Y(K)
      DO 11 I=1,IEND
      DIFF = X(I)-X(K)
      IF (DIFF) 11,31,11
   11 T(I+1) = (A(I)-T(I))/DIFF
      GO TO 22
C
   20 R = R+1.0
      F = F*R
      T(1) = Y(K)/F
      IF (IEND.EQ.0) GO TO 22
      DO 21 I=1,IEND
   21 T(I+1) = (T(I+1)-T(I))/(X(I)-X(K))
   22 A(K) = T(IBEG)
      RETURN
C
   30 IERR = 1
      RETURN
   31 IERR = 2
      T(1) = I
      T(2) = K
      RETURN
      END
