      subroutine cbsu3_actdif_mpi(adif,actsum1,actsum2,my_id) 
C Bernd Berg Jun 14 2008. 
C Action comparison and adjustment for U1 MPI checkerboard. Aborts if 
C discrepancy with actsum1 (sum of actions before recalculation) is 
C found. Set eps below! No discrepancy: returns relative error adif.
C actsum1,2: Indices refer to before and after recalculation.
C acthw1,2:  Indices refer to torus 1 and 2 (both after recalculation).
      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' ! Set eps:
      parameter(mstot=nlat*msmpi,lcollect=.false.,eps=one/10**8) 
      include '../../Libs/MPI_par/common_cblat.f'
      include '../../Libs/MPISU3/common_cbsu3.f'
      dimension actgather1(mstot),actgather2(mstot)
      common/acthw/acthw1,acthw2
      data icall/0/
      save icall
      if(icall.lt.1000) icall=icall+1 ! prevents overflow.
      ltest=.true.
      ltest=.false.
C
      call mpi_allgather(act,ione,mpi_double_precision,actgather1,
     &             ione,mpi_double_precision,mpi_comm_world,ierr)
      actsum1=sum_fun(mstot,actgather1)
      call cbsu3_act_mpi(lcollect,my_id) ! Check. Overwrites previous act.
      call mpi_allgather(act,ione,mpi_double_precision,actgather2,
     &             ione,mpi_double_precision,mpi_comm_world,ierr)
      actsum2=sum_fun(mstot,actgather2)
      adif=abs((actsum1-actsum2)/mpc) 
C
      if(nlat.eq.2) then ! acthw1, 2 kept in common_cbu1.f.
        acthw1=sum_fun(msmpi,actgather2) ! act of half-world 1.
        acthw2=actsum2-acthw1            ! act of half-world 2.
      else
        acthw1=actsum1
        acthw2=zero
      if(nlat.ne.1) stop "cbsu3_actdif_mpi STOP: nlat false." 
      endif
C
      if(ltest.or.(adif.gt.eps)) then
        if(my_id.eq.0) write(iuo,'(/," cbsu3_actdif_mpi: see MPI*.d.")')
        write(iud2,'(/," cbsu3_actdif_mpi: icall, mstot =",2I6,6X,
     &                 "ltest =",L2)') icall,mstot,ltest
        if(adif.gt.eps) write(iud2,'(" Error discrepancy of actions!")')
        write(iud2,'(" actsum1,actsum2:",2G14.6)') actsum1,actsum2
        write(iud2,'(" actgather1:     ",4G14.6)') actgather1
        write(iud2,'(" actgather2:     ",4G14.6)') actgather2
        write(iud2,'(" Relative error actdif, eps:",2G16.7,/)') adif,eps
        if(my_id.eq.0) write(iuo,'("cbsu3_actdif_mpi: stop.")')
        close(iud2)
        call mpi_finalize(ierr)
      if(adif.gt.eps) stop "cbsu3_actdif_mpi: action discrepancies."
      if(ltest) stop "cbsu3_actdif_mpi: ltest."
      endif
      return
      end
