!---------------------------------------------------------------------
!     Copyright (C) GFD Dennou Club, 2004. All rights reserved.
!---------------------------------------------------------------------
                                                                 !=begin
!= Subroutine AdvectVelZ
!
!   * Developer: SUGIYAMA Ko-ichiro (sugiyama@gfd-dennou.org)
!   * Version: $Id: advectvelz.f90,v 1.2 2005/01/28 12:41:21 sugiyama Exp $
!   * Tag Name: $Name:  $
!   * Change History: 
!
!== Overview
!
! Z 方向の運動方程式の移流項を計算する. ただし運動方程式は 2 次元とする. 
! AdvZ = u \DP{u}{z} + w \DP{w}{z}
! 
!== Error Handling
!
!== Bugs
!
!== Note
!
!== Future Plans
!
!
                                                                 !=end

subroutine AdvectVelZ(fs_VelX_B, sf_VelZ_B, sf_AdvZ_B)
                                                                 !=begin
  !== Dependency
  use gridset,        only: DimXMin, DimXMax, DimZMin, DimZMax 
  use average,       only: sf_avr_ff, ff_avr_fs, sf_avr_ss, ss_avr_sf
  use differentiate, only: ff_dx_sf, ss_dz_sf
                                                                 !=end
  !--- 暗黙の型宣言禁止
  implicit none
                                                                 !=begin  
  !== input
  real(8), intent(in)     :: fs_VelX_B(DimXMin:DimXMax, DimZMin:DimZMax)
  real(8), intent(in)     :: sf_VelZ_B(DimXMin:DimXMax, DimZMin:DimZMax)
                                                                 !=end
                                                                 !=begin
  !== output
  real(8), intent(out)    :: sf_AdvZ_B(DimXMin:DimXMax, DimZMin:DimZMax)
                                                                 !=end

  !--- 移流項 
  sf_AdvZ_B = &
       &   sf_avr_ff( ff_avr_fs( fs_VelX_B ) * ff_dx_sf( sf_VelZ_B ) ) &
       & + sf_avr_ss( ss_avr_sf( sf_VelZ_B ) * ss_dz_sf( sf_VelZ_B ) ) 
  
end subroutine AdvectVelZ
