UFO
ufo_gnssroonedvarcheck_humidcheck_mod.f90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
2 ! (C) Crown copyright Met Office. All rights reserved.
3 ! Refer to COPYRIGHT.txt of this distribution for details.
4 !-------------------------------------------------------------------------------
5 ! Check values of humidity -limit to supersat and set <0.0 to = 0.0
6 !-------------------------------------------------------------------------------
7 
9 
10 use kinds
11 
12 private
13 public :: ops_gpsro_humidcheck
14 
15 contains
16 
17 SUBROUTINE ops_gpsro_humidcheck (nstate, &
18  nlevp, &
19  nlevq, &
20  za, &
21  zb, &
22  capsupersat, &
23  x)
24 
25 use ufo_constants_mod, only: &
26  rd, & ! Gas constant for dry air
27  grav, & ! Gravitational field strength
28  c_virtual ! Related to mw_ratio
29 
30 USE ufo_utils_mod, ONLY: &
31  ops_qsat, &
33 
34 IMPLICIT NONE
35 
36 ! Subroutine arguments:
37 INTEGER, INTENT(IN) :: nstate
38 INTEGER, INTENT(IN) :: nlevp
39 INTEGER, INTENT(IN) :: nlevq
40 REAL(kind_real), INTENT(IN) :: za(:)
41 REAL(kind_real), INTENT(IN) :: zb(:)
42 LOGICAL, INTENT(IN) :: capsupersat ! Whether to remove super-saturation (wrt ice?)
43 REAL(kind_real), INTENT(INOUT) :: x(:)
44 
45 ! Local declarations:
46 CHARACTER(len=*), PARAMETER :: routinename = "Ops_GPSRO_humidcheck"
47 INTEGER :: i
48 REAL(kind_real) :: p(nlevp)
49 REAL(kind_real) :: q(nlevq)
50 REAL(kind_real) :: t(nlevq)
51 REAL(kind_real) :: pb(nlevq)
52 REAL(kind_real) :: qsaturated(nlevq)
53 REAL(kind_real) :: tv
54 REAL(kind_real) :: pwt1
55 REAL(kind_real) :: pwt2
56 
57 !---------------------------------------------------------------------
58 ! 1. Check values of humidity -limit to supersat and set <0.0 to = 0.0
59 !---------------------------------------------------------------------
60 
61 ! Set up the P and Q vectors from x
62 
63 p(:) = 1.0e2 * x(1:nlevp) ! in Pa
64 q(:) = 1.0e-3 * x(nlevp + 1:nstate) ! in kg/kg
65 
66 DO i = 1, nlevq
67 
68  ! Calculate `mean P' for layer
69 
70  pwt1 = (za(i + 1) - zb(i)) / (za(i + 1) - za(i))
71 
72  pwt2 = 1.0 - pwt1
73 
74  pb(i) = exp(pwt1 * log(p(i)) + pwt2 * log(p(i + 1)))
75 
76  ! Derive the layer mean virtual temp. using the hydrostatic relationship
77 
78  tv = grav * (za(i + 1) - za(i)) / (rd * log(p(i) / p(i + 1)))
79 
80  ! Calculate the temperature
81 
82  t(i) = tv / (1.0 + c_virtual * q(i))
83 
84 END DO
85 
86 ! Calculate the super.sat for T and Pmean
87 
88 ! For T < 0 Ops_Qsat returns the saturated specific humidity over ice.
89 ! Supersaturation with respect to ice is possible, although is largely
90 ! suppressed when CapSupersat is true. When CapSupersat is false the
91 ! humidity check should be done with respect to water.
92 
93 IF (capsupersat) THEN
94  CALL ops_qsat (qsaturated, & ! out
95  t, &
96  pb, &
97  nlevq)
98 ELSE
99  CALL ops_qsatwat (qsaturated, & ! out
100  t, &
101  pb, &
102  nlevq)
103 END IF
104 
105 ! Check no values have gone -ve
106 WHERE (x(nlevp + 1:nstate) < 0.0)
107  x(nlevp + 1:nstate) = 1.0e-4
108 END WHERE
109 
110 ! Limit saturated value
111 WHERE (x(nlevp + 1:nstate) > 1.0e3 * qsaturated(1:nlevq))
112  x(nlevp + 1:nstate) = 1.0e3 * qsaturated(1:nlevq) ! in g/kg
113 END WHERE
114 
115 END SUBROUTINE ops_gpsro_humidcheck
116 
real(kind_real), parameter, public rd
subroutine, public ops_gpsro_humidcheck(nstate, nlevp, nlevq, za, zb, capsupersat, x)
Fortran module with various useful routines.
subroutine, public ops_qsat(QS, T, P, npnts)
Calculate the Saturation Specific Humidity Scheme (Qsat): Vapour to Liquid/Ice.
subroutine, public ops_qsatwat(QS, T, P, npnts)
Saturation Specific Humidity Scheme: Vapour to Liquid.