      subroutine cbsu3_wloops_mpi(imeas,my_id) ! Bernd Berg Mar 24 2008.
C MPI checkerboard: SU3 space- and time-like Wilson loops.
      include '../../Libs/Fortran/implicit.sta'
      include 'mpif.h'
      include '../../Libs/Fortran/constants.par'
      include '../../Libs/Fortran_par/latmpi.par'
      include '../../Libs/Fortran_par/mc.par'
      include '../../Libs/MPI_par/common_cblat.f'
      include '../../Libs/MPISU3/common_cbsu3.f' ! Defines n18.
      include '../../Libs/MPI_par/common_mpi.f'
      dimension am1(n18),am2(n18)
      ltest=.true.
      ltest=.false.
      if(ltest.and.my_id.eq.0) then
        write(iuo,'(/,"cbsu3_wloops_mpi: ")') 
      endif
C
      ws=zero
      wt=zero
      do is=1,msc ! Calculate Wloops for checkerboard 1:
        do id1=1,nd-1
          do id2=id1+1,nd
            call su3mult_m_mh_m(a2su3(1,ipf1(id1,is),id2),
     &                          a2su3(1,ipf1(id2,is),id1),am1)
            call su3mult_m_mh_m(am1,a1su3(1,is,id2),am2)
            call su3mult_m_m_m(am2,a1su3(1,is,id1),am1) ! result in am1
            trace=am1(1)+am1(5)+am1(9) ! Real part of trace[matrix am1].
            if((id1.ne.nd).and.(id2.ne.nd)) then ! nd is time direction.
              ws=ws+trace/three ! Add to Wilson space-loop.
            else
              wt=wt+trace/three ! Add to Wilson time-loop.
            endif
          end do
        end do
      end do
c
      do is=1,msc ! Calculate Wloops for checkerboard 2:
        do id1=1,nd-1
          do id2=id1+1,nd
            call su3mult_m_mh_m(a1su3(1,ipf2(id1,is),id2),
     &                          a1su3(1,ipf2(id2,is),id1),am1)
            call su3mult_m_mh_m(am1,a2su3(1,is,id2),am2)
            call su3mult_m_m_m(am2,a2su3(1,is,id1),am1) ! result in am1
            trace=am1(1)+am1(5)+am1(9) ! Real part of trace[matrix am1].
            if((id1.ne.nd).and.(id2.ne.nd)) then ! nd is time direction.
              ws=ws+trace/three ! Add to Wilson space-loop.
            else
              wt=wt+trace/three ! Add to Wilson time-loop.
            endif
          end do
        end do
      end do
C
      tsws(imeas)=ws/mpspace
      tswt(imeas)=wt/mptime
C
      if(ltest) then ! ----------------------------------------
        if(my_id.eq.0) write(iuo,'(/,"cbsu3_wloops_mpi: ltest.",/)')
        if(lud2) write(iud2,'(/,"cbsu3_wloops_mpi: ltest.",/)')
        if(lud2) close(iud2)
        call mpi_finalize(ierr)
      stop "cbsu3_wloops_mpi: ltest."
      endif ! --------------------------------------------------
C
      return
      end
