42 subroutine tempo_init(aerosolaware_flag, hailaware_flag, semi_sedi_flag, cloud_condensation_flag, &
43 refl10cm_from_melting_flag, ml_for_bl_nc_flag, ml_for_nc_flag, force_init_flag, tempo_cfgs)
46 initialize_graupel_vars, initialize_parameters, initialize_bins_for_tables, &
47 initialize_array_efrw, initialize_array_efsw, initialize_arrays_drop_evap, &
48 initialize_arrays_ccn, initialize_arrays_qi_aut_qs, &
49 initialize_arrays_qr_acr_qs, initialize_arrays_qr_acr_qg, initialize_arrays_freezewater, &
50 initialize_bins_for_hail_size, initialize_bins_for_radar
52 logical,
intent(in),
optional :: aerosolaware_flag, hailaware_flag, refl10cm_from_melting_flag, &
53 ml_for_bl_nc_flag, ml_for_nc_flag, force_init_flag, semi_sedi_flag, cloud_condensation_flag
56 character(len=100) :: table_filename
58 logical :: initialize_mp_vars, force_init
61 call get_version(tempo_version, tempo_cfgs%verbose)
66 if (
present(force_init_flag)) force_init = force_init_flag
68 initialize_mp_vars = .true.
69 if (
allocated(t_efrw)) initialize_mp_vars = .false.
70 if (force_init) initialize_mp_vars = .true.
72 if (initialize_mp_vars)
then
73 if (
present(aerosolaware_flag)) tempo_cfgs%aerosolaware_flag = aerosolaware_flag
74 if (
present(hailaware_flag)) tempo_cfgs%hailaware_flag = hailaware_flag
75 if (
present(ml_for_bl_nc_flag)) tempo_cfgs%ml_for_bl_nc_flag = ml_for_bl_nc_flag
76 if (
present(ml_for_nc_flag)) tempo_cfgs%ml_for_nc_flag = ml_for_nc_flag
77 if (
present(semi_sedi_flag)) tempo_cfgs%semi_sedi_flag = semi_sedi_flag
78 if (
present(cloud_condensation_flag)) tempo_cfgs%cloud_condensation_flag = cloud_condensation_flag
79 if (
present(refl10cm_from_melting_flag)) tempo_cfgs%refl10cm_from_melting_flag = refl10cm_from_melting_flag
81 if (tempo_cfgs%verbose)
then
82 write(*,
'(A)')
'tempo_init() --- TEMPO microphysics configuration options: '
83 write(*,
'(A,L)')
'tempo_init() --- aerosol aware = ', tempo_cfgs%aerosolaware_flag
84 write(*,
'(A,L)')
'tempo_init() --- hail aware = ', tempo_cfgs%hailaware_flag
85 write(*,
'(A,L)')
'tempo_init() --- ML for subgrid cloud number = ', tempo_cfgs%ml_for_bl_nc_flag
86 write(*,
'(A,L)')
'tempo_init() --- ML for cloud number = ', tempo_cfgs%ml_for_nc_flag
87 write(*,
'(A,L)')
'tempo_init() --- reflectivity from melting snow/graupel = ', tempo_cfgs%refl10cm_from_melting_flag
88 write(*,
'(A,L)')
'tempo_init() --- semi-lagrangian sedimentation = ', tempo_cfgs%semi_sedi_flag
92 call initialize_graupel_vars(tempo_cfgs%hailaware_flag)
93 if (tempo_cfgs%verbose)
then
94 write(*,
'(A,L)')
'tempo_init() --- initialized graupel variables using hail aware = ', tempo_cfgs%hailaware_flag
98 call initialize_parameters()
99 if (tempo_cfgs%verbose)
write(*,
'(A)')
'tempo_init() --- initialized parameters'
102 call initialize_bins_for_tables()
103 if (tempo_cfgs%verbose)
write(*,
'(A)')
'tempo_init() --- initialized bins for lookup tables'
106 call initialize_array_efrw()
108 if (tempo_cfgs%verbose)
then
109 write(*,
'(A)')
'tempo_init() --- initialized collision efficiency data for rain collecting cloud water'
111 call initialize_array_efsw()
113 if (tempo_cfgs%verbose)
then
114 write(*,
'(A)')
'tempo_init() --- initialized collision efficiency data for snow collecting cloud water'
118 call initialize_arrays_drop_evap()
119 call compute_drop_evap()
120 if (tempo_cfgs%verbose)
write(*,
'(A)')
'tempo_init() --- initialized drop evaporation data'
123 call initialize_arrays_qi_aut_qs()
127 table_filename = tempo_table_cfgs%ccn_table_name
128 call initialize_arrays_ccn(table_size)
129 call read_table_ccn(trim(table_filename), table_size, tempo_cfgs)
130 if (tempo_cfgs%verbose)
write(*,
'(A)')
'tempo_init() --- initialized data for ccn lookup table'
133 table_filename = tempo_table_cfgs%freezewater_table_name
134 call initialize_arrays_freezewater(table_size)
135 call read_table_freezewater(trim(table_filename), table_size, tempo_cfgs)
136 if (tempo_cfgs%verbose)
then
137 write(*,
'(A)')
'tempo_init() --- initialized data for frozen cloud water and rain lookup table'
141 table_filename = tempo_table_cfgs%qrqs_table_name
142 call initialize_arrays_qr_acr_qs(table_size)
143 call read_table_qr_acr_qs(trim(table_filename), table_size, tempo_cfgs)
144 if (tempo_cfgs%verbose)
then
145 write(*,
'(A)')
'tempo_init() --- initialized data for rain-snow collection lookup table'
149 table_filename = tempo_table_cfgs%qrqg_table_name
150 call initialize_arrays_qr_acr_qg(table_size)
151 call read_table_qr_acr_qg(trim(table_filename), table_size, tempo_cfgs)
152 if (tempo_cfgs%verbose)
then
153 write(*,
'(A)')
'tempo_init() --- initialized data for rain-graupel collection lookup table'
157 if (tempo_cfgs%refl10cm_from_melting_flag)
then
158 call initialize_bins_for_radar()
159 if (tempo_cfgs%verbose)
then
160 write(*,
'(A,L)')
'tempo_init() --- flag to calcuate reflectivity with contributions from melting snow and graupel = ', &
161 tempo_cfgs%refl10cm_from_melting_flag
162 write(*,
'(A)')
'tempo_init() --- initialized bins for reflectivity calcuation with meting snow and graupel'
167 if (tempo_cfgs%max_hail_diameter_flag)
then
168 call initialize_bins_for_hail_size()
169 if (tempo_cfgs%verbose)
then
170 write(*,
'(A,L)')
'tempo_init() --- flag to calculate max hail diameter = ', &
171 tempo_cfgs%max_hail_diameter_flag
172 write(*,
'(A)')
'tempo_init() --- initialized bins for hail size calculation'
177 if(tempo_cfgs%ml_for_bl_nc_flag .or. tempo_cfgs%ml_for_nc_flag)
then
179 if (tempo_cfgs%verbose)
write(*,
'(A)')
'tempo_init() --- initialized data for cloud number machine learning'
187 subroutine tempo_run(tempo_cfgs, dt, itimestep, &
188 t, th, pii, p, w, dz, &
189 qv, qc, qr, qi, qs, qg, ni, nr, &
190 nc, nwfa, nifa, ng, qb, &
193 thten_bl, qvten_bl, qcten_bl, qiten_bl, &
194 thten_lwrad, thten_swrad, &
196 ids, ide, jds, jde, kds, kde, &
197 ims, ime, jms, jme, kms, kme, &
198 its, ite, jts, jte, kts, kte, tempo_diags)
201 real(wp),
intent(in) :: dt
202 integer,
intent(in) :: itimestep
203 integer,
intent(in) :: ids, ide, jds, jde, kds, kde
204 integer,
intent(in) :: ims, ime, jms, jme, kms, kme
205 integer,
intent(in) :: its, ite, jts, jte, kts, kte
207 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(inout),
optional :: t
208 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(inout),
optional :: th
210 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(in) :: p
211 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(in) :: w
212 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(in) :: dz
213 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(in),
optional :: pii
215 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(inout) :: qv
216 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(inout) :: qc
217 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(inout) :: qr
218 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(inout) :: qi
219 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(inout) :: qs
220 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(inout) :: qg
221 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(inout) :: ni
222 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(inout) :: nr
224 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(inout),
optional :: nc
225 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(inout),
optional :: nwfa
226 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(inout),
optional :: nifa
227 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(inout),
optional :: qb
228 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(inout),
optional :: ng
229 integer,
dimension(ims:ime, jms:jme),
intent(in),
optional :: land_input
232 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(inout),
optional :: qcfrac
233 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(inout),
optional :: qifrac
234 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(in),
optional :: qc_bl
235 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(in),
optional :: qcfrac_bl
236 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(in),
optional :: thten_bl
237 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(in),
optional :: qvten_bl
238 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(in),
optional :: qcten_bl
239 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(in),
optional :: qiten_bl
240 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(in),
optional :: thten_lwrad
241 real(wp),
dimension(ims:ime, kms:kme, jms:jme),
intent(in),
optional :: thten_swrad
242 integer,
allocatable :: land1d
244 real(wp),
dimension(kts:kte) :: t1d
245 real(wp),
dimension(kts:kte) :: p1d
246 real(wp),
dimension(kts:kte) :: qv1d
247 real(wp),
dimension(kts:kte) :: qc1d
248 real(wp),
dimension(kts:kte) :: qr1d
249 real(wp),
dimension(kts:kte) :: qi1d
250 real(wp),
dimension(kts:kte) :: qs1d
251 real(wp),
dimension(kts:kte) :: qg1d
252 real(wp),
dimension(kts:kte) :: ni1d
253 real(wp),
dimension(kts:kte) :: nr1d
254 real(wp),
dimension(kts:kte) :: w1d
255 real(wp),
dimension(kts:kte) :: dz1d
257 real(wp),
dimension(:),
allocatable :: nc1d
258 real(wp),
dimension(:),
allocatable :: nwfa1d
259 real(wp),
dimension(:),
allocatable :: nifa1d
260 real(wp),
dimension(:),
allocatable :: qb1d
261 real(wp),
dimension(:),
allocatable :: ng1d
264 real(wp),
dimension(:),
allocatable :: qcfrac1d
265 real(wp),
dimension(:),
allocatable :: qifrac1d
266 real(wp),
dimension(:),
allocatable :: qc_bl1d
267 real(wp),
dimension(:),
allocatable :: qcfrac_bl1d
268 real(wp),
dimension(:),
allocatable :: thten_bl1d
269 real(wp),
dimension(:),
allocatable :: qvten_bl1d
270 real(wp),
dimension(:),
allocatable :: qcten_bl1d
271 real(wp),
dimension(:),
allocatable :: qiten_bl1d
272 real(wp),
dimension(:),
allocatable :: thten_lwrad1d
273 real(wp),
dimension(:),
allocatable :: thten_swrad1d
275 integer :: i, j, k, nz
276 logical :: use_temperature
283 if (
present(nwfa))
allocate(nwfa1d(nz), source=0._wp)
284 if (
present(nifa))
allocate(nifa1d(nz), source=0._wp)
285 if (
present(nc))
allocate(nc1d(nz), source=0._wp)
286 if (
present(ng))
allocate(ng1d(nz), source=0._wp)
287 if (
present(qb))
allocate(qb1d(nz), source=0._wp)
290 if (
present(qcfrac))
allocate(qcfrac1d(nz), source=0._wp)
291 if (
present(qifrac))
allocate(qifrac1d(nz), source=0._wp)
292 if (
present(qc_bl))
allocate(qc_bl1d(nz), source=0._wp)
293 if (
present(qcfrac_bl))
allocate(qcfrac_bl1d(nz), source=0._wp)
294 if (
present(thten_bl))
allocate(thten_bl1d(nz), source=0._wp)
295 if (
present(qvten_bl))
allocate(qvten_bl1d(nz), source=0._wp)
296 if (
present(qcten_bl))
allocate(qcten_bl1d(nz), source=0._wp)
297 if (
present(qiten_bl))
allocate(qiten_bl1d(nz), source=0._wp)
298 if (
present(thten_lwrad))
allocate(thten_lwrad1d(nz), source=0._wp)
299 if (
present(thten_swrad))
allocate(thten_swrad1d(nz), source=0._wp)
300 if (
present(land_input))
allocate(land1d)
304 if (tempo_cfgs%cloud_number_mixing_ratio_flag)
then
305 if (.not.
allocated(tempo_diags%cloud_number_mixing_ratio))
then
306 allocate(tempo_diags%cloud_number_mixing_ratio(its:ite, kts:kte, jts:jte), source=0._wp)
308 tempo_diags%cloud_number_mixing_ratio = 0._wp
312 if (tempo_cfgs%rain_med_vol_diam_flag)
then
313 if (.not.
allocated(tempo_diags%rain_med_vol_diam))
then
314 allocate(tempo_diags%rain_med_vol_diam(its:ite, kts:kte, jts:jte), source=0._wp)
316 tempo_diags%rain_med_vol_diam = 0._wp
320 if (tempo_cfgs%graupel_med_vol_diam_flag)
then
321 if (.not.
allocated(tempo_diags%graupel_med_vol_diam))
then
322 allocate(tempo_diags%graupel_med_vol_diam(its:ite, kts:kte, jts:jte), source=0._wp)
324 tempo_diags%graupel_med_vol_diam = 0._wp
328 if (tempo_cfgs%refl10cm_flag)
then
329 if (.not.
allocated(tempo_diags%refl10cm))
then
330 allocate(tempo_diags%refl10cm(its:ite, kts:kte, jts:jte), source=-35._wp)
332 tempo_diags%refl10cm = -35._wp
336 if (tempo_cfgs%re_cloud_flag)
then
337 if (.not.
allocated(tempo_diags%re_cloud))
then
338 allocate(tempo_diags%re_cloud(its:ite, kts:kte, jts:jte), source=0._wp)
340 tempo_diags%re_cloud = 0._wp
344 if (tempo_cfgs%re_ice_flag)
then
345 if (.not.
allocated(tempo_diags%re_ice))
then
346 allocate(tempo_diags%re_ice(its:ite, kts:kte, jts:jte), source=0._wp)
348 tempo_diags%re_ice = 0._wp
352 if (tempo_cfgs%re_snow_flag)
then
353 if (.not.
allocated(tempo_diags%re_snow))
then
354 allocate(tempo_diags%re_snow(its:ite, kts:kte, jts:jte), source=0._wp)
356 tempo_diags%re_snow = 0._wp
361 if (tempo_cfgs%max_hail_diameter_flag)
then
362 if (.not.
allocated(tempo_diags%max_hail_diameter_sfc))
then
363 allocate(tempo_diags%max_hail_diameter_sfc(its:ite, jts:jte), source=0._wp)
364 allocate(tempo_diags%max_hail_diameter_column(its:ite, jts:jte), source=0._wp)
366 tempo_diags%max_hail_diameter_sfc = 0._wp
367 tempo_diags%max_hail_diameter_column = 0._wp
372 if (.not.
allocated(tempo_diags%rain_precip))
then
373 allocate(tempo_diags%rain_precip(its:ite, jts:jte), source=0._wp)
374 allocate(tempo_diags%ice_liquid_equiv_precip(its:ite, jts:jte), source=0._wp)
375 allocate(tempo_diags%snow_liquid_equiv_precip(its:ite, jts:jte), source=0._wp)
376 allocate(tempo_diags%graupel_liquid_equiv_precip(its:ite, jts:jte), source=0._wp)
377 allocate(tempo_diags%frozen_fraction(its:ite, jts:jte), source=0._wp)
378 allocate(tempo_diags%frz_rain_precip(its:ite, jts:jte), source=0._wp)
380 tempo_diags%rain_precip = 0._wp
381 tempo_diags%ice_liquid_equiv_precip = 0._wp
382 tempo_diags%snow_liquid_equiv_precip = 0._wp
383 tempo_diags%graupel_liquid_equiv_precip = 0._wp
384 tempo_diags%frozen_fraction = 0._wp
385 tempo_diags%frz_rain_precip = 0._wp
390 use_temperature = .true.
391 elseif (
present(th) .and.
present(pii))
then
392 use_temperature = .false.
401 if (use_temperature)
then
404 t1d(k) = th(i,k,j) * pii(i,k,j)
419 if (
present(nwfa)) nwfa1d(k) = nwfa(i,k,j)
420 if (
present(nifa)) nifa1d(k) = nifa(i,k,j)
421 if (
present(nc)) nc1d(k) = nc(i,k,j)
424 if ((
present(ng)) .and. (
present(qb)))
then
430 if (
present(qc_bl) .and.
present(qcfrac_bl))
then
431 qc_bl1d(k) = qc_bl(i,k,j)
432 qcfrac_bl1d(k) = qcfrac_bl(i,k,j)
437 if (
present(land_input)) land1d = land_input(i,j)
440 call tempo_main(tempo_cfgs=tempo_cfgs, &
441 qv1d=qv1d, qc1d=qc1d, qi1d=qi1d, qr1d=qr1d, qs1d=qs1d, qg1d=qg1d, qb1d=qb1d, &
442 ni1d=ni1d, nr1d=nr1d, nc1d=nc1d, ng1d=ng1d, nwfa1d=nwfa1d, nifa1d=nifa1d, t1d=t1d, p1d=p1d, &
443 w1d=w1d, dz1d=dz1d, land1d=land1d, &
444 qcfrac1d=qcfrac1d, qifrac1d=qifrac1d, qc_bl1d=qc_bl1d, qcfrac_bl1d=qcfrac_bl1d, &
445 thten_bl1d=thten_bl1d, qvten_bl1d=qvten_bl1d, qcten_bl1d=qcten_bl1d, qiten_bl1d=qiten_bl1d, &
446 thten_lwrad1d=thten_lwrad1d, thten_swrad1d=thten_swrad1d, &
447 kts=kts, kte=kte, dt=dt, ii=i, jj=j, tempo_main_diags=tempo_main_diags)
450 tempo_diags%rain_precip(i,j) = tempo_main_diags%rain_precip
451 tempo_diags%ice_liquid_equiv_precip(i,j) = tempo_main_diags%ice_liquid_equiv_precip
452 tempo_diags%snow_liquid_equiv_precip(i,j) = tempo_main_diags%snow_liquid_equiv_precip
453 tempo_diags%graupel_liquid_equiv_precip(i,j) = tempo_main_diags%graupel_liquid_equiv_precip
454 tempo_diags%frozen_fraction(i,j) = tempo_main_diags%frozen_fraction
455 tempo_diags%frz_rain_precip(i,j) = tempo_main_diags%frz_rain_precip
458 if (
allocated(tempo_diags%cloud_number_mixing_ratio) .and.
allocated(tempo_main_diags%cloud_number_mixing_ratio))
then
459 tempo_diags%cloud_number_mixing_ratio(i,:,j) = tempo_main_diags%cloud_number_mixing_ratio
461 if (
allocated(tempo_diags%rain_med_vol_diam) .and.
allocated(tempo_main_diags%rain_med_vol_diam))
then
462 tempo_diags%rain_med_vol_diam(i,:,j) = tempo_main_diags%rain_med_vol_diam
464 if (
allocated(tempo_diags%graupel_med_vol_diam) .and.
allocated(tempo_main_diags%graupel_med_vol_diam))
then
465 tempo_diags%graupel_med_vol_diam(i,:,j) = tempo_main_diags%graupel_med_vol_diam
467 if (
allocated(tempo_diags%re_cloud) .and.
allocated(tempo_main_diags%re_cloud))
then
468 tempo_diags%re_cloud(i,:,j) = tempo_main_diags%re_cloud
470 if (
allocated(tempo_diags%re_ice) .and.
allocated(tempo_main_diags%re_ice))
then
471 tempo_diags%re_ice(i,:,j) = tempo_main_diags%re_ice
473 if (
allocated(tempo_diags%re_snow) .and.
allocated(tempo_main_diags%re_snow))
then
474 tempo_diags%re_snow(i,:,j) = tempo_main_diags%re_snow
476 if (
allocated(tempo_diags%refl10cm) .and.
allocated(tempo_main_diags%refl10cm))
then
477 tempo_diags%refl10cm(i,:,j) = tempo_main_diags%refl10cm
479 if (
allocated(tempo_diags%max_hail_diameter_sfc) .and.
allocated(tempo_diags%max_hail_diameter_column) .and.
allocated(tempo_main_diags%max_hail_diameter))
then
480 tempo_diags%max_hail_diameter_sfc(i,j) = tempo_main_diags%max_hail_diameter(1)
481 tempo_diags%max_hail_diameter_column(i,j) = maxval(tempo_main_diags%max_hail_diameter)
486 if (
present(nc)) nc(i,k,j) = nc1d(k)
487 if (
present(nwfa)) nwfa(i,k,j) = nwfa1d(k)
488 if (
present(nifa)) nifa(i,k,j) = nifa1d(k)
489 if ((
present(ng)) .and. (
present(qb)))
then
503 if (use_temperature)
then
506 th(i,k,j) = t1d(k) / pii(i,k,j)