!&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
       Subroutine Bocoh_cb(H,im,jm)
!     ******************************************************************
!c    *                                                                *
!c    *  Boundary Conditions for Height Points on cube                 *
!c    *                                                                *
!c    ******************************************************************
!c----------------------------------------------------------------------
!c-------------------------------------------------------------------
      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
!c-----------------------------------------------------------------------
!c                Lateral Faces                                          
!c-----------------------------------------------------------------------
!c
!c Lateral Conditions
!c
      Do n=1,4
        nl=n-1+4*((5-n)/4)
        nr=n+1-4*(n/4)
         Do j=1,jm
           H(0   ,j,n)=H(im1,j,nl)
           H(im+1,j,n)=H(2  ,j,nr)
	 End Do
      End Do
!c
!c Lower and Upper Conditions
!c
      Do i=1,im
        H(i,jm+1,1)=H(i,2  ,5)             !     Face 1
        H(i,0   ,1)=H(i,jm1,6)             !
        H(i,jm+1,2)=H(im1,i     ,5)        !     Face 2
        H(i,0   ,2)=H(im1,jm+1-i,6)        !
        H(i,jm+1,3)=H(im+1-i,jm1,5)        !     Face 3
        H(i,0   ,3)=H(im+1-i,2  ,6)        !
        H(i,jm+1,4)=H(2,jm+1-i,5)          !     Face 4
        H(i,0   ,4)=H(2,i     ,6)          !
      End Do
!c-----------------------------------------------------------------------
!c                Upper and Lower Faces                                  
!c-----------------------------------------------------------------------
!c
!c Lateral Conditions
!c
      Do j=1,jm
        H(0   ,j,5)=H(im+1-j,jm1,4)        !     Face 5
        H(im+1,j,5)=H(j     ,jm1,2)        !
        H(0   ,j,6)=H(j     ,2,4)          !     Face 6
        H(im+1,j,6)=H(im+1-j,2,2)          !
      End Do
!c
!c Lower and Upper Conditions
!c
      Do i=1,im
        H(i,jm+1,5)=H(im+1-i,jm1,3)        !     Face 5
        H(i,0   ,5)=H(i     ,jm1,1)        !
        H(i,jm+1,6)=H(i     ,2,1)          !     Face 6
        H(i,0   ,6)=H(im+1-i,2,3)          !
      End Do

      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


!c-----------------------------------------------------------------------
!c  corners
!c
      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 Bocoh_cb


