phys_tv.F90 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. !
  2. ! virtual temperature calcualtions
  3. !
  4. ! xm_air = 28.964 e-3 kg air/mol
  5. ! xm_h2o = 18.0 e-3 kg h2o/mol
  6. !
  7. ! eps1 = (kg air/mol) / (kg h2o/mol) - 1 = 0.609
  8. !
  9. ! virtual temperature : Tv = T * ( 1 + eps1*q )
  10. !
  11. module phys_tv
  12. implicit none
  13. ! --- in/out -----------------------------
  14. private
  15. public :: VirtualTemperature
  16. public :: RealTemperature
  17. contains
  18. ! convert from real temperature to virtual temperature
  19. elemental function VirtualTemperature( T, Q )
  20. use Binas, only : xm_air ! 28.964 e-3 kg air/mol
  21. use Binas, only : xm_h2o ! 18.0 e-3 kg h2o/mol
  22. ! --- in/out --------------------------------
  23. real :: VirtualTemperature ! K
  24. real, intent(in) :: T ! real temperature (K)
  25. real, intent(in) :: Q ! specific humidity (kg H2O / kg air)
  26. ! --- const ---------------------------------
  27. ! eps1 = (kg air/mol) / (kg h2o/mol) - 1 = 0.609
  28. real, parameter :: eps1 = xm_air/xm_h2o - 1.0
  29. ! --- begin ---------------------------------
  30. ! Tv = T * ( 1 + eps1*q )
  31. ! T = Tv / ( 1 + eps1*q )
  32. VirtualTemperature = T * ( 1.0 + eps1 * Q ) ! K
  33. end function VirtualTemperature
  34. ! convert from virtual temperature to temperature
  35. elemental function RealTemperature( Tv, Q )
  36. use Binas, only : xm_air ! 28.964 e-3 kg air/mol
  37. use Binas, only : xm_h2o ! 18.0 e-3 kg h2o/mol
  38. ! --- in/out --------------------------------
  39. real :: RealTemperature ! K
  40. real, intent(in) :: Tv ! virtual temper (K)
  41. real, intent(in) :: Q ! specific humidity (kg H2O / kg air)
  42. ! --- const ---------------------------------
  43. ! eps1 = (kg air/mol) / (kg h2o/mol) - 1 = 0.609
  44. real, parameter :: eps1 = xm_air/xm_h2o - 1.0
  45. ! --- begin ---------------------------------
  46. ! Tv = T * ( 1 + eps1*q )
  47. ! T = Tv / ( 1 + eps1*q )
  48. RealTemperature = Tv / ( 1.0 + eps1 * Q ) ! K
  49. end function RealTemperature
  50. end module phys_tv