!&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
       subroutine bocov2l_cb(h,im,jm,ln)
!     ******************************************************************
!     *                                                                *
!     *  boundary conditions for scalar defened in v points on cube    *
!     *                                                                *
!     ******************************************************************
!--------------------------------------------------------------------
      implicit none

      integer:: im,jm,ln
      integer, parameter:: nm=6
      real    :: h(1-ln:im+ln,1-ln:jm+ln,6)
      integer :: n,nl,nr,i,j,im1,jm1,k

      im1=im-1
      jm1=jm-1
!------------------------------------------------------------------------
!                 lateral faces                                          
!------------------------------------------------------------------------
! 
! lateral conditions
!
      do k=1,ln
      do n=1,4
        nl=n-1+4*((5-n)/4)
        nr=n+1-4*(n/4)
         do j=1,jm-1
           h(1-k   ,j,n)=h(im-k,j,nl)
           h(im+k-1,j,n)=h(k  ,j,nr)
         end do
      end do
!
! lower and upper conditions
!
      do i=1,im-1
        h(i,jm+k-1,1)=h(i,k  ,5)              !     face 1
        h(i,1-k   ,1)=h(i,jm-k,6)             !
        h(i,jm+k-1,2)=h(im-k,i     ,5)        !     face 2
        h(i,1-k   ,2)=h(im-k,jm-i,6)          !
        h(i,jm+k-1,3)=h(im-i,jm-k,5)          !     face 3
        h(i,1-k   ,3)=h(im-i,k  ,6)           !
        h(i,jm+k-1,4)=h(k,jm-i,5)             !     face 4
        h(i,1-k   ,4)=h(k,i     ,6)           !
      end do
!------------------------------------------------------------------------
!                upper and lower faces                                  
!------------------------------------------------------------------------
!
! lateral conditions
!
      do j=1,jm-1
        h(1-k   ,j,5)=h(im-j,jm-k,4)          !     face 5
        h(im+k-1,j,5)=h(j     ,jm-k,2)        !
        h(1-k   ,j,6)=h(j     ,k,4)           !     face 6
        h(im+k-1,j,6)=h(im-j,k,2)             !
      end do
!
! lower and upper conditions
!
      do i=1,im-1
        h(i,jm+k-1,5)=h(im-i,jm-k,3)          !     face 5
        h(i,1-k   ,5)=h(i     ,jm-k,1)        !
        h(i,jm+k-1,6)=h(i     ,k,1)           !     face 6
        h(i,1-k   ,6)=h(im-i,k,3)             !
      end do
      enddo


!------------------------------------------------------------------------
!  corners
!
      h(0,0,:)=0.
      h(im,0,:)=0.
      h(0,jm,:)=0.
      h(im,jm,:)=0.

    
!------------------------------------------------------------------------
      return
      end subroutine bocov2l_cb


