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

subroutine AdvectVelX(fs_VelX_n, sf_VelZ_n, fs_AdvX_n)
                                                                 !=begin
  !== Dependency
  use gridset,       only: DimXMin, DimXMax, DimZMin, DimZMax
  use average,       only: fs_avr_ss, ss_avr_fs, fs_avr_ff, ff_avr_sf
  use differentiate, only: ss_dx_fs, ff_dz_fs
                                                                 !=end
  !--- 暗黙の型宣言禁止
  implicit none
                                                                 !=begin  
  !== input
  real(8), intent(in)     :: fs_VelX_n(DimXMin:DimXMax, DimZMin:DimZMax)
  real(8), intent(in)     :: sf_VelZ_n(DimXMin:DimXMax, DimZMin:DimZMax)
                                                                 !=end
                                                                 !=begin
  !== output
  real(8), intent(out)    :: fs_AdvX_n(DimXMin:DimXMax, DimZMin:DimZMax)
                                                                 !=end

  !--- 移流項 (X)
  fs_AdvX_n = &
       &    fs_avr_ss( ss_avr_fs( fs_VelX_n ) * ss_dx_fs( fs_VelX_n ) ) &
       & +  fs_avr_ff( ff_avr_sf( sf_VelZ_n ) * ff_dz_fs( fs_VelX_n ) )
  
end subroutine AdvectVelX
