c/* BeginSourceFile corel2.f */


	subroutine correl(cor, sig1, sig2, beg1, beg2, n)
	implicit real*8(a-h,o-z)
	integer beg1, beg2, n
	dimension sig1(n), sig2(n)
	parameter ( ipar = 20, icache = 4 )
	dimension sump(ipar * icache)
	ipn = n/ipar
c LOOP C-2. This loop should parallelize, but is not considered
c profitable, so we force it to parallelize.
c$par doall
	do ip = 1, ipar
		istart = 1 + (ip-1)*ipn
		iend = ip*ipn
		if (ip .eq. ipar) iend = n
		ipx = ip * icache
		sump(ipx) = 0.0
c LOOP C-3. Will not parallelize because of dependency.
		do i = istart, iend
			sump(ipx) = sump(ipx) + sig1(i+beg1-1) * sig2(i+beg2-1)
		end do
	end do
	cor = 0.0
c LOOP C-4. To collect partial sums. Will not parallelize.
	do ip = 1, ipar
		cor = cor + sump(ip * icache)
	end do
	return
	end
c/* EndSourceFile */
