!=======================================
! 2D cumulus model - kaminari
!  - subroutine vel_u
! 
! Author    : TAKAHASHI Koko
! Date      : 2003/11/04
! Note      : $B?eJ?B.EY(B u
! 
!=======================================
subroutine vel_u(i,k,im,km,cp,alp,dts,g13z,divx,divz,dx,dz, &
     &          vptemp_bs,pi,u_adv,u_cori,u_trb,u)

  implicit none

  integer, intent(in) :: im
  integer, intent(in) :: km
  integer, intent(in) :: i, k

  real(8), intent(in) :: vptemp_bs(0:im+1,0:km+1)
  real(8), intent(in) :: pi(0:im+1,0:km+1)
  real(8), intent(in) :: g13z(0:im+1,0:km+1)
  real(8), intent(in) :: divx(0:im+1,0:km+1)
  real(8), intent(in) :: divz(0:im+1,0:km+1)

  real(8), intent(in) :: u_adv(0:im+1,0:km+1)
  real(8), intent(in) :: u_cori(0:im+1,0:km+1)
  real(8), intent(in) :: u_trb(0:im+1,0:km+1)

  real(8), intent(inout) :: u(0:im+1,0:km+1)

  real(8), intent(in) :: cp, alp, dts

  real(8), intent(in) :: dx, dz

  !--- $BB.EY(B u
  u(i,k) = u(i,k)                                  &
       & + dts*(                                   &
       &        - cp*vptemp_bs(i,k)                &
       &          *(pi(i+1,k)- pi(i,k))/dx         &
       &        - alp*cp*vptemp_bs(i,k)*divx(i,k)  &
       &        - g13z(i,k)*(                      &
       &                     pi(i+1,k+1)           &
       &                     + pi(i-1,k+1)         &
       &                     - pi(i+1,k-1)         &
       &                     - pi(i-1,k-1)         &
       &                    )/(4*dz)               &
       &        - alp*g13z(i,k)*divz(i,k)          &
       &        - u_adv(i,k) + u_cori(i,k)         &
       &        + u_trb(i,k)                       &
       &       )

end subroutine vel_u

