C  * * * * * * * * * * * * * * * * * * * * * * * * *                    
C     SUBROUTINE FOR AUTOCORRELATION COEFFICIENTS                       
C  * * * * * * * * * * * * * * * * * * * * * * * * *                    
C                                                                       
C                               CODED BY Y.OHSAKI                       
C                                                                       
C     PURPOSE                                                           
C       TO COMPUTE AUTOCORRELATION COEFFICIENTS OF A SERIES OF EQUI-    
C       SPACED DATA                                                     
C                                                                       
C     USAGE                                                             
C       CALL AUTO(N,X,ND1,R,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       R(ND2) - AUTOCORRELATION COEFFICIENTS                           
C       ND2    - DIMENSION OF R IN CALLING PROGRAM  ND2.GE.N/2+1        
C       NFOLD  - TOTAL NUMBER OF AUTOCORRELATION COEFFICIENTS           
C                                                                       
C     REMARKS                                                           
C       (1) AUTOCORRELATION COEFFICIENTS ARE NORMALIZED IN TERMS OF     
C           THE MEAN OF SQUARED DATA                                    
C       (2) AUTOCORRELATION COEFFICIENS ARE SPACED AT THE SAME INTER-  
C           VAL AS THE GIVEN SERIES OF DATA                             
C                                                                       
C     SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED                     
C       NONE                                                            
C                                                                       
      SUBROUTINE AUTO(N,X,ND1,R,ND2,NFOLD)                              
C                                                                       
      DIMENSION X(ND1),R(ND2)                                           
C                                                                       
      NFOLD=N/2+1                                                       
      DO 120 J=1,NFOLD                                                  
      RJ=0.                                                             
      DO 110 M=1,N                                                      
      MJ=M+J-1                                                          
      IF(MJ.GT.N) MJ=MJ-N                                               
      RJ=RJ+X(M)*X(MJ)                                                  
  110 CONTINUE                                                          
      R(J)=RJ                                                           
  120 CONTINUE                                                          
      R0=R(1)                                                           
      DO 130 J=1,NFOLD                                                  
      R(J)=R(J)/R0                                                      
  130 CONTINUE                                                          
      RETURN                                                            
      END                                                               
