      subroutine cbsu3_bnd1a_mpi(idg,my_id) ! Bernd Berg Dec 12 2008. 
C Collect boundaries without corners from checkerboard 1 for SU3 action.
      include '../../Libs/Fortran/implicit.sta'
      include 'mpif.h'
      include '../../Libs/Fortran/constants.par'
      include '../../Libs/Fortran_par/latmpi.par' ! Defines n18.
      include '../../Libs/Fortran_par/mc.par'
C nbufsize dimensions buffer in common_mpibuffer.
      parameter(mscb18=n18*mscb,nbufsize=mscb18)
      include '../../Libs/MPI_par/common_cblat.f'
      include '../../Libs/MPISU3/common_cbsu3.f' 
      include '../../Libs/MPI_par/common_mpi.f'
      include '../../Libs/MPI_par/common_mpibuffer.f'
      ltest=.true. 
      ltest=.false.
      if(ltest.and. my_id.eq.0) 
     &  print*,"cbsu3_bnd1a_mpi: idg,mscb,mscb18 =",idg,mscb,mscb18
C
C Gather boundaries on checkerboard 1 (used for update of checkerboard 2):
      ismpi=my_id+1
      itag=idg
      nbuff=mscb18
      do idmpi=1,ndmpi
        do iscb=1,mscb 
          do isu3=1,n18 ! Gather:
            a1su3fb(isu3,iscb)=a1su3(isu3,ipfb1(iscb,idmpi),idg)
            a1su3bb(isu3,iscb)=a1su3(isu3,ipbb1(iscb,idmpi),idg) 
          enddo
        enddo
C Send from checkerboard 1 to receive by checkerboard 2:
        irecv=ipf_mpi(idmpi,ismpi)-1 ! Send forward.
        call mpi_buffer_attach(buffer,nbuff,ierr)
        call mpi_bsend(a1su3fb,mscb18,mpi_double_precision,
     &                irecv,itag,mpi_comm_world,ierr)
        i1=1+msc+(idmpi-1)*mscb      ! Position in a1su3.
        isend=ipb_mpi(idmpi,ismpi)-1 ! Received from isend:
        call mpi_recv(a1su3(1,i1,idg),mscb18,mpi_double_precision,
     &                isend,itag,mpi_comm_world,istatus,ierr)
        call mpi_buffer_detach(buffer,nbuff,ierr)
        irecv=ipb_mpi(idmpi,ismpi)-1 ! Send backward:
        call mpi_buffer_attach(buffer,mscb18,ierr)
        call mpi_bsend(a1su3bb,mscb18,mpi_double_precision,
     &                irecv,itag,mpi_comm_world,ierr)
        i1=1+noffset+(idmpi-1)*mscb  ! Position in a1su3.
        isend=ipf_mpi(idmpi,ismpi)-1 ! Received from isend:
        call mpi_recv(a1su3(1,i1,idg),mscb18,mpi_double_precision,
     &                isend,itag,mpi_comm_world,istatus,ierr)
        call mpi_buffer_detach(buffer,nbuff,ierr)
      enddo
      if(ltest) then ! -----------
        if(my_id.eq.0) print*,"nbuff =",nbuff
        if(my_id.eq.0) print*,"cbsu3_bnd1a_mpi: stop for ltest."
        call mpi_finalize(ierr)
      stop
      endif ! --------------------
C
      return
      end
