!=======================================
! 2D cumulus model - kaminari
!  - subroutine boundary_bs
! 
! Author    : TAKAHASHI Koko
! Date      : 2003/12/04 $B?75,:n@.(B
! Note      : $B4pK\>l$N6-3&$h$j30$NG[Ns$NCM(B
! 
!=======================================
subroutine boundary_bs(im,km,                               &
     &                 qv_bs,prss_bs,pi_bs,temp_bs,ptemp_bs,&
     &                 vptemp_bs,dens_bs)

  implicit none

  integer(8), intent(in) :: im, km

  real(8), intent(inout) :: qv_bs(-2:im+1,-2:km+1)
  real(8), intent(inout) :: prss_bs(-2:im+1,-2:km+1)
  real(8), intent(inout) :: pi_bs(-2:im+1,-2:km+1)
  real(8), intent(inout) :: temp_bs(-2:im+1,-2:km+1)
  real(8), intent(inout) :: ptemp_bs(-2:im+1,-2:km+1)
  real(8), intent(inout) :: vptemp_bs(-2:im+1,-2:km+1)
  real(8), intent(inout) :: dens_bs(-2:im+1,-2:km+1)

  integer(8)             :: i, k

  !---  k = -1 : $B2<It6-3&(B
  do i = 0,im-2
     qv_bs(i,-1) = 0.0d0
     prss_bs(i,-1) = prss_bs(i,0)
     pi_bs(i,-1) = pi_bs(i,0)
     temp_bs(i,-1) = temp_bs(i,0)
     ptemp_bs(i,-1) = ptemp_bs(i,0)
     vptemp_bs(i,-1) = vptemp_bs(i,0)
     dens_bs(i,-1) = dens_bs(i,0)
  end do

  !---  k = -2 : $B2<It6-3&(B
  do i = 0,im-2
     qv_bs(i,-2) = 0.0d0
     prss_bs(i,-2) = prss_bs(i,0)
     pi_bs(i,-2) = pi_bs(i,0)
     temp_bs(i,-2) = temp_bs(i,0)
     ptemp_bs(i,-2) = ptemp_bs(i,0)
     vptemp_bs(i,-2) = vptemp_bs(i,0)
     dens_bs(i,-2) = dens_bs(i,0)
  end do

  !---  k = km : $B>eIt6-3&(B
  do i = 0,im-2
     qv_bs(i,km) = 0.0d0
     prss_bs(i,km) = prss_bs(i,km-1)
     pi_bs(i,km) = pi_bs(i,km-1)
     temp_bs(i,km) = temp_bs(i,km-1)
     ptemp_bs(i,km) = ptemp_bs(i,km-1)
     vptemp_bs(i,km) = vptemp_bs(i,km-1)
     dens_bs(i,km) = dens_bs(i,km-1)
  end do

  !---  k = km+1 : $B>eIt6-3&(B
  do i = 0,im-2
     qv_bs(i,km+1) = 0.0d0
     prss_bs(i,km+1) = prss_bs(i,km-1)
     pi_bs(i,km+1) = pi_bs(i,km-1)
     temp_bs(i,km+1) = temp_bs(i,km-1)
     ptemp_bs(i,km+1) = ptemp_bs(i,km-1)
     vptemp_bs(i,km+1) = vptemp_bs(i,km-1)
     dens_bs(i,km+1) = dens_bs(i,km-1)
  end do

  !---  i = -1 : $BB&LL6-3&(B
  do k = -2,km+1
     qv_bs(-1,k) = 0.0d0
     prss_bs(-1,k) = prss_bs(im-2,k)
     pi_bs(-1,k) = pi_bs(im-2,k)
     temp_bs(-1,k) = temp_bs(im-2,k)
     ptemp_bs(-1,k) = ptemp_bs(im-2,k)
     vptemp_bs(-1,k) = vptemp_bs(km-2,k)
     dens_bs(-1,k) = dens_bs(im-2,k)
  end do

  !---  i = -2 : $BB&LL6-3&(B
  do k = -2,km+1
     qv_bs(-2,k) = 0.0d0
     prss_bs(-2,k) = prss_bs(im-3,k)
     pi_bs(-2,k) = pi_bs(im-3,k)
     temp_bs(-2,k) = temp_bs(im-3,k)
     ptemp_bs(-2,k) = ptemp_bs(im-3,k)
     vptemp_bs(-2,k) = vptemp_bs(im-3,k)
     dens_bs(-2,k) = dens_bs(im-3,k)
  end do

  !---  i = im-1 : $BB&LL6-3&(B
  do k = -2,km+1
     qv_bs(im-1,k) = 0.0d0
     prss_bs(im-1,k) = prss_bs(1,k)
     pi_bs(im-1,k) = pi_bs(1,k)
     temp_bs(im-1,k) = temp_bs(1,k)
     ptemp_bs(im-1,k) = ptemp_bs(1,k)
     vptemp_bs(im-1,k) = vptemp_bs(1,k)
     dens_bs(im-1,k) = dens_bs(1,k)
  end do

  !---  i = im : $BB&LL6-3&(B
  do k = -2,km+1
     qv_bs(im,k) = 0.0d0
     prss_bs(im,k) = prss_bs(1,k)
     pi_bs(im,k) = pi_bs(1,k)
     temp_bs(im,k) = temp_bs(1,k)
     ptemp_bs(im,k) = ptemp_bs(1,k)
     vptemp_bs(im,k) = vptemp_bs(1,k)
     dens_bs(im,k) = dens_bs(1,k)
  end do

  !---  i = im+1 : $BB&LL6-3&(B
  do k = -2,km+1
     qv_bs(im+1,k) = 0.0d0
     prss_bs(im+1,k) = prss_bs(2,k)
     pi_bs(im+1,k) = pi_bs(2,k)
     temp_bs(im+1,k) = temp_bs(2,k)
     ptemp_bs(im+1,k) = ptemp_bs(2,k)
     vptemp_bs(im+1,k) = vptemp_bs(2,k)
     dens_bs(im+1,k) = dens_bs(2,k)
  end do

end subroutine boundary_bs
