!=======================================
! 2D cumulus model - kaminari
!  - subroutine omgw
! 
! Author    : TAKAHASHI Koko
! Date      : 2003/12/06  $B:G=*99?7(B
!             2003/11/04  $B?75,:n@.(B
! Note      : $BCO7A$K1h$C$?:BI87O$G$N1tD>B.EY(B omg
! 
!=======================================
!--- 1$B9TL\F~NOJQ?t(B, 2$B9TL\=PNOJQ?t(B
subroutine omgw(im,km,g_sqrt_z,g13x,u,w,                    &
     &          omg)

  implicit none

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

  real(8), intent(in) :: g_sqrt_z(-2:im+2,-2:km+2)
  real(8), intent(in) :: g13x(-2:im+2,-2:km+2)
  real(8), intent(in) :: u(-2:im+2,-2:km+2)
  real(8), intent(in) :: w(-2:im+2,-2:km+2)

  real(8), intent(out) :: omg(-2:im+2,-2:km+2)

  integer(8)           :: i, k

  do k = -1,km+1
     do i = -1,im+1
        omg(i,k) = g13x(i,k)                                &
             &     *(                                       &
             &       u(i,k+1) + u(i,k)                      &
             &       + u(i-1,k+1) + u(i-1,k)                &
             &      )/4.0d0                                 &
             &     + w(i,k)/g_sqrt_z(i,k)
     end do
  end do

end subroutine omgw
