C Corr-coef calculation:
	subroutine corcoef(nn,res1,res2,corf,sf12)
C	nn - number of pair X,Y
	dimension res1(5183),res2(5183)
	cnt=float(nn)
	af1f2=0.
	af1=0.
	af2=0.
	aff1=0.
	aff2=0.

C
	do i=1,nn
	af1f2=af1f2+res1(i)*res2(i)
	af1=af1+res1(i)
	af2=af2+res2(i)
	aff1=aff1+res1(i)*res1(i)
	aff2=aff2+res2(i)*res2(i)
	enddo
	af1f2=af1f2/cnt
	af1=af1/cnt
	af2=af2/cnt
	aff1=aff1/cnt
	aff2=aff2/cnt

	corf=(af1f2-af1*af2)/(sqrt(aff1-af1*af1)*sqrt(aff2-af2*af2))

C  Dispersion:
	sf1=sqrt(aff1-af1*af1)
	sf2=sqrt(aff2-af2*af2)
	sf12=sf2*sqrt(1.-corf)
	bf21=corf*sf2/sf1
	avf1=af1
	avf2=af2

C Output of results
c	WRITE(*,150) corf,sf12,corx,sx12,avf1,sf1,avf2,sf2,bf21
c	+,avx1,sx1,avx2,sx2,bx21,ii
	RETURN
	end
