!&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
       subroutine bocov1_cb(h,im,jm)
!     ******************************************************************
!     *                                                                *
!     * boundary conditions for scalars defined in wind points on cube * 
!     *                                                                *
!     ******************************************************************
      implicit none

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

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


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

    
      return
      end subroutine bocov1_cb


