      subroutine exact_cor ! Bernd Berg Apr 10 2012. 
C Measurement of correlations functions.
      include '../../Libs/Fortran/implicit.sta'
      include '../../Libs/Fortran/constants.par'
      include '../../Libs/Fortran_par/lat.par'
      include '../../Libs/Fortran_par/mc.par'
      include '../../Libs/Fortran_par/common_exactl.f'
      include '../../Libs/Scalar_par/common_exactc.f'
      dimension ix(nd),dkx(nd)
      ltest=.false.
      if(ltest) stop "exact_cor: ltest."
      ltest=.true.
C 
C Initialization of momentum space arrays and correlation functions:
C
      do id=1,nd ! Momenta stepsizes.
        dkx(id)=tpi/nla(id) 
      enddo
      write(iuo,'("nla:",4I4)') nla
      write(iuo,'("dkx:",4G14.6,/)') dkx
      do is=1,ms 
        call ixcor(ix,nla,is,nd)
        prop(is)=xm**2
        do id=1,nd
          xk(id,is)=ix(id)*dkx(id)
          prop(is)=prop(is)+four*sin(half*xk(id,is))**2
        enddo
        prop(is)=one/prop(is)
      enddo
      do it=0,mtm1 ! Correlations. Distance in it=ix(nd).
        cor0(it)=zero
        cor1r(it)=zero
        cor1i(it)=zero
      enddo
C
C Calculation of correlation functions:
C
      do is=1,ms 
        call ixcor(ix,nla,is,nd)
        it=ix(nd)
        xdkndm1=ix(1)*dkx(1)
        cxdkndm1=cos(xdkndm1)
        sxdkndm1=sin(xdkndm1)
        do ik=1,ms ! Momentum space sum.
          xdk=zero ! Vector product for exp of numerator.
          do id=1,nd
            xdk=xdk+ix(id)*xk(id,ik)
          enddo
          add=cos(xdk)*prop(ik)
          cor0(it)=cor0(it)+add
          cor1r(it)=cor1r(it)+cxdkndm1*add
          cor1i(it)=cor1i(it)+sxdkndm1*add
        enddo
      enddo
C
      write(iuo,'("Correlations:",/)') dkx
      cor0(mt)=cor0(0)   ! Complete symmetry ! 
      cor1r(mt)=cor1r(0) ! Complete symmetry ! 
      cor1i(mt)=cor1i(0) ! Complete symmetry ! 
      factor=1.92275d00/cor0(0)
      fact1=147.26d00/cor1r(0)
      do it=0,mt
        cor0(it)=half*cor0(it)  ! Correct normalizations ???
        cor1r(it)=half*cor1r(it)
        write(iuo,'(I5,3G15.7)') it,cor0(it),cor1r(it),cor1i(it)
      enddo
      return
      end
