!---------------------------------------------------------------------
!     Copyright (C) GFD Dennou Club, 2005. All rights reserved.
!---------------------------------------------------------------------
                                                                 !=begin
!= Module SatVap
!
!   * Developer: SUGIYAMA Ko-ichiro
!   * Version: $Id: $
!   * Tag Name: $Name:  $
!   * Change History: 
!
!== Overview
!
!水の飽和水蒸気圧混合比を計算. 
!  * 現在は Antoine の式を利用
! 
!== Error Handling
!
!== Bugs
!
!== Note
!
!== Future Plans
!
! * Antoine の式から飽和水蒸気混合比を計算できるようにもする
!
                                                                 !=end

module SatVap
  
  interface ss_SatVap_ss
    function ss_AntoineSatVap_ss( AntoineConst, ss_Temp )
      use gridset
      real(8), intent(in) :: AntoineConst(3)
      real(8), intent(in) :: ss_Temp(DimXMin:DimXMax, DimZMin:DimZMax)       !温度
      real(8)             :: ss_AntoineSatVap_ss(DimXMin:DimXMax, DimZMin:DimZMax)
    end function ss_AntoineSatVap_ss
  end interface
  
  interface s_SatVap_s
    function s_AntoineSatVap_s( AntoineConst, ss_Temp )
      use gridset
      real(8), intent(in) :: AntoineConst(3)
      real(8), intent(in) :: s_Temp              !温度
      real(8)             :: s_AntoineSatVap_s   !飽和蒸気圧混合比
    end function s_AntoineSatVap_s
  end interface
  
end module SatVap


function ss_AntoineSatVap_ss( AntoineConst, ss_Temp )
  use gridset, only: DimXMin, DimXMax, DimZMin, DimZMax
  implicit none
  
  real(8), intent(in) :: AntoineConst(3)
  real(8), intent(in) :: ss_Temp(DimXMin:DimXMax, DimZMin:DimZMax)       !温度
  real(8)             :: ss_AntoineSatVap_ss(DimXMin:DimXMax, DimZMin:DimZMax)
                                                             !飽和蒸気圧混合比
  ss_AntoineSatVap_ss = 0.0d0 !初期化
  ss_AntoineSatVap_ss = & 
    & dexp(AntoineConst(1) - AntoineConst(2) / (AntoineConst(3) + ss_Temp)) 
  
end function ss_AntoineSatVap_ss


function s_AntoineSatVap_s( AntoineConst, s_Temp )
  use gridset, only: DimXMin, DimXMax, DimZMin, DimZMax
  implicit none
  
  real(8), intent(in) :: AntoineConst(3)
  real(8), intent(in) :: s_Temp              !温度
  real(8)             :: s_AntoineSatVap_s   !飽和蒸気圧混合比

  s_AntoineSatVap_s = 0.0d0 !初期化
  s_AntoineSatVap_s = & 
    & dexp(AntoineConst(1) - AntoineConst(2) / (AntoineConst(3) + s_Temp)) 
  
end function s_AntoineSatVap_s
