!&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
       subroutine bocoh2l_cb(h,im,jm,ln)
!     ******************************************************************
!     *                                                                *
!     *  boundary conditions for height points on cube                 *
!     *                                                                *
!     ******************************************************************
!--------------------------------------------------------------------
      implicit none

      integer, parameter:: nm=6
      integer:: im,jm,ln
      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
           h(1-k  ,j,n)=h(im-k,j,nl)
           h(im+k,j,n)=h(1+k  ,j,nr)
         end do
      end do
! 
!  lower and upper conditions
! 
      do i=1,im
        h(i,jm+k,1)=h(i,1+k  ,5)             !     face 1
        h(i,1-k   ,1)=h(i,jm-k,6)            !
        h(i,jm+k,2)=h(im-k,i     ,5)         !     face 2
        h(i,1-k   ,2)=h(im-k,jm+1-i,6)       !
        h(i,jm+k,3)=h(im+1-i,jm-k,5)         !     face 3
        h(i,1-k   ,3)=h(im+1-i,1+k  ,6)      !
        h(i,jm+k,4)=h(1+k,jm+1-i,5)          !     face 4
        h(i,1-k   ,4)=h(1+k,i     ,6)        !
      end do
!------------------------------------------------------------------------
!                 upper and lower faces                                  
!------------------------------------------------------------------------
! 
! lateral conditions
!
      do j=1,jm
        h(1-k   ,j,5)=h(im+1-j,jm-k,4)        !     face 5
        h(im+k,j,5)=h(j     ,jm-k,2)          !
        h(1-k   ,j,6)=h(j     ,1+k,4)         !     face 6
        h(im+k,j,6)=h(im+1-j,1+k,2)           !
      end do
!
! lower and upper conditions
!
      do i=1,im
        h(i,jm+k,5)=h(im+1-i,jm-k,3)          !     face 5
        h(i,1-k   ,5)=h(i     ,jm-k,1)        !
        h(i,jm+k,6)=h(i     ,1+k,1)           !     face 6
        h(i,1-k   ,6)=h(im+1-i,1+k,3)         !
      end do
      enddo

      h(im,2:jm-1,1)=h(1,2:jm-1,2)
      h(im,2:jm-1,2)=h(1,2:jm-1,3)
      h(im,2:jm-1,3)=h(1,2:jm-1,4)
      h(im,2:jm-1,4)=h(1,2:jm-1,1)

      do j=2,jm-1
        h(1   ,j,5)=h(im+1-j,jm,4)           !     face 5
        h(im,j,5)=h(j     ,jm,2)             !
        h(1   ,j,6)=h(j     ,1,4)            !     face 6
        h(im,j,6)=h(im+1-j,1,2)              !
      end do

      do i=2,im-1
        h(i,jm,5)=h(im+1-i,jm,3)             !     face 5
        h(i,1   ,5)=h(i     ,jm,1)           !
        h(i,jm,6)=h(i     ,1,1)              !     face 6
        h(i,1   ,6)=h(im+1-i,1,3)            !
      end do


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

      h(im,1,1)=h(1,1,2)
      h(im,1,2)=h(1,1,3)
      h(im,1,3)=h(1,1,4)
      h(im,1,4)=h(1,1,1)

      h(im,jm,1)=h(1,jm,2)
      h(im,jm,2)=h(1,jm,3)
      h(im,jm,3)=h(1,jm,4)
      h(im,jm,4)=h(1,jm,1)

      h(1,1,5)=h(1,jm,1)
      h(im,1,5)=h(im,jm,1)
      h(1,jm,5)=h(im,jm,3)
      h(im,jm,5)=h(1,jm,3)

      h(1,1,6)=h(im,1,3)
      h(im,1,6)=h(1,1,3)
      h(1,jm,6)=h(1,1,1)
      h(im,jm,6)=h(im,1,1)

      do n=1,4
        h(1,0,n)=h(0,1,n)
        h(im,0,n)=h(im+1,1,n)
        h(1,jm+1,n)=h(0,jm,n)
        h(im,jm+1,n)=h(im+1,jm,n)
      enddo

      h(0,1,5)=h(1,0,5)
      h(im,0,5)=h(im+1,1,5)
      h(im+1,jm,5)=h(im,jm+1,5)
      h(1,jm+1,5)=h(0,jm,5)

      h(1,0,6)=h(0,1,6)
      h(im+1,1,6)=h(im,0,6)
      h(im,jm+1,6)=h(im+1,jm,6)
      h(0,jm,6)=h(1,jm+1,6)
     
!------------------------------------------------------------------------
      return
      end subroutine bocoh2l_cb


