C....*...1.........2.........3.........4.........5.........6.........7.*.......8
C     SLOWF  10/1/71
C
C     PURPOSE
C     COMPUTES ALL FOURIER COEFFICIENTS AND PERIODOGRAM ORDINATES FOR
C     A GIVEN REAL TIME SERIES OF LENGTH N.
C
C     THIS ROUTINE COMPUTES:
C     C= A(0), A(1), B(1), ..., A((N-1)/2), B((N-1)/2)          N ODD
C     C= A(0), A(1), B(1), ..., A((N-2)/2), B((N-2)/2), A(N/2)  N EVEN
C     P = P(W0), P(W1), ..., P(W(N-1)/2)                        N ODD
C     P = P(W0), P(W1), ..., P(WN/2)                            N EVEN
C     NP = THE NUMBER OF PERIODOGRAM ORDINATES
C
C     DPER is probably a better choice.
C
C
C     USAGE
C     CALL SLOWF(X,N,C,P,NP)
C
C
C     ARGUMENTS
C     X   - INPUT ARRAY
C           REAL*8
C     N   - LENGTH OF INPUT ARRAY
C           INTEGER
C     C   - ARRAY OF COMPUTED COEFFICIENTS ARRANGED AS ABOVE
C           REAL*8
C     P   - ARRAY OF COMPUTED PERIODOGRAM ORDINATES ARRANGED AS ABOVE
C           REAL*8
C     NP  - COMPUTED NUMBER OF PERIODOGRAM ORDINATES
C           INTEGER
C
      SUBROUTINE SLOWF(X,N,C,P,NP)
      implicit real*8 (a-h,o-z)
      save
      REAL*8 X(1), C(1), P(1)
      C(1) = 0.d0
      DO 100 K = 1, N
  100 C(1) = C(1) + X(K)/N
      P(1) = C(1) * C(1) * N * 2.d0
      IF(N.EQ.1) RETURN
      N2 = N/2
      MODN2 = MOD(N,2)
      IF(MODN2 .EQ. 0) N2 = N2 - 1
      DO 300 M = 1, N2
      ARG = 6.283185307179586d0 * M / N
      CALL TRIG(N,X,ARG,SC,CC)
      MC = 2*M
      MS = 2*M + 1
      C(MC) = CC/N*2.d0
      C(MS) = SC/N*2.d0
      P(M+1) = C(MC)*C(MC)*N/2.d0+C(MS)*C(MS)*N/2.d0
  300 CONTINUE
      NP = MC/2 +1
      IF(MODN2 .EQ. 1) RETURN
      ARG = 6.283185307179586d0 * (N2+1) / N
      CALL TRIG(N,X,ARG,SC,CC)
      C(N) = CC / N
      P(NP+1) = C(N)*C(N)*N*2.d0
      NP = NP+1
      RETURN
      END
C     TRIG  11/18/70  ROUGH TEXT
C     COMPUTE SIN AND COS TRANSFORMS FOR A GIVEN HARMONIC W.
C
C     PURPOSE
C     THIS ROUTINE COMPUTES
C     C=SUM(X(I)*COS((I-1)*W))
C     S=SUM(X(J)*SIN((J-1)*W))
C
C     USAGE
C     CALL TRIG(LX,X,W,SS,CC)
C
C     ARGUMENTS
C     LX      LENGTH OF INPUT ARRAY
C     X(LX)   INPUT ARRAY
C     W       FREQUENCY IN RADIANS
C     S       SINE TRANSFORM
C     C       COSINE TRANSFORM
C
C
C
      SUBROUTINE TRIG(LX,X,W, S, C)
      implicit real*8 (a-h,o-z)
      save
      DIMENSION X(1)
      SINW=dSIN(W)
      COSW=dCOS(W)
      S=0.0d0
      C=X(LX)
      NX=LX+1
      DO 10 J=2,LX
      I=NX-J
      T=C
      C=T*COSW-S*SINW+X(I)
      S=T*SINW+S*COSW
10    CONTINUE
      RETURN
      END
