C  * * * * * * * * * * * * * * * * * * * * *                            
C     SUBROUTINE FOR FOURIER COEFFICIENTS                               
C  * * * * * * * * * * * * * * * * * * * * *                            
C                                                                       
C                       CODED BY Y.OHSAKI                               
C                                                                       
C     PURPOSE                                                           
C       TO COMPUTE FINITE FOURIER SINE AND COSINE COEFFICIENTS FOR      
C       A SERIES OF EQUI-SPACED DATA                                    
C                                                                       
C     USAGE                                                             
C       CALL FOUC(N,X,ND1,A,B,ND2,NFOLD)                                
C                                                                       
C     DESCRIPTION OF ARGUMENTS                                          
C       N      - TOTAL NUMBER OF DATA                                   
C       X(ND1) - EQUI-SPACED DATA                                       
C       ND1    - DIMENSION OF X IN CALLING PROGRAM                      
C       A(ND2) - FOURIER COS COEFFICIENTS                               
C       B(ND2) - FOURIER SIN COEFFICIENTS                               
C       ND2    - DIMENSION OF A,B IN CALLING PROGRAM  ND2.GE.N/2+1      
C       NFOLD  - TOTAL NUMBER OF EACH COEFFICIENT                       
C                                                                       
C     SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED                     
C       NONE                                                            
C                                                                       
      SUBROUTINE FOUC(N,X,ND1,A,B,ND2,NFOLD)                            
C                                                                       
      DIMENSION X(ND1),A(ND2),B(ND2)                                    
      PARAMETER (P2=6.283185)                                           
C                                                                       
      NFOLD=N/2+1                                                       
      DO 120 K=1,NFOLD                                                  
      AK=0.                                                             
      BK=0.                                                             
      DO 110 M=1,N                                                      
      AK=AK+X(M)*COS(P2*REAL((K-1)*(M-1))/REAL(N))                      
      BK=BK+X(M)*SIN(P2*REAL((K-1)*(M-1))/REAL(N))                      
  110 CONTINUE                                                          
      A(K)=2./REAL(N)*AK                                                
      B(K)=2./REAL(N)*BK                                                
  120 CONTINUE                                                          
      RETURN                                                            
      END                                                               
