C....*...1.........2.........3.........4.........5.........6.........7.*.......8
C     SLOWCP   8/21/72
C
C     PURPOSE
C     COMPUTE THE PERIODOGRAMS AND CROSS PERIODOGRAMS OF TWO REAL TIME
C     SERIES.
C
C     USAGE
C     CALL SLOWCP(X,Y,N,PX,PY,CXY,QXY,NP)
C
C     SUBROUTINES CALLED
C     CXSX
C
C     ARGUMENTS
C     X   - INPUT VECTOR OF LENGTH N.
C           REAL*8
C     Y   - INPUT VECTOR OF LENGTH N.
C           REAL*8
C     N   - LENGTH OF X AND Y.
C           INTEGER
C     PX  - PERIODOGRAM OF X; VECTOR OF LENGTH NP.
C           REAL*8
C     PY  - PERIODOGRAM OF Y; VECTOR OF LENGTH NP.
C           REAL*8
C     CXY - REAL PART OF THE CROSS PERIODOGRAM; VECTOR OF LENGTH NP.
C           REAL*8
C     QXY - IMAGINARY PART OF THE CROSS PERIODOGRAM; VECTOR OF LENGTH NP
C           REAL*8
C     NP  - COMPUTED LENGTH OF PX, PY, CXY, QXY.
C           INTEGER
C
C     REMARKS
C     FOR GIVEN W LET:
C     CX=SUM(X(I)*COS((I-1)*W))   (I=1,2,...,N)
C     SX=SUM(X(I)*SIN((I-1)*W))   (I=1,2 ...,N)
C     CY=SUM(Y(I)*COS((I-1)*W))   (I=1,2 ...,N)
C     SY=SUM(Y(I)*SIN((I-1)*W))   (I=1,2 ...,N)
C     C=2.E0/N
C     THIS ROUTINE COMPUTES:
C     PX(K)=C*(CX*CX+SX*SX)
C     PY(K)=C*(CY*CY+SY*SY)
C     CXY(K)=C*(CX*CY+SX*SY)
C     QXY(K)=C*(CX*SY-SX*CY)
C     FOR W=6.28*(K-1)/N WHERE K=1,2,...,NP.
C
      SUBROUTINE SLOWCP(X,Y,N,PX,PY,CXY,QXY,NP)
      implicit real*8 (a-h,o-z)
      save
      REAL*8 X(1),Y(1),PX(1),PY(1),CXY(1),QXY(1)
      MODN2=MOD(N,2)
      IF(MODN2.EQ.0) NP=N/2+1
      IF(MODN2.EQ.1) NP=(N-1)/2+1
      FN=dFLOAT(N)
      C=2.d0/FN
      DO 10 K=1,NP
      WK=6.283185307179586d0*dFLOAT(K-1)/FN
      CALL dCXSX(X,N,WK,CX,SX)
      CALL dCXSX(Y,N,WK,CY,SY)
      PX(K)=   C*(CX*CX+SX*SX)
      PY(K)=   C*(CY*CY+SY*SY)
      CXY(K)=  C*(CX*CY+SX*SY)
10    QXY(K)=  C*(CX*SY-SX*CY)
      RETURN
      END
