FV3 Bundle
fv_cmp_nlm.F90
Go to the documentation of this file.
2 
4  use fv_mp_nlm_mod, only: is_master
5  use fv_arrays_nlm_mod, only: r_grid
6 
7  implicit none
8  real, parameter:: cv_vap = 3.*rvgas ! 1384.8
9  real, parameter:: cv_air = cp_air - rdgas ! = rdgas * (7/2-1) = 2.5*rdgas=717.68
10 ! 2050 at 0 deg C; 1972 at -15 C; 1818. at -40 C
11 ! real, parameter:: c_ice = 2106. ! heat capacity of ice at 0.C (same as IFS)
12 ! real, parameter:: c_liq = 4218. ! ECMWF-IFS at 0 deg C
13  real, parameter:: c_ice = 1972. ! -15 C
14  real, parameter:: c_liq = 4.1855e+3 ! GFS, at 15 deg C
15  real, parameter:: cp_vap = cp_vapor ! 4*rv_gas=1846.
16  real, parameter:: dc_vap = cp_vap - c_liq ! = -2344. isobaric heating/cooling
17  real, parameter:: dc_ice = c_liq - c_ice ! = 2084
18  real, parameter:: tice = 273.16
19  real, parameter:: t_wfr = tice - 40.
20 ! Values at 0 Deg C
21  real, parameter:: hlv0 = 2.5e6
22  real, parameter:: hlf0 = 3.3358e5
23 ! Latent heat at absolute zero:
24  real, parameter:: lv0 = hlv0 - dc_vap*tice ! = 3.141264e6
25  real, parameter:: li00 = hlf0 - dc_ice*tice ! = -2.355446e5
26 ! Li (T=113) ~ 0.
27 !!! real(kind=R_GRID), parameter:: e00 = 610.71 ! saturation vapor pressure at T0
28  real(kind=R_GRID), parameter:: e00 = 611.21 ! IFS: saturation vapor pressure at T0
29  real(kind=R_GRID), parameter:: d2ice = cp_vap - c_ice
30  real(kind=R_GRID), parameter:: li2 = hlv0+hlf0 - d2ice*tice
31 ! Local:
32  real:: dw_ocean = 0.12 ! This parameter is different from that in major MP
33  real:: crevp(5), lat2
34  real, allocatable:: table(:), table2(:), tablew(:), des2(:), desw(:)
35  real:: d0_vap, lv00
36 
37  logical:: mp_initialized = .false.
38 
39  private
40  public fv_sat_adj, qs_init
41 
42 contains
43 
44  subroutine fv_sat_adj(mdt, zvir, is, ie, js, je, ng, hydrostatic, consv_te, &
45  te0, qv, ql, qi, qr, qs, qg, dpln, delz, pt, dp, &
46  q_con, cappa, area, dtdt, out_dt, last_step, do_qa, qa)
47 ! This is designed for 6-class micro-physics schemes; handles the heat release
48 ! due to in situ phase changes
49 ! input pt is T_vir
50  integer, intent(in):: is, ie, js, je, ng
51  real, intent(in):: mdt ! remapping time step
52  real, intent(in):: zvir
53  logical, intent(in):: hydrostatic, consv_te, out_dt
54  logical, intent(in):: last_step
55  logical, intent(in):: do_qa
56  real, intent(in), dimension(is-ng:ie+ng,js-ng:je+ng):: dp, delz
57  real, intent(in):: dpln(is:ie,js:je)
58  real, intent(inout), dimension(is-ng:ie+ng,js-ng:je+ng):: pt, qv, ql, qi, qr, qs, qg
59  real, intent(out):: qa(is-ng:ie+ng,js-ng:je+ng)
60  real(kind=R_GRID), intent(in), dimension(is-ng:ie+ng,js-ng:je+ng):: area
61  real, intent(inout), dimension(is-ng:,js-ng:):: q_con
62  real, intent(inout), dimension(is-ng:,js-ng:):: cappa
63  real, intent(inout)::dtdt(is:ie,js:je)
64  real, intent(out):: te0(is-ng:ie+ng,js-ng:je+ng)
65 !---
66  real, dimension(is:ie):: wqsat, dq2dt, qpz, cvm, t0, pt1, icp2, lcp2, tcp2, tcp3, &
67  den, q_liq, q_sol, src, hvar
68  real, dimension(is:ie):: mc_air, lhl, lhi ! latent heat
69  real:: sink, qsw, rh, fac_v2l, fac_l2v
70  real:: tc, qsi, dqsdt, dq, dq0, pidep, qi_crt, tmp, dtmp
71  real:: condensates, tin, qstar, rqi, q_plus, q_minus
72  real:: sdt, dt_bigg, adj_fac, fac_s, fac_r, fac_i2s, fac_mlt, fac_l2r
73  real:: factor, qim, tice0, c_air, c_vap
74  integer i,j
75 
76 
77 end subroutine fv_sat_adj
78 
79 
80  real function wqs1(ta, den)
81 ! Pure water phase; universal dry/moist formular using air density
82 ! Input "den" can be either dry or moist air density
83  real, intent(in):: ta, den
84 ! local:
85  real es, ap1
86  real, parameter:: tmin=tice - 160.
87  integer it
88 
89  ap1 = 10.*dim(ta, tmin) + 1.
90  ap1 = min(2621., ap1)
91  it = ap1
92  es = tablew(it) + (ap1-it)*desw(it)
93  wqs1 = es / (rvgas*ta*den)
94 
95  end function wqs1
96 
97  real function iqs1(ta, den)
98 ! water-ice phase; universal dry/moist formular using air density
99 ! Input "den" can be either dry or moist air density
100  real, intent(in):: ta, den
101 ! local:
102  real es, ap1
103  real, parameter:: tmin=tice - 160.
104  integer it
105 
106  ap1 = 10.*dim(ta, tmin) + 1.
107  ap1 = min(2621., ap1)
108  it = ap1
109  es = table2(it) + (ap1-it)*des2(it)
110  iqs1 = es / (rvgas*ta*den)
111 
112  end function iqs1
113 
114 
115  real function wqs2(ta, den, dqdt)
116 ! Pure water phase; universal dry/moist formular using air density
117 ! Input "den" can be either dry or moist air density
118  real, intent(in):: ta, den
119  real, intent(out):: dqdt
120 ! local:
121  real es, ap1
122  real, parameter:: tmin=tice - 160.
123  integer it
124 
125  ap1 = 10.*dim(ta, tmin) + 1.
126  ap1 = min(2621., ap1)
127  it = ap1
128  es = tablew(it) + (ap1-it)*desw(it)
129  wqs2 = es / (rvgas*ta*den)
130  it = ap1 - 0.5
131 ! Finite diff, del_T = 0.1:
132  dqdt = 10.*(desw(it) + (ap1-it)*(desw(it+1)-desw(it))) / (rvgas*ta*den)
133 
134  end function wqs2
135 
136  subroutine wqs2_vect(is, ie, ta, den, wqsat, dqdt)
137 ! Pure water phase; universal dry/moist formular using air density
138 ! Input "den" can be either dry or moist air density
139  integer, intent(in):: is, ie
140  real, intent(in), dimension(is:ie):: ta, den
141  real, intent(out), dimension(is:ie):: wqsat, dqdt
142 ! local:
143  real es, ap1
144  real, parameter:: tmin=tice - 160.
145  integer i, it
146 
147  do i=is, ie
148  ap1 = 10.*dim(ta(i), tmin) + 1.
149  ap1 = min(2621., ap1)
150  it = ap1
151  es = tablew(it) + (ap1-it)*desw(it)
152  wqsat(i) = es / (rvgas*ta(i)*den(i))
153  it = ap1 - 0.5
154 ! Finite diff, del_T = 0.1:
155  dqdt(i) = 10.*(desw(it)+(ap1-it)*(desw(it+1)-desw(it)))/(rvgas*ta(i)*den(i))
156  enddo
157 
158  end subroutine wqs2_vect
159 
160 
161 
162  real function iqs2(ta, den, dqdt)
163 ! water-ice phase; universal dry/moist formular using air density
164 ! Input "den" can be either dry or moist air density
165  real, intent(in):: ta, den
166  real, intent(out):: dqdt
167 ! local:
168  real es, ap1
169  real, parameter:: tmin=tice - 160.
170  integer it
171 
172  ap1 = 10.*dim(ta, tmin) + 1.
173  ap1 = min(2621., ap1)
174  it = ap1
175  es = table2(it) + (ap1-it)*des2(it)
176  iqs2 = es / (rvgas*ta*den)
177  it = ap1 - 0.5
178  dqdt = 10.*(des2(it) + (ap1-it)*(des2(it+1)-des2(it))) / (rvgas*ta*den)
179 
180  end function iqs2
181 
182 
183  subroutine qs_init(kmp)
184  integer, intent(in):: kmp
185  integer, parameter:: length=2621
186  real, parameter:: rhor = 1.0e3 ! LFO83
187  real, parameter:: vdifu = 2.11e-5
188  real, parameter:: tcond = 2.36e-2
189  real, parameter:: visk = 1.259e-5
190  real, parameter:: hltc = 2.5e6
191  real, parameter:: gam290 = 1.827363
192  real, parameter:: gam380 = 4.694155
193  real, parameter:: alin = 842.0
194  !Intercept parameters
195  real, parameter:: rnzr = 8.0e6
196  real, parameter:: c_cracw = 0.9 ! rain accretion efficiency
197  real:: scm3, act2
198  integer i
199 
200  if ( mp_initialized ) return
201  if (is_master()) write(*,*) 'Top layer for GFDL_MP=', kmp
202 
203  lat2 = (hlv + hlf) ** 2
204 
205  scm3 = (visk/vdifu)**(1./3.)
206  act2 = pi * rnzr * rhor
207 
208  crevp(1) = 2.*pi*vdifu*tcond*rvgas*rnzr
209  crevp(2) = 0.78/sqrt(act2)
210  crevp(3) = 0.31*scm3*gam290*sqrt(alin/visk)/act2**0.725
211  crevp(4) = tcond*rvgas
212  crevp(5) = hltc**2*vdifu
213 
214 ! generate es table (dt = 0.1 deg. c)
215  allocate ( table(length) )
216  allocate ( table2(length) )
217  allocate ( tablew(length) )
218  allocate ( des2(length) )
219  allocate ( desw(length) )
220 
221  call qs_table (length )
222  call qs_table2(length )
223  call qs_tablew(length )
224 
225  do i=1,length-1
226  des2(i) = max(0., table2(i+1) - table2(i))
227  desw(i) = max(0., tablew(i+1) - tablew(i))
228  enddo
229  des2(length) = des2(length-1)
230  desw(length) = desw(length-1)
231 
232  mp_initialized = .true.
233 
234  end subroutine qs_init
235 
236  subroutine qs_table(n)
237  integer, intent(in):: n
238  real(kind=R_GRID):: esupc(200)
239  real(kind=R_GRID):: tmin, tem, esh20
240  real(kind=R_GRID):: wice, wh2o, t_ice
241  real(kind=R_GRID):: delt=0.1
242  integer i
243 
244 ! constants
245  t_ice = tice
246 
247 ! compute es over ice between -160c and 0 c.
248  tmin = t_ice - 160.
249  do i=1,1600
250  tem = tmin+delt*real(i-1)
251  table(i) = e00*exp((d2ice*log(tem/t_ice)+li2*(tem-t_ice)/(tem*t_ice))/rvgas)
252  enddo
253 
254 ! compute es over water between -20c and 102c.
255  do i=1,1221
256  tem = 253.16+delt*real(i-1)
257  esh20 = e00*exp((dc_vap*log(tem/t_ice)+lv0*(tem-t_ice)/(tem*t_ice))/rvgas)
258  if (i <= 200) then
259  esupc(i) = esh20
260  else
261  table(i+1400) = esh20
262  endif
263  enddo
264 
265 ! derive blended es over ice and supercooled water between -20c and 0c
266  do i=1,200
267  tem = 253.16+delt*real(i-1)
268  wice = 0.05*(t_ice-tem)
269  wh2o = 0.05*(tem-253.16)
270  table(i+1400) = wice*table(i+1400)+wh2o*esupc(i)
271  enddo
272 
273  end subroutine qs_table
274 
275  subroutine qs_tablew(n)
276 ! Over water
277  integer, intent(in):: n
278  real(kind=R_GRID), parameter:: delt=0.1
279  real(kind=R_GRID):: tmin
280  real(kind=R_GRID):: tem0, t_ice, fac1
281  integer i
282 
283 ! constants
284  t_ice = tice
285  tmin = t_ice - 160.
286  do i=1,n
287  tem0 = tmin + delt*real(i-1)
288 ! compute es over water
289  fac1 = lv0*(tem0-t_ice) / (tem0*t_ice)
290  fac1 = (dc_vap*log(tem0/t_ice)+fac1) / rvgas
291  fac1 = e00*exp(fac1)
292  tablew(i) = fac1
293  enddo
294 
295  end subroutine qs_tablew
296 
297 
298  subroutine qs_table2(n)
299 ! 2-phase table
300  integer, intent(in):: n
301  real(kind=R_GRID):: delt=0.1
302  real(kind=R_GRID):: tmin
303  real(kind=R_GRID):: tem0, tem1, t_ice, fac0, fac1, fac2
304  integer:: i, i0, i1
305 
306 ! constants
307  t_ice = tice
308  tmin = t_ice - 160.
309 
310 ! High-precision computation:
311  do i=1,n
312  tem0 = tmin+delt*real(i-1)
313  fac0 = (tem0-t_ice) / (tem0*t_ice)
314  if ( i<= 1600 ) then
315 ! compute es over ice between -160c and 0 c.
316  fac1 = fac0*li2
317  fac2 = (d2ice*log(tem0/t_ice)+fac1) / rvgas
318  else
319 ! compute es over water between 0c and 102c.
320  fac1 = fac0*lv0
321  fac2 = (dc_vap*log(tem0/t_ice)+fac1) / rvgas
322  endif
323  fac2 = e00*exp(fac2)
324  table2(i) = fac2
325  enddo
326 
327 !----------
328 ! smoother
329 !----------
330  i0 = 1600; i1 = 1601
331  tem0 = 0.25*(table2(i0-1) + 2.*table(i0) + table2(i0+1))
332  tem1 = 0.25*(table2(i1-1) + 2.*table(i1) + table2(i1+1))
333  table2(i0) = tem0
334  table2(i1) = tem1
335 
336  end subroutine qs_table2
337 
338 end module fv_cmp_nlm_mod
real, parameter hlf0
Definition: fv_cmp_nlm.F90:22
real, dimension(:), allocatable table
Definition: fv_cmp_nlm.F90:34
subroutine, public fv_sat_adj(mdt, zvir, is, ie, js, je, ng, hydrostatic, consv_te, te0, qv, ql, qi, qr, qs, qg, dpln, delz, pt, dp, q_con, cappa, area, dtdt, out_dt, last_step, do_qa, qa)
Definition: fv_cmp_nlm.F90:47
real, parameter c_liq
Definition: fv_cmp_nlm.F90:14
real(kind=8), parameter, public pi_8
Ratio of circle circumference to diameter [N/A].
Definition: constants.F90:73
real, parameter, public hlv
Latent heat of evaporation [J/kg].
Definition: constants.F90:80
real, parameter tice
Definition: fv_cmp_nlm.F90:18
subroutine qs_table(n)
Definition: fv_cmp_nlm.F90:237
real, parameter li00
Definition: fv_cmp_nlm.F90:25
real, parameter, public rdgas
Gas constant for dry air [J/kg/deg].
Definition: constants.F90:77
real, dimension(:), allocatable table2
Definition: fv_cmp_nlm.F90:34
real, parameter, public cp_vapor
Specific heat capacity of water vapor at constant pressure [J/kg/deg].
Definition: constants.F90:89
real, parameter cv_air
Definition: fv_cmp_nlm.F90:9
real, parameter lv0
Definition: fv_cmp_nlm.F90:24
real function iqs1(ta, den)
Definition: fv_cmp_nlm.F90:98
real function wqs2(ta, den, dqdt)
Definition: fv_cmp_nlm.F90:116
subroutine qs_tablew(n)
Definition: fv_cmp_nlm.F90:276
real, parameter, public rvgas
Gas constant for water vapor [J/kg/deg].
Definition: constants.F90:78
real function wqs1(ta, den)
Definition: fv_cmp_nlm.F90:81
real(kind=r_grid), parameter e00
Definition: fv_cmp_nlm.F90:28
real, dimension(:), allocatable des2
Definition: fv_cmp_nlm.F90:34
subroutine, public qs_init(kmp)
Definition: fv_cmp_nlm.F90:184
real, parameter, public cp_air
Specific heat capacity of dry air at constant pressure [J/kg/deg].
Definition: constants.F90:83
real(kind=r_grid), parameter d2ice
Definition: fv_cmp_nlm.F90:29
subroutine qs_table2(n)
Definition: fv_cmp_nlm.F90:299
real, parameter cv_vap
Definition: fv_cmp_nlm.F90:8
integer, parameter, public r_grid
real, parameter t_wfr
Definition: fv_cmp_nlm.F90:19
real, parameter dc_ice
Definition: fv_cmp_nlm.F90:17
real, dimension(5) crevp
Definition: fv_cmp_nlm.F90:33
real, parameter, public hlf
Latent heat of fusion [J/kg].
Definition: constants.F90:81
real, parameter, public grav
Acceleration due to gravity [m/s^2].
Definition: constants.F90:76
subroutine wqs2_vect(is, ie, ta, den, wqsat, dqdt)
Definition: fv_cmp_nlm.F90:137
#define max(a, b)
Definition: mosaic_util.h:33
real, dimension(:), allocatable desw
Definition: fv_cmp_nlm.F90:34
real, parameter c_ice
Definition: fv_cmp_nlm.F90:13
real(kind=r_grid), parameter li2
Definition: fv_cmp_nlm.F90:30
real, dimension(:), allocatable tablew
Definition: fv_cmp_nlm.F90:34
real, parameter cp_vap
Definition: fv_cmp_nlm.F90:15
#define min(a, b)
Definition: mosaic_util.h:32
real function iqs2(ta, den, dqdt)
Definition: fv_cmp_nlm.F90:163
logical mp_initialized
Definition: fv_cmp_nlm.F90:37
real, parameter hlv0
Definition: fv_cmp_nlm.F90:21
real, parameter dc_vap
Definition: fv_cmp_nlm.F90:16
The namespace for the qg model.
real(fp), parameter, public pi