UFO
thermo_utils.F90
Go to the documentation of this file.
1 ! (C) Copyright 2018 UCAR
2 !
3 ! This software is licensed under the terms of the Apache Licence Version 2.0
4 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5 
6 !> Fortran module for thermodynamic computations and conversions for use in UFO
7 
9 
10 use kinds, only: kind_real
11 
12 implicit none
13 public
14 
15 contains
16 
17 ! ------------------------------------------------------------------------------
18 
19 subroutine calc_theta(t_in, p_in, t_out)
20  ! compute potential (virtual) temperature from a given (virtual) temperature
21  ! and pressure value, assumes the standard definition of theta at 1000 hPa
22  ! units must be in K and Pa!
23  use ufo_constants_mod, only: rd_over_cp
24  implicit none
25  real(kind_real), intent(in) :: t_in, p_in
26  real(kind_real), intent(out) :: t_out
27 
28  t_out = t_in * (1.0e5_kind_real / p_in) ** rd_over_cp
29 
30 end subroutine calc_theta
31 
32 ! ------------------------------------------------------------------------------
33 
34 subroutine gsi_tp_to_qs( t, p, es, qs)
35  ! calculate saturation specific humidity for a given
36  ! temperature and pressure
37  ! based on subroutin DA_TP_To_Qs in GSI
39 
40  implicit none
41  real(kind_real), intent(in) :: t ! Temperature.
42  real(kind_real), intent(in) :: p ! Pressure.
43  real(kind_real), intent(out) :: es ! Sat. vapour pressure.
44  real(kind_real), intent(out) :: qs ! Sat. specific humidity.
45 
46 ! Saturation Vapour Pressure Constants(Rogers & Yau, 1989)
47  real(kind_real), parameter :: es_beta = 17.67_kind_real
48  real(kind_real), parameter :: es_gamma = 243.5_kind_real
49 
50  real(kind_real) :: omeps
51  real(kind_real) :: t_c ! T in degreesC.
52 
53  omeps = 1.0_kind_real - rd_over_rv
54  t_c = t - t0c
55 
56  es = es_w_0 * exp( es_beta * t_c / ( t_c + es_gamma ) )
57 
58  qs = rd_over_rv * es / ( p - omeps * es )
59 
60  return
61 end subroutine gsi_tp_to_qs
62 
63 ! ------------------------------------------------------------------------------
64 
65 end module thermo_utils_mod
Fortran module for thermodynamic computations and conversions for use in UFO.
Definition: thermo_utils.F90:8
subroutine gsi_tp_to_qs(t, p, es, qs)
subroutine calc_theta(t_in, p_in, t_out)
real(kind_real), parameter, public es_w_0
real(kind_real), parameter, public t0c
real(kind_real), parameter, public rd_over_cp
real(kind_real), parameter, public rd_over_rv