!---------------------------------------------------------------------
!     Copyright (C) GFD Dennou Club, 2004. All rights reserved.
!---------------------------------------------------------------------
                                                                 !=begin
!= Subroutine PressureGradVelZ
!
!   * Developer: SUGIYAMA Ko-ichiro (sugiyama@gfd-dennou.org)
!   * Version: $Id: pressuregradvelz.f90,v 1.2 2005/01/28 12:41:21 sugiyama Exp $ 
!   * Tag Name: $Name:  $
!   * Change History: 
!
!== Overview 
!
!速度 w の傾きを計算. 後退差分で評価
!
!== Error Handling
!
!== Known Bugs
!
!== Note
!
!== Future Plans
!
                                                                 !=end

subroutine PressureGradVelZ(ss_Exner_n, ss_Exner_a, ss_Div_n, &
     &                      sf_TendVelZ_n)
                                                                 !=begin
  !== Dependency
  use gridset,  only: DimXMin, DimXMax, DimZMin, DimZMax
  use basicset, only: ss_CpBasicZ, ss_PotTempBasicZ
  use arareprm, only: alpha, beta
  use average,   only: sf_avr_ss
  use differentiate,  only: sf_dz_ss
                                                                 !=end  
  !--- 暗黙の型宣言禁止
  implicit none
                                                                 !=begin  
  !== Input
  real(8), intent(in)      :: ss_Exner_n(DimXMin:DimXMax, DimZMin:DimZMax)
  real(8), intent(in)      :: ss_Exner_a(DimXMin:DimXMax, DimZMin:DimZMax)
  real(8), intent(in)      :: ss_Div_n(DimXMin:DimXMax, DimZMin:DimZMax)

  !== Output
  real(8), intent(out)     :: sf_TendVelZ_n(DimXMin:DimXMax, DimZMin:DimZMax)
                                                                 !=end  
  !--- 速度 u
  sf_TendVelZ_n =   &
       & - sf_avr_ss( ss_CpBasicZ * ss_PotTempBasicZ ) &
       &   * (                                         &
       &       beta * sf_dz_ss( ss_Exner_a )               &
       &       + (1.0d0 - beta) * sf_dz_ss( ss_Exner_n )   &
       &       - sf_dz_ss( alpha * ss_Div_n )              &
       &     )                                             

  
end subroutine PressureGradVelZ
