C
C     ..................................................................
C
C        SUBROUTINE SE35
C
C        PURPOSE
C           TO COMPUTE A VECTOR OF SMOOTHED FUNCTION VALUES GIVEN A
C           VECTOR OF FUNCTION VALUES WHOSE ENTRIES CORRESPOND TO
C           EQUIDISTANTLY SPACED ARGUMENT VALUES.
C
C        USAGE
C           CALL SE35(Y,Z,NDIM,IER)
C
C        DESCRIPTION OF PARAMETERS
C           Y     -  GIVEN VECTOR OF FUNCTION VALUES (DIMENSION NDIM)
C           Z     -  RESULTING VECTOR OF SMOOTHED FUNCTION VALUES
C                    (DIMENSION NDIM)
C           NDIM  -  DIMENSION OF VECTORS Y AND Z
C           IER   -  RESULTING ERROR PARAMETER
C                    IER = -1  - NDIM IS LESS THAN 5
C                    IER =  0  - NO ERROR
C
C        REMARKS
C           (1)  IF IER=-1 THERE HAS BEEN NO COMPUTATION.
C           (2)   Z CAN HAVE THE SAME STORAGE ALLOCATION AS Y.  IF Y IS
C                 DISTINCT FROM Z, THEN IT IS NOT DESTROYED.
C
C        SUBROUTINE AND FUNCTION SUBPROGRAMS REQUIRED
C           NONE
C
C        METHOD
C           IF X IS THE (SUPPRESSED) VECTOR OF ARGUMENT VALUES, THEN
C           EXCEPT AT THE POINTS X(1),X(2),X(NDIM-1) AND X(NDIM), EACH
C           SMOOTHED VALUE Z(I) IS OBTAINED BY EVALUATING AT X(I) THE
C           LEAST-SQUARES POLYNOMIAL OF DEGREE 3 RELEVANT TO THE 5
C           SUCCESSIVE POINTS (X(I+K),Y(I+K)) K = -2,-1,...,2.  (SEE
C           HILDEBRAND, F.B., INTRODUCTION TO NUMERICAL ANALYSIS,
C           MC GRAW-HILL, NEW YORK/TORONTO/LONDON, 1956, PP. 295-302.)
C
C     ..................................................................
C
      SUBROUTINE SE35(Y,Z,NDIM,IER)
C
C
      DIMENSION Y(1),Z(1)
C
C        TEST OF DIMENSION
      IF(NDIM-5)4,1,1
C
C        PREPARE LOOP
    1 B=Y(1)
      C=Y(2)
C
C        START LOOP
      DO 3 I=5,NDIM
      A=B
      B=C
      C=Y(I-2)
C
C        GENERATE FOURTH CENTRAL DIFFERENCE
      D=C-B-Y(I-1)
      D=D+D+C
      D=D+D+A+Y(I)
C
C        CHECK FIRST TWO COMPONENTS
      IF(I-5)2,2,3
    2 Z(1)=A-.01428571*D
      Z(2)=B+.05714286*D
    3 Z(I-2)=C-.08571429*D
C        END OF LOOP
C
C        UPDATE LAST TWO COMPONENTS
      Z(NDIM-1)=Y(NDIM-1)+.05714286*D
      Z(NDIM)=Y(NDIM)-.01428571*D
      IER=0
      RETURN
C
C        ERROR EXIT IN CASE NDIM IS LESS THAN 5
    4 IER=-1
      RETURN
      END
