C
C     ..................................................................
C
C        SUBROUTINE SE15
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 SE15(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 1 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 SE15(Y,Z,NDIM,IER)
C
C
      DIMENSION Y(1),Z(1)
C
C        TEST OF DIMENSION
      IF(NDIM-5)3,1,1
C
C        PREPARE LOOP
    1 A=Y(1)+Y(1)
      C=Y(2)+Y(2)
      B=.2*(A+Y(1)+C+Y(3)-Y(5))
      C=.1*(A+A+C+Y(2)+Y(3)+Y(3)+Y(4))
C
C        START LOOP
      DO 2 I=5,NDIM
      A=B
      B=C
      C=.2*(Y(I-4)+Y(I-3)+Y(I-2)+Y(I-1)+Y(I))
    2 Z(I-4)=A
C        END OF LOOP
C
C        UPDATE LAST FOUR COMPONENTS
      A=Y(NDIM)+Y(NDIM)
     0A=.1*(A+A+Y(NDIM-1)+Y(NDIM-1)+Y(NDIM-1)+Y(NDIM-2)+Y(NDIM-2)
     1      +Y(NDIM-3))
      Z(NDIM-3)=B
      Z(NDIM-2)=C
      Z(NDIM-1)=A
      Z(NDIM)=A+A-C
      IER=0
      RETURN
C
C        ERROR EXIT IN CASE NDIM IS LESS THAN 5
    3 IER=-1
      RETURN
      END
