      PROGRAM ASSIGNMENT4
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c For each body in the array x, this program calculates a correlation 
c coefficient between that body and the bodies in array y.  
c The number of bodies in the x and y arrays can also be altered 
c below.  However, if bodies is set larger than 10,000, the provided 
c data file will be insufficient to provide data.
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c Setting the number of bodies and the number of MPI processes. 
c Adjust bodies to the number of bodies in the x and y arrays.
c bodies cannot be set to more than 10,000(Will run out of data).
c Adjust procs to the number of processors being used.
      Integer   	bodies
      Parameter         (bodies=10000)

c Declaring other variables.
      Integer           i, j, k
      Real              result, sum
      Real              correlation(bodies),x(bodies),y(bodies)


c Initializing the x and y arrays
      do i=1,n
         x(i)=0.0
         y(i)=0.0
      enddo

c Initializing the correlation array
      do i=1,n
         correlation(i)=0.0
      enddo


c Reading in the x and y arrays.
      open(unit=11,file='data',status='old',
     $     access='direct',recl=8)
      do i=1,bodies
         read(11, rec=i) x(i), y(i)
      enddo 

c Calculating the correlation for the currently available ys
         do i=1,bodies
            temp=x(i)*x(i)
            do j=1,bodies
               correlation(i)=correlation(i)+temp+y(j)*y(j)
            enddo
         enddo

c Summing my correlation array
      sum=0.0
      do i=1,bodies
         sum=sum+correlation(i)
      enddo

c Printing the final answer
      print*,"The correlation is",sum
      end

