!---------------------------------------------------------------------
!     Copyright (C) GFD Dennou Club, 2004. All rights reserved.
!---------------------------------------------------------------------
                                                                 !=begin
!= Subroutine DExnerDtCondense
!
!   * Developer: KITAMORI Taichi
!   * Version: $Id: dexnerdtcondense.f90,v 1.1.2.1 2005/12/28 11:29:30 kitamo Exp $ 
!   * Tag Name: $Name:  $
!   * Change History: 
!
!== Overview 
!
!大気主成分の凝結に伴う圧力変化を計算する. 
!長い時間ステップ DelTimeLong において評価する. 
!
!== Error Handling
!
!== Known Bugs
!
!== Note
!
!== Future Plans
!
                                                                 !=end
subroutine DExnerDTimeCondense( &
  & ss_MassCond_nl,         &  !(in)  凝結量
  & ss_LatHeatPerMass_nl,   &  !(in)  単位質量あたりの潜熱
  & ss_ExnerTendCond_nl)       !(out) 凝結に伴う圧力変化
                                                                 !=begin
  !== Dependency
  use dc_trace, only: BeginSub, EndSub
  use gridset,  only: DimXMin, DimXMax, DimZMin, DimZMax, DelXZ
  use bcset,    only: ss_BC
  use basicset, only: ss_VelSoundBasicZ,  &  ! 音速 
    &                 ss_CpBasicZ,        &  ! 定圧比熱
    &                 ss_PotTempBasicZ,   &  ! 温位基本場
    &                 ss_ExnerBasicZ,     &  ! 圧力基本場
    &                 ss_DensBasicZ          ! 密度基本場
  use average,  only: fs_avr_ss, ss_avr_fs, ss_avr_sf
  use differentiate_center4, only: fs_dx_ss, sf_dz_ss
                                                                 !=end  
  !== 暗黙の型宣言禁止 
  implicit none
                                                                 !=begin
  !== Input
  real(8)              :: DelTime     ! 時間ステップ
  real(8), intent(in)  :: ss_MassCond_nl(DimXMin:DimXMax, DimZMin:DimZMax)
                                      ! 凝結量
  real(8), intent(in)  :: ss_LatHeatPerMass_nl(DimXMin:DimXMax, DimZMin:DimZMax)
                                      ! 単位質量あたりの潜熱

  !== Output
  real(8), intent(out) :: ss_ExnerTendCond_nl(DimXMin:DimXMax, DimZMin:DimZMax)
                                      ! 主成分の凝結に伴う圧力変化
                                                                 !=end    
  
  call BeginSub("DExnerDTimeCondense", &
    &        fmt="%c",    &
    &        c1="calculation of extra force term in nondimensional pressure.")

  ss_ExnerTendCond_nl =  &
    &   ss_VelSoundBasicZ**2.0d0 * ss_MassCond_nl &
    &   / ( ss_CpBasicZ * ss_PotTempBasicZ**2.0d0 * ss_DensBasicZ)  &
    &   * (  &
    &        ss_LatHeatPerMass_nl / (ss_ExnerBasicZ * ss_CpBasicZ) &
    &      - 1.0d0 &
    &     )  

  call EndSub("DExnerDTimeCondense")
  
end subroutine DExnerDTimeCondense
