!---------------------------------------------------------------------
!     Copyright (C) GFD Dennou Club, 2004. All rights reserved.
!---------------------------------------------------------------------
                                                                 !=begin
!= Subroutine LatentHeat
!
!   * Developer: KITAMORI Taichi 
!   * Version: $Id: latentheat.f90,v 1.1.2.1 2005/12/21 05:46:28 kitamo Exp $
!   * Tag Name: $Name:  $
!   * Change History: 
!
!== Overview 
!
!凝結量から凝結熱を計算する. 
!
!== Error Handling
!
!== Known Bugs
!
!== Note
!
!
!
!== Future Plans
!
                                                                 !=end
subroutine LatentHeat(xz_Masscond,         & !(in) 凝結量
  &                   xz_LatHeatPerMass,   & !(in) 単位質量あたりの潜熱
  &                   xz_Qcond)              !(out) 凝結熱による温度変化率
                                                                 !=begin
  !==Dependency
  use dc_trace, only: BeginSub, EndSub  
  use gridset,  only: DimXMin, DimXMax, DimZMin, DimZMax
!  use physset,  only: GasR              ! 気体定数
!  use cloudset, only: SatPressB         ! Antoine の式の係数 B
  use ChemData, only: ChemData_SVapPress_AntoineB, & ! Antoine の式の係数 B
    &                 ChemData_Cp        ! 湿潤成分の定圧比熱
  use basicset, only: xz_DensBasicZ,  &  ! 密度基本場 
    &                 xz_ExnerBasicZ, &  ! 無次元圧力基本場
!    &                 ss_CpBasicZ, &    ! 定圧比熱
    &                 GasRDry, &         ! 気体定数
    &                 CpDry              ! 定圧比熱
                                                                 !=end
  !==暗黙の型宣言を禁止
  implicit none
  
  !==Input
  real(8)                :: xz_LatHeatPerMass(DimXMin:DimXMax, DimZMin:DimZMax)
                                           ! 単位質量あたりの潜熱 [J/kg]
  real(8)                :: xz_Masscond(DimXMin:DimXMax, DimZMin:DimZMax) 
                                           ! 凝結量 [kg/m^3 s]

  !==Output
  real(8), intent(out)   :: xz_Qcond(DimXMin:DimXMax, DimZMin:DimZMax) 
                                           ! 凝結熱による温度変化率 [K/s]
  
  !==Work

  call BeginSub("LatentHeat", &
&           fmt="%c",        &
&           c1="Calculate potential temperature tendency bylatent heating.")

  xz_Qcond = xz_LatHeatPerMass * xz_Masscond &
    & / (CpDry * xz_DensBasicZ * xz_ExnerBasicZ)  
!    & / (ss_CpBasicZ * xz_DensBasicZ * xz_ExnerBasicZ)  

  call EndSub("LatentHeat")

end subroutine LatentHeat
