Line data Source code
1 : !--------------------------------------------------------------------------------------------------
2 : ! $Id$
3 : !==================================================================================================
4 : !
5 : ! ######## ### ### ### ######### ######### ### ######### ###########
6 : ! ### ### ### ### ### ### ### ### ### ### ### ### ### ###
7 : ! ### ### ### ### ### ### ### ### ### ### ### ### ###
8 : ! ### ### ### ### ######### ######### ########### ######### ###
9 : ! ### ### ### ### ### ### ### ### ### ### ### ###
10 : ! ### ### ### ### ### ### ### ### ### ### ### ### ###
11 : ! ######## ########## ######## ######### ######### ### ### ### ###########
12 : !
13 : ! The CLUBB API serves as the doorway through which external models can interact with CLUBB.
14 : !
15 : ! PLEASE REMEMBER, IF ANY CODE IS CHANGED IN THIS DOCUMENT,
16 : ! THE CHANGES MUST BE PROPOGATED TO ALL HOST MODELS.
17 : !
18 :
19 : module clubb_api_module
20 :
21 :
22 : use mt95, only : &
23 : assignment( = ), &
24 : genrand_state, & ! Internal representation of the RNG state.
25 : genrand_srepr, & ! Public representation of the RNG state. Should be used to save the RNG state
26 : genrand_intg, &
27 : genrand_init_api => genrand_init
28 :
29 : use clubb_precision, only : &
30 : time_precision, &
31 : core_rknd, &
32 : stat_nknd, &
33 : stat_rknd, &
34 : dp ! Double Precision
35 :
36 : use constants_clubb, only : &
37 : cloud_frac_min, & ! Threshold for cloud fractions
38 : cm3_per_m3, & ! Cubic centimeters per cubic meter
39 : Cp, & ! Dry air specific heat at constant p [J/kg/K]
40 : em_min, & ! Minimum value for em (turbulence kinetic energy)
41 : ep, & ! ep = 0.622 [-]
42 : fstderr, & ! Fortran file unit I/O constant
43 : fstdout, & ! Fortran file unit I/O constant
44 : grav, & ! Gravitational acceleration [m/s^2]
45 : Ls, & ! Latent heat of sublimation [J/kg]
46 : Lv, & ! Latent heat of vaporization [J/kg]
47 : Lf, & ! Latent heat of fusion [J/kg]
48 : pi, & ! The ratio of radii to their circumference
49 : pi_dp, & ! pi in double precision
50 : radians_per_deg_dp, &
51 : Rd, & ! Dry air gas constant [J/kg/K]
52 : Rv, & ! Water vapor gas constant [J/kg/K]
53 : sec_per_day, & ! Seconds in a day.
54 : sec_per_hr, & ! Seconds in an hour.
55 : sec_per_min, & ! Seconds in a minute.
56 : T_freeze_K, & ! Freezing point of water [K]
57 : var_length, & ! Maximum variable name length in CLUBB GrADS or netCDF output
58 : zero, & ! 0.0_core_rknd
59 : zero_threshold, & ! Defining a threshold on a physical quantity to be 0.
60 : ! Tolerances
61 : Nc_tol, & ! Tolerance value for N_c [#/kg]
62 : Ng_tol, & ! Tolerance value for N_s [#/kg]
63 : Ni_tol, & ! Tolerance value for N_i [#/kg]
64 : Nr_tol, & ! Tolerance value for N_r [#/kg]
65 : Ns_tol, & ! Tolerance value for N_s [#/kg]
66 : rg_tol, & ! Tolerance value for r_g [kg/kg]
67 : rho_lw, &
68 : ri_tol, & ! Tolerance value for r_i [kg/kg]
69 : rr_tol, & ! Tolerance value for r_r [kg/kg]
70 : rs_tol, & ! Tolerance value for r_s [kg/kg]
71 : rt_tol, & ! [kg/kg]
72 : thl_tol, & ! [K]
73 : w_tol_sqd, & ! [m^2/s^2]
74 : num_hf_draw_points ! Neighboring points to use in hole filling algorithm
75 :
76 : use corr_varnce_module, only : &
77 : hmp2_ip_on_hmm2_ip_slope_type, & ! Types
78 : hmp2_ip_on_hmm2_ip_intrcpt_type, &
79 : hm_metadata_type
80 :
81 : use array_index, only: &
82 : sclr_idx_type
83 :
84 : use error_code, only: &
85 : clubb_at_least_debug_level, & ! Procedure
86 : err_code, & ! Error Indicator
87 : clubb_no_error, & ! Constants
88 : clubb_fatal_error
89 :
90 : use hydromet_pdf_parameter_module, only : &
91 : hydromet_pdf_parameter, &
92 : precipitation_fractions
93 :
94 : use model_flags, only : &
95 : clubb_config_flags_type, & ! Type
96 : iiPDF_ADG1, &
97 : iiPDF_new_hybrid, &
98 : ipdf_pre_advance_fields, &
99 : ipdf_post_advance_fields, &
100 : l_use_boussinesq ! Use Boussinesq form of predictive equations (default is Anelastic).
101 :
102 : use parameters_tunable, only : &
103 : params_list, & ! Variable(s)
104 : nu_vertical_res_dep ! Type(s)
105 :
106 : use parameter_indices, only: &
107 : nparams, & ! Variable(s)
108 : iC1, iC1b, iC1c, &
109 : iC2rt, iC2thl, iC2rtthl, iC4, iC_uu_shr, iC_uu_buoy, &
110 : iC6rt, iC6rtb, iC6rtc, iC6thl, iC6thlb, iC6thlc, &
111 : iC7, iC7b, iC7c, iC8, iC8b, iC10, iC11, iC11b, iC11c, &
112 : iC12, iC13, iC14, iC_wp3_pr_turb, iC_wp3_pr_dfsn, iC_wp2_splat, &
113 : iC6rt_Lscale0, iC6thl_Lscale0, &
114 : iC7_Lscale0, iwpxp_L_thresh, ic_K, ic_K1, inu1, &
115 : ic_K2, inu2, ic_K6, inu6, ic_K8, inu8, ic_K9, inu9, &
116 : inu10, ic_K_hm, ic_K_hmb, iK_hm_min_coef, inu_hm, &
117 : islope_coef_spread_DG_means_w, ipdf_component_stdev_factor_w, &
118 : icoef_spread_DG_means_rt, icoef_spread_DG_means_thl, &
119 : ibeta, igamma_coef, igamma_coefb, igamma_coefc, ilmin_coef, &
120 : iomicron, izeta_vrnce_rat, iupsilon_precip_frac_rat, &
121 : ilambda0_stability_coef, imult_coef, itaumin, itaumax, imu, &
122 : iLscale_mu_coef, iLscale_pert_coef, ialpha_corr, iSkw_denom_coef, &
123 : ic_K10, ic_K10h, ithlp2_rad_coef, ithlp2_rad_cloud_frac_thresh, &
124 : iup2_sfc_coef, iSkw_max_mag, iC_invrs_tau_bkgnd, &
125 : iC_invrs_tau_sfc, iC_invrs_tau_shear, iC_invrs_tau_N2, &
126 : iC_invrs_tau_N2_wp2, iC_invrs_tau_N2_xp2, iC_invrs_tau_N2_wpxp, &
127 : iC_invrs_tau_N2_clear_wp3, ialtitude_threshold, irtp2_clip_coef, &
128 : iRichardson_num_min, iRichardson_num_max, iwpxp_Ri_exp, &
129 : ia3_coef_min, ia_const, iCx_min, iCx_max, ibv_efold, iz_displace
130 :
131 :
132 : use pdf_parameter_module, only : &
133 : ! The CLUBB_CAM preprocessor directives are being commented out because this
134 : ! code is now also used for WRF-CLUBB.
135 : !#ifdef CLUBB_CAM /* Code for storing pdf_parameter structs in pbuf as array */
136 : num_pdf_params, &
137 : !#endif
138 : pdf_parameter, &
139 : implicit_coefs_terms
140 :
141 : use sponge_layer_damping, only : &
142 : thlm_sponge_damp_settings, & ! Variable(s)
143 : rtm_sponge_damp_settings, &
144 : uv_sponge_damp_settings, &
145 : wp2_sponge_damp_settings, &
146 : wp3_sponge_damp_settings, &
147 : up2_vp2_sponge_damp_settings, &
148 : thlm_sponge_damp_profile, &
149 : rtm_sponge_damp_profile, &
150 : uv_sponge_damp_profile, &
151 : wp2_sponge_damp_profile, &
152 : wp3_sponge_damp_profile, &
153 : up2_vp2_sponge_damp_profile
154 :
155 : use stat_file_module, only : &
156 : clubb_i, & ! Used to output multiple columns
157 : clubb_j ! The indices must not exceed nlon (for i) or nlat (for j).
158 :
159 : use stats_rad_zm_module, only : &
160 : nvarmax_rad_zm ! Maximum variables allowed
161 :
162 : use stats_rad_zt_module, only : &
163 : nvarmax_rad_zt ! Maximum variables allowed
164 :
165 : use stats_zm_module, only : &
166 : nvarmax_zm ! Maximum variables allowed
167 :
168 : use stats_zt_module, only : &
169 : nvarmax_zt ! Maximum variables allowed
170 :
171 : use stats_sfc_module, only : &
172 : nvarmax_sfc
173 :
174 : use stats_variables, only: &
175 : stats_metadata_type
176 :
177 : use grid_class, only: grid ! Type
178 :
179 : use grid_class, only: &
180 : ! Interpolate momentum level variables to thermodynamic levels
181 : zm2zt_api => zm2zt, &
182 :
183 : ! Interpolate thermodynamic level variables to momentum levels
184 : zt2zm_api => zt2zm
185 :
186 : use saturation, only: &
187 : ! Used to compute the saturation mixing ratio of liquid water.
188 : sat_mixrat_liq_api => sat_mixrat_liq
189 :
190 : use T_in_K_module, only : &
191 : ! Calculates absolute temperature from liquid water potential
192 : ! temperature. (Does not include ice.)
193 : thlm2T_in_K_api => thlm2T_in_K, &
194 :
195 : ! Calculates liquid water potential temperature from absolute temperature
196 : T_in_K2thlm_api => T_in_K2thlm
197 :
198 : use advance_clubb_core_module, only: &
199 : check_clubb_settings_api => check_clubb_settings
200 :
201 : use parameters_model, only: &
202 : setup_parameters_model_api => setup_parameters_model
203 :
204 : use fill_holes, only : &
205 : fill_holes_driver_api => fill_holes_driver, &
206 : fill_holes_hydromet_api => fill_holes_hydromet, &
207 : fill_holes_vertical_api => fill_holes_vertical
208 :
209 : use stats_rad_zm_module, only : &
210 : stats_init_rad_zm_api => stats_init_rad_zm
211 :
212 : use stats_rad_zt_module, only : &
213 : stats_init_rad_zt_api => stats_init_rad_zt
214 :
215 : use stats_zm_module, only : &
216 : stats_init_zm_api => stats_init_zm
217 :
218 : use stats_zt_module, only : &
219 : stats_init_zt_api => stats_init_zt
220 :
221 : use stats_sfc_module, only : &
222 : stats_init_sfc_api => stats_init_sfc
223 :
224 : use stats_clubb_utilities, only : &
225 : stats_begin_timestep_api => stats_begin_timestep
226 :
227 : use model_flags, only: &
228 : initialize_clubb_config_flags_type_api => initialize_clubb_config_flags_type, &
229 : set_default_clubb_config_flags_api => set_default_clubb_config_flags, &
230 : saturation_bolton, & ! Constant for Bolton approximations of saturation
231 : saturation_gfdl, & ! Constant for the GFDL approximation of saturation
232 : saturation_flatau, & ! Constant for Flatau approximations of saturation
233 : saturation_lookup ! Use a lookup table for mixing length
234 :
235 : use corr_varnce_module, only : &
236 : setup_corr_varnce_array_api => setup_corr_varnce_array, &
237 : init_pdf_hydromet_arrays_api => init_pdf_hydromet_arrays
238 :
239 : use stats_clubb_utilities, only : &
240 : stats_accumulate_hydromet_api => stats_accumulate_hydromet, &
241 : stats_init_api => stats_init
242 :
243 : use stats_type, only: stats ! Type
244 :
245 : implicit none
246 :
247 : private
248 :
249 : public &
250 : ! To Implement CLUBB:
251 : set_default_parameters_api, & ! Procedure(s)
252 : read_parameters_api, &
253 : check_clubb_settings_api, &
254 : setup_parameters_model_api, &
255 : ! CLUBB can be set more specifically using these flags:
256 : iiPDF_ADG1, &
257 : iiPDF_new_hybrid, &
258 : ipdf_pre_advance_fields, &
259 : ipdf_post_advance_fields, &
260 : l_use_boussinesq, &
261 : saturation_bolton, &
262 : saturation_gfdl, &
263 : saturation_flatau, &
264 : saturation_lookup, &
265 : ! The parameters of CLUBB can be retrieved and tuned using these indices:
266 : iC1, iC1b, iC1c, &
267 : iC2rt, iC2thl, iC2rtthl, iC4, iC_uu_shr, iC_uu_buoy, &
268 : iC6rt, iC6rtb, iC6rtc, iC6thl, iC6thlb, iC6thlc, &
269 : iC7, iC7b, iC7c, iC8, iC8b, iC10, iC11, iC11b, iC11c, &
270 : iC12, iC13, iC14, iC_wp3_pr_turb, iC_wp3_pr_dfsn, iC_wp2_splat, &
271 : iC6rt_Lscale0, iC6thl_Lscale0, &
272 : iC7_Lscale0, iwpxp_L_thresh, ic_K, ic_K1, inu1, &
273 : ic_K2, inu2, ic_K6, inu6, ic_K8, inu8, ic_K9, inu9, &
274 : inu10, ic_K_hm, ic_K_hmb, iK_hm_min_coef, inu_hm, &
275 : islope_coef_spread_DG_means_w, ipdf_component_stdev_factor_w, &
276 : icoef_spread_DG_means_rt, icoef_spread_DG_means_thl, &
277 : ibeta, igamma_coef, igamma_coefb, igamma_coefc, ilmin_coef, &
278 : iomicron, izeta_vrnce_rat, iupsilon_precip_frac_rat, &
279 : ilambda0_stability_coef, imult_coef, itaumin, itaumax, imu, &
280 : iLscale_mu_coef, iLscale_pert_coef, ialpha_corr, iSkw_denom_coef, &
281 : ic_K10, ic_K10h, ithlp2_rad_coef, ithlp2_rad_cloud_frac_thresh, &
282 : iup2_sfc_coef, iSkw_max_mag, iC_invrs_tau_bkgnd, &
283 : iC_invrs_tau_sfc, iC_invrs_tau_shear, iC_invrs_tau_N2, &
284 : iC_invrs_tau_N2_wp2, iC_invrs_tau_N2_xp2, iC_invrs_tau_N2_wpxp, &
285 : iC_invrs_tau_N2_clear_wp3, ialtitude_threshold, irtp2_clip_coef, &
286 : iRichardson_num_min, iRichardson_num_max, iwpxp_Ri_exp, &
287 : ia3_coef_min, ia_const, iCx_min, iCx_max, ibv_efold, iz_displace
288 :
289 :
290 :
291 : public &
292 : advance_clubb_core_api, &
293 : advance_clubb_core_api_single_col, &
294 : advance_clubb_core_api_multi_col, &
295 : pdf_parameter, &
296 : implicit_coefs_terms, &
297 : cleanup_clubb_core_api
298 :
299 : public &
300 : ! To Implement SILHS:
301 : setup_corr_varnce_array_api, &
302 : setup_pdf_parameters_api, &
303 : hydromet_pdf_parameter, &
304 : init_pdf_hydromet_arrays_api, &
305 : ! generate_silhs_sample - SILHS API
306 : genrand_init_api, & ! if you are doing restarts)
307 : genrand_state, &
308 : genrand_srepr, &
309 : genrand_intg, &
310 : ! To use the results, you will need these variables:
311 : hmp2_ip_on_hmm2_ip_slope_type, & ! Types
312 : hmp2_ip_on_hmm2_ip_intrcpt_type, &
313 : hm_metadata_type, &
314 : sclr_idx_type, &
315 : grid, &
316 : stats
317 :
318 : public &
319 : ! To Interact With CLUBB's Grid:
320 : ! For Varying Grids
321 : setup_grid_heights_api, & ! if heights vary with time
322 : setup_grid_api
323 :
324 : public &
325 : ! To Obtain More Output from CLUBB for Diagnostics:
326 : stats_begin_timestep_api, &
327 : stats_end_timestep_api, &
328 : stats_finalize_api, &
329 : stats_init_api
330 :
331 : public :: &
332 : calculate_thlp2_rad_api, params_list, &
333 : update_xp2_mc_api, sat_mixrat_liq_api
334 :
335 : public :: &
336 : ! To Convert Between Common CLUBB-related quantities:
337 : lin_interpolate_two_points_api, & ! OR
338 : lin_interpolate_on_grid_api, &
339 : T_in_K2thlm_api, &
340 : thlm2T_in_K_api, &
341 : zm2zt_api, &
342 : zt2zm_api
343 :
344 : public &
345 : ! To Check For and Handle CLUBB's Errors:
346 : calculate_spurious_source_api, &
347 : clubb_at_least_debug_level_api, &
348 : clubb_fatal_error, &
349 : clubb_no_error, &
350 : fill_holes_driver_api, & ! OR
351 : fill_holes_vertical_api, &
352 : fill_holes_hydromet_api, &
353 : set_clubb_debug_level_api, &
354 : vertical_integral_api, &
355 : num_hf_draw_points
356 :
357 : public &
358 : ! Constants That May be Helpful:
359 : cloud_frac_min, &
360 : cm3_per_m3, &
361 : core_rknd, &
362 : Cp, &
363 : dp, &
364 : em_min, &
365 : ep, &
366 : fstderr, &
367 : fstdout, &
368 : grav, &
369 : Lf, &
370 : Ls, &
371 : Lv, &
372 : pi_dp, &
373 : pi, &
374 : radians_per_deg_dp, &
375 : Rd, &
376 : Rv, &
377 : sec_per_day, &
378 : sec_per_hr, &
379 : sec_per_min, &
380 : T_freeze_K, &
381 : time_precision, &
382 : var_length, &
383 : zero_threshold, &
384 : zero, &
385 : ! Tolerances
386 : Nc_tol, &
387 : Ng_tol, &
388 : Ni_tol, &
389 : Nr_tol, &
390 : Ns_tol, &
391 : rg_tol, &
392 : rho_lw, &
393 : ri_tol, &
394 : rr_tol, &
395 : rs_tol, &
396 : rt_tol, &
397 : thl_tol, &
398 : w_tol_sqd
399 :
400 : public &
401 : ! Attempt to Not Use the Following:
402 : ! The CLUBB_CAM preprocessor directives are being commented out because this
403 : ! code is now also used for WRF-CLUBB.
404 : !#ifdef CLUBB_CAM /* Code for storing pdf_parameter structs in pbuf as array */
405 : pack_pdf_params_api, &
406 : unpack_pdf_params_api, &
407 : num_pdf_params, &
408 : !#endif
409 : init_pdf_params_api, &
410 : init_precip_fracs_api, &
411 : precipitation_fractions, &
412 : init_pdf_implicit_coefs_terms_api, &
413 : adj_low_res_nu_api, &
414 : assignment( = ), &
415 : clubb_i, &
416 : clubb_j, &
417 : compute_current_date_api, &
418 : gregorian2julian_day_api, &
419 : leap_year_api, &
420 : nvarmax_rad_zm, &
421 : nvarmax_rad_zt, &
422 : nvarmax_sfc, &
423 : nvarmax_zm, &
424 : nvarmax_zt
425 :
426 : public &
427 : nparams, &
428 : nu_vertical_res_dep, &
429 : setup_parameters_api, &
430 : stat_nknd, &
431 : stat_rknd, &
432 : stats_accumulate_hydromet_api, &
433 : stats_init_rad_zm_api, &
434 : stats_init_rad_zt_api, &
435 : stats_init_sfc_api, &
436 : stats_init_zm_api, &
437 : stats_init_zt_api, &
438 : stats_metadata_type
439 :
440 : public &
441 : ! Needed to use the configurable CLUBB flags
442 : clubb_config_flags_type, &
443 : set_default_clubb_config_flags_api, &
444 : initialize_clubb_config_flags_type_api, &
445 : print_clubb_config_flags_api
446 :
447 : public &
448 : thlm_sponge_damp_settings, & ! Variable(s)
449 : rtm_sponge_damp_settings, &
450 : uv_sponge_damp_settings, &
451 : wp2_sponge_damp_settings, &
452 : wp3_sponge_damp_settings, &
453 : up2_vp2_sponge_damp_settings, &
454 : thlm_sponge_damp_profile, &
455 : rtm_sponge_damp_profile, &
456 : uv_sponge_damp_profile, &
457 : wp2_sponge_damp_profile, &
458 : wp3_sponge_damp_profile, &
459 : up2_vp2_sponge_damp_profile, &
460 : initialize_tau_sponge_damp_api, & ! Procedure(s)
461 : finalize_tau_sponge_damp_api
462 :
463 : public &
464 : copy_single_pdf_params_to_multi, &
465 : copy_multi_pdf_params_to_single
466 :
467 : interface setup_pdf_parameters_api
468 : module procedure setup_pdf_parameters_api_single_col
469 : module procedure setup_pdf_parameters_api_multi_col
470 : end interface
471 :
472 : interface advance_clubb_core_api
473 : module procedure advance_clubb_core_api_single_col
474 : module procedure advance_clubb_core_api_multi_col
475 : end interface
476 :
477 : interface setup_grid_api
478 : module procedure setup_grid_api_single_col
479 : module procedure setup_grid_api_multi_col
480 : end interface
481 :
482 : interface setup_parameters_api
483 : module procedure setup_parameters_api_single_col
484 : module procedure setup_parameters_api_multi_col
485 : end interface
486 :
487 : interface adj_low_res_nu_api
488 : module procedure adj_low_res_nu_api_single_col
489 : module procedure adj_low_res_nu_api_multi_col
490 : end interface
491 :
492 : interface setup_grid_heights_api
493 : module procedure setup_grid_heights_api_single_col
494 : module procedure setup_grid_heights_api_multi_col
495 : end interface
496 :
497 : interface update_xp2_mc_api
498 : module procedure update_xp2_mc_api_single_col
499 : module procedure update_xp2_mc_api_multi_col
500 : end interface
501 :
502 : contains
503 :
504 : !================================================================================================
505 : ! advance_clubb_core - Advances the model one timestep.
506 : !================================================================================================
507 :
508 0 : subroutine advance_clubb_core_api_single_col( gr, & ! intent(in)
509 : l_implemented, dt, fcor, sfc_elevation, & ! intent(in)
510 : hydromet_dim, & ! intent(in)
511 0 : sclr_dim, sclr_tol, edsclr_dim, sclr_idx, & ! intent(in)
512 0 : thlm_forcing, rtm_forcing, um_forcing, vm_forcing, & ! intent(in)
513 0 : sclrm_forcing, edsclrm_forcing, wprtp_forcing, & ! intent(in)
514 0 : wpthlp_forcing, rtp2_forcing, thlp2_forcing, & ! intent(in)
515 0 : rtpthlp_forcing, wm_zm, wm_zt, & ! intent(in)
516 : wpthlp_sfc, wprtp_sfc, upwp_sfc, vpwp_sfc, & ! intent(in)
517 0 : wpsclrp_sfc, wpedsclrp_sfc, & ! intent(in)
518 : upwp_sfc_pert, vpwp_sfc_pert, & ! intent(in)
519 0 : rtm_ref, thlm_ref, um_ref, vm_ref, ug, vg, & ! Intent(in)
520 0 : p_in_Pa, rho_zm, rho, exner, & ! intent(in)
521 0 : rho_ds_zm, rho_ds_zt, invrs_rho_ds_zm, & ! intent(in)
522 0 : invrs_rho_ds_zt, thv_ds_zm, thv_ds_zt, & ! intent(in)
523 0 : hydromet, l_mix_rat_hm, & ! intent(in)
524 0 : rfrzm, radf, & ! intent(in)
525 : #ifdef CLUBBND_CAM
526 : varmu, & ! intent(in)
527 : #endif
528 0 : wphydrometp, wp2hmp, rtphmp_zt, thlphmp_zt, & ! intent(in)
529 : host_dx, host_dy, & ! intent(in)
530 : clubb_params, nu_vert_res_dep, lmin, & ! intent(in)
531 : clubb_config_flags, & ! intent(in)
532 : stats_metadata, & ! intent(in)
533 : stats_zt, stats_zm, stats_sfc, & ! intent(inout)
534 0 : um, vm, upwp, vpwp, up2, vp2, up3, vp3, & ! intent(inout)
535 0 : thlm, rtm, wprtp, wpthlp, & ! intent(inout)
536 0 : wp2, wp3, rtp2, rtp3, thlp2, thlp3, rtpthlp, & ! intent(inout)
537 0 : sclrm, &
538 : #ifdef GFDL
539 : sclrm_trsport_only, & ! h1g, 2010-06-16 ! intent(inout)
540 : #endif
541 0 : sclrp2, sclrp3, sclrprtp, sclrpthlp, & ! intent(inout)
542 0 : wpsclrp, edsclrm, err_code_api, & ! intent(inout)
543 0 : rcm, cloud_frac, & ! intent(inout)
544 0 : wpthvp, wp2thvp, rtpthvp, thlpthvp, & ! intent(inout)
545 0 : sclrpthvp, & ! intent(inout)
546 0 : wp2rtp, wp2thlp, uprcp, vprcp, rc_coef_zm, wp4, & ! intent(inout)
547 0 : wpup2, wpvp2, wp2up2, wp2vp2, ice_supersat_frac, & ! intent(inout)
548 0 : um_pert, vm_pert, upwp_pert, vpwp_pert, & ! intent(inout)
549 : pdf_params, pdf_params_zm, & ! intent(inout)
550 : pdf_implicit_coefs_terms, & ! intent(inout)
551 : #ifdef GFDL
552 : RH_crit, & !h1g, 2010-06-16 ! intent(inout)
553 : do_liquid_only_in_clubb, & ! intent(in)
554 : #endif
555 0 : Kh_zm, Kh_zt, & ! intent(out)
556 : #ifdef CLUBB_CAM
557 0 : qclvar, & ! intent(out)
558 : #endif
559 0 : thlprcp, wprcp, w_up_in_cloud, w_down_in_cloud, & ! intent(out)
560 0 : cloudy_updraft_frac, cloudy_downdraft_frac, & ! intent(out)
561 0 : rcm_in_layer, cloud_cover, invrs_tau_zm ) ! intent(out)
562 :
563 : use advance_clubb_core_module, only : advance_clubb_core
564 :
565 : use pdf_parameter_module, only: &
566 : implicit_coefs_terms ! Variable Type(s)
567 :
568 : use model_flags, only: &
569 : clubb_config_flags_type
570 :
571 : use stats_zm_module, only: &
572 : stats_init_zm ! Procedure(s)
573 :
574 : use stats_zt_module, only: &
575 : stats_init_zt
576 :
577 : use stats_sfc_module, only: &
578 : stats_init_sfc ! Procedure(s)
579 :
580 : use array_index, only: &
581 : sclr_idx_type
582 :
583 : implicit none
584 :
585 : !------------------------- Input Variables -------------------------
586 : type(grid), target, intent(in) :: gr
587 :
588 : logical, intent(in) :: &
589 : l_implemented ! Is this part of a larger host model (T/F) ?
590 :
591 : real( kind = core_rknd ), intent(in) :: &
592 : dt ! Current timestep duration [s]
593 :
594 : real( kind = core_rknd ), intent(in) :: &
595 : fcor, & ! Coriolis forcing [s^-1]
596 : sfc_elevation ! Elevation of ground level [m AMSL]
597 :
598 : integer, intent(in) :: &
599 : hydromet_dim, & ! Total number of hydrometeor species [#]
600 : sclr_dim, & ! Number of passive scalars [#]
601 : edsclr_dim ! Number of eddy-diff. passive scalars [#]
602 :
603 : real( kind = core_rknd ), intent(in), dimension(sclr_dim) :: &
604 : sclr_tol ! Threshold(s) on the passive scalars [units vary]
605 :
606 : type (sclr_idx_type), intent(in) :: &
607 : sclr_idx
608 :
609 : ! Input Variables
610 : real( kind = core_rknd ), intent(in), dimension(gr%nz) :: &
611 : thlm_forcing, & ! theta_l forcing (thermodynamic levels) [K/s]
612 : rtm_forcing, & ! r_t forcing (thermodynamic levels) [(kg/kg)/s]
613 : um_forcing, & ! u wind forcing (thermodynamic levels) [m/s/s]
614 : vm_forcing, & ! v wind forcing (thermodynamic levels) [m/s/s]
615 : wprtp_forcing, & ! <w'r_t'> forcing (momentum levels) [m*K/s^2]
616 : wpthlp_forcing, & ! <w'th_l'> forcing (momentum levels) [m*(kg/kg)/s^2]
617 : rtp2_forcing, & ! <r_t'^2> forcing (momentum levels) [(kg/kg)^2/s]
618 : thlp2_forcing, & ! <th_l'^2> forcing (momentum levels) [K^2/s]
619 : rtpthlp_forcing, & ! <r_t'th_l'> forcing (momentum levels) [K*(kg/kg)/s]
620 : wm_zm, & ! w mean wind component on momentum levels [m/s]
621 : wm_zt, & ! w mean wind component on thermo. levels [m/s]
622 : rho_zm, & ! Air density on momentum levels [kg/m^3]
623 : rho, & ! Air density on thermodynamic levels [kg/m^3]
624 : rho_ds_zm, & ! Dry, static density on momentum levels [kg/m^3]
625 : rho_ds_zt, & ! Dry, static density on thermo. levels [kg/m^3]
626 : invrs_rho_ds_zm, & ! Inv. dry, static density @ momentum levs. [m^3/kg]
627 : invrs_rho_ds_zt, & ! Inv. dry, static density @ thermo. levs. [m^3/kg]
628 : thv_ds_zm, & ! Dry, base-state theta_v on momentum levs. [K]
629 : thv_ds_zt, & ! Dry, base-state theta_v on thermo. levs. [K]
630 : rfrzm ! Total ice-phase water mixing ratio [kg/kg]
631 :
632 : real( kind = core_rknd ), dimension(gr%nz,hydromet_dim), intent(in) :: &
633 : hydromet ! Collection of hydrometeors [units vary]
634 :
635 : logical, dimension(hydromet_dim), intent(in) :: &
636 : l_mix_rat_hm ! if true, then the quantity is a hydrometeor mixing ratio
637 :
638 : real( kind = core_rknd ), dimension(gr%nz), intent(in) :: &
639 : radf ! Buoyancy production at the CL top due to LW radiative cooling [m^2/s^3]
640 :
641 : #ifdef CLUBBND_CAM
642 : real( kind = core_rknd ), intent(in) :: &
643 : varmu
644 : #endif
645 :
646 : real( kind = core_rknd ), dimension(gr%nz, hydromet_dim), intent(in) :: &
647 : wphydrometp, & ! Covariance of w and a hydrometeor [(m/s) <hm units>]
648 : wp2hmp, & ! Third moment: <w'^2> * <hydro.'> [(m/s)^2 <hm units>]
649 : rtphmp_zt, & ! Covariance of rt and a hydrometeor [(kg/kg) <hm units>]
650 : thlphmp_zt ! Covariance of thl and a hydrometeor [K <hm units>]
651 :
652 : real( kind = core_rknd ), intent(in) :: &
653 : wpthlp_sfc, & ! w' theta_l' at surface [(m K)/s]
654 : wprtp_sfc, & ! w' r_t' at surface [(kg m)/( kg s)]
655 : upwp_sfc, & ! u'w' at surface [m^2/s^2]
656 : vpwp_sfc ! v'w' at surface [m^2/s^2]
657 :
658 : ! Passive scalar variables
659 : real( kind = core_rknd ), intent(in), dimension(gr%nz,sclr_dim) :: &
660 : sclrm_forcing ! Passive scalar forcing [{units vary}/s]
661 :
662 : real( kind = core_rknd ), intent(in), dimension(sclr_dim) :: &
663 : wpsclrp_sfc ! Scalar flux at surface [{units vary} m/s]
664 :
665 : real( kind = core_rknd ), intent(in) :: &
666 : upwp_sfc_pert, & ! pertubed u'w' at surface [m^2/s^2]
667 : vpwp_sfc_pert ! pertubed v'w' at surface [m^2/s^2]
668 :
669 : ! Eddy passive scalar variables
670 : real( kind = core_rknd ), intent(in), dimension(gr%nz,edsclr_dim) :: &
671 : edsclrm_forcing ! Eddy passive scalar forcing [{units vary}/s]
672 :
673 : real( kind = core_rknd ), intent(in), dimension(edsclr_dim) :: &
674 : wpedsclrp_sfc ! Eddy-Scalar flux at surface [{units vary} m/s]
675 :
676 : ! Reference profiles (used for nudging, sponge damping, and Coriolis effect)
677 : real( kind = core_rknd ), dimension(gr%nz), intent(in) :: &
678 : rtm_ref, & ! Initial total water mixing ratio [kg/kg]
679 : thlm_ref, & ! Initial liquid water potential temperature [K]
680 : um_ref, & ! Initial u wind; Michael Falk [m/s]
681 : vm_ref, & ! Initial v wind; Michael Falk [m/s]
682 : ug, & ! u geostrophic wind [m/s]
683 : vg ! v geostrophic wind [m/s]
684 :
685 : ! Host model horizontal grid spacing, if part of host model.
686 : real( kind = core_rknd ), intent(in) :: &
687 : host_dx, & ! East-West horizontal grid spacing [m]
688 : host_dy ! North-South horizontal grid spacing [m]
689 :
690 : real( kind = core_rknd ), dimension(nparams), intent(in) :: &
691 : clubb_params ! Array of CLUBB's tunable parameters [units vary]
692 :
693 : type(nu_vertical_res_dep), intent(in) :: &
694 : nu_vert_res_dep ! Vertical resolution dependent nu values
695 :
696 : real( kind = core_rknd ), intent(in) :: &
697 : lmin ! Min. value for the length scale [m]
698 :
699 : type( clubb_config_flags_type ), intent(in) :: &
700 : clubb_config_flags ! Derived type holding all configurable CLUBB flags
701 :
702 : type (stats_metadata_type), intent(in) :: &
703 : stats_metadata
704 :
705 : !------------------------- Input/Output Variables -------------------------
706 : type(stats), target, intent(inout) :: &
707 : stats_zt, &
708 : stats_zm, &
709 : stats_sfc
710 :
711 : ! These are prognostic or are planned to be in the future
712 : real( kind = core_rknd ), intent(inout), dimension(gr%nz) :: &
713 : um, & ! u mean wind component (thermodynamic levels) [m/s]
714 : upwp, & ! u'w' (momentum levels) [m^2/s^2]
715 : vm, & ! v mean wind component (thermodynamic levels) [m/s]
716 : vpwp, & ! v'w' (momentum levels) [m^2/s^2]
717 : up2, & ! u'^2 (momentum levels) [m^2/s^2]
718 : vp2, & ! v'^2 (momentum levels) [m^2/s^2]
719 : up3, & ! u'^3 (thermodynamic levels) [m^3/s^3]
720 : vp3, & ! v'^3 (thermodynamic levels) [m^3/s^3]
721 : rtm, & ! total water mixing ratio, r_t (thermo. levels) [kg/kg]
722 : wprtp, & ! w' r_t' (momentum levels) [(kg/kg) m/s]
723 : thlm, & ! liq. water pot. temp., th_l (thermo. levels) [K]
724 : wpthlp, & ! w' th_l' (momentum levels) [(m/s) K]
725 : rtp2, & ! r_t'^2 (momentum levels) [(kg/kg)^2]
726 : rtp3, & ! r_t'^3 (thermodynamic levels) [(kg/kg)^3]
727 : thlp2, & ! th_l'^2 (momentum levels) [K^2]
728 : thlp3, & ! th_l'^3 (thermodynamic levels) [K^3]
729 : rtpthlp, & ! r_t' th_l' (momentum levels) [(kg/kg) K]
730 : wp2, & ! w'^2 (momentum levels) [m^2/s^2]
731 : wp3 ! w'^3 (thermodynamic levels) [m^3/s^3]
732 :
733 : ! Passive scalar variables
734 : real( kind = core_rknd ), intent(inout), dimension(gr%nz,sclr_dim) :: &
735 : sclrm, & ! Passive scalar mean (thermo. levels) [units vary]
736 : wpsclrp, & ! w'sclr' (momentum levels) [{units vary} m/s]
737 : sclrp2, & ! sclr'^2 (momentum levels) [{units vary}^2]
738 : sclrp3, & ! sclr'^3 (thermodynamic levels) [{units vary}^3]
739 : sclrprtp, & ! sclr'rt' (momentum levels) [{units vary} (kg/kg)]
740 : sclrpthlp ! sclr'thl' (momentum levels) [{units vary} K]
741 :
742 : real( kind = core_rknd ), intent(inout), dimension(gr%nz) :: &
743 : p_in_Pa, & ! Air pressure (thermodynamic levels) [Pa]
744 : exner ! Exner function (thermodynamic levels) [-]
745 :
746 : real( kind = core_rknd ), intent(inout), dimension(gr%nz) :: &
747 : rcm, & ! cloud water mixing ratio, r_c (thermo. levels) [kg/kg]
748 : cloud_frac, & ! cloud fraction (thermodynamic levels) [-]
749 : wpthvp, & ! < w' th_v' > (momentum levels) [kg/kg K]
750 : wp2thvp, & ! < w'^2 th_v' > (thermodynamic levels) [m^2/s^2 K]
751 : rtpthvp, & ! < r_t' th_v' > (momentum levels) [kg/kg K]
752 : thlpthvp ! < th_l' th_v' > (momentum levels) [K^2]
753 :
754 : real( kind = core_rknd ), intent(inout), dimension(gr%nz,sclr_dim) :: &
755 : sclrpthvp ! < sclr' th_v' > (momentum levels) [units vary]
756 :
757 : real( kind = core_rknd ), intent(inout), dimension(gr%nz) :: &
758 : wp2rtp, & ! w'^2 rt' (thermodynamic levels) [m^2/s^2 kg/kg]
759 : wp2thlp, & ! w'^2 thl' (thermodynamic levels) [m^2/s^2 K]
760 : uprcp, & ! < u' r_c' > (momentum levels) [(m/s)(kg/kg)]
761 : vprcp, & ! < v' r_c' > (momentum levels) [(m/s)(kg/kg)]
762 : rc_coef_zm, & ! Coef of X'r_c' in Eq. (34) (m-levs.) [K/(kg/kg)]
763 : wp4, & ! w'^4 (momentum levels) [m^4/s^4]
764 : wpup2, & ! w'u'^2 (thermodynamic levels) [m^3/s^3]
765 : wpvp2, & ! w'v'^2 (thermodynamic levels) [m^3/s^3]
766 : wp2up2, & ! w'^2 u'^2 (momentum levels) [m^4/s^4]
767 : wp2vp2, & ! w'^2 v'^2 (momentum levels) [m^4/s^4]
768 : ice_supersat_frac ! ice cloud fraction (thermo. levels) [-]
769 :
770 : ! Variables used to track perturbed version of winds.
771 : real( kind = core_rknd ), intent(inout), dimension(gr%nz) :: &
772 : um_pert, & ! perturbed <u> [m/s]
773 : vm_pert, & ! perturbed <v> [m/s]
774 : upwp_pert, & ! perturbed <u'w'> [m^2/s^2]
775 : vpwp_pert ! perturbed <v'w'> [m^2/s^2]
776 :
777 : type(pdf_parameter), intent(inout) :: &
778 : pdf_params, & ! PDF parameters (thermodynamic levels) [units vary]
779 : pdf_params_zm ! PDF parameters on momentum levels [units vary]
780 :
781 : type(implicit_coefs_terms), intent(inout) :: &
782 : pdf_implicit_coefs_terms ! Implicit coefs / explicit terms [units vary]
783 :
784 : #ifdef GFDL
785 : real( kind = core_rknd ), intent(inout), dimension(gr%nz,sclr_dim) :: & ! h1g, 2010-06-16
786 : sclrm_trsport_only ! Passive scalar concentration due to pure transport [{units vary}/s]
787 : #endif
788 :
789 : real( kind = core_rknd ), intent(inout), dimension(gr%nz,edsclr_dim) :: &
790 : edsclrm ! Eddy passive scalar mean (thermo. levels) [units vary]
791 :
792 : !------------------------- Output Variables -------------------------
793 : real( kind = core_rknd ), intent(out), dimension(gr%nz) :: &
794 : rcm_in_layer, & ! rcm in cloud layer [kg/kg]
795 : cloud_cover ! cloud cover [-]
796 :
797 : ! Variables that need to be output for use in host models
798 : real( kind = core_rknd ), intent(out), dimension(gr%nz) :: &
799 : wprcp, & ! w'r_c' (momentum levels) [(kg/kg) m/s]
800 : w_up_in_cloud, & ! Average cloudy updraft velocity [m/s]
801 : w_down_in_cloud, & ! Average cloudy downdraft velocity [m/s]
802 : cloudy_updraft_frac, & ! cloudy updraft fraction [-]
803 : cloudy_downdraft_frac, & ! cloudy downdraft fraction [-]
804 : invrs_tau_zm ! One divided by tau on zm levels [1/s]
805 :
806 : real( kind = core_rknd ), dimension(gr%nz), intent(out) :: &
807 : Kh_zt, & ! Eddy diffusivity coefficient on thermodynamic levels [m^2/s]
808 : Kh_zm ! Eddy diffusivity coefficient on momentum levels [m^2/s]
809 :
810 : #ifdef CLUBB_CAM
811 : real( kind = core_rknd), intent(out), dimension(gr%nz) :: &
812 : qclvar ! cloud water variance
813 : #endif
814 :
815 : real( kind = core_rknd ), dimension(gr%nz), intent(out) :: &
816 : thlprcp ! thl'rc' [K kg/kg]
817 :
818 : !!! Output Variable
819 : integer, intent(inout) :: err_code_api ! Diagnostic, for if some calculation goes amiss.
820 :
821 : #ifdef GFDL
822 : ! hlg, 2010-06-16
823 : real( kind = core_rknd ), intent(inOUT), dimension(gr%nz, min(1,sclr_dim) , 2) :: &
824 : RH_crit ! critical relative humidity for droplet and ice nucleation
825 : logical, intent(in) :: do_liquid_only_in_clubb
826 : #endif
827 :
828 :
829 : !------------------------- Local Variables -------------------------
830 : type(stats), dimension(1) :: &
831 0 : stats_zt_col, &
832 0 : stats_zm_col, &
833 0 : stats_sfc_col
834 :
835 : real( kind = core_rknd ), dimension(1) :: &
836 : fcor_col, & ! Coriolis forcing [s^-1]
837 : sfc_elevation_col ! Elevation of ground level [m AMSL]
838 :
839 : ! Input Variables
840 : real( kind = core_rknd ), dimension(1,gr%nz) :: &
841 0 : thlm_forcing_col, & ! theta_l forcing (thermodynamic levels) [K/s]
842 0 : rtm_forcing_col, & ! r_t forcing (thermodynamic levels) [(kg/kg)/s]
843 0 : um_forcing_col, & ! u wind forcing (thermodynamic levels) [m/s/s]
844 0 : vm_forcing_col, & ! v wind forcing (thermodynamic levels) [m/s/s]
845 0 : wprtp_forcing_col, & ! <w'r_t'> forcing (momentum levels) [m*K/s^2]
846 0 : wpthlp_forcing_col, & ! <w'th_l'> forcing (momentum levels) [m*(kg/kg)/s^2]
847 0 : rtp2_forcing_col, & ! <r_t'^2> forcing (momentum levels) [(kg/kg)^2/s]
848 0 : thlp2_forcing_col, & ! <th_l'^2> forcing (momentum levels) [K^2/s]
849 0 : rtpthlp_forcing_col, & ! <r_t'th_l'> forcing (momentum levels) [K*(kg/kg)/s]
850 0 : wm_zm_col, & ! w mean wind component on momentum levels [m/s]
851 0 : wm_zt_col, & ! w mean wind component on thermo. levels [m/s]
852 0 : rho_zm_col, & ! Air density on momentum levels [kg/m^3]
853 0 : rho_col, & ! Air density on thermodynamic levels [kg/m^3]
854 0 : rho_ds_zm_col, & ! Dry, static density on momentum levels [kg/m^3]
855 0 : rho_ds_zt_col, & ! Dry, static density on thermo. levels [kg/m^3]
856 0 : invrs_rho_ds_zm_col, & ! Inv. dry, static density @ momentum levs. [m^3/kg]
857 0 : invrs_rho_ds_zt_col, & ! Inv. dry, static density @ thermo. levs. [m^3/kg]
858 0 : thv_ds_zm_col, & ! Dry, base-state theta_v on momentum levs. [K]
859 0 : thv_ds_zt_col, & ! Dry, base-state theta_v on thermo. levs. [K]
860 0 : rfrzm_col ! Total ice-phase water mixing ratio [kg/kg]
861 :
862 : real( kind = core_rknd ), dimension(1,gr%nz,hydromet_dim) :: &
863 0 : hydromet_col ! Collection of hydrometeors [units vary]
864 :
865 : real( kind = core_rknd ), dimension(1,gr%nz) :: &
866 0 : radf_col ! Buoyancy production at the CL top due to LW radiative cooling [m^2/s^3]
867 :
868 : #ifdef CLUBBND_CAM
869 : real( kind = core_rknd ), dimension(1) :: &
870 : varmu_col
871 : #endif
872 :
873 : real( kind = core_rknd ), dimension(1,gr%nz, hydromet_dim) :: &
874 0 : wphydrometp_col, & ! Covariance of w and a hydrometeor [(m/s) <hm units>]
875 0 : wp2hmp_col, & ! Third moment: <w'^2> * <hydro.'> [(m/s)^2 <hm units>]
876 0 : rtphmp_zt_col, & ! Covariance of rt and a hydrometeor [(kg/kg) <hm units>]
877 0 : thlphmp_zt_col ! Covariance of thl and a hydrometeor [K <hm units>]
878 :
879 : real( kind = core_rknd ), dimension(1) :: &
880 : wpthlp_sfc_col, & ! w' theta_l' at surface [(m K)/s]
881 : wprtp_sfc_col, & ! w' r_t' at surface [(kg m)/( kg s)]
882 : upwp_sfc_col, & ! u'w' at surface [m^2/s^2]
883 : vpwp_sfc_col ! v'w' at surface [m^2/s^2]
884 :
885 : ! Passive scalar variables
886 : real( kind = core_rknd ), dimension(1,gr%nz,sclr_dim) :: &
887 0 : sclrm_forcing_col ! Passive scalar forcing [{units vary}/s]
888 :
889 : real( kind = core_rknd ), dimension(1,sclr_dim) :: &
890 0 : wpsclrp_sfc_col ! Scalar flux at surface [{units vary} m/s]
891 :
892 : ! Eddy passive scalar variables
893 : real( kind = core_rknd ), dimension(1,gr%nz,edsclr_dim) :: &
894 0 : edsclrm_forcing_col ! Eddy passive scalar forcing [{units vary}/s]
895 :
896 : real( kind = core_rknd ), dimension(1) :: &
897 : upwp_sfc_pert_col, & ! pertubed u'w' at surface [m^2/s^2]
898 : vpwp_sfc_pert_col ! pertubed v'w' at surface [m^2/s^2]
899 :
900 : real( kind = core_rknd ), dimension(1,edsclr_dim) :: &
901 0 : wpedsclrp_sfc_col ! Eddy-Scalar flux at surface [{units vary} m/s]
902 :
903 : ! Reference profiles (used for nudging, sponge damping, and Coriolis effect)
904 : real( kind = core_rknd ), dimension(1,gr%nz) :: &
905 0 : rtm_ref_col, & ! Initial total water mixing ratio [kg/kg]
906 0 : thlm_ref_col, & ! Initial liquid water potential temperature [K]
907 0 : um_ref_col, & ! Initial u wind; Michael Falk [m/s]
908 0 : vm_ref_col, & ! Initial v wind; Michael Falk [m/s]
909 0 : ug_col, & ! u geostrophic wind [m/s]
910 0 : vg_col ! v geostrophic wind [m/s]
911 :
912 : ! Host model horizontal grid spacing, if part of host model.
913 : real( kind = core_rknd ), dimension(1) :: &
914 : host_dx_col, & ! East-West horizontal grid spacing [m]
915 : host_dy_col ! North-South horizontal grid spacing [m]
916 :
917 : real( kind = core_rknd ), dimension(1,nparams) :: &
918 : clubb_params_col ! Array of CLUBB's tunable parameters [units vary]
919 :
920 : ! These are prognostic or are planned to be in the future
921 : real( kind = core_rknd ), dimension(1,gr%nz) :: &
922 0 : um_col, & ! u mean wind component (thermodynamic levels) [m/s]
923 0 : upwp_col, & ! u'w' (momentum levels) [m^2/s^2]
924 0 : vm_col, & ! v mean wind component (thermodynamic levels) [m/s]
925 0 : vpwp_col, & ! v'w' (momentum levels) [m^2/s^2]
926 0 : up2_col, & ! u'^2 (momentum levels) [m^2/s^2]
927 0 : vp2_col, & ! v'^2 (momentum levels) [m^2/s^2]
928 0 : up3_col, & ! u'^3 (thermodynamic levels) [m^3/s^3]
929 0 : vp3_col, & ! v'^3 (thermodynamic levels) [m^3/s^3]
930 0 : rtm_col, & ! total water mixing ratio, r_t (thermo. levels) [kg/kg]
931 0 : wprtp_col, & ! w' r_t' (momentum levels) [(kg/kg) m/s]
932 0 : thlm_col, & ! liq. water pot. temp., th_l (thermo. levels) [K]
933 0 : wpthlp_col, & ! w' th_l' (momentum levels) [(m/s) K]
934 0 : rtp2_col, & ! r_t'^2 (momentum levels) [(kg/kg)^2]
935 0 : rtp3_col, & ! r_t'^3 (thermodynamic levels) [(kg/kg)^3]
936 0 : thlp2_col, & ! th_l'^2 (momentum levels) [K^2]
937 0 : thlp3_col, & ! th_l'^3 (thermodynamic levels) [K^3]
938 0 : rtpthlp_col, & ! r_t' th_l' (momentum levels) [(kg/kg) K]
939 0 : wp2_col, & ! w'^2 (momentum levels) [m^2/s^2]
940 0 : wp3_col ! w'^3 (thermodynamic levels) [m^3/s^3]
941 :
942 : ! Passive scalar variables
943 : real( kind = core_rknd ), dimension(1,gr%nz,sclr_dim) :: &
944 0 : sclrm_col, & ! Passive scalar mean (thermo. levels) [units vary]
945 0 : wpsclrp_col, & ! w'sclr' (momentum levels) [{units vary} m/s]
946 0 : sclrp2_col, & ! sclr'^2 (momentum levels) [{units vary}^2]
947 0 : sclrp3_col, & ! sclr'^3 (thermodynamic levels) [{units vary}^3]
948 0 : sclrprtp_col, & ! sclr'rt' (momentum levels) [{units vary} (kg/kg)]
949 0 : sclrpthlp_col ! sclr'thl' (momentum levels) [{units vary} K]
950 :
951 : real( kind = core_rknd ), dimension(1,gr%nz) :: &
952 0 : p_in_Pa_col, & ! Air pressure (thermodynamic levels) [Pa]
953 0 : exner_col ! Exner function (thermodynamic levels) [-]
954 :
955 : real( kind = core_rknd ), dimension(1,gr%nz) :: &
956 0 : rcm_col, & ! cloud water mixing ratio, r_c (thermo. levels) [kg/kg]
957 0 : cloud_frac_col, & ! cloud fraction (thermodynamic levels) [-]
958 0 : wpthvp_col, & ! < w' th_v' > (momentum levels) [kg/kg K]
959 0 : wp2thvp_col, & ! < w'^2 th_v' > (thermodynamic levels) [m^2/s^2 K]
960 0 : rtpthvp_col, & ! < r_t' th_v' > (momentum levels) [kg/kg K]
961 0 : thlpthvp_col ! < th_l' th_v' > (momentum levels) [K^2]
962 :
963 : real( kind = core_rknd ), dimension(1,gr%nz,sclr_dim) :: &
964 0 : sclrpthvp_col ! < sclr' th_v' > (momentum levels) [units vary]
965 :
966 : real( kind = core_rknd ), dimension(1,gr%nz) :: &
967 0 : wp2rtp_col, & ! w'^2 rt' (thermodynamic levels) [m^2/s^2 kg/kg]
968 0 : wp2thlp_col, & ! w'^2 thl' (thermodynamic levels) [m^2/s^2 K]
969 0 : uprcp_col, & ! < u' r_c' > (momentum levels) [(m/s)(kg/kg)]
970 0 : vprcp_col, & ! < v' r_c' > (momentum levels) [(m/s)(kg/kg)]
971 0 : rc_coef_zm_col, & ! Coef of X'r_c' in Eq. (34) (m-levs.) [K/(kg/kg)]
972 0 : wp4_col, & ! w'^4 (momentum levels) [m^4/s^4]
973 0 : wpup2_col, & ! w'u'^2 (thermodynamic levels) [m^3/s^3]
974 0 : wpvp2_col, & ! w'v'^2 (thermodynamic levels) [m^3/s^3]
975 0 : wp2up2_col, & ! w'^2 u'^2 (momentum levels) [m^4/s^4]
976 0 : wp2vp2_col, & ! w'^2 v'^2 (momentum levels) [m^4/s^4]
977 0 : ice_supersat_frac_col ! ice cloud fraction (thermo. levels) [-]
978 :
979 : ! Variables used to track perturbed version of winds.
980 : real( kind = core_rknd ), dimension(1,gr%nz) :: &
981 0 : um_pert_col, & ! perturbed <u> [m/s]
982 0 : vm_pert_col, & ! perturbed <v> [m/s]
983 0 : upwp_pert_col, & ! perturbed <u'w'> [m^2/s^2]
984 0 : vpwp_pert_col ! perturbed <v'w'> [m^2/s^2]
985 :
986 : #ifdef GFDL
987 : real( kind = core_rknd ), dimension(1,gr%nz,sclr_dim) :: & ! h1g, 2010-06-16
988 : sclrm_trsport_only_col ! Passive scalar concentration due to pure transport [{units vary}/s]
989 : #endif
990 :
991 : real( kind = core_rknd ), dimension(1,gr%nz,edsclr_dim) :: &
992 0 : edsclrm_col ! Eddy passive scalar mean (thermo. levels) [units vary]
993 :
994 : real( kind = core_rknd ), dimension(1,gr%nz) :: &
995 0 : rcm_in_layer_col, & ! rcm in cloud layer [kg/kg]
996 0 : cloud_cover_col ! cloud cover [-]
997 :
998 : ! Variables that need to be output for use in host models
999 : real( kind = core_rknd ), dimension(1,gr%nz) :: &
1000 0 : wprcp_col, & ! w'r_c' (momentum levels) [(kg/kg) m/s]
1001 0 : w_up_in_cloud_col, & ! Average cloudy updraft velocity [m/s]
1002 0 : w_down_in_cloud_col, & ! Average cloudy downdraft velocity [m/s]
1003 0 : cloudy_updraft_frac_col, & ! cloudy updraft fraction [-]
1004 0 : cloudy_downdraft_frac_col, & ! cloudy downdraft fraction [-]
1005 0 : invrs_tau_zm_col ! One divided by tau on zm levels [1/s]
1006 :
1007 : real( kind = core_rknd ), dimension(1,gr%nz) :: &
1008 0 : Kh_zt_col, & ! Eddy diffusivity coefficient on thermodynamic levels [m^2/s]
1009 0 : Kh_zm_col ! Eddy diffusivity coefficient on momentum levels [m^2/s]
1010 :
1011 : #ifdef CLUBB_CAM
1012 : real( kind = core_rknd), dimension(1,gr%nz) :: &
1013 0 : qclvar_col ! cloud water variance
1014 : #endif
1015 :
1016 : real( kind = core_rknd ), dimension(1,gr%nz) :: &
1017 0 : thlprcp_col ! thl'rc' [K kg/kg]
1018 :
1019 : #ifdef GFDL
1020 : ! hlg, 2010-06-16
1021 : real( kind = core_rknd ), dimension(1,gr%nz, min(1,sclr_dim) , 2) :: &
1022 : RH_crit_col ! critical relative humidity for droplet and ice nucleation
1023 : logical, intent(in) :: do_liquid_only_in_clubb
1024 : #endif
1025 :
1026 : integer :: i
1027 :
1028 : !------------------------- Begin Code -------------------------
1029 :
1030 0 : fcor_col(1) = fcor
1031 0 : sfc_elevation_col(1) = sfc_elevation
1032 :
1033 0 : thlm_forcing_col(1,:) = thlm_forcing
1034 0 : rtm_forcing_col(1,:) = rtm_forcing
1035 0 : um_forcing_col(1,:) = um_forcing
1036 0 : vm_forcing_col(1,:) = vm_forcing
1037 0 : sclrm_forcing_col(1,:,:) = sclrm_forcing
1038 0 : edsclrm_forcing_col(1,:,:) = edsclrm_forcing
1039 0 : wprtp_forcing_col(1,:) = wprtp_forcing
1040 0 : wpthlp_forcing_col(1,:) = wpthlp_forcing
1041 0 : rtp2_forcing_col(1,:) = rtp2_forcing
1042 0 : thlp2_forcing_col(1,:) = thlp2_forcing
1043 0 : rtpthlp_forcing_col(1,:) = rtpthlp_forcing
1044 0 : wm_zm_col(1,:) = wm_zm
1045 0 : wm_zt_col(1,:) = wm_zt
1046 :
1047 0 : wpthlp_sfc_col(1) = wpthlp_sfc
1048 0 : wprtp_sfc_col(1) = wprtp_sfc
1049 0 : upwp_sfc_col(1) = upwp_sfc
1050 0 : vpwp_sfc_col(1) = vpwp_sfc
1051 :
1052 0 : wpsclrp_sfc_col(1,:) = wpsclrp_sfc
1053 0 : wpedsclrp_sfc_col(1,:) = wpedsclrp_sfc
1054 :
1055 0 : upwp_sfc_pert_col(1) = upwp_sfc_pert
1056 0 : vpwp_sfc_pert_col(1) = vpwp_sfc_pert
1057 :
1058 0 : rtm_ref_col(1,:) = rtm_ref
1059 0 : thlm_ref_col(1,:) = thlm_ref
1060 0 : um_ref_col(1,:) = um_ref
1061 0 : vm_ref_col(1,:) = vm_ref
1062 0 : ug_col(1,:) = ug
1063 0 : vg_col(1,:) = vg
1064 :
1065 0 : p_in_Pa_col(1,:) = p_in_Pa
1066 0 : rho_zm_col(1,:) = rho_zm
1067 0 : rho_col(1,:) = rho
1068 0 : exner_col(1,:) = exner
1069 0 : rho_ds_zm_col(1,:) = rho_ds_zm
1070 0 : rho_ds_zt_col(1,:) = rho_ds_zt
1071 0 : invrs_rho_ds_zm_col(1,:) = invrs_rho_ds_zm
1072 0 : invrs_rho_ds_zt_col(1,:) = invrs_rho_ds_zt
1073 0 : thv_ds_zm_col(1,:) = thv_ds_zm
1074 0 : thv_ds_zt_col(1,:) = thv_ds_zt
1075 0 : rfrzm_col(1,:) = rfrzm
1076 :
1077 0 : hydromet_col(1,:,:) = hydromet
1078 :
1079 0 : radf_col(1,:) = radf
1080 : #ifdef CLUBBND_CAM
1081 : varmu_col(1) = varmu
1082 : #endif
1083 0 : wphydrometp_col(1,:,:) = wphydrometp
1084 0 : wp2hmp_col(1,:,:) = wp2hmp
1085 0 : rtphmp_zt_col(1,:,:) = rtphmp_zt
1086 0 : thlphmp_zt_col(1,:,:) = thlphmp_zt
1087 :
1088 0 : host_dx_col(1) = host_dx
1089 0 : host_dy_col(1) = host_dy
1090 :
1091 0 : clubb_params_col(1,:) = clubb_params
1092 :
1093 0 : stats_zt_col(1) = stats_zt
1094 0 : stats_zm_col(1) = stats_zm
1095 0 : stats_sfc_col(1) = stats_sfc
1096 :
1097 0 : um_col(1,:) = um
1098 0 : vm_col(1,:) = vm
1099 0 : upwp_col(1,:) = upwp
1100 0 : vpwp_col(1,:) = vpwp
1101 0 : up2_col(1,:) = up2
1102 0 : vp2_col(1,:) = vp2
1103 0 : up3_col(1,:) = up3
1104 0 : vp3_col(1,:) = vp3
1105 0 : thlm_col(1,:) = thlm
1106 0 : rtm_col(1,:) = rtm
1107 0 : wprtp_col(1,:) = wprtp
1108 0 : wpthlp_col(1,:) = wpthlp
1109 0 : wp2_col(1,:) = wp2
1110 0 : wp3_col(1,:) = wp3
1111 0 : rtp2_col(1,:) = rtp2
1112 0 : rtp3_col(1,:) = rtp3
1113 0 : thlp2_col(1,:) = thlp2
1114 0 : thlp3_col(1,:) = thlp3
1115 0 : rtpthlp_col(1,:) = rtpthlp
1116 :
1117 0 : sclrm_col(1,:,:) = sclrm
1118 : #ifdef GFDL
1119 : sclrm_trsport_only_col(1,:,:) = sclrm_trsport_only
1120 : #endif
1121 0 : sclrp2_col(1,:,:) = sclrp2
1122 0 : sclrp3_col(1,:,:) = sclrp3
1123 0 : sclrprtp_col(1,:,:) = sclrprtp
1124 0 : sclrpthlp_col(1,:,:) = sclrpthlp
1125 0 : wpsclrp_col(1,:,:) = wpsclrp
1126 0 : edsclrm_col(1,:,:) = edsclrm
1127 :
1128 0 : rcm_col(1,:) = rcm
1129 0 : cloud_frac_col(1,:) = cloud_frac
1130 0 : wpthvp_col(1,:) = wpthvp
1131 0 : wp2thvp_col(1,:) = wp2thvp
1132 0 : rtpthvp_col(1,:) = rtpthvp
1133 0 : thlpthvp_col(1,:) = thlpthvp
1134 0 : sclrpthvp_col(1,:,:) = sclrpthvp
1135 0 : wp2rtp_col(1,:) = wp2rtp
1136 0 : wp2thlp_col(1,:) = wp2thlp
1137 0 : uprcp_col(1,:) = uprcp
1138 0 : vprcp_col(1,:) = vprcp
1139 0 : rc_coef_zm_col(1,:) = rc_coef_zm
1140 0 : wp4_col(1,:) = wp4
1141 0 : wpup2_col(1,:) = wpup2
1142 0 : wpvp2_col(1,:) = wpvp2
1143 0 : wp2up2_col(1,:) = wp2up2
1144 0 : wp2vp2_col(1,:) = wp2vp2
1145 0 : ice_supersat_frac_col(1,:) = ice_supersat_frac
1146 0 : um_pert_col(1,:) = um_pert
1147 0 : vm_pert_col(1,:) = vm_pert
1148 0 : upwp_pert_col(1,:) = upwp_pert
1149 0 : vpwp_pert_col(1,:) = vpwp_pert
1150 : #ifdef GFDL
1151 : RH_crit_col(1,:,:,:) = RH_crit
1152 : #endif
1153 0 : Kh_zm_col(1,:) = Kh_zm
1154 0 : Kh_zt_col(1,:) = Kh_zt
1155 : #ifdef CLUBB_CAM
1156 0 : qclvar_col(1,:) = qclvar
1157 : #endif
1158 0 : thlprcp_col(1,:) = thlprcp
1159 0 : wprcp_col(1,:) = wprcp
1160 0 : w_up_in_cloud_col(1,:) = w_up_in_cloud
1161 0 : w_down_in_cloud_col(1,:) = w_down_in_cloud
1162 0 : cloudy_updraft_frac_col(1,:) = cloudy_updraft_frac
1163 0 : cloudy_downdraft_frac_col(1,:) = cloudy_downdraft_frac
1164 0 : rcm_in_layer_col(1,:) = rcm_in_layer
1165 0 : cloud_cover_col(1,:) = cloud_cover
1166 0 : invrs_tau_zm_col(1,:) = invrs_tau_zm
1167 :
1168 : !$acc data copyin( gr, gr%zm, gr%zt, gr%dzm, gr%dzt, gr%invrs_dzt, gr%invrs_dzm, &
1169 : !$acc gr%weights_zt2zm, gr%weights_zm2zt, &
1170 : !$acc nu_vert_res_dep, nu_vert_res_dep%nu2, nu_vert_res_dep%nu9, &
1171 : !$acc nu_vert_res_dep%nu1, nu_vert_res_dep%nu8, nu_vert_res_dep%nu10, &
1172 : !$acc nu_vert_res_dep%nu6, &
1173 : !$acc sclr_idx, clubb_params_col, &
1174 : !$acc fcor_col, sfc_elevation_col, thlm_forcing_col, rtm_forcing_col, um_forcing_col, &
1175 : !$acc vm_forcing_col, wprtp_forcing_col, wpthlp_forcing_col, rtp2_forcing_col, thlp2_forcing_col, &
1176 : !$acc rtpthlp_forcing_col, wm_zm_col, wm_zt_col, rho_zm_col, rho_col, rho_ds_zm_col, rho_ds_zt_col, &
1177 : !$acc invrs_rho_ds_zm_col, invrs_rho_ds_zt_col, thv_ds_zm_col, thv_ds_zt_col, rfrzm_col, &
1178 : !$acc radf_col, wpthlp_sfc_col, &
1179 : !$acc wprtp_sfc_col, upwp_sfc_col, vpwp_sfc_col, &
1180 : !$acc upwp_sfc_pert_col, vpwp_sfc_pert_col, rtm_ref_col, thlm_ref_col, um_ref_col, &
1181 : !$acc vm_ref_col, ug_col, vg_col, host_dx_col, host_dy_col, &
1182 : !$acc pdf_params, pdf_params_zm ) &
1183 : !$acc copy( um_col, upwp_col, vm_col, vpwp_col, up2_col, vp2_col, up3_col, vp3_col, rtm_col, wprtp_col, thlm_col, wpthlp_col, rtp2_col, &
1184 : !$acc rtp3_col, thlp2_col, thlp3_col, rtpthlp_col, wp2_col, wp3_col, &
1185 : !$acc p_in_Pa_col, exner_col, rcm_col, cloud_frac_col, wpthvp_col, wp2thvp_col, &
1186 : !$acc rtpthvp_col, thlpthvp_col, wp2rtp_col, wp2thlp_col, uprcp_col, vprcp_col, rc_coef_zm_col, &
1187 : !$acc wp4_col, wpup2_col, wpvp2_col, wp2up2_col, wp2vp2_col, ice_supersat_frac_col, um_pert_col, &
1188 : !$acc vm_pert_col, upwp_pert_col, vpwp_pert_col, &
1189 : !$acc pdf_params%w_1, pdf_params%w_2, &
1190 : !$acc pdf_params%varnce_w_1, pdf_params%varnce_w_2, &
1191 : !$acc pdf_params%rt_1, pdf_params%rt_2, &
1192 : !$acc pdf_params%varnce_rt_1, pdf_params%varnce_rt_2, &
1193 : !$acc pdf_params%thl_1, pdf_params%thl_2, &
1194 : !$acc pdf_params%varnce_thl_1, pdf_params%varnce_thl_2, &
1195 : !$acc pdf_params%corr_w_rt_1, pdf_params%corr_w_rt_2, &
1196 : !$acc pdf_params%corr_w_thl_1, pdf_params%corr_w_thl_2, &
1197 : !$acc pdf_params%corr_rt_thl_1, pdf_params%corr_rt_thl_2,&
1198 : !$acc pdf_params%alpha_thl, pdf_params%alpha_rt, &
1199 : !$acc pdf_params%crt_1, pdf_params%crt_2, pdf_params%cthl_1, &
1200 : !$acc pdf_params%cthl_2, pdf_params%chi_1, &
1201 : !$acc pdf_params%chi_2, pdf_params%stdev_chi_1, &
1202 : !$acc pdf_params%stdev_chi_2, pdf_params%stdev_eta_1, &
1203 : !$acc pdf_params%stdev_eta_2, pdf_params%covar_chi_eta_1, &
1204 : !$acc pdf_params%covar_chi_eta_2, pdf_params%corr_w_chi_1, &
1205 : !$acc pdf_params%corr_w_chi_2, pdf_params%corr_w_eta_1, &
1206 : !$acc pdf_params%corr_w_eta_2, pdf_params%corr_chi_eta_1, &
1207 : !$acc pdf_params%corr_chi_eta_2, pdf_params%rsatl_1, &
1208 : !$acc pdf_params%rsatl_2, pdf_params%rc_1, pdf_params%rc_2, &
1209 : !$acc pdf_params%cloud_frac_1, pdf_params%cloud_frac_2, &
1210 : !$acc pdf_params%mixt_frac, pdf_params%ice_supersat_frac_1, &
1211 : !$acc pdf_params%ice_supersat_frac_2, &
1212 : !$acc pdf_params_zm%w_1, pdf_params_zm%w_2, &
1213 : !$acc pdf_params_zm%varnce_w_1, pdf_params_zm%varnce_w_2, &
1214 : !$acc pdf_params_zm%rt_1, pdf_params_zm%rt_2, &
1215 : !$acc pdf_params_zm%varnce_rt_1, pdf_params_zm%varnce_rt_2, &
1216 : !$acc pdf_params_zm%thl_1, pdf_params_zm%thl_2, &
1217 : !$acc pdf_params_zm%varnce_thl_1, pdf_params_zm%varnce_thl_2, &
1218 : !$acc pdf_params_zm%corr_w_rt_1, pdf_params_zm%corr_w_rt_2, &
1219 : !$acc pdf_params_zm%corr_w_thl_1, pdf_params_zm%corr_w_thl_2, &
1220 : !$acc pdf_params_zm%corr_rt_thl_1, pdf_params_zm%corr_rt_thl_2,&
1221 : !$acc pdf_params_zm%alpha_thl, pdf_params_zm%alpha_rt, &
1222 : !$acc pdf_params_zm%crt_1, pdf_params_zm%crt_2, pdf_params_zm%cthl_1, &
1223 : !$acc pdf_params_zm%cthl_2, pdf_params_zm%chi_1, &
1224 : !$acc pdf_params_zm%chi_2, pdf_params_zm%stdev_chi_1, &
1225 : !$acc pdf_params_zm%stdev_chi_2, pdf_params_zm%stdev_eta_1, &
1226 : !$acc pdf_params_zm%stdev_eta_2, pdf_params_zm%covar_chi_eta_1, &
1227 : !$acc pdf_params_zm%covar_chi_eta_2, pdf_params_zm%corr_w_chi_1, &
1228 : !$acc pdf_params_zm%corr_w_chi_2, pdf_params_zm%corr_w_eta_1, &
1229 : !$acc pdf_params_zm%corr_w_eta_2, pdf_params_zm%corr_chi_eta_1, &
1230 : !$acc pdf_params_zm%corr_chi_eta_2, pdf_params_zm%rsatl_1, &
1231 : !$acc pdf_params_zm%rsatl_2, pdf_params_zm%rc_1, pdf_params_zm%rc_2, &
1232 : !$acc pdf_params_zm%cloud_frac_1, pdf_params_zm%cloud_frac_2, &
1233 : !$acc pdf_params_zm%mixt_frac, pdf_params_zm%ice_supersat_frac_1, &
1234 : !$acc pdf_params_zm%ice_supersat_frac_2 ) &
1235 : !$acc copyout( rcm_in_layer_col, cloud_cover_col, wprcp_col, w_up_in_cloud_col, w_down_in_cloud_col, &
1236 : !$acc cloudy_updraft_frac_col, cloudy_downdraft_frac_col, invrs_tau_zm_col, Kh_zt_col, &
1237 : !$acc Kh_zm_col, &
1238 : !$acc thlprcp_col )
1239 :
1240 : !$acc data if( sclr_dim > 0 ) &
1241 : !$acc copyin( sclr_tol, sclrm_forcing_col, wpsclrp_sfc_col ) &
1242 : !$acc copy( sclrm_col, wpsclrp_col, sclrp2_col, sclrp3_col, sclrprtp_col, sclrpthlp_col, sclrpthvp_col )
1243 :
1244 : !$acc data if( edsclr_dim > 0 ) &
1245 : !$acc copyin( wpedsclrp_sfc_col, edsclrm_forcing_col ) &
1246 : !$acc copy( edsclrm_col )
1247 :
1248 : !$acc data if( hydromet_dim > 0 ) &
1249 : !$acc copyin( hydromet_col, wphydrometp_col, wp2hmp_col, rtphmp_zt_col, thlphmp_zt_col, &
1250 : !$acc l_mix_rat_hm )
1251 :
1252 : #ifdef CLUBB_CAM
1253 : !$acc data copyout( qclvar_col )
1254 : #endif
1255 :
1256 : #ifdef CLUBBND_CAM
1257 : !$acc data copyin( varmu_col )
1258 : #endif
1259 :
1260 : #ifdef GFDL
1261 : !$acc data if( sclr_dim > 0 ) copy( sclrm_trsport_only )
1262 : #endif
1263 :
1264 : call advance_clubb_core( gr, gr%nz, 1, &
1265 : l_implemented, dt, fcor_col, sfc_elevation_col, & ! intent(in)
1266 : hydromet_dim, & ! intent(in)
1267 : sclr_dim, sclr_tol, edsclr_dim, sclr_idx, & ! intent(in)
1268 : thlm_forcing_col, rtm_forcing_col, um_forcing_col, vm_forcing_col, & ! intent(in)
1269 : sclrm_forcing_col, edsclrm_forcing_col, wprtp_forcing_col, & ! intent(in)
1270 : wpthlp_forcing_col, rtp2_forcing_col, thlp2_forcing_col, & ! intent(in)
1271 : rtpthlp_forcing_col, wm_zm_col, wm_zt_col, & ! intent(in)
1272 : wpthlp_sfc_col, wprtp_sfc_col, upwp_sfc_col, vpwp_sfc_col, & ! intent(in)
1273 : wpsclrp_sfc_col, wpedsclrp_sfc_col, & ! intent(in)
1274 : upwp_sfc_pert_col, vpwp_sfc_pert_col, & ! intent(in)
1275 : rtm_ref_col, thlm_ref_col, um_ref_col, vm_ref_col, ug_col, vg_col, & ! Intent(in)
1276 : p_in_Pa_col, rho_zm_col, rho_col, exner_col, & ! intent(in)
1277 : rho_ds_zm_col, rho_ds_zt_col, invrs_rho_ds_zm_col, & ! intent(in)
1278 : invrs_rho_ds_zt_col, thv_ds_zm_col, thv_ds_zt_col, & ! intent(in)
1279 : hydromet_col, l_mix_rat_hm, & ! intent(in)
1280 : rfrzm_col, radf_col, & ! intent(in)
1281 : #ifdef CLUBBND_CAM
1282 : varmu_col, &
1283 : #endif
1284 : wphydrometp_col, wp2hmp_col, rtphmp_zt_col, thlphmp_zt_col, & ! intent(in)
1285 : host_dx_col, host_dy_col, & ! intent(in)
1286 : clubb_params_col, nu_vert_res_dep, lmin, & ! intent(in)
1287 : clubb_config_flags, & ! intent(in)
1288 : stats_metadata, & ! intent(in)
1289 : stats_zt_col, stats_zm_col, stats_sfc_col, & ! intent(inout)
1290 : um_col, vm_col, upwp_col, vpwp_col, up2_col, vp2_col, up3_col, vp3_col, & ! intent(inout)
1291 : thlm_col, rtm_col, wprtp_col, wpthlp_col, & ! intent(inout)
1292 : wp2_col, wp3_col, rtp2_col, rtp3_col, thlp2_col, thlp3_col, rtpthlp_col, & ! intent(inout)
1293 : sclrm_col, &
1294 : #ifdef GFDL
1295 : sclrm_trsport_only_col, & ! h1g, 2010-06-16 ! intent(inout)
1296 : #endif
1297 : sclrp2_col, sclrp3_col, sclrprtp_col, sclrpthlp_col, & ! intent(inout)
1298 : wpsclrp_col, edsclrm_col, & ! intent(inout)
1299 : rcm_col, cloud_frac_col, & ! intent(inout)
1300 : wpthvp_col, wp2thvp_col, rtpthvp_col, thlpthvp_col, & ! intent(inout)
1301 : sclrpthvp_col, & ! intent(inout)
1302 : wp2rtp_col, wp2thlp_col, uprcp_col, vprcp_col, rc_coef_zm_col, wp4_col, & ! intent(inout)
1303 : wpup2_col, wpvp2_col, wp2up2_col, wp2vp2_col, ice_supersat_frac_col, & ! intent(inout)
1304 : um_pert_col, vm_pert_col, upwp_pert_col, vpwp_pert_col, & ! intent(inout)
1305 : pdf_params, pdf_params_zm, & ! intent(inout)
1306 : pdf_implicit_coefs_terms, & ! intent(inout)
1307 : #ifdef GFDL
1308 : RH_crit_col, & !h1g, 2010-06-16 ! intent(inout)
1309 : do_liquid_only_in_clubb, & ! intent(in)
1310 : #endif
1311 : Kh_zm_col, Kh_zt_col, & ! intent(out)
1312 : #ifdef CLUBB_CAM
1313 : qclvar_col, & ! intent(out)
1314 : #endif
1315 : thlprcp_col, wprcp_col, w_up_in_cloud_col, w_down_in_cloud_col, & ! intent(out)
1316 : cloudy_updraft_frac_col, cloudy_downdraft_frac_col, & ! intent(out)
1317 : rcm_in_layer_col, cloud_cover_col, invrs_tau_zm_col, & ! intent(out)
1318 0 : err_code_api ) ! intent(out)
1319 :
1320 : !$acc end data
1321 : !$acc end data
1322 : !$acc end data
1323 : !$acc end data
1324 :
1325 : #ifdef CLUBB_CAM
1326 : !$acc end data
1327 : #endif
1328 :
1329 : #ifdef CLUBBND_CAM
1330 : !$acc end data
1331 : #endif
1332 :
1333 : #ifdef GFDL
1334 : !$acc end data
1335 : #endif
1336 :
1337 : ! The following does not work for stats
1338 : ! stats_zt = stats_zt_col(1)
1339 : ! stats_zm = stats_zm_col(1)
1340 : ! stats_sfc = stats_sfc_col(1)
1341 : ! because of some mysterious pointer issue. However, the only thing that
1342 : ! updates in stats is the field values, so we can copy only those instead.
1343 0 : if ( stats_metadata%l_stats ) then
1344 0 : stats_zm%accum_field_values = stats_zm_col(1)%accum_field_values
1345 0 : stats_zm%accum_num_samples = stats_zm_col(1)%accum_num_samples
1346 :
1347 0 : stats_zt%accum_field_values = stats_zt_col(1)%accum_field_values
1348 0 : stats_zt%accum_num_samples = stats_zt_col(1)%accum_num_samples
1349 :
1350 0 : stats_sfc%accum_field_values = stats_sfc_col(1)%accum_field_values
1351 0 : stats_sfc%accum_num_samples = stats_sfc_col(1)%accum_num_samples
1352 : end if
1353 :
1354 :
1355 0 : um = um_col(1,:)
1356 0 : upwp = upwp_col(1,:)
1357 0 : vm = vm_col(1,:)
1358 0 : vpwp = vpwp_col(1,:)
1359 0 : up2 = up2_col(1,:)
1360 0 : vp2 = vp2_col(1,:)
1361 0 : up3 = up3_col(1,:)
1362 0 : vp3 = vp3_col(1,:)
1363 0 : rtm = rtm_col(1,:)
1364 0 : wprtp = wprtp_col(1,:)
1365 0 : thlm = thlm_col(1,:)
1366 0 : wpthlp = wpthlp_col(1,:)
1367 0 : rtp2 = rtp2_col(1,:)
1368 0 : rtp3 = rtp3_col(1,:)
1369 0 : thlp2 = thlp2_col(1,:)
1370 0 : thlp3 = thlp3_col(1,:)
1371 0 : rtpthlp = rtpthlp_col(1,:)
1372 0 : wp2 = wp2_col(1,:)
1373 0 : wp3 = wp3_col(1,:)
1374 0 : sclrm = sclrm_col(1,:,:)
1375 0 : wpsclrp = wpsclrp_col(1,:,:)
1376 0 : sclrp2 = sclrp2_col(1,:,:)
1377 0 : sclrp3 = sclrp3_col(1,:,:)
1378 0 : sclrprtp = sclrprtp_col(1,:,:)
1379 0 : sclrpthlp = sclrpthlp_col(1,:,:)
1380 0 : p_in_Pa = p_in_Pa_col(1,:)
1381 0 : exner = exner_col(1,:)
1382 0 : rcm = rcm_col(1,:)
1383 0 : cloud_frac = cloud_frac_col(1,:)
1384 0 : wpthvp = wpthvp_col(1,:)
1385 0 : wp2thvp = wp2thvp_col(1,:)
1386 0 : rtpthvp = rtpthvp_col(1,:)
1387 0 : thlpthvp = thlpthvp_col(1,:)
1388 0 : sclrpthvp = sclrpthvp_col(1,:,:)
1389 0 : wp2rtp = wp2rtp_col(1,:)
1390 0 : wp2thlp = wp2thlp_col(1,:)
1391 0 : uprcp = uprcp_col(1,:)
1392 0 : vprcp = vprcp_col(1,:)
1393 0 : rc_coef_zm = rc_coef_zm_col(1,:)
1394 0 : wp4 = wp4_col(1,:)
1395 0 : wpup2 = wpup2_col(1,:)
1396 0 : wpvp2 = wpvp2_col(1,:)
1397 0 : wp2vp2 = wp2vp2_col(1,:)
1398 0 : wp2up2 = wp2up2_col(1,:)
1399 0 : ice_supersat_frac = ice_supersat_frac_col(1,:)
1400 : #ifdef GFDL
1401 : sclrm_trsport_only = sclrm_trsport_only_col(1,:,:)
1402 : #endif
1403 0 : edsclrm = edsclrm_col(1,:,:)
1404 0 : rcm_in_layer = rcm_in_layer_col(1,:)
1405 0 : cloud_cover = cloud_cover_col(1,:)
1406 0 : wprcp = wprcp_col(1,:)
1407 0 : w_up_in_cloud = w_up_in_cloud_col(1,:)
1408 0 : w_down_in_cloud = w_down_in_cloud_col(1,:)
1409 0 : cloudy_updraft_frac = cloudy_updraft_frac_col(1,:)
1410 0 : cloudy_downdraft_frac = cloudy_downdraft_frac_col(1,:)
1411 0 : invrs_tau_zm = invrs_tau_zm_col(1,:)
1412 0 : Kh_zt = Kh_zt_col(1,:)
1413 0 : Kh_zm = Kh_zm_col(1,:)
1414 : #ifdef CLUBB_CAM
1415 0 : qclvar = qclvar_col(1,:)
1416 : #endif
1417 0 : thlprcp = thlprcp_col(1,:)
1418 : #ifdef GFDL
1419 : RH_crit = RH_crit_col(1,:,:,:)
1420 : #endif
1421 :
1422 0 : end subroutine advance_clubb_core_api_single_col
1423 :
1424 8935056 : subroutine advance_clubb_core_api_multi_col( gr, nz, ngrdcol, &
1425 8935056 : l_implemented, dt, fcor, sfc_elevation, & ! intent(in)
1426 : hydromet_dim, & ! intent(in)
1427 8935056 : sclr_dim, sclr_tol, edsclr_dim, sclr_idx, & ! intent(in)
1428 8935056 : thlm_forcing, rtm_forcing, um_forcing, vm_forcing, & ! intent(in)
1429 8935056 : sclrm_forcing, edsclrm_forcing, wprtp_forcing, & ! intent(in)
1430 8935056 : wpthlp_forcing, rtp2_forcing, thlp2_forcing, & ! intent(in)
1431 8935056 : rtpthlp_forcing, wm_zm, wm_zt, & ! intent(in)
1432 8935056 : wpthlp_sfc, wprtp_sfc, upwp_sfc, vpwp_sfc, & ! intent(in)
1433 8935056 : wpsclrp_sfc, wpedsclrp_sfc, & ! intent(in)
1434 8935056 : upwp_sfc_pert, vpwp_sfc_pert, & ! intent(in)
1435 8935056 : rtm_ref, thlm_ref, um_ref, vm_ref, ug, vg, & ! Intent(in)
1436 8935056 : p_in_Pa, rho_zm, rho, exner, & ! intent(in)
1437 8935056 : rho_ds_zm, rho_ds_zt, invrs_rho_ds_zm, & ! intent(in)
1438 8935056 : invrs_rho_ds_zt, thv_ds_zm, thv_ds_zt, & ! intent(in)
1439 8935056 : hydromet, l_mix_rat_hm, & ! intent(in)
1440 8935056 : rfrzm, radf, & ! intent(in)
1441 : #ifdef CLUBBND_CAM
1442 : varmu, & ! intent(in)
1443 : #endif
1444 8935056 : wphydrometp, wp2hmp, rtphmp_zt, thlphmp_zt, & ! intent(in)
1445 8935056 : host_dx, host_dy, & ! intent(in)
1446 8935056 : clubb_params, nu_vert_res_dep, lmin, & ! intent(in)
1447 : clubb_config_flags, & ! intent(in)
1448 : stats_metadata, & ! intent(in)
1449 8935056 : stats_zt, stats_zm, stats_sfc, & ! intent(inout)
1450 8935056 : um, vm, upwp, vpwp, up2, vp2, up3, vp3, & ! intent(inout)
1451 8935056 : thlm, rtm, wprtp, wpthlp, & ! intent(inout)
1452 8935056 : wp2, wp3, rtp2, rtp3, thlp2, thlp3, rtpthlp, & ! intent(inout)
1453 8935056 : sclrm, &
1454 : #ifdef GFDL
1455 : sclrm_trsport_only, & ! h1g, 2010-06-16 ! intent(inout)
1456 : #endif
1457 8935056 : sclrp2, sclrp3, sclrprtp, sclrpthlp, & ! intent(inout)
1458 8935056 : wpsclrp, edsclrm, err_code_api, & ! intent(inout)
1459 8935056 : rcm, cloud_frac, & ! intent(inout)
1460 8935056 : wpthvp, wp2thvp, rtpthvp, thlpthvp, & ! intent(inout)
1461 8935056 : sclrpthvp, & ! intent(inout)
1462 8935056 : wp2rtp, wp2thlp, uprcp, vprcp, rc_coef_zm, wp4, & ! intent(inout)
1463 8935056 : wpup2, wpvp2, wp2up2, wp2vp2, ice_supersat_frac, & ! intent(inout)
1464 8935056 : um_pert, vm_pert, upwp_pert, vpwp_pert, & ! intent(inout)
1465 : pdf_params, pdf_params_zm, & ! intent(inout)
1466 : pdf_implicit_coefs_terms, & ! intent(inout)
1467 : #ifdef GFDL
1468 : RH_crit, & !h1g, 2010-06-16 ! intent(inout)
1469 : do_liquid_only_in_clubb, & ! intent(in)
1470 : #endif
1471 8935056 : Kh_zm, Kh_zt, & ! intent(out)
1472 : #ifdef CLUBB_CAM
1473 8935056 : qclvar, & ! intent(out)
1474 : #endif
1475 8935056 : thlprcp, wprcp, w_up_in_cloud, w_down_in_cloud, & ! intent(out)
1476 8935056 : cloudy_updraft_frac, cloudy_downdraft_frac, & ! intent(out)
1477 8935056 : rcm_in_layer, cloud_cover, invrs_tau_zm ) ! intent(out)
1478 :
1479 : use advance_clubb_core_module, only : advance_clubb_core
1480 :
1481 : use pdf_parameter_module, only: &
1482 : implicit_coefs_terms ! Variable Type(s)
1483 :
1484 : use model_flags, only: &
1485 : clubb_config_flags_type
1486 :
1487 : use array_index, only: &
1488 : sclr_idx_type
1489 :
1490 : implicit none
1491 :
1492 : !------------------------ Input Variables ------------------------
1493 : integer, intent(in) :: &
1494 : nz, &
1495 : ngrdcol ! Number of grid columns
1496 :
1497 : type(grid), target, intent(in) :: &
1498 : gr
1499 :
1500 : logical, intent(in) :: &
1501 : l_implemented ! Is this part of a larger host model (T/F) ?
1502 :
1503 : real( kind = core_rknd ), intent(in) :: &
1504 : dt ! Current timestep duration [s]
1505 :
1506 : real( kind = core_rknd ), intent(in), dimension(ngrdcol) :: &
1507 : fcor, & ! Coriolis forcing [s^-1]
1508 : sfc_elevation ! Elevation of ground level [m AMSL]
1509 :
1510 : integer, intent(in) :: &
1511 : hydromet_dim, & ! Total number of hydrometeor species [#]
1512 : sclr_dim, & ! Number of passive scalars [#]
1513 : edsclr_dim ! Number of eddy-diff. passive scalars [#]
1514 :
1515 : real( kind = core_rknd ), intent(in), dimension(sclr_dim) :: &
1516 : sclr_tol ! Threshold(s) on the passive scalars [units vary]
1517 :
1518 : type (sclr_idx_type), intent(in) :: &
1519 : sclr_idx
1520 :
1521 : real( kind = core_rknd ), intent(in), dimension(ngrdcol,nz) :: &
1522 : thlm_forcing, & ! theta_l forcing (thermodynamic levels) [K/s]
1523 : rtm_forcing, & ! r_t forcing (thermodynamic levels) [(kg/kg)/s]
1524 : um_forcing, & ! u wind forcing (thermodynamic levels) [m/s/s]
1525 : vm_forcing, & ! v wind forcing (thermodynamic levels) [m/s/s]
1526 : wprtp_forcing, & ! <w'r_t'> forcing (momentum levels) [m*K/s^2]
1527 : wpthlp_forcing, & ! <w'th_l'> forcing (momentum levels) [m*(kg/kg)/s^2]
1528 : rtp2_forcing, & ! <r_t'^2> forcing (momentum levels) [(kg/kg)^2/s]
1529 : thlp2_forcing, & ! <th_l'^2> forcing (momentum levels) [K^2/s]
1530 : rtpthlp_forcing, & ! <r_t'th_l'> forcing (momentum levels) [K*(kg/kg)/s]
1531 : wm_zm, & ! w mean wind component on momentum levels [m/s]
1532 : wm_zt, & ! w mean wind component on thermo. levels [m/s]
1533 : rho_zm, & ! Air density on momentum levels [kg/m^3]
1534 : rho, & ! Air density on thermodynamic levels [kg/m^3]
1535 : rho_ds_zm, & ! Dry, static density on momentum levels [kg/m^3]
1536 : rho_ds_zt, & ! Dry, static density on thermo. levels [kg/m^3]
1537 : invrs_rho_ds_zm, & ! Inv. dry, static density @ momentum levs. [m^3/kg]
1538 : invrs_rho_ds_zt, & ! Inv. dry, static density @ thermo. levs. [m^3/kg]
1539 : thv_ds_zm, & ! Dry, base-state theta_v on momentum levs. [K]
1540 : thv_ds_zt, & ! Dry, base-state theta_v on thermo. levs. [K]
1541 : rfrzm ! Total ice-phase water mixing ratio [kg/kg]
1542 :
1543 : real( kind = core_rknd ), dimension(ngrdcol,nz,hydromet_dim), intent(in) :: &
1544 : hydromet ! Collection of hydrometeors [units vary]
1545 :
1546 : logical, dimension(hydromet_dim), intent(in) :: &
1547 : l_mix_rat_hm ! if true, then the quantity is a hydrometeor mixing ratio
1548 :
1549 : real( kind = core_rknd ), dimension(ngrdcol,nz), intent(in) :: &
1550 : radf ! Buoyancy production at the CL top due to LW radiative cooling [m^2/s^3]
1551 :
1552 : #ifdef CLUBBND_CAM
1553 : real( kind = core_rknd ), intent(in), dimension(ngrdcol) :: &
1554 : varmu
1555 : #endif
1556 :
1557 : real( kind = core_rknd ), dimension(ngrdcol,nz, hydromet_dim), intent(in) :: &
1558 : wphydrometp, & ! Covariance of w and a hydrometeor [(m/s) <hm units>]
1559 : wp2hmp, & ! Third moment: <w'^2> * <hydro.'> [(m/s)^2 <hm units>]
1560 : rtphmp_zt, & ! Covariance of rt and a hydrometeor [(kg/kg) <hm units>]
1561 : thlphmp_zt ! Covariance of thl and a hydrometeor [K <hm units>]
1562 :
1563 : real( kind = core_rknd ), intent(in), dimension(ngrdcol) :: &
1564 : wpthlp_sfc, & ! w' theta_l' at surface [(m K)/s]
1565 : wprtp_sfc, & ! w' r_t' at surface [(kg m)/( kg s)]
1566 : upwp_sfc, & ! u'w' at surface [m^2/s^2]
1567 : vpwp_sfc ! v'w' at surface [m^2/s^2]
1568 :
1569 : ! Passive scalar variables
1570 : real( kind = core_rknd ), intent(in), dimension(ngrdcol,nz,sclr_dim) :: &
1571 : sclrm_forcing ! Passive scalar forcing [{units vary}/s]
1572 :
1573 : real( kind = core_rknd ), intent(in), dimension(ngrdcol,sclr_dim) :: &
1574 : wpsclrp_sfc ! Scalar flux at surface [{units vary} m/s]
1575 :
1576 : real( kind = core_rknd ), intent(in), dimension(ngrdcol) :: &
1577 : upwp_sfc_pert, & ! pertubed u'w' at surface [m^2/s^2]
1578 : vpwp_sfc_pert ! pertubed v'w' at surface [m^2/s^2]
1579 :
1580 : ! Eddy passive scalar variables
1581 : real( kind = core_rknd ), intent(in), dimension(ngrdcol,nz,edsclr_dim) :: &
1582 : edsclrm_forcing ! Eddy passive scalar forcing [{units vary}/s]
1583 :
1584 : real( kind = core_rknd ), intent(in), dimension(ngrdcol,edsclr_dim) :: &
1585 : wpedsclrp_sfc ! Eddy-Scalar flux at surface [{units vary} m/s]
1586 :
1587 : ! Reference profiles (used for nudging, sponge damping, and Coriolis effect)
1588 : real( kind = core_rknd ), dimension(ngrdcol,nz), intent(in) :: &
1589 : rtm_ref, & ! Initial total water mixing ratio [kg/kg]
1590 : thlm_ref, & ! Initial liquid water potential temperature [K]
1591 : um_ref, & ! Initial u wind; Michael Falk [m/s]
1592 : vm_ref, & ! Initial v wind; Michael Falk [m/s]
1593 : ug, & ! u geostrophic wind [m/s]
1594 : vg ! v geostrophic wind [m/s]
1595 :
1596 : ! Host model horizontal grid spacing, if part of host model.
1597 : real( kind = core_rknd ), intent(in), dimension(ngrdcol) :: &
1598 : host_dx, & ! East-West horizontal grid spacing [m]
1599 : host_dy ! North-South horizontal grid spacing [m]
1600 :
1601 : real( kind = core_rknd ), dimension(ngrdcol,nparams), intent(in) :: &
1602 : clubb_params ! Array of CLUBB's tunable parameters [units vary]
1603 :
1604 : type(nu_vertical_res_dep), intent(in) :: &
1605 : nu_vert_res_dep ! Vertical resolution dependent nu values
1606 :
1607 : real( kind = core_rknd ), intent(in) :: &
1608 : lmin ! Min. value for the length scale [m]
1609 :
1610 : type( clubb_config_flags_type ), intent(in) :: &
1611 : clubb_config_flags ! Derived type holding all configurable CLUBB flags
1612 :
1613 : type (stats_metadata_type), intent(in) :: &
1614 : stats_metadata
1615 :
1616 : !------------------------ Input/Output Variables ------------------------
1617 : type(stats), target, intent(inout), dimension(ngrdcol) :: &
1618 : stats_zt, &
1619 : stats_zm, &
1620 : stats_sfc
1621 :
1622 : ! These are prognostic or are planned to be in the future
1623 : real( kind = core_rknd ), intent(inout), dimension(ngrdcol,nz) :: &
1624 : um, & ! u mean wind component (thermodynamic levels) [m/s]
1625 : upwp, & ! u'w' (momentum levels) [m^2/s^2]
1626 : vm, & ! v mean wind component (thermodynamic levels) [m/s]
1627 : vpwp, & ! v'w' (momentum levels) [m^2/s^2]
1628 : up2, & ! u'^2 (momentum levels) [m^2/s^2]
1629 : vp2, & ! v'^2 (momentum levels) [m^2/s^2]
1630 : up3, & ! u'^3 (thermodynamic levels) [m^3/s^3]
1631 : vp3, & ! v'^3 (thermodynamic levels) [m^3/s^3]
1632 : rtm, & ! total water mixing ratio, r_t (thermo. levels) [kg/kg]
1633 : wprtp, & ! w' r_t' (momentum levels) [(kg/kg) m/s]
1634 : thlm, & ! liq. water pot. temp., th_l (thermo. levels) [K]
1635 : wpthlp, & ! w' th_l' (momentum levels) [(m/s) K]
1636 : rtp2, & ! r_t'^2 (momentum levels) [(kg/kg)^2]
1637 : rtp3, & ! r_t'^3 (thermodynamic levels) [(kg/kg)^3]
1638 : thlp2, & ! th_l'^2 (momentum levels) [K^2]
1639 : thlp3, & ! th_l'^3 (thermodynamic levels) [K^3]
1640 : rtpthlp, & ! r_t' th_l' (momentum levels) [(kg/kg) K]
1641 : wp2, & ! w'^2 (momentum levels) [m^2/s^2]
1642 : wp3 ! w'^3 (thermodynamic levels) [m^3/s^3]
1643 :
1644 : ! Passive scalar variables
1645 : real( kind = core_rknd ), intent(inout), dimension(ngrdcol,nz,sclr_dim) :: &
1646 : sclrm, & ! Passive scalar mean (thermo. levels) [units vary]
1647 : wpsclrp, & ! w'sclr' (momentum levels) [{units vary} m/s]
1648 : sclrp2, & ! sclr'^2 (momentum levels) [{units vary}^2]
1649 : sclrp3, & ! sclr'^3 (thermodynamic levels) [{units vary}^3]
1650 : sclrprtp, & ! sclr'rt' (momentum levels) [{units vary} (kg/kg)]
1651 : sclrpthlp ! sclr'thl' (momentum levels) [{units vary} K]
1652 :
1653 : real( kind = core_rknd ), intent(inout), dimension(ngrdcol,nz) :: &
1654 : p_in_Pa, & ! Air pressure (thermodynamic levels) [Pa]
1655 : exner ! Exner function (thermodynamic levels) [-]
1656 :
1657 : real( kind = core_rknd ), intent(inout), dimension(ngrdcol,nz) :: &
1658 : rcm, & ! cloud water mixing ratio, r_c (thermo. levels) [kg/kg]
1659 : cloud_frac, & ! cloud fraction (thermodynamic levels) [-]
1660 : wpthvp, & ! < w' th_v' > (momentum levels) [kg/kg K]
1661 : wp2thvp, & ! < w'^2 th_v' > (thermodynamic levels) [m^2/s^2 K]
1662 : rtpthvp, & ! < r_t' th_v' > (momentum levels) [kg/kg K]
1663 : thlpthvp ! < th_l' th_v' > (momentum levels) [K^2]
1664 :
1665 : real( kind = core_rknd ), intent(inout), dimension(ngrdcol,nz,sclr_dim) :: &
1666 : sclrpthvp ! < sclr' th_v' > (momentum levels) [units vary]
1667 :
1668 : real( kind = core_rknd ), intent(inout), dimension(ngrdcol,nz) :: &
1669 : wp2rtp, & ! w'^2 rt' (thermodynamic levels) [m^2/s^2 kg/kg]
1670 : wp2thlp, & ! w'^2 thl' (thermodynamic levels) [m^2/s^2 K]
1671 : uprcp, & ! < u' r_c' > (momentum levels) [(m/s)(kg/kg)]
1672 : vprcp, & ! < v' r_c' > (momentum levels) [(m/s)(kg/kg)]
1673 : rc_coef_zm, & ! Coef of X'r_c' in Eq. (34) (m-levs.) [K/(kg/kg)]
1674 : wp4, & ! w'^4 (momentum levels) [m^4/s^4]
1675 : wpup2, & ! w'u'^2 (thermodynamic levels) [m^3/s^3]
1676 : wpvp2, & ! w'v'^2 (thermodynamic levels) [m^3/s^3]
1677 : wp2up2, & ! w'^2 u'^2 (momentum levels) [m^4/s^4]
1678 : wp2vp2, & ! w'^2 v'^2 (momentum levels) [m^4/s^4]
1679 : ice_supersat_frac ! ice cloud fraction (thermo. levels) [-]
1680 :
1681 : ! Variables used to track perturbed version of winds.
1682 : real( kind = core_rknd ), intent(inout), dimension(ngrdcol,nz) :: &
1683 : um_pert, & ! perturbed <u> [m/s]
1684 : vm_pert, & ! perturbed <v> [m/s]
1685 : upwp_pert, & ! perturbed <u'w'> [m^2/s^2]
1686 : vpwp_pert ! perturbed <v'w'> [m^2/s^2]
1687 :
1688 : type(pdf_parameter), intent(inout) :: &
1689 : pdf_params, & ! PDF parameters (thermodynamic levels) [units vary]
1690 : pdf_params_zm ! PDF parameters on momentum levels [units vary]
1691 :
1692 : type(implicit_coefs_terms), intent(inout) :: &
1693 : pdf_implicit_coefs_terms ! Implicit coefs / explicit terms [units vary]
1694 :
1695 : #ifdef GFDL
1696 : real( kind = core_rknd ), intent(inout), dimension(ngrdcol,nz,sclr_dim) :: & ! h1g, 2010-06-16
1697 : sclrm_trsport_only ! Passive scalar concentration due to pure transport [{units vary}/s]
1698 : #endif
1699 :
1700 : real( kind = core_rknd ), intent(inout), dimension(ngrdcol,nz,edsclr_dim) :: &
1701 : edsclrm ! Eddy passive scalar mean (thermo. levels) [units vary]
1702 :
1703 :
1704 : !------------------------ Output Variables ------------------------
1705 : real( kind = core_rknd ), intent(out), dimension(ngrdcol,nz) :: &
1706 : rcm_in_layer, & ! rcm in cloud layer [kg/kg]
1707 : cloud_cover ! cloud cover [-]
1708 :
1709 : ! Variables that need to be output for use in host models
1710 : real( kind = core_rknd ), intent(out), dimension(ngrdcol,nz) :: &
1711 : wprcp, & ! w'r_c' (momentum levels) [(kg/kg) m/s]
1712 : w_up_in_cloud, & ! Average cloudy updraft velocity [m/s]
1713 : w_down_in_cloud, & ! Average cloudy downdraft velocity [m/s]
1714 : cloudy_updraft_frac, & ! cloudy updraft fraction [-]
1715 : cloudy_downdraft_frac, & ! cloudy downdraft fraction [-]
1716 : invrs_tau_zm ! One divided by tau on zm levels [1/s]
1717 :
1718 : real( kind = core_rknd ), dimension(ngrdcol,nz), intent(out) :: &
1719 : Kh_zt, & ! Eddy diffusivity coefficient on thermodynamic levels [m^2/s]
1720 : Kh_zm ! Eddy diffusivity coefficient on momentum levels [m^2/s]
1721 :
1722 : #ifdef CLUBB_CAM
1723 : real( kind = core_rknd), intent(out), dimension(ngrdcol,nz) :: &
1724 : qclvar ! cloud water variance
1725 : #endif
1726 :
1727 : real( kind = core_rknd ), dimension(ngrdcol,nz), intent(out) :: &
1728 : thlprcp ! thl'rc' [K kg/kg]
1729 :
1730 : integer, intent(inout) :: err_code_api ! Diagnostic, for if some calculation goes amiss.
1731 :
1732 : #ifdef GFDL
1733 : ! hlg, 2010-06-16
1734 : real( kind = core_rknd ), intent(inOUT), dimension(ngrdcol,nz, min(1,sclr_dim) , 2) :: &
1735 : RH_crit ! critical relative humidity for droplet and ice nucleation
1736 : logical, intent(in) :: do_liquid_only_in_clubb
1737 : #endif
1738 :
1739 : !$acc data copyin( gr, gr%zm, gr%zt, gr%dzm, gr%dzt, gr%invrs_dzt, gr%invrs_dzm, &
1740 : !$acc gr%weights_zt2zm, gr%weights_zm2zt, &
1741 : !$acc nu_vert_res_dep, nu_vert_res_dep%nu2, nu_vert_res_dep%nu9, &
1742 : !$acc nu_vert_res_dep%nu1, nu_vert_res_dep%nu8, nu_vert_res_dep%nu10, &
1743 : !$acc nu_vert_res_dep%nu6, &
1744 : !$acc sclr_idx, clubb_params, &
1745 : !$acc fcor, sfc_elevation, thlm_forcing, rtm_forcing, um_forcing, &
1746 : !$acc vm_forcing, wprtp_forcing, wpthlp_forcing, rtp2_forcing, thlp2_forcing, &
1747 : !$acc rtpthlp_forcing, wm_zm, wm_zt, rho_zm, rho, rho_ds_zm, rho_ds_zt, &
1748 : !$acc invrs_rho_ds_zm, invrs_rho_ds_zt, thv_ds_zm, thv_ds_zt, rfrzm, &
1749 : !$acc radf, wpthlp_sfc, &
1750 : !$acc wprtp_sfc, upwp_sfc, vpwp_sfc, &
1751 : !$acc upwp_sfc_pert, vpwp_sfc_pert, rtm_ref, thlm_ref, um_ref, &
1752 : !$acc vm_ref, ug, vg, host_dx, host_dy, &
1753 : !$acc pdf_params, pdf_params_zm ) &
1754 : !$acc copy( um, upwp, vm, vpwp, up2, vp2, up3, vp3, rtm, wprtp, thlm, wpthlp, rtp2, &
1755 : !$acc rtp3, thlp2, thlp3, rtpthlp, wp2, wp3, &
1756 : !$acc p_in_Pa, exner, rcm, cloud_frac, wpthvp, wp2thvp, &
1757 : !$acc rtpthvp, thlpthvp, wp2rtp, wp2thlp, uprcp, vprcp, rc_coef_zm, &
1758 : !$acc wp4, wpup2, wpvp2, wp2up2, wp2vp2, ice_supersat_frac, um_pert, &
1759 : !$acc vm_pert, upwp_pert, vpwp_pert, &
1760 : !$acc pdf_params%w_1, pdf_params%w_2, &
1761 : !$acc pdf_params%varnce_w_1, pdf_params%varnce_w_2, &
1762 : !$acc pdf_params%rt_1, pdf_params%rt_2, &
1763 : !$acc pdf_params%varnce_rt_1, pdf_params%varnce_rt_2, &
1764 : !$acc pdf_params%thl_1, pdf_params%thl_2, &
1765 : !$acc pdf_params%varnce_thl_1, pdf_params%varnce_thl_2, &
1766 : !$acc pdf_params%corr_w_rt_1, pdf_params%corr_w_rt_2, &
1767 : !$acc pdf_params%corr_w_thl_1, pdf_params%corr_w_thl_2, &
1768 : !$acc pdf_params%corr_rt_thl_1, pdf_params%corr_rt_thl_2,&
1769 : !$acc pdf_params%alpha_thl, pdf_params%alpha_rt, &
1770 : !$acc pdf_params%crt_1, pdf_params%crt_2, pdf_params%cthl_1, &
1771 : !$acc pdf_params%cthl_2, pdf_params%chi_1, &
1772 : !$acc pdf_params%chi_2, pdf_params%stdev_chi_1, &
1773 : !$acc pdf_params%stdev_chi_2, pdf_params%stdev_eta_1, &
1774 : !$acc pdf_params%stdev_eta_2, pdf_params%covar_chi_eta_1, &
1775 : !$acc pdf_params%covar_chi_eta_2, pdf_params%corr_w_chi_1, &
1776 : !$acc pdf_params%corr_w_chi_2, pdf_params%corr_w_eta_1, &
1777 : !$acc pdf_params%corr_w_eta_2, pdf_params%corr_chi_eta_1, &
1778 : !$acc pdf_params%corr_chi_eta_2, pdf_params%rsatl_1, &
1779 : !$acc pdf_params%rsatl_2, pdf_params%rc_1, pdf_params%rc_2, &
1780 : !$acc pdf_params%cloud_frac_1, pdf_params%cloud_frac_2, &
1781 : !$acc pdf_params%mixt_frac, pdf_params%ice_supersat_frac_1, &
1782 : !$acc pdf_params%ice_supersat_frac_2, &
1783 : !$acc pdf_params_zm%w_1, pdf_params_zm%w_2, &
1784 : !$acc pdf_params_zm%varnce_w_1, pdf_params_zm%varnce_w_2, &
1785 : !$acc pdf_params_zm%rt_1, pdf_params_zm%rt_2, &
1786 : !$acc pdf_params_zm%varnce_rt_1, pdf_params_zm%varnce_rt_2, &
1787 : !$acc pdf_params_zm%thl_1, pdf_params_zm%thl_2, &
1788 : !$acc pdf_params_zm%varnce_thl_1, pdf_params_zm%varnce_thl_2, &
1789 : !$acc pdf_params_zm%corr_w_rt_1, pdf_params_zm%corr_w_rt_2, &
1790 : !$acc pdf_params_zm%corr_w_thl_1, pdf_params_zm%corr_w_thl_2, &
1791 : !$acc pdf_params_zm%corr_rt_thl_1, pdf_params_zm%corr_rt_thl_2,&
1792 : !$acc pdf_params_zm%alpha_thl, pdf_params_zm%alpha_rt, &
1793 : !$acc pdf_params_zm%crt_1, pdf_params_zm%crt_2, pdf_params_zm%cthl_1, &
1794 : !$acc pdf_params_zm%cthl_2, pdf_params_zm%chi_1, &
1795 : !$acc pdf_params_zm%chi_2, pdf_params_zm%stdev_chi_1, &
1796 : !$acc pdf_params_zm%stdev_chi_2, pdf_params_zm%stdev_eta_1, &
1797 : !$acc pdf_params_zm%stdev_eta_2, pdf_params_zm%covar_chi_eta_1, &
1798 : !$acc pdf_params_zm%covar_chi_eta_2, pdf_params_zm%corr_w_chi_1, &
1799 : !$acc pdf_params_zm%corr_w_chi_2, pdf_params_zm%corr_w_eta_1, &
1800 : !$acc pdf_params_zm%corr_w_eta_2, pdf_params_zm%corr_chi_eta_1, &
1801 : !$acc pdf_params_zm%corr_chi_eta_2, pdf_params_zm%rsatl_1, &
1802 : !$acc pdf_params_zm%rsatl_2, pdf_params_zm%rc_1, pdf_params_zm%rc_2, &
1803 : !$acc pdf_params_zm%cloud_frac_1, pdf_params_zm%cloud_frac_2, &
1804 : !$acc pdf_params_zm%mixt_frac, pdf_params_zm%ice_supersat_frac_1, &
1805 : !$acc pdf_params_zm%ice_supersat_frac_2 ) &
1806 : !$acc copyout( rcm_in_layer, cloud_cover, wprcp, w_up_in_cloud, w_down_in_cloud, &
1807 : !$acc cloudy_updraft_frac, cloudy_downdraft_frac, invrs_tau_zm, Kh_zt, &
1808 : !$acc Kh_zm, &
1809 : !$acc thlprcp )
1810 :
1811 : !$acc data if( sclr_dim > 0 ) &
1812 : !$acc copyin( sclr_tol, sclrm_forcing, wpsclrp_sfc ) &
1813 : !$acc copy( sclrm, wpsclrp, sclrp2, sclrp3, sclrprtp, sclrpthlp, sclrpthvp )
1814 :
1815 : !$acc data if( edsclr_dim > 0 ) &
1816 : !$acc copyin( wpedsclrp_sfc, edsclrm_forcing ) &
1817 : !$acc copy( edsclrm )
1818 :
1819 : !$acc data if( hydromet_dim > 0 ) &
1820 : !$acc copyin( hydromet, wphydrometp, wp2hmp, rtphmp_zt, thlphmp_zt, &
1821 : !$acc l_mix_rat_hm )
1822 :
1823 : #ifdef CLUBB_CAM
1824 : !$acc data copyout( qclvar )
1825 : #endif
1826 :
1827 : #ifdef CLUBBND_CAM
1828 : !$acc data copyin( varmu )
1829 : #endif
1830 :
1831 : #ifdef GFDL
1832 : !$acc data if( sclr_dim > 0 ) copy( sclrm_trsport_only )
1833 : #endif
1834 :
1835 : call advance_clubb_core( gr, nz, ngrdcol, &
1836 : l_implemented, dt, fcor, sfc_elevation, & ! intent(in)
1837 : hydromet_dim, & ! intent(in)
1838 : sclr_dim, sclr_tol, edsclr_dim, sclr_idx, & ! intent(in)
1839 : thlm_forcing, rtm_forcing, um_forcing, vm_forcing, & ! intent(in)
1840 : sclrm_forcing, edsclrm_forcing, wprtp_forcing, & ! intent(in)
1841 : wpthlp_forcing, rtp2_forcing, thlp2_forcing, & ! intent(in)
1842 : rtpthlp_forcing, wm_zm, wm_zt, & ! intent(in)
1843 : wpthlp_sfc, wprtp_sfc, upwp_sfc, vpwp_sfc, & ! intent(in)
1844 : wpsclrp_sfc, wpedsclrp_sfc, & ! intent(in)
1845 : upwp_sfc_pert, vpwp_sfc_pert, & ! intent(in)
1846 : rtm_ref, thlm_ref, um_ref, vm_ref, ug, vg, & ! Intent(in)
1847 : p_in_Pa, rho_zm, rho, exner, & ! intent(in)
1848 : rho_ds_zm, rho_ds_zt, invrs_rho_ds_zm, & ! intent(in)
1849 : invrs_rho_ds_zt, thv_ds_zm, thv_ds_zt, & ! intent(in)
1850 : hydromet, l_mix_rat_hm,& ! intent(in)
1851 : rfrzm, radf, & ! intent(in)
1852 : #ifdef CLUBBND_CAM
1853 : varmu, &
1854 : #endif
1855 : wphydrometp, wp2hmp, rtphmp_zt, thlphmp_zt, & ! intent(in)
1856 : host_dx, host_dy, & ! intent(in)
1857 : clubb_params, nu_vert_res_dep, lmin, & ! intent(in)
1858 : clubb_config_flags, & ! intent(in)
1859 : stats_metadata, & ! intent(in)
1860 : stats_zt, stats_zm, stats_sfc, & ! intent(inout)
1861 : um, vm, upwp, vpwp, up2, vp2, up3, vp3, & ! intent(inout)
1862 : thlm, rtm, wprtp, wpthlp, & ! intent(inout)
1863 : wp2, wp3, rtp2, rtp3, thlp2, thlp3, rtpthlp, & ! intent(inout)
1864 : sclrm, &
1865 : #ifdef GFDL
1866 : sclrm_trsport_only, & ! h1g, 2010-06-16 ! intent(inout)
1867 : #endif
1868 : sclrp2, sclrp3, sclrprtp, sclrpthlp, & ! intent(inout)
1869 : wpsclrp, edsclrm, & ! intent(inout)
1870 : rcm, cloud_frac, & ! intent(inout)
1871 : wpthvp, wp2thvp, rtpthvp, thlpthvp, & ! intent(inout)
1872 : sclrpthvp, & ! intent(inout)
1873 : wp2rtp, wp2thlp, uprcp, vprcp, rc_coef_zm, wp4, & ! intent(inout)
1874 : wpup2, wpvp2, wp2up2, wp2vp2, ice_supersat_frac, & ! intent(inout)
1875 : um_pert, vm_pert, upwp_pert, vpwp_pert, & ! intent(inout)
1876 : pdf_params, pdf_params_zm, & ! intent(inout)
1877 : pdf_implicit_coefs_terms, & ! intent(inout)
1878 : #ifdef GFDL
1879 : RH_crit, & !h1g, 2010-06-16 ! intent(inout)
1880 : do_liquid_only_in_clubb, & ! intent(in)
1881 : #endif
1882 : Kh_zm, Kh_zt, & ! intent(out)
1883 : #ifdef CLUBB_CAM
1884 : qclvar, & ! intent(out)
1885 : #endif
1886 : thlprcp, wprcp, w_up_in_cloud, w_down_in_cloud, & ! intent(out)
1887 : cloudy_updraft_frac, cloudy_downdraft_frac, & ! intent(out)
1888 : rcm_in_layer, cloud_cover, invrs_tau_zm, & ! intent(out)
1889 8935056 : err_code_api ) ! intent(out)
1890 :
1891 : !$acc end data
1892 : !$acc end data
1893 : !$acc end data
1894 : !$acc end data
1895 :
1896 : #ifdef CLUBB_CAM
1897 : !$acc end data
1898 : #endif
1899 :
1900 : #ifdef CLUBBND_CAM
1901 : !$acc end data
1902 : #endif
1903 :
1904 : #ifdef GFDL
1905 : !$acc end data
1906 : #endif
1907 :
1908 :
1909 8935056 : end subroutine advance_clubb_core_api_multi_col
1910 :
1911 : !================================================================================================
1912 : ! cleanup_clubb_core_api - Frees memory used by the model.
1913 : !================================================================================================
1914 :
1915 0 : subroutine cleanup_clubb_core_api( gr )
1916 :
1917 : use advance_clubb_core_module, only : cleanup_clubb_core
1918 :
1919 :
1920 :
1921 : implicit none
1922 :
1923 : type(grid), target, intent(inout) :: gr
1924 0 : call cleanup_clubb_core( gr ) ! intent(inout)
1925 :
1926 0 : end subroutine cleanup_clubb_core_api
1927 :
1928 : !================================================================================================
1929 : ! gregorian2julian_day - Computes the number of days since 1 January 4713 BC.
1930 : !================================================================================================
1931 :
1932 0 : integer function gregorian2julian_day_api( &
1933 : day, month, year )
1934 :
1935 : use calendar, only : gregorian2julian_day
1936 :
1937 : implicit none
1938 :
1939 : ! Input Variables
1940 : integer, intent(in) :: &
1941 : day, & ! Gregorian Calendar Day for given Month [dd]
1942 : month, & ! Gregorian Calendar Month for given Year [mm]
1943 : year ! Gregorian Calendar Year [yyyy]
1944 :
1945 : gregorian2julian_day_api = gregorian2julian_day( &
1946 0 : day, month, year )
1947 0 : end function gregorian2julian_day_api
1948 :
1949 : !================================================================================================
1950 : ! compute_current_date - Computes the current date and the seconds since that date.
1951 : !================================================================================================
1952 :
1953 0 : subroutine compute_current_date_api( &
1954 : previous_day, previous_month, &
1955 : previous_year, &
1956 : seconds_since_previous_date, &
1957 : current_day, current_month, &
1958 : current_year, &
1959 : seconds_since_current_date )
1960 :
1961 : use calendar, only : compute_current_date
1962 :
1963 : implicit none
1964 :
1965 : ! Previous date
1966 : integer, intent(in) :: &
1967 : previous_day, & ! Day of the month [dd]
1968 : previous_month, & ! Month of the year [mm]
1969 : previous_year ! Year [yyyy]
1970 :
1971 : real(kind=time_precision), intent(in) :: &
1972 : seconds_since_previous_date ! [s]
1973 :
1974 : ! Output Variable(s)
1975 :
1976 : ! Current date
1977 : integer, intent(out) :: &
1978 : current_day, & ! Day of the month [dd]
1979 : current_month, & ! Month of the year [mm]
1980 : current_year ! Year [yyyy]
1981 :
1982 : real(kind=time_precision), intent(out) :: &
1983 : seconds_since_current_date
1984 :
1985 : call compute_current_date( &
1986 : previous_day, previous_month, & ! intent(in)
1987 : previous_year, & ! intent(in)
1988 : seconds_since_previous_date, & ! intent(in)
1989 : current_day, current_month, & ! intent(out)
1990 : current_year, & ! intent(out)
1991 0 : seconds_since_current_date ) ! intent(out)
1992 0 : end subroutine compute_current_date_api
1993 :
1994 : !================================================================================================
1995 : ! leap_year - Determines if the given year is a leap year.
1996 : !================================================================================================
1997 :
1998 0 : logical function leap_year_api( &
1999 : year )
2000 :
2001 : use calendar, only : leap_year
2002 :
2003 : implicit none
2004 :
2005 : ! External
2006 : intrinsic :: mod
2007 :
2008 : ! Input Variable(s)
2009 : integer, intent(in) :: year ! Gregorian Calendar Year [yyyy]
2010 :
2011 : leap_year_api = leap_year( &
2012 0 : year )
2013 0 : end function leap_year_api
2014 :
2015 : !================================================================================================
2016 : ! set_clubb_debug_level - Controls the importance of error messages sent to the console.
2017 : !================================================================================================
2018 :
2019 1536 : subroutine set_clubb_debug_level_api( &
2020 : level )
2021 :
2022 : use error_code, only: &
2023 : set_clubb_debug_level ! Procedure
2024 :
2025 : implicit none
2026 :
2027 : ! Input variable
2028 : integer, intent(in) :: level ! The debug level being checked against the current setting
2029 :
2030 : call set_clubb_debug_level( &
2031 1536 : level ) ! intent(in)
2032 1536 : end subroutine set_clubb_debug_level_api
2033 :
2034 : !================================================================================================
2035 : ! clubb_at_least_debug_level - Checks to see if clubb has been set to a specified debug level.
2036 : !================================================================================================
2037 :
2038 0 : logical function clubb_at_least_debug_level_api( &
2039 : level )
2040 :
2041 : use error_code, only: &
2042 : clubb_at_least_debug_level ! Procedure
2043 :
2044 : implicit none
2045 :
2046 : ! Input variable
2047 : integer, intent(in) :: level ! The debug level being checked against the current setting
2048 :
2049 : clubb_at_least_debug_level_api = clubb_at_least_debug_level( &
2050 0 : level )
2051 0 : end function clubb_at_least_debug_level_api
2052 :
2053 : !================================================================================================
2054 : ! vertical_integral - Computes the vertical integral.
2055 : !================================================================================================
2056 :
2057 0 : function vertical_integral_api( &
2058 0 : total_idx, rho_ds, &
2059 0 : field, dz )
2060 :
2061 : use advance_helper_module, only : vertical_integral
2062 :
2063 : implicit none
2064 :
2065 : ! Input variables
2066 : integer, intent(in) :: &
2067 : total_idx ! The total numer of indices within the range of averaging
2068 :
2069 : real( kind = core_rknd ), dimension(total_idx), intent(in) :: &
2070 : rho_ds, & ! Dry, static density [kg/m^3]
2071 : field, & ! The field to be vertically averaged [Units vary]
2072 : dz ! Level thickness [1/m]
2073 : ! Note: The rho_ds and field points need to be arranged from
2074 : ! lowest to highest in altitude, with rho_ds(1) and
2075 : ! field(1) actually their respective values at level k = begin_idx.
2076 :
2077 : real( kind = core_rknd ) :: &
2078 : vertical_integral_api ! Integral in the numerator (see description)
2079 :
2080 : vertical_integral_api = vertical_integral( &
2081 : total_idx, rho_ds, &
2082 0 : field, dz )
2083 0 : end function vertical_integral_api
2084 :
2085 : !================================================================================================
2086 : ! setup_grid_heights - Sets the heights and interpolation weights of the column.
2087 : !================================================================================================
2088 :
2089 0 : subroutine setup_grid_heights_api_single_col( &
2090 : l_implemented, grid_type, &
2091 0 : deltaz, zm_init, momentum_heights, &
2092 0 : gr, thermodynamic_heights )
2093 :
2094 : use grid_class, only: &
2095 : grid, & ! Type
2096 : setup_grid_heights
2097 :
2098 : use error_code, only : &
2099 : clubb_fatal_error ! Constant
2100 :
2101 : implicit none
2102 :
2103 : ! Input Variables
2104 :
2105 : type(grid), target, intent(inout) :: gr
2106 :
2107 : ! Flag to see if CLUBB is running on it's own,
2108 : ! or if it's implemented as part of a host model.
2109 : logical, intent(in) :: l_implemented
2110 :
2111 : ! If CLUBB is running on it's own, this option determines if it is using:
2112 : ! 1) an evenly-spaced grid;
2113 : ! 2) a stretched (unevenly-spaced) grid entered on the thermodynamic grid
2114 : ! levels (with momentum levels set halfway between thermodynamic levels);
2115 : ! or
2116 : ! 3) a stretched (unevenly-spaced) grid entered on the momentum grid levels
2117 : ! (with thermodynamic levels set halfway between momentum levels).
2118 : integer, intent(in) :: grid_type
2119 :
2120 : ! If the CLUBB model is running by itself, and is using an evenly-spaced
2121 : ! grid (grid_type = 1), it needs the vertical grid spacing and
2122 : ! momentum-level starting altitude as input.
2123 : real( kind = core_rknd ), intent(in) :: &
2124 : deltaz, & ! Vertical grid spacing [m]
2125 : zm_init ! Initial grid altitude (momentum level) [m]
2126 :
2127 :
2128 : ! If the CLUBB parameterization is implemented in a host model, it needs to
2129 : ! use the host model's momentum level altitudes and thermodynamic level
2130 : ! altitudes.
2131 : ! If the CLUBB model is running by itself, but is using a stretched grid
2132 : ! entered on thermodynamic levels (grid_type = 2), it needs to use the
2133 : ! thermodynamic level altitudes as input.
2134 : ! If the CLUBB model is running by itself, but is using a stretched grid
2135 : ! entered on momentum levels (grid_type = 3), it needs to use the momentum
2136 : ! level altitudes as input.
2137 : real( kind = core_rknd ), intent(in), dimension(gr%nz) :: &
2138 : momentum_heights, & ! Momentum level altitudes (input) [m]
2139 : thermodynamic_heights ! Thermodynamic level altitudes (input) [m]
2140 :
2141 : ! ------------------- Local Variables -------------------
2142 :
2143 : real( kind = core_rknd ), dimension(1) :: &
2144 : deltaz_col, & ! Vertical grid spacing [m]
2145 : zm_init_col ! Initial grid altitude (momentum level) [m]
2146 :
2147 : real( kind = core_rknd ), dimension(1,gr%nz) :: &
2148 0 : momentum_heights_col, & ! Momentum level altitudes (input) [m]
2149 0 : thermodynamic_heights_col ! Thermodynamic level altitudes (input) [m]
2150 :
2151 0 : deltaz_col(1) = deltaz
2152 0 : zm_init_col(1) = zm_init
2153 0 : momentum_heights_col(1,:) = momentum_heights
2154 0 : thermodynamic_heights_col(1,:) = thermodynamic_heights
2155 :
2156 : call setup_grid_heights( &
2157 : gr%nz, 1, & ! intent(in)
2158 : l_implemented, grid_type, & ! intent(in)
2159 : deltaz_col, zm_init_col, momentum_heights_col, & ! intent(in)
2160 : thermodynamic_heights_col, & ! intent(in)
2161 0 : gr ) ! intent(inout)
2162 :
2163 0 : if ( err_code == clubb_fatal_error ) error stop
2164 :
2165 0 : end subroutine setup_grid_heights_api_single_col
2166 :
2167 : !================================================================================================
2168 : ! setup_grid_heights - Sets the heights and interpolation weights of the column.
2169 : !================================================================================================
2170 :
2171 0 : subroutine setup_grid_heights_api_multi_col( &
2172 : nz, ngrdcol, &
2173 : l_implemented, grid_type, &
2174 0 : deltaz, zm_init, momentum_heights, &
2175 0 : gr, thermodynamic_heights )
2176 :
2177 : use grid_class, only: &
2178 : grid, & ! Type
2179 : setup_grid_heights
2180 :
2181 : use error_code, only : &
2182 : clubb_fatal_error ! Constant
2183 :
2184 : implicit none
2185 :
2186 : ! Input Variables
2187 : integer, intent(in) :: &
2188 : nz, &
2189 : ngrdcol
2190 :
2191 : type (grid), target, intent(inout) :: gr
2192 :
2193 : ! Flag to see if CLUBB is running on it's own,
2194 : ! or if it's implemented as part of a host model.
2195 : logical, intent(in) :: l_implemented
2196 :
2197 : ! If CLUBB is running on it's own, this option determines if it is using:
2198 : ! 1) an evenly-spaced grid;
2199 : ! 2) a stretched (unevenly-spaced) grid entered on the thermodynamic grid
2200 : ! levels (with momentum levels set halfway between thermodynamic levels);
2201 : ! or
2202 : ! 3) a stretched (unevenly-spaced) grid entered on the momentum grid levels
2203 : ! (with thermodynamic levels set halfway between momentum levels).
2204 : integer, intent(in) :: grid_type
2205 :
2206 : ! If the CLUBB model is running by itself, and is using an evenly-spaced
2207 : ! grid (grid_type = 1), it needs the vertical grid spacing and
2208 : ! momentum-level starting altitude as input.
2209 : real( kind = core_rknd ), dimension(ngrdcol), intent(in) :: &
2210 : deltaz, & ! Vertical grid spacing [m]
2211 : zm_init ! Initial grid altitude (momentum level) [m]
2212 :
2213 :
2214 : ! If the CLUBB parameterization is implemented in a host model, it needs to
2215 : ! use the host model's momentum level altitudes and thermodynamic level
2216 : ! altitudes.
2217 : ! If the CLUBB model is running by itself, but is using a stretched grid
2218 : ! entered on thermodynamic levels (grid_type = 2), it needs to use the
2219 : ! thermodynamic level altitudes as input.
2220 : ! If the CLUBB model is running by itself, but is using a stretched grid
2221 : ! entered on momentum levels (grid_type = 3), it needs to use the momentum
2222 : ! level altitudes as input.
2223 : real( kind = core_rknd ), intent(in), dimension(ngrdcol,nz) :: &
2224 : momentum_heights, & ! Momentum level altitudes (input) [m]
2225 : thermodynamic_heights ! Thermodynamic level altitudes (input) [m]
2226 :
2227 : call setup_grid_heights( &
2228 : nz, ngrdcol, & ! intent(in)
2229 : l_implemented, grid_type, & ! intent(in)
2230 : deltaz, zm_init, momentum_heights, & ! intent(in)
2231 : thermodynamic_heights, & ! intent(in)
2232 0 : gr ) ! intent(inout)
2233 :
2234 0 : if ( err_code == clubb_fatal_error ) error stop
2235 :
2236 0 : end subroutine setup_grid_heights_api_multi_col
2237 :
2238 : !================================================================================================
2239 : ! setup_grid - This subroutine sets up the CLUBB vertical grid for a single column
2240 : !================================================================================================
2241 0 : subroutine setup_grid_api_single_col( nzmax, sfc_elevation, l_implemented, &
2242 : grid_type, deltaz, zm_init, zm_top, &
2243 0 : momentum_heights, thermodynamic_heights, &
2244 : gr )
2245 :
2246 : use grid_class, only: &
2247 : grid, & ! Type
2248 : setup_grid
2249 :
2250 : implicit none
2251 :
2252 : ! Input Variables
2253 : integer, intent(in) :: &
2254 : nzmax ! Number of vertical levels in grid [#]
2255 :
2256 : type(grid), target, intent(inout) :: gr
2257 :
2258 : real( kind = core_rknd ), intent(in) :: &
2259 : sfc_elevation ! Elevation of ground level [m AMSL]
2260 :
2261 : logical, intent(in) :: l_implemented
2262 :
2263 : integer, intent(in) :: grid_type
2264 :
2265 : real( kind = core_rknd ), intent(in) :: &
2266 : deltaz, & ! Vertical grid spacing [m]
2267 : zm_init, & ! Initial grid altitude (momentum level) [m]
2268 : zm_top ! Maximum grid altitude (momentum level) [m]
2269 :
2270 : real( kind = core_rknd ), intent(in), dimension(nzmax) :: &
2271 : momentum_heights, & ! Momentum level altitudes (input) [m]
2272 : thermodynamic_heights ! Thermodynamic level altitudes (input) [m]
2273 :
2274 : real( kind = core_rknd ), dimension(1) :: &
2275 : sfc_elevation_col ! Elevation of ground level [m AMSL]
2276 :
2277 : real( kind = core_rknd ), dimension(1) :: &
2278 : deltaz_col, & ! Vertical grid spacing [m]
2279 : zm_init_col, & ! Initial grid altitude (momentum level) [m]
2280 : zm_top_col ! Maximum grid altitude (momentum level) [m]
2281 :
2282 : real( kind = core_rknd ), dimension(1,nzmax) :: &
2283 0 : momentum_heights_col, & ! Momentum level altitudes (input) [m]
2284 0 : thermodynamic_heights_col ! Thermodynamic level altitudes (input) [m]
2285 :
2286 0 : sfc_elevation_col(1) = sfc_elevation
2287 0 : deltaz_col(1) = deltaz
2288 0 : zm_init_col(1) = zm_init
2289 0 : zm_top_col(1) = zm_top
2290 0 : momentum_heights_col(1,:) = momentum_heights
2291 0 : thermodynamic_heights_col(1,:) = thermodynamic_heights
2292 :
2293 : call setup_grid( nzmax, 1, sfc_elevation_col, l_implemented, & ! intent(in)
2294 : grid_type, deltaz_col, zm_init_col, zm_top_col, & ! intent(in)
2295 : momentum_heights_col, thermodynamic_heights_col, & ! intent(in)
2296 0 : gr ) ! intent(out)
2297 :
2298 0 : end subroutine setup_grid_api_single_col
2299 :
2300 : !================================================================================================
2301 : ! setup_grid - This subroutine sets up the CLUBB vertical grid.
2302 : !================================================================================================
2303 4467528 : subroutine setup_grid_api_multi_col( nzmax, ngrdcol, sfc_elevation, l_implemented, &
2304 4467528 : grid_type, deltaz, zm_init, zm_top, &
2305 4467528 : momentum_heights, thermodynamic_heights, &
2306 : gr )
2307 :
2308 : use grid_class, only: &
2309 : grid, & ! Type
2310 : setup_grid
2311 :
2312 : implicit none
2313 :
2314 : ! Input Variables
2315 : integer, intent(in) :: &
2316 : nzmax, & ! Number of vertical levels in grid [#]
2317 : ngrdcol ! Number of grid columns [#]
2318 :
2319 : type (grid), target, intent(inout) :: gr
2320 :
2321 : real( kind = core_rknd ), dimension(ngrdcol), intent(in) :: &
2322 : sfc_elevation ! Elevation of ground level [m AMSL]
2323 :
2324 : logical, intent(in) :: l_implemented
2325 :
2326 : integer, intent(in) :: grid_type
2327 :
2328 : real( kind = core_rknd ), dimension(ngrdcol), intent(in) :: &
2329 : deltaz, & ! Vertical grid spacing [m]
2330 : zm_init, & ! Initial grid altitude (momentum level) [m]
2331 : zm_top ! Maximum grid altitude (momentum level) [m]
2332 :
2333 : real( kind = core_rknd ), intent(in), dimension(ngrdcol,nzmax) :: &
2334 : momentum_heights, & ! Momentum level altitudes (input) [m]
2335 : thermodynamic_heights ! Thermodynamic level altitudes (input) [m]
2336 :
2337 :
2338 : call setup_grid( nzmax, ngrdcol, sfc_elevation, l_implemented, & ! intent(in)
2339 : grid_type, deltaz, zm_init, zm_top, & ! intent(in)
2340 : momentum_heights, thermodynamic_heights, & ! intent(in)
2341 4467528 : gr ) ! intent(out)
2342 :
2343 4467528 : end subroutine setup_grid_api_multi_col
2344 :
2345 : !================================================================================================
2346 : ! lin_interpolate_two_points - Computes a linear interpolation of the value of a variable.
2347 : !================================================================================================
2348 :
2349 0 : function lin_interpolate_two_points_api( &
2350 : height_int, height_high, height_low, &
2351 : var_high, var_low )
2352 :
2353 : use interpolation, only : lin_interpolate_two_points
2354 :
2355 : implicit none
2356 :
2357 : real( kind = core_rknd ), intent(in) :: &
2358 : height_int, & ! Height to be interpolated to [m]
2359 : height_high, & ! Height above the interpolation [m]
2360 : height_low, & ! Height below the interpolation [m]
2361 : var_high, & ! Variable above the interpolation [units vary]
2362 : var_low ! Variable below the interpolation [units vary]
2363 :
2364 : ! Output Variables
2365 : real( kind = core_rknd ) :: lin_interpolate_two_points_api
2366 :
2367 : lin_interpolate_two_points_api = lin_interpolate_two_points( &
2368 : height_int, height_high, height_low, &
2369 0 : var_high, var_low )
2370 :
2371 0 : end function lin_interpolate_two_points_api
2372 :
2373 : !================================================================================================
2374 : ! lin_interpolate_on_grid - Linear interpolation for 25 June 1996 altocumulus case.
2375 : !================================================================================================
2376 :
2377 0 : subroutine lin_interpolate_on_grid_api( &
2378 0 : nparam, xlist, tlist, xvalue, tvalue )
2379 :
2380 : use interpolation, only : lin_interpolate_on_grid
2381 :
2382 : implicit none
2383 :
2384 : ! Input Variables
2385 : integer, intent(in) :: nparam ! Number of parameters in xlist and tlist
2386 :
2387 : ! Input/Output Variables
2388 : real( kind = core_rknd ), intent(inout), dimension(nparam) :: &
2389 : xlist, & ! List of x-values (independent variable)
2390 : tlist ! List of t-values (dependent variable)
2391 :
2392 : real( kind = core_rknd ), intent(in) :: &
2393 : xvalue ! x-value at which to interpolate
2394 :
2395 : real( kind = core_rknd ), intent(inout) :: &
2396 : tvalue ! t-value solved by interpolation
2397 :
2398 : call lin_interpolate_on_grid( &
2399 : nparam, xlist, tlist, xvalue, & ! intent(in)
2400 0 : tvalue ) ! intent(inout)
2401 :
2402 0 : end subroutine lin_interpolate_on_grid_api
2403 :
2404 : !================================================================================================
2405 : ! read_parameters - Read a namelist containing the model parameters.
2406 : !================================================================================================
2407 :
2408 1536 : subroutine read_parameters_api( ngrdcol, iunit, filename, &
2409 : C1, C1b, C1c, C2rt, C2thl, C2rtthl, &
2410 : C4, C_uu_shr, C_uu_buoy, C6rt, C6rtb, C6rtc, &
2411 : C6thl, C6thlb, C6thlc, C7, C7b, C7c, C8, C8b, C10, &
2412 : C11, C11b, C11c, C12, C13, C14, C_wp2_pr_dfsn, C_wp3_pr_tp, &
2413 : C_wp3_pr_turb, C_wp3_pr_dfsn, C_wp2_splat, &
2414 : C6rt_Lscale0, C6thl_Lscale0, C7_Lscale0, wpxp_L_thresh, &
2415 : c_K, c_K1, nu1, c_K2, nu2, c_K6, nu6, c_K8, nu8, &
2416 : c_K9, nu9, nu10, c_K_hm, c_K_hmb, K_hm_min_coef, nu_hm, &
2417 : slope_coef_spread_DG_means_w, pdf_component_stdev_factor_w, &
2418 : coef_spread_DG_means_rt, coef_spread_DG_means_thl, &
2419 : gamma_coef, gamma_coefb, gamma_coefc, mu, beta, lmin_coef, &
2420 : omicron, zeta_vrnce_rat, upsilon_precip_frac_rat, &
2421 : lambda0_stability_coef, mult_coef, taumin, taumax, &
2422 : Lscale_mu_coef, Lscale_pert_coef, alpha_corr, &
2423 : Skw_denom_coef, c_K10, c_K10h, thlp2_rad_coef, &
2424 : thlp2_rad_cloud_frac_thresh, up2_sfc_coef, &
2425 : Skw_max_mag, xp3_coef_base, xp3_coef_slope, &
2426 : altitude_threshold, rtp2_clip_coef, C_invrs_tau_bkgnd, &
2427 : C_invrs_tau_sfc, C_invrs_tau_shear, C_invrs_tau_N2, &
2428 : C_invrs_tau_N2_wp2, C_invrs_tau_N2_xp2, &
2429 : C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, &
2430 : C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, &
2431 : Cx_min, Cx_max, Richardson_num_min, Richardson_num_max, &
2432 : wpxp_Ri_exp, a3_coef_min, a_const, bv_efold, z_displace, &
2433 : clubb_params )
2434 :
2435 : use parameters_tunable, only : read_parameters
2436 :
2437 : use parameter_indices, only: &
2438 : nparams ! Variable(s)
2439 :
2440 : implicit none
2441 :
2442 : ! Input variables
2443 : integer, intent(in) :: &
2444 : ngrdcol
2445 :
2446 : integer, intent(in) :: iunit
2447 :
2448 : character(len=*), intent(in) :: filename
2449 :
2450 : ! Input/Output variables
2451 : real( kind = core_rknd ), intent(inout) :: &
2452 : C1, C1b, C1c, C2rt, C2thl, C2rtthl, &
2453 : C4, C_uu_shr, C_uu_buoy, C6rt, C6rtb, C6rtc, C6thl, C6thlb, C6thlc, &
2454 : C7, C7b, C7c, C8, C8b, C10, &
2455 : C11, C11b, C11c, C12, C13, C14, C_wp2_pr_dfsn, C_wp3_pr_tp, &
2456 : C_wp3_pr_turb, C_wp3_pr_dfsn, C_wp2_splat, &
2457 : C6rt_Lscale0, C6thl_Lscale0, C7_Lscale0, wpxp_L_thresh, &
2458 : c_K, c_K1, nu1, c_K2, nu2, c_K6, nu6, c_K8, nu8, &
2459 : c_K9, nu9, nu10, c_K_hm, c_K_hmb, K_hm_min_coef, nu_hm, &
2460 : slope_coef_spread_DG_means_w, pdf_component_stdev_factor_w, &
2461 : coef_spread_DG_means_rt, coef_spread_DG_means_thl, &
2462 : gamma_coef, gamma_coefb, gamma_coefc, mu, beta, lmin_coef, &
2463 : omicron, zeta_vrnce_rat, upsilon_precip_frac_rat, &
2464 : lambda0_stability_coef, mult_coef, taumin, taumax, Lscale_mu_coef, &
2465 : Lscale_pert_coef, alpha_corr, Skw_denom_coef, c_K10, c_K10h, &
2466 : thlp2_rad_coef, thlp2_rad_cloud_frac_thresh, up2_sfc_coef, &
2467 : Skw_max_mag, xp3_coef_base, xp3_coef_slope, altitude_threshold, &
2468 : rtp2_clip_coef, C_invrs_tau_bkgnd, C_invrs_tau_sfc, &
2469 : C_invrs_tau_shear, C_invrs_tau_N2, C_invrs_tau_N2_wp2, &
2470 : C_invrs_tau_N2_xp2, C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, &
2471 : C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, &
2472 : Cx_min, Cx_max, Richardson_num_min, Richardson_num_max, &
2473 : wpxp_Ri_exp, a3_coef_min, a_const, bv_efold, z_displace
2474 :
2475 : ! Output variables
2476 : real( kind = core_rknd ), intent(out), dimension(nparams) :: clubb_params
2477 :
2478 : call read_parameters( ngrdcol, iunit, filename, & ! intent(in)
2479 : C1, C1b, C1c, C2rt, C2thl, C2rtthl, &
2480 : C4, C_uu_shr, C_uu_buoy, C6rt, C6rtb, C6rtc, &
2481 : C6thl, C6thlb, C6thlc, C7, C7b, C7c, C8, C8b, C10, &
2482 : C11, C11b, C11c, C12, C13, C14, C_wp2_pr_dfsn, C_wp3_pr_tp, &
2483 : C_wp3_pr_turb, C_wp3_pr_dfsn, C_wp2_splat, &
2484 : C6rt_Lscale0, C6thl_Lscale0, C7_Lscale0, wpxp_L_thresh, &
2485 : c_K, c_K1, nu1, c_K2, nu2, c_K6, nu6, c_K8, nu8, &
2486 : c_K9, nu9, nu10, c_K_hm, c_K_hmb, K_hm_min_coef, nu_hm, &
2487 : slope_coef_spread_DG_means_w, pdf_component_stdev_factor_w, &
2488 : coef_spread_DG_means_rt, coef_spread_DG_means_thl, &
2489 : gamma_coef, gamma_coefb, gamma_coefc, mu, beta, lmin_coef, &
2490 : omicron, zeta_vrnce_rat, upsilon_precip_frac_rat, &
2491 : lambda0_stability_coef, mult_coef, taumin, taumax, &
2492 : Lscale_mu_coef, Lscale_pert_coef, alpha_corr, &
2493 : Skw_denom_coef, c_K10, c_K10h, thlp2_rad_coef, &
2494 : thlp2_rad_cloud_frac_thresh, up2_sfc_coef, &
2495 : Skw_max_mag, xp3_coef_base, xp3_coef_slope, &
2496 : altitude_threshold, rtp2_clip_coef, C_invrs_tau_bkgnd, &
2497 : C_invrs_tau_sfc, C_invrs_tau_shear, C_invrs_tau_N2, &
2498 : C_invrs_tau_N2_wp2, C_invrs_tau_N2_xp2, &
2499 : C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, &
2500 : C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, &
2501 : Cx_min, Cx_max, Richardson_num_min, Richardson_num_max, &
2502 : wpxp_Ri_exp, a3_coef_min, a_const, bv_efold, z_displace, &
2503 1536 : clubb_params ) ! intent(out)
2504 :
2505 1536 : end subroutine read_parameters_api
2506 :
2507 : !================================================================================================
2508 : ! setup_parameters - Sets up model parameters for a single column
2509 : !================================================================================================
2510 0 : subroutine setup_parameters_api_single_col( &
2511 : deltaz, clubb_params, gr, grid_type, &
2512 : l_prescribed_avg_deltaz, &
2513 : lmin, nu_vert_res_dep, err_code_api )
2514 :
2515 : use grid_class, only: &
2516 : grid ! Type(s)
2517 :
2518 : use parameters_tunable, only: &
2519 : setup_parameters
2520 :
2521 : use parameter_indices, only: &
2522 : nparams ! Variable(s)
2523 :
2524 : implicit none
2525 :
2526 : ! Input Variables
2527 : real( kind = core_rknd ), intent(in) :: &
2528 : deltaz ! Change per height level [m]
2529 :
2530 : real( kind = core_rknd ), intent(in), dimension(nparams) :: &
2531 : clubb_params ! Tuneable model parameters [-]
2532 :
2533 : ! Grid definition
2534 : type(grid), target, intent(in) :: &
2535 : gr
2536 :
2537 : ! If CLUBB is running on its own, this option determines
2538 : ! if it is using:
2539 : ! 1) an evenly-spaced grid,
2540 : ! 2) a stretched (unevenly-spaced) grid entered on the
2541 : ! thermodynamic grid levels (with momentum levels set
2542 : ! halfway between thermodynamic levels), or
2543 : ! 3) a stretched (unevenly-spaced) grid entered on the
2544 : ! momentum grid levels (with thermodynamic levels set
2545 : ! halfway between momentum levels).
2546 : integer, intent(in) :: grid_type
2547 :
2548 : logical, intent(in) :: &
2549 : l_prescribed_avg_deltaz ! used in adj_low_res_nu. If .true., avg_deltaz = deltaz
2550 :
2551 : ! Output Variables
2552 : real( kind = core_rknd ), intent(out) :: &
2553 : lmin ! Min. value for the length scale [m]
2554 :
2555 : type(nu_vertical_res_dep), intent(out) :: &
2556 : nu_vert_res_dep ! Vertical resolution dependent nu values
2557 :
2558 : integer, intent(out) :: &
2559 : err_code_api ! Error condition
2560 :
2561 :
2562 : real( kind = core_rknd ), dimension(1) :: &
2563 : deltaz_col ! Change per height level [m]
2564 :
2565 0 : deltaz_col(1) = deltaz
2566 :
2567 : call setup_parameters( &
2568 : deltaz_col, clubb_params, gr, 1, grid_type, &
2569 : l_prescribed_avg_deltaz, &
2570 0 : lmin, nu_vert_res_dep, err_code_api )
2571 :
2572 0 : end subroutine setup_parameters_api_single_col
2573 :
2574 : !================================================================================================
2575 : ! setup_parameters - Sets up model parameters.
2576 : !================================================================================================
2577 :
2578 4467528 : subroutine setup_parameters_api_multi_col( &
2579 4467528 : deltaz, clubb_params, gr, ngrdcol, grid_type, &
2580 : l_prescribed_avg_deltaz, &
2581 : lmin, nu_vert_res_dep, err_code_api )
2582 :
2583 : use grid_class, only: &
2584 : grid
2585 :
2586 : use parameters_tunable, only: &
2587 : setup_parameters
2588 :
2589 : use parameter_indices, only: &
2590 : nparams ! Variable(s)
2591 :
2592 : implicit none
2593 :
2594 : ! Input Variables
2595 :
2596 : ! Grid definition
2597 : type(grid), target, intent(in) :: &
2598 : gr
2599 :
2600 : integer, intent(in) :: &
2601 : ngrdcol ! Number of grid columns [#]
2602 :
2603 : real( kind = core_rknd ), dimension(ngrdcol), intent(in) :: &
2604 : deltaz ! Change per height level [m]
2605 :
2606 : real( kind = core_rknd ), intent(in), dimension(ngrdcol,nparams) :: &
2607 : clubb_params ! Tuneable model parameters [-]
2608 :
2609 : ! If CLUBB is running on its own, this option determines
2610 : ! if it is using:
2611 : ! 1) an evenly-spaced grid,
2612 : ! 2) a stretched (unevenly-spaced) grid entered on the
2613 : ! thermodynamic grid levels (with momentum levels set
2614 : ! halfway between thermodynamic levels), or
2615 : ! 3) a stretched (unevenly-spaced) grid entered on the
2616 : ! momentum grid levels (with thermodynamic levels set
2617 : ! halfway between momentum levels).
2618 : integer, intent(in) :: grid_type
2619 :
2620 : logical, intent(in) :: &
2621 : l_prescribed_avg_deltaz ! used in adj_low_res_nu. If .true., avg_deltaz = deltaz
2622 :
2623 : ! Output Variables
2624 : real( kind = core_rknd ), intent(out) :: &
2625 : lmin ! Min. value for the length scale [m]
2626 :
2627 : type(nu_vertical_res_dep), intent(out) :: &
2628 : nu_vert_res_dep ! Vertical resolution dependent nu values
2629 :
2630 : integer, intent(out) :: &
2631 : err_code_api ! Error condition
2632 :
2633 : call setup_parameters( &
2634 : deltaz, clubb_params, gr, ngrdcol, grid_type, &
2635 : l_prescribed_avg_deltaz, &
2636 4467528 : lmin, nu_vert_res_dep, err_code_api )
2637 :
2638 4467528 : end subroutine setup_parameters_api_multi_col
2639 :
2640 : !================================================================================================
2641 : ! adj_low_res_nu - Adjusts values of background eddy diffusivity based on vertical grid spacing.
2642 : !================================================================================================
2643 :
2644 0 : subroutine adj_low_res_nu_api_single_col( gr, grid_type, deltaz, & ! Intent(in)
2645 : clubb_params, & ! Intent(in)
2646 : l_prescribed_avg_deltaz, & ! Intent(in)
2647 : nu_vert_res_dep ) ! Intent(out)
2648 :
2649 : use parameters_tunable, only : adj_low_res_nu
2650 :
2651 : implicit none
2652 :
2653 : ! Input Variables
2654 :
2655 : ! Grid definition
2656 : type(grid), target, intent(in) :: &
2657 : gr
2658 :
2659 : ! If CLUBB is running on it's own, this option determines
2660 : ! if it is using:
2661 : ! 1) an evenly-spaced grid,
2662 : ! 2) a stretched (unevenly-spaced) grid entered on the
2663 : ! thermodynamic grid levels (with momentum levels set
2664 : ! halfway between thermodynamic levels), or
2665 : ! 3) a stretched (unevenly-spaced) grid entered on the
2666 : ! momentum grid levels (with thermodynamic levels set
2667 : ! halfway between momentum levels).
2668 : integer, intent(in) :: grid_type
2669 :
2670 : real( kind = core_rknd ), intent(in) :: &
2671 : deltaz ! Change per height level [m]
2672 :
2673 : real( kind = core_rknd ), intent(in), dimension(nparams) :: &
2674 : clubb_params ! Tuneable model parameters [-]
2675 :
2676 : logical, intent(in) :: &
2677 : l_prescribed_avg_deltaz ! used in adj_low_res_nu. If .true., avg_deltaz = deltaz
2678 :
2679 : ! Output Variables
2680 : type(nu_vertical_res_dep), intent(out) :: &
2681 : nu_vert_res_dep ! Vertical resolution dependent nu values
2682 :
2683 : ! Local variables
2684 : real( kind = core_rknd ), dimension(1) :: &
2685 : deltaz_col ! Change per height level [m]
2686 :
2687 : real( kind = core_rknd ), dimension(1,nparams) :: &
2688 : clubb_params_col ! Tuneable model parameters [-]
2689 :
2690 0 : deltaz_col(1) = deltaz
2691 0 : clubb_params_col(1,:) = clubb_params
2692 :
2693 : call adj_low_res_nu( gr, 1, grid_type, deltaz_col, & ! Intent(in)
2694 : clubb_params, & ! Intent(in)
2695 : l_prescribed_avg_deltaz, & ! Intent(in)
2696 0 : nu_vert_res_dep ) ! Intent(out)
2697 :
2698 0 : end subroutine adj_low_res_nu_api_single_col
2699 :
2700 : !================================================================================================
2701 : ! adj_low_res_nu - Adjusts values of background eddy diffusivity based on vertical grid spacing.
2702 : !================================================================================================
2703 :
2704 0 : subroutine adj_low_res_nu_api_multi_col( gr, ngrdcol, grid_type, deltaz, & ! Intent(in)
2705 0 : clubb_params, & ! Intent(in)
2706 : l_prescribed_avg_deltaz, & ! Intent(in)
2707 : nu_vert_res_dep ) ! Intent(out)
2708 :
2709 : use parameters_tunable, only : adj_low_res_nu
2710 :
2711 : implicit none
2712 :
2713 : ! Input Variables
2714 :
2715 : ! Grid definition
2716 : type(grid), target, intent(in) :: &
2717 : gr
2718 :
2719 : integer, intent(in) :: &
2720 : ngrdcol
2721 :
2722 : ! If CLUBB is running on it's own, this option determines
2723 : ! if it is using:
2724 : ! 1) an evenly-spaced grid,
2725 : ! 2) a stretched (unevenly-spaced) grid entered on the
2726 : ! thermodynamic grid levels (with momentum levels set
2727 : ! halfway between thermodynamic levels), or
2728 : ! 3) a stretched (unevenly-spaced) grid entered on the
2729 : ! momentum grid levels (with thermodynamic levels set
2730 : ! halfway between momentum levels).
2731 : integer, intent(in) :: grid_type
2732 :
2733 : real( kind = core_rknd ), dimension(ngrdcol), intent(in) :: &
2734 : deltaz ! Change per height level [m]
2735 :
2736 : real( kind = core_rknd ), intent(in), dimension(ngrdcol,nparams) :: &
2737 : clubb_params ! Tuneable model parameters [-]
2738 :
2739 : logical, intent(in) :: &
2740 : l_prescribed_avg_deltaz ! used in adj_low_res_nu. If .true., avg_deltaz = deltaz
2741 :
2742 : ! Output Variables
2743 : type(nu_vertical_res_dep), intent(out) :: &
2744 : nu_vert_res_dep ! Vertical resolution dependent nu values
2745 :
2746 : call adj_low_res_nu( gr, ngrdcol, grid_type, deltaz, & ! Intent(in)
2747 : clubb_params, & ! Intent(in)
2748 : l_prescribed_avg_deltaz, & ! Intent(in)
2749 0 : nu_vert_res_dep ) ! Intent(out)
2750 :
2751 0 : end subroutine adj_low_res_nu_api_multi_col
2752 :
2753 : ! The CLUBB_CAM preprocessor directives are being commented out because this
2754 : ! code is now also used for WRF-CLUBB.
2755 : !#ifdef CLUBB_CAM /* Code for storing pdf_parameter structs in pbuf as array */
2756 : !================================================================================================
2757 : ! pack_pdf_params - Returns a two dimensional real array with all values.
2758 : !================================================================================================
2759 :
2760 0 : subroutine pack_pdf_params_api( pdf_params, nz, r_param_array, &
2761 : k_start, k_end )
2762 :
2763 : use pdf_parameter_module, only : pack_pdf_params
2764 :
2765 : !use statements
2766 :
2767 : implicit none
2768 :
2769 : integer, intent(in) :: nz ! Num Vert Model Levs
2770 :
2771 : ! Input a pdf_parameter array with nz instances of pdf_parameter
2772 : type (pdf_parameter), intent(inout) :: pdf_params
2773 :
2774 : ! Output a two dimensional real array with all values
2775 : real (kind = core_rknd), dimension(nz,num_pdf_params), intent(inout) :: &
2776 : r_param_array
2777 :
2778 : integer, optional, intent(in) :: k_start, k_end
2779 :
2780 0 : if( present( k_start ) .and. present( k_end ) ) then
2781 : call pack_pdf_params( pdf_params, nz, & ! intent(in)
2782 : r_param_array, & ! intent(out)
2783 0 : k_start, k_end ) ! intent(in/optional)
2784 : else
2785 : call pack_pdf_params( pdf_params, nz, & ! intent(in)
2786 0 : r_param_array ) ! intent(out)
2787 : end if
2788 :
2789 0 : end subroutine pack_pdf_params_api
2790 :
2791 : !================================================================================================
2792 : ! unpack_pdf_params - Returns a pdf_parameter array with nz instances of pdf_parameter.
2793 : !================================================================================================
2794 :
2795 0 : subroutine unpack_pdf_params_api( r_param_array, nz, pdf_params, &
2796 : k_start, k_end )
2797 :
2798 : use pdf_parameter_module, only : unpack_pdf_params
2799 :
2800 : implicit none
2801 :
2802 : integer, intent(in) :: nz ! Num Vert Model Levs
2803 :
2804 : ! Input a two dimensional real array with pdf values
2805 : real (kind = core_rknd), dimension(nz,num_pdf_params), intent(in) :: &
2806 : r_param_array
2807 :
2808 : ! Output a pdf_parameter array with nz instances of pdf_parameter
2809 : type (pdf_parameter), intent(inout) :: pdf_params
2810 :
2811 : integer, optional, intent(in) :: k_start, k_end
2812 :
2813 0 : if( present( k_start ) .and. present( k_end ) ) then
2814 : call unpack_pdf_params( r_param_array, nz, & ! intent(in)
2815 : pdf_params, & ! intent(inout)
2816 0 : k_start, k_end ) ! intent(in/optional)
2817 : else
2818 : call unpack_pdf_params( r_param_array, nz, & ! intent(in)
2819 0 : pdf_params ) ! intent(inout)
2820 : end if
2821 :
2822 :
2823 0 : end subroutine unpack_pdf_params_api
2824 :
2825 : !#endif
2826 : !================================================================================================
2827 : ! init_pdf_params - allocates arrays for pdf_params
2828 : !================================================================================================
2829 12384 : subroutine init_pdf_params_api( nz, ngrdcol, pdf_params )
2830 :
2831 : use pdf_parameter_module, only : init_pdf_params
2832 :
2833 : implicit none
2834 :
2835 : ! Input Variable(s)
2836 : integer, intent(in) :: &
2837 : nz, & ! Number of vertical grid levels [-]
2838 : ngrdcol ! Number of grid columns [-]
2839 :
2840 : ! Output Variable(s)
2841 : type(pdf_parameter), intent(out) :: &
2842 : pdf_params ! PDF parameters [units vary]
2843 :
2844 : call init_pdf_params( nz, ngrdcol, & ! intent(in)
2845 12384 : pdf_params ) ! intent(out)
2846 :
2847 12384 : end subroutine init_pdf_params_api
2848 :
2849 : !================================================================================================
2850 : ! copy_single_pdf_params_to_multi - copies values of a single column version of pdf_params
2851 : ! to a multiple column version for a specified column.
2852 : !
2853 : ! NOTE: THIS SUBROUTINE IS INTENDED TO BE TEMPORARY AND SHOULD BECOME UNNECESSARY ONCE
2854 : ! CLUBB IS ABLE TO OPERATE OVER MULTIPLE COLUMNS.
2855 : ! See https://github.com/larson-group/cam/issues/129#issuecomment-827944454
2856 : !================================================================================================
2857 0 : subroutine copy_single_pdf_params_to_multi( pdf_params_single, icol, &
2858 : pdf_params_multi )
2859 :
2860 : implicit none
2861 :
2862 : ! Input Variable(s)
2863 : integer, intent(in) :: &
2864 : icol ! Column number to copy to
2865 :
2866 : type(pdf_parameter), intent(in) :: &
2867 : pdf_params_single ! PDF parameters [units vary]
2868 :
2869 : ! Output Variable(s)
2870 : type(pdf_parameter), intent(inout) :: &
2871 : pdf_params_multi ! PDF parameters [units vary]
2872 :
2873 0 : pdf_params_multi%w_1(icol,:) = pdf_params_single%w_1(1,:)
2874 0 : pdf_params_multi%w_2(icol,:) = pdf_params_single%w_2(1,:)
2875 0 : pdf_params_multi%varnce_w_1(icol,:) = pdf_params_single%varnce_w_1(1,:)
2876 0 : pdf_params_multi%varnce_w_2(icol,:) = pdf_params_single%varnce_w_2(1,:)
2877 0 : pdf_params_multi%rt_1(icol,:) = pdf_params_single%rt_1(1,:)
2878 0 : pdf_params_multi%rt_2(icol,:) = pdf_params_single%rt_2(1,:)
2879 0 : pdf_params_multi%varnce_rt_1(icol,:) = pdf_params_single%varnce_rt_1(1,:)
2880 0 : pdf_params_multi%varnce_rt_2(icol,:) = pdf_params_single%varnce_rt_2(1,:)
2881 0 : pdf_params_multi%thl_1(icol,:) = pdf_params_single%thl_1(1,:)
2882 0 : pdf_params_multi%thl_2(icol,:) = pdf_params_single%thl_2(1,:)
2883 0 : pdf_params_multi%varnce_thl_1(icol,:) = pdf_params_single%varnce_thl_1(1,:)
2884 0 : pdf_params_multi%varnce_thl_2(icol,:) = pdf_params_single%varnce_thl_2(1,:)
2885 0 : pdf_params_multi%corr_w_rt_1(icol,:) = pdf_params_single%corr_w_rt_1(1,:)
2886 0 : pdf_params_multi%corr_w_rt_2(icol,:) = pdf_params_single%corr_w_rt_2(1,:)
2887 0 : pdf_params_multi%corr_w_thl_1(icol,:) = pdf_params_single%corr_w_thl_1(1,:)
2888 0 : pdf_params_multi%corr_w_thl_2(icol,:) = pdf_params_single%corr_w_thl_2(1,:)
2889 0 : pdf_params_multi%corr_rt_thl_1(icol,:) = pdf_params_single%corr_rt_thl_1(1,:)
2890 0 : pdf_params_multi%corr_rt_thl_2(icol,:) = pdf_params_single%corr_rt_thl_2(1,:)
2891 0 : pdf_params_multi%alpha_thl(icol,:) = pdf_params_single%alpha_thl(1,:)
2892 0 : pdf_params_multi%alpha_rt(icol,:) = pdf_params_single%alpha_rt(1,:)
2893 0 : pdf_params_multi%crt_1(icol,:) = pdf_params_single%crt_1(1,:)
2894 0 : pdf_params_multi%crt_2(icol,:) = pdf_params_single%crt_2(1,:)
2895 0 : pdf_params_multi%cthl_1(icol,:) = pdf_params_single%cthl_1(1,:)
2896 0 : pdf_params_multi%cthl_2(icol,:) = pdf_params_single%cthl_2(1,:)
2897 0 : pdf_params_multi%chi_1(icol,:) = pdf_params_single%chi_1(1,:)
2898 0 : pdf_params_multi%chi_2(icol,:) = pdf_params_single%chi_2(1,:)
2899 0 : pdf_params_multi%stdev_chi_1(icol,:) = pdf_params_single%stdev_chi_1(1,:)
2900 0 : pdf_params_multi%stdev_chi_2(icol,:) = pdf_params_single%stdev_chi_2(1,:)
2901 0 : pdf_params_multi%stdev_eta_1(icol,:) = pdf_params_single%stdev_eta_1(1,:)
2902 0 : pdf_params_multi%stdev_eta_2(icol,:) = pdf_params_single%stdev_eta_2(1,:)
2903 0 : pdf_params_multi%covar_chi_eta_1(icol,:) = pdf_params_single%covar_chi_eta_1(1,:)
2904 0 : pdf_params_multi%covar_chi_eta_2(icol,:) = pdf_params_single%covar_chi_eta_2(1,:)
2905 0 : pdf_params_multi%corr_w_chi_1(icol,:) = pdf_params_single%corr_w_chi_1(1,:)
2906 0 : pdf_params_multi%corr_w_chi_2(icol,:) = pdf_params_single%corr_w_chi_2(1,:)
2907 0 : pdf_params_multi%corr_w_eta_1(icol,:) = pdf_params_single%corr_w_eta_1(1,:)
2908 0 : pdf_params_multi%corr_w_eta_2(icol,:) = pdf_params_single%corr_w_eta_2(1,:)
2909 0 : pdf_params_multi%corr_chi_eta_1(icol,:) = pdf_params_single%corr_chi_eta_1(1,:)
2910 0 : pdf_params_multi%corr_chi_eta_2(icol,:) = pdf_params_single%corr_chi_eta_2(1,:)
2911 0 : pdf_params_multi%rsatl_1(icol,:) = pdf_params_single%rsatl_1(1,:)
2912 0 : pdf_params_multi%rsatl_2(icol,:) = pdf_params_single%rsatl_2(1,:)
2913 0 : pdf_params_multi%rc_1(icol,:) = pdf_params_single%rc_1(1,:)
2914 0 : pdf_params_multi%rc_2(icol,:) = pdf_params_single%rc_2(1,:)
2915 0 : pdf_params_multi%cloud_frac_1(icol,:) = pdf_params_single%cloud_frac_1(1,:)
2916 0 : pdf_params_multi%cloud_frac_2(icol,:) = pdf_params_single%cloud_frac_2(1,:)
2917 0 : pdf_params_multi%mixt_frac(icol,:) = pdf_params_single%mixt_frac(1,:)
2918 0 : pdf_params_multi%ice_supersat_frac_1(icol,:) = pdf_params_single%ice_supersat_frac_1(1,:)
2919 0 : pdf_params_multi%ice_supersat_frac_2(icol,:) = pdf_params_single%ice_supersat_frac_2(1,:)
2920 :
2921 0 : end subroutine copy_single_pdf_params_to_multi
2922 :
2923 : !================================================================================================
2924 : ! copy_multi_pdf_params_to_single - copies values of a multiple column version of pdf_params
2925 : ! at a specified column to a single column version.
2926 : !
2927 : ! NOTE: THIS SUBROUTINE IS INTENDED TO BE TEMPORARY AND SHOULD BECOME UNNECESSARY ONCE
2928 : ! CLUBB IS ABLE TO OPERATE OVER MULTIPLE COLUMNS.
2929 : ! See https://github.com/larson-group/cam/issues/129#issuecomment-827944454
2930 : !================================================================================================
2931 0 : subroutine copy_multi_pdf_params_to_single( pdf_params_multi, icol, &
2932 : pdf_params_single )
2933 :
2934 : implicit none
2935 :
2936 : ! Input Variable(s)
2937 : integer, intent(in) :: &
2938 : icol ! Column number to copy to
2939 :
2940 : type(pdf_parameter), intent(in) :: &
2941 : pdf_params_multi ! PDF parameters [units vary]
2942 :
2943 : ! Output Variable(s)
2944 : type(pdf_parameter), intent(inout) :: &
2945 : pdf_params_single ! PDF parameters [units vary]
2946 :
2947 0 : pdf_params_single%w_1(1,:) = pdf_params_multi%w_1(icol,:)
2948 0 : pdf_params_single%w_2(1,:) = pdf_params_multi%w_2(icol,:)
2949 0 : pdf_params_single%varnce_w_1(1,:) = pdf_params_multi%varnce_w_1(icol,:)
2950 0 : pdf_params_single%varnce_w_2(1,:) = pdf_params_multi%varnce_w_2(icol,:)
2951 0 : pdf_params_single%rt_1(1,:) = pdf_params_multi%rt_1(icol,:)
2952 0 : pdf_params_single%rt_2(1,:) = pdf_params_multi%rt_2(icol,:)
2953 0 : pdf_params_single%varnce_rt_1(1,:) = pdf_params_multi%varnce_rt_1(icol,:)
2954 0 : pdf_params_single%varnce_rt_2(1,:) = pdf_params_multi%varnce_rt_2(icol,:)
2955 0 : pdf_params_single%thl_1(1,:) = pdf_params_multi%thl_1(icol,:)
2956 0 : pdf_params_single%thl_2(1,:) = pdf_params_multi%thl_2(icol,:)
2957 0 : pdf_params_single%varnce_thl_1(1,:) = pdf_params_multi%varnce_thl_1(icol,:)
2958 0 : pdf_params_single%varnce_thl_2(1,:) = pdf_params_multi%varnce_thl_2(icol,:)
2959 0 : pdf_params_single%corr_w_rt_1(1,:) = pdf_params_multi%corr_w_rt_1(icol,:)
2960 0 : pdf_params_single%corr_w_rt_2(1,:) = pdf_params_multi%corr_w_rt_2(icol,:)
2961 0 : pdf_params_single%corr_w_thl_1(1,:) = pdf_params_multi%corr_w_thl_1(icol,:)
2962 0 : pdf_params_single%corr_w_thl_2(1,:) = pdf_params_multi%corr_w_thl_2(icol,:)
2963 0 : pdf_params_single%corr_rt_thl_1(1,:) = pdf_params_multi%corr_rt_thl_1(icol,:)
2964 0 : pdf_params_single%corr_rt_thl_2(1,:) = pdf_params_multi%corr_rt_thl_2(icol,:)
2965 0 : pdf_params_single%alpha_thl(1,:) = pdf_params_multi%alpha_thl(icol,:)
2966 0 : pdf_params_single%alpha_rt(1,:) = pdf_params_multi%alpha_rt(icol,:)
2967 0 : pdf_params_single%crt_1(1,:) = pdf_params_multi%crt_1(icol,:)
2968 0 : pdf_params_single%crt_2(1,:) = pdf_params_multi%crt_2(icol,:)
2969 0 : pdf_params_single%cthl_1(1,:) = pdf_params_multi%cthl_1(icol,:)
2970 0 : pdf_params_single%cthl_2(1,:) = pdf_params_multi%cthl_2(icol,:)
2971 0 : pdf_params_single%chi_1(1,:) = pdf_params_multi%chi_1(icol,:)
2972 0 : pdf_params_single%chi_2(1,:) = pdf_params_multi%chi_2(icol,:)
2973 0 : pdf_params_single%stdev_chi_1(1,:) = pdf_params_multi%stdev_chi_1(icol,:)
2974 0 : pdf_params_single%stdev_chi_2(1,:) = pdf_params_multi%stdev_chi_2(icol,:)
2975 0 : pdf_params_single%stdev_eta_1(1,:) = pdf_params_multi%stdev_eta_1(icol,:)
2976 0 : pdf_params_single%stdev_eta_2(1,:) = pdf_params_multi%stdev_eta_2(icol,:)
2977 0 : pdf_params_single%covar_chi_eta_1(1,:) = pdf_params_multi%covar_chi_eta_1(icol,:)
2978 0 : pdf_params_single%covar_chi_eta_2(1,:) = pdf_params_multi%covar_chi_eta_2(icol,:)
2979 0 : pdf_params_single%corr_w_chi_1(1,:) = pdf_params_multi%corr_w_chi_1(icol,:)
2980 0 : pdf_params_single%corr_w_chi_2(1,:) = pdf_params_multi%corr_w_chi_2(icol,:)
2981 0 : pdf_params_single%corr_w_eta_1(1,:) = pdf_params_multi%corr_w_eta_1(icol,:)
2982 0 : pdf_params_single%corr_w_eta_2(1,:) = pdf_params_multi%corr_w_eta_2(icol,:)
2983 0 : pdf_params_single%corr_chi_eta_1(1,:) = pdf_params_multi%corr_chi_eta_1(icol,:)
2984 0 : pdf_params_single%corr_chi_eta_2(1,:) = pdf_params_multi%corr_chi_eta_2(icol,:)
2985 0 : pdf_params_single%rsatl_1(1,:) = pdf_params_multi%rsatl_1(icol,:)
2986 0 : pdf_params_single%rsatl_2(1,:) = pdf_params_multi%rsatl_2(icol,:)
2987 0 : pdf_params_single%rc_1(1,:) = pdf_params_multi%rc_1(icol,:)
2988 0 : pdf_params_single%rc_2(1,:) = pdf_params_multi%rc_2(icol,:)
2989 0 : pdf_params_single%cloud_frac_1(1,:) = pdf_params_multi%cloud_frac_1(icol,:)
2990 0 : pdf_params_single%cloud_frac_2(1,:) = pdf_params_multi%cloud_frac_2(icol,:)
2991 0 : pdf_params_single%mixt_frac(1,:) = pdf_params_multi%mixt_frac(icol,:)
2992 0 : pdf_params_single%ice_supersat_frac_1(1,:) = pdf_params_multi%ice_supersat_frac_1(icol,:)
2993 0 : pdf_params_single%ice_supersat_frac_2(1,:) = pdf_params_multi%ice_supersat_frac_2(icol,:)
2994 :
2995 0 : end subroutine copy_multi_pdf_params_to_single
2996 :
2997 :
2998 : !================================================================================================
2999 : ! init_precip_fracs - allocates arrays for precip_fracs
3000 : !================================================================================================
3001 0 : subroutine init_precip_fracs_api( nz, ngrdcol, &
3002 : precip_fracs )
3003 :
3004 : use hydromet_pdf_parameter_module, only : init_precip_fracs
3005 :
3006 : implicit none
3007 :
3008 : ! Input Variable(s)
3009 : integer, intent(in) :: &
3010 : nz, & ! Number of vertical grid levels [-]
3011 : ngrdcol ! Number of grid columns [-]
3012 :
3013 : ! Output Variable
3014 : type(precipitation_fractions), intent(out) :: &
3015 : precip_fracs ! Hydrometeor PDF parameters [units vary]
3016 :
3017 : call init_precip_fracs( nz, ngrdcol, & ! intent(in)
3018 0 : precip_fracs ) ! intent(out)
3019 :
3020 0 : return
3021 :
3022 : end subroutine init_precip_fracs_api
3023 :
3024 : !================================================================================================
3025 : ! init_pdf_implicit_coefs_terms - allocates arrays for the PDF implicit
3026 : ! coefficient and explicit terms.
3027 : !================================================================================================
3028 6192 : subroutine init_pdf_implicit_coefs_terms_api( nz, ngrdcol, sclr_dim, &
3029 : pdf_implicit_coefs_terms )
3030 :
3031 : use pdf_parameter_module, only: &
3032 : init_pdf_implicit_coefs_terms ! Procedure(s)
3033 :
3034 : implicit none
3035 :
3036 : ! Input Variables
3037 : integer, intent(in) :: &
3038 : nz, & ! Number of vertical grid levels [-]
3039 : ngrdcol, & ! Number of grid columns [-]
3040 : sclr_dim ! Number of scalar variables [-]
3041 :
3042 : ! Output Variable
3043 : type(implicit_coefs_terms), intent(out) :: &
3044 : pdf_implicit_coefs_terms ! Implicit coefs / explicit terms [units vary]
3045 :
3046 : call init_pdf_implicit_coefs_terms( nz, ngrdcol, sclr_dim, & ! intent(in)
3047 6192 : pdf_implicit_coefs_terms ) ! intent(out)
3048 :
3049 6192 : end subroutine init_pdf_implicit_coefs_terms_api
3050 :
3051 : !================================================================================================
3052 : ! setup_pdf_parameters
3053 : !================================================================================================
3054 :
3055 0 : subroutine setup_pdf_parameters_api_single_col( gr, & ! intent(in)
3056 : nz, pdf_dim, hydromet_dim, dt, & ! Intent(in)
3057 0 : Nc_in_cloud, cloud_frac, Kh_zm, & ! Intent(in)
3058 0 : ice_supersat_frac, hydromet, wphydrometp, & ! Intent(in)
3059 0 : corr_array_n_cloud, corr_array_n_below, & ! Intent(in)
3060 : hm_metadata, & ! Intent(in)
3061 : pdf_params, & ! Intent(in)
3062 : clubb_params, & ! Intent(in)
3063 : iiPDF_type, & ! Intent(in)
3064 : l_use_precip_frac, & ! Intent(in)
3065 : l_predict_upwp_vpwp, & ! Intent(in)
3066 : l_diagnose_correlations, & ! Intent(in)
3067 : l_calc_w_corr, & ! Intent(in)
3068 : l_const_Nc_in_cloud, & ! Intent(in)
3069 : l_fix_w_chi_eta_correlations, & ! Intent(in)
3070 : stats_metadata, & ! Intent(in)
3071 : stats_zt, stats_zm, stats_sfc, & ! intent(inout)
3072 0 : hydrometp2, & ! Intent(inout)
3073 0 : mu_x_1_n, mu_x_2_n, & ! Intent(out)
3074 0 : sigma_x_1_n, sigma_x_2_n, & ! Intent(out)
3075 0 : corr_array_1_n, corr_array_2_n, & ! Intent(out)
3076 0 : corr_cholesky_mtx_1, corr_cholesky_mtx_2, & ! Intent(out)
3077 : precip_fracs, & ! Intent(out)
3078 0 : hydromet_pdf_params ) ! Intent(out)
3079 :
3080 : use setup_clubb_pdf_params, only : &
3081 : setup_pdf_parameters
3082 :
3083 : use parameter_indices, only: &
3084 : nparams ! Variable(s)
3085 :
3086 : use error_code, only : &
3087 : err_code, & ! Error Indicator
3088 : clubb_fatal_error ! Constant
3089 :
3090 : implicit none
3091 :
3092 : !----------------------- Input Variables -----------------------
3093 : type(grid), target, intent(in) :: gr
3094 :
3095 : integer, intent(in) :: &
3096 : nz, & ! Number of model vertical grid levels
3097 : pdf_dim, & ! Number of variables in the correlation array
3098 : hydromet_dim ! Number of hydrometeor species
3099 :
3100 : real( kind = core_rknd ), intent(in) :: &
3101 : dt ! Model timestep [s]
3102 :
3103 : real( kind = core_rknd ), dimension(nz), intent(in) :: &
3104 : Nc_in_cloud, & ! Mean (in-cloud) cloud droplet conc. [num/kg]
3105 : cloud_frac, & ! Cloud fraction [-]
3106 : Kh_zm, & ! Eddy diffusivity coef. on momentum levels [m^2/s]
3107 : ice_supersat_frac ! Ice supersaturation fraction [-]
3108 :
3109 : real( kind = core_rknd ), dimension(nz,hydromet_dim), intent(in) :: &
3110 : hydromet, & ! Mean of hydrometeor, hm (overall) (t-levs.) [units]
3111 : wphydrometp ! Covariance < w'h_m' > (momentum levels) [(m/s)units]
3112 :
3113 : real( kind = core_rknd ), dimension(pdf_dim,pdf_dim), &
3114 : intent(in) :: &
3115 : corr_array_n_cloud, & ! Prescribed norm. space corr. array in cloud [-]
3116 : corr_array_n_below ! Prescribed norm. space corr. array below cloud [-]
3117 :
3118 : type (hm_metadata_type), intent(in) :: &
3119 : hm_metadata
3120 :
3121 : type(pdf_parameter), intent(in) :: &
3122 : pdf_params ! PDF parameters [units vary]
3123 :
3124 : real( kind = core_rknd ), dimension(nparams), intent(in) :: &
3125 : clubb_params ! Array of CLUBB's tunable parameters [units vary]
3126 :
3127 : integer, intent(in) :: &
3128 : iiPDF_type ! Selected option for the two-component normal (double
3129 : ! Gaussian) PDF type to use for the w, rt, and theta-l (or
3130 : ! w, chi, and eta) portion of CLUBB's multivariate,
3131 : ! two-component PDF.
3132 :
3133 : logical, intent(in) :: &
3134 : l_use_precip_frac, & ! Flag to use precipitation fraction in KK microphysics. The
3135 : ! precipitation fraction is automatically set to 1 when this
3136 : ! flag is turned off.
3137 : l_predict_upwp_vpwp, & ! Flag to predict <u'w'> and <v'w'> along with <u> and <v>
3138 : ! alongside the advancement of <rt>, <w'rt'>, <thl>,
3139 : ! <wpthlp>, <sclr>, and <w'sclr'> in subroutine
3140 : ! advance_xm_wpxp. Otherwise, <u'w'> and <v'w'> are still
3141 : ! approximated by eddy diffusivity when <u> and <v> are
3142 : ! advanced in subroutine advance_windm_edsclrm.
3143 : l_diagnose_correlations, & ! Diagnose correlations instead of using fixed ones
3144 : l_calc_w_corr, & ! Calculate the correlations between w and the hydrometeors
3145 : l_const_Nc_in_cloud, & ! Use a constant cloud droplet conc. within cloud (K&K)
3146 : l_fix_w_chi_eta_correlations ! Use a fixed correlation for s and t Mellor(chi/eta)
3147 :
3148 : type (stats_metadata_type), intent(in) :: &
3149 : stats_metadata
3150 :
3151 : !----------------------- Input/Output Variables -----------------------
3152 : type(stats), target, intent(inout) :: &
3153 : stats_zt, &
3154 : stats_zm, &
3155 : stats_sfc
3156 :
3157 : real( kind = core_rknd ), dimension(nz,hydromet_dim), intent(inout) :: &
3158 : hydrometp2 ! Variance of a hydrometeor (overall) (m-levs.) [units^2]
3159 :
3160 : !----------------------- Output Variables -----------------------
3161 : real( kind = core_rknd ), dimension(nz,pdf_dim), intent(out) :: &
3162 : mu_x_1_n, & ! Mean array (normal space): PDF vars. (comp. 1) [un. vary]
3163 : mu_x_2_n, & ! Mean array (normal space): PDF vars. (comp. 2) [un. vary]
3164 : sigma_x_1_n, & ! Std. dev. array (normal space): PDF vars (comp. 1) [u.v.]
3165 : sigma_x_2_n ! Std. dev. array (normal space): PDF vars (comp. 2) [u.v.]
3166 :
3167 : real( kind = core_rknd ), dimension(nz,pdf_dim,pdf_dim), &
3168 : intent(out) :: &
3169 : corr_array_1_n, & ! Corr. array (normal space): PDF vars. (comp. 1) [-]
3170 : corr_array_2_n ! Corr. array (normal space): PDF vars. (comp. 2) [-]
3171 :
3172 : real( kind = core_rknd ), dimension(nz,pdf_dim,pdf_dim), &
3173 : intent(out) :: &
3174 : corr_cholesky_mtx_1, & ! Transposed corr. cholesky matrix, 1st comp. [-]
3175 : corr_cholesky_mtx_2 ! Transposed corr. cholesky matrix, 2nd comp. [-]
3176 :
3177 : ! This is only an output, but it contains allocated arrays, so we need to treat it as inout
3178 : type(precipitation_fractions), intent(inout) :: &
3179 : precip_fracs ! Precipitation fractions [-]
3180 :
3181 : type(hydromet_pdf_parameter), dimension(nz), optional, intent(out) :: &
3182 : hydromet_pdf_params ! Hydrometeor PDF parameters [units vary]
3183 :
3184 : !----------------------- Local Variables -----------------------
3185 : real( kind = core_rknd ), dimension(1,nz) :: &
3186 0 : Nc_in_cloud_col, & ! Mean (in-cloud) cloud droplet conc. [num/kg]
3187 0 : cloud_frac_col, & ! Cloud fraction [-]
3188 0 : Kh_zm_col, & ! Eddy diffusivity coef. on momentum levels [m^2/s]
3189 0 : ice_supersat_frac_col ! Ice supersaturation fraction [-]
3190 :
3191 : real( kind = core_rknd ), dimension(1,nz,hydromet_dim) :: &
3192 0 : hydromet_col, & ! Mean of hydrometeor, hm (overall) (t-levs.) [units]
3193 0 : wphydrometp_col ! Covariance < w'h_m' > (momentum levels) [(m/s)units]
3194 :
3195 : ! Input/Output Variables
3196 : real( kind = core_rknd ), dimension(1,nz,hydromet_dim) :: &
3197 0 : hydrometp2_col ! Variance of a hydrometeor (overall) (m-levs.) [units^2]
3198 :
3199 : ! Output Variables
3200 : real( kind = core_rknd ), dimension(1,nz,pdf_dim) :: &
3201 0 : mu_x_1_n_col, & ! Mean array (normal space): PDF vars. (comp. 1) [un. vary]
3202 0 : mu_x_2_n_col, & ! Mean array (normal space): PDF vars. (comp. 2) [un. vary]
3203 0 : sigma_x_1_n_col, & ! Std. dev. array (normal space): PDF vars (comp. 1) [u.v.]
3204 0 : sigma_x_2_n_col ! Std. dev. array (normal space): PDF vars (comp. 2) [u.v.]
3205 :
3206 : real( kind = core_rknd ), dimension(1,nz,pdf_dim,pdf_dim) :: &
3207 0 : corr_array_1_n_col, & ! Corr. array (normal space): PDF vars. (comp. 1) [-]
3208 0 : corr_array_2_n_col ! Corr. array (normal space): PDF vars. (comp. 2) [-]
3209 :
3210 : real( kind = core_rknd ), dimension(1,nz,pdf_dim,pdf_dim) :: &
3211 0 : corr_cholesky_mtx_1_col, & ! Transposed corr. cholesky matrix, 1st comp. [-]
3212 0 : corr_cholesky_mtx_2_col ! Transposed corr. cholesky matrix, 2nd comp. [-]
3213 :
3214 : type(hydromet_pdf_parameter), dimension(1,nz) :: &
3215 0 : hydromet_pdf_params_col ! Hydrometeor PDF parameters [units vary]
3216 :
3217 : type(stats), dimension(1) :: &
3218 0 : stats_zt_col, &
3219 0 : stats_zm_col, &
3220 0 : stats_sfc_col
3221 :
3222 : !----------------------- Begin Code -----------------------
3223 :
3224 0 : Nc_in_cloud_col(1,:) = Nc_in_cloud
3225 0 : cloud_frac_col(1,:) = cloud_frac
3226 0 : Kh_zm_col(1,:) = Kh_zm
3227 0 : ice_supersat_frac_col(1,:) = ice_supersat_frac
3228 :
3229 0 : hydromet_col(1,:,:) = hydromet
3230 0 : wphydrometp_col(1,:,:) = wphydrometp
3231 :
3232 0 : stats_zt_col(1) = stats_zt
3233 0 : stats_zm_col(1) = stats_zm
3234 0 : stats_sfc_col(1) = stats_sfc
3235 :
3236 : call setup_pdf_parameters( gr, & ! intent(in)
3237 : nz, 1, pdf_dim, hydromet_dim, dt, & ! Intent(in)
3238 : Nc_in_cloud_col, cloud_frac_col, Kh_zm_col, & ! Intent(in)
3239 : ice_supersat_frac_col, hydromet_col, wphydrometp_col, & ! Intent(in)
3240 : corr_array_n_cloud, corr_array_n_below, & ! Intent(in)
3241 : hm_metadata, & ! Intent(in)
3242 : pdf_params, & ! Intent(in)
3243 : clubb_params, & ! Intent(in)
3244 : iiPDF_type, & ! Intent(in)
3245 : l_use_precip_frac, & ! Intent(in)
3246 : l_predict_upwp_vpwp, & ! Intent(in)
3247 : l_diagnose_correlations, & ! Intent(in)
3248 : l_calc_w_corr, & ! Intent(in)
3249 : l_const_Nc_in_cloud, & ! Intent(in)
3250 : l_fix_w_chi_eta_correlations, & ! Intent(in)
3251 : stats_metadata, & ! Intent(in)
3252 : stats_zt_col, stats_zm_col, stats_sfc_col, & ! Intent(inout)
3253 : hydrometp2_col, & ! Intent(inout)
3254 : mu_x_1_n_col, mu_x_2_n_col, & ! Intent(out)
3255 : sigma_x_1_n_col, sigma_x_2_n_col, & ! Intent(out)
3256 : corr_array_1_n_col, corr_array_2_n_col, & ! Intent(out)
3257 : corr_cholesky_mtx_1_col, corr_cholesky_mtx_2_col, & ! Intent(out)
3258 : precip_fracs, & ! Intent(inout)
3259 0 : hydromet_pdf_params_col ) ! Optional(out)
3260 :
3261 0 : if ( err_code == clubb_fatal_error ) error stop
3262 :
3263 : ! The following does not work for stats
3264 : ! stats_zt = stats_zt_col(1)
3265 : ! stats_zm = stats_zm_col(1)
3266 : ! stats_sfc = stats_sfc_col(1)
3267 : ! because of some mysterious pointer issue. However, the only thing that
3268 : ! updates in stats is the field values, so we can copy only those instead.
3269 0 : if ( stats_metadata%l_stats ) then
3270 0 : stats_zm%accum_field_values = stats_zm_col(1)%accum_field_values
3271 0 : stats_zm%accum_num_samples = stats_zm_col(1)%accum_num_samples
3272 :
3273 0 : stats_zt%accum_field_values = stats_zt_col(1)%accum_field_values
3274 0 : stats_zt%accum_num_samples = stats_zt_col(1)%accum_num_samples
3275 :
3276 0 : stats_sfc%accum_field_values = stats_sfc_col(1)%accum_field_values
3277 0 : stats_sfc%accum_num_samples = stats_sfc_col(1)%accum_num_samples
3278 : end if
3279 :
3280 0 : hydrometp2 = hydrometp2_col(1,:,:)
3281 0 : mu_x_1_n = mu_x_1_n_col(1,:,:)
3282 0 : mu_x_2_n = mu_x_2_n_col(1,:,:)
3283 0 : sigma_x_1_n = sigma_x_1_n_col(1,:,:)
3284 0 : sigma_x_2_n = sigma_x_2_n_col(1,:,:)
3285 0 : corr_array_1_n = corr_array_1_n_col(1,:,:,:)
3286 0 : corr_array_2_n = corr_array_2_n_col(1,:,:,:)
3287 0 : corr_cholesky_mtx_1 = corr_cholesky_mtx_1_col(1,:,:,:)
3288 0 : corr_cholesky_mtx_2 = corr_cholesky_mtx_2_col(1,:,:,:)
3289 0 : if ( present(hydromet_pdf_params) ) then
3290 0 : hydromet_pdf_params = hydromet_pdf_params_col(1,:)
3291 : end if
3292 :
3293 0 : end subroutine setup_pdf_parameters_api_single_col
3294 : !===========================================================================!
3295 0 : subroutine setup_pdf_parameters_api_multi_col( gr, &
3296 : nz, ngrdcol, pdf_dim, hydromet_dim, dt, & ! Intent(in)
3297 0 : Nc_in_cloud, cloud_frac, Kh_zm, & ! Intent(in)
3298 0 : ice_supersat_frac, hydromet, wphydrometp, & ! Intent(in)
3299 0 : corr_array_n_cloud, corr_array_n_below, & ! Intent(in)
3300 : hm_metadata, & ! Intent(in)
3301 : pdf_params, & ! Intent(in)
3302 : clubb_params, & ! Intent(in)
3303 : iiPDF_type, & ! Intent(in)
3304 : l_use_precip_frac, & ! Intent(in)
3305 : l_predict_upwp_vpwp, & ! Intent(in)
3306 : l_diagnose_correlations, & ! Intent(in)
3307 : l_calc_w_corr, & ! Intent(in)
3308 : l_const_Nc_in_cloud, & ! Intent(in)
3309 : l_fix_w_chi_eta_correlations, & ! Intent(in)
3310 : stats_metadata, & ! Intent(in)
3311 0 : stats_zt, stats_zm, stats_sfc, & ! Intent(inout)
3312 0 : hydrometp2, & ! Intent(inout)
3313 0 : mu_x_1_n, mu_x_2_n, & ! Intent(out)
3314 0 : sigma_x_1_n, sigma_x_2_n, & ! Intent(out)
3315 0 : corr_array_1_n, corr_array_2_n, & ! Intent(out)
3316 0 : corr_cholesky_mtx_1, corr_cholesky_mtx_2, & ! Intent(out)
3317 : precip_fracs, & ! Intent(out)
3318 0 : hydromet_pdf_params ) ! Intent(out)
3319 :
3320 : use setup_clubb_pdf_params, only : setup_pdf_parameters
3321 :
3322 : use parameter_indices, only: &
3323 : nparams ! Variable(s)
3324 :
3325 : use error_code, only : &
3326 : err_code, & ! Error Indicator
3327 : clubb_fatal_error ! Constant
3328 :
3329 : implicit none
3330 :
3331 : ! Input Variables
3332 : integer, intent(in) :: &
3333 : nz, & ! Number of model vertical grid levels
3334 : pdf_dim, & ! Number of variables in the correlation array
3335 : ngrdcol, & ! Number of grid columns
3336 : hydromet_dim ! Number of hydrometeor species
3337 :
3338 : type (grid), target, intent(in) :: gr
3339 :
3340 : real( kind = core_rknd ), intent(in) :: &
3341 : dt ! Model timestep [s]
3342 :
3343 : real( kind = core_rknd ), dimension(ngrdcol,nz), intent(in) :: &
3344 : Nc_in_cloud, & ! Mean (in-cloud) cloud droplet conc. [num/kg]
3345 : cloud_frac, & ! Cloud fraction [-]
3346 : Kh_zm, & ! Eddy diffusivity coef. on momentum levels [m^2/s]
3347 : ice_supersat_frac ! Ice supersaturation fraction [-]
3348 :
3349 : real( kind = core_rknd ), dimension(ngrdcol,nz,hydromet_dim), intent(in) :: &
3350 : hydromet, & ! Mean of hydrometeor, hm (overall) (t-levs.) [units]
3351 : wphydrometp ! Covariance < w'h_m' > (momentum levels) [(m/s)units]
3352 :
3353 : real( kind = core_rknd ), dimension(pdf_dim,pdf_dim), &
3354 : intent(in) :: &
3355 : corr_array_n_cloud, & ! Prescribed norm. space corr. array in cloud [-]
3356 : corr_array_n_below ! Prescribed norm. space corr. array below cloud [-]
3357 :
3358 : type (hm_metadata_type), intent(in) :: &
3359 : hm_metadata
3360 :
3361 : type(pdf_parameter), intent(in) :: &
3362 : pdf_params ! PDF parameters [units vary]
3363 :
3364 : real( kind = core_rknd ), dimension(nparams), intent(in) :: &
3365 : clubb_params ! Array of CLUBB's tunable parameters [units vary]
3366 :
3367 : integer, intent(in) :: &
3368 : iiPDF_type ! Selected option for the two-component normal (double
3369 : ! Gaussian) PDF type to use for the w, rt, and theta-l (or
3370 : ! w, chi, and eta) portion of CLUBB's multivariate,
3371 : ! two-component PDF.
3372 :
3373 : logical, intent(in) :: &
3374 : l_use_precip_frac, & ! Flag to use precipitation fraction in KK microphysics. The
3375 : ! precipitation fraction is automatically set to 1 when this
3376 : ! flag is turned off.
3377 : l_predict_upwp_vpwp, & ! Flag to predict <u'w'> and <v'w'> along with <u> and <v>
3378 : ! alongside the advancement of <rt>, <w'rt'>, <thl>,
3379 : ! <wpthlp>, <sclr>, and <w'sclr'> in subroutine
3380 : ! advance_xm_wpxp. Otherwise, <u'w'> and <v'w'> are still
3381 : ! approximated by eddy diffusivity when <u> and <v> are
3382 : ! advanced in subroutine advance_windm_edsclrm.
3383 : l_diagnose_correlations, & ! Diagnose correlations instead of using fixed ones
3384 : l_calc_w_corr, & ! Calculate the correlations between w and the hydrometeors
3385 : l_const_Nc_in_cloud, & ! Use a constant cloud droplet conc. within cloud (K&K)
3386 : l_fix_w_chi_eta_correlations ! Use a fixed correlation for s and t Mellor(chi/eta)
3387 :
3388 : type (stats_metadata_type), intent(in) :: &
3389 : stats_metadata
3390 :
3391 : ! Input/Output Variables
3392 : real( kind = core_rknd ), dimension(ngrdcol,nz,hydromet_dim), intent(inout) :: &
3393 : hydrometp2 ! Variance of a hydrometeor (overall) (m-levs.) [units^2]
3394 :
3395 : type(stats), target, dimension(ngrdcol), intent(inout) :: &
3396 : stats_zt, &
3397 : stats_zm, &
3398 : stats_sfc
3399 :
3400 : ! Output Variables
3401 : real( kind = core_rknd ), dimension(ngrdcol,nz,pdf_dim), intent(out) :: &
3402 : mu_x_1_n, & ! Mean array (normal space): PDF vars. (comp. 1) [un. vary]
3403 : mu_x_2_n, & ! Mean array (normal space): PDF vars. (comp. 2) [un. vary]
3404 : sigma_x_1_n, & ! Std. dev. array (normal space): PDF vars (comp. 1) [u.v.]
3405 : sigma_x_2_n ! Std. dev. array (normal space): PDF vars (comp. 2) [u.v.]
3406 :
3407 : real( kind = core_rknd ), dimension(ngrdcol,nz,pdf_dim,pdf_dim), &
3408 : intent(out) :: &
3409 : corr_array_1_n, & ! Corr. array (normal space): PDF vars. (comp. 1) [-]
3410 : corr_array_2_n ! Corr. array (normal space): PDF vars. (comp. 2) [-]
3411 :
3412 : real( kind = core_rknd ), dimension(ngrdcol,nz,pdf_dim,pdf_dim), &
3413 : intent(out) :: &
3414 : corr_cholesky_mtx_1, & ! Transposed corr. cholesky matrix, 1st comp. [-]
3415 : corr_cholesky_mtx_2 ! Transposed corr. cholesky matrix, 2nd comp. [-]
3416 :
3417 : type(hydromet_pdf_parameter), dimension(ngrdcol,nz), optional, intent(out) :: &
3418 : hydromet_pdf_params ! Hydrometeor PDF parameters [units vary]
3419 :
3420 : ! This is only an output, but it contains allocated arrays, so we need to treat it as inout
3421 : type(precipitation_fractions), intent(inout) :: &
3422 : precip_fracs ! Precipitation fractions [-]
3423 :
3424 : call setup_pdf_parameters( gr, & ! intent(in)
3425 : nz, ngrdcol, pdf_dim, hydromet_dim, dt, & ! Intent(in)
3426 : Nc_in_cloud, cloud_frac, Kh_zm, & ! Intent(in)
3427 : ice_supersat_frac, hydromet, wphydrometp, & ! Intent(in)
3428 : corr_array_n_cloud, corr_array_n_below, & ! Intent(in)
3429 : hm_metadata, & ! Intent(in)
3430 : pdf_params, & ! Intent(in)
3431 : clubb_params, & ! Intent(in)
3432 : iiPDF_type, & ! Intent(in)
3433 : l_use_precip_frac, & ! Intent(in)
3434 : l_predict_upwp_vpwp, & ! Intent(in)
3435 : l_diagnose_correlations, & ! Intent(in)
3436 : l_calc_w_corr, & ! Intent(in)
3437 : l_const_Nc_in_cloud, & ! Intent(in)
3438 : l_fix_w_chi_eta_correlations, & ! Intent(in)
3439 : stats_metadata, & ! Intent(in)
3440 : stats_zt, stats_zm, stats_sfc, & ! intent(inout)
3441 : hydrometp2, & ! Intent(inout)
3442 : mu_x_1_n, mu_x_2_n, & ! Intent(out)
3443 : sigma_x_1_n, sigma_x_2_n, & ! Intent(out)
3444 : corr_array_1_n, corr_array_2_n, & ! Intent(out)
3445 : corr_cholesky_mtx_1, corr_cholesky_mtx_2, & ! Intent(out)
3446 : precip_fracs, & ! Intent(inout)
3447 0 : hydromet_pdf_params ) ! Optional(out)
3448 :
3449 0 : if ( err_code == clubb_fatal_error ) error stop
3450 :
3451 0 : end subroutine setup_pdf_parameters_api_multi_col
3452 :
3453 : !================================================================================================
3454 : ! stats_end_timestep - Calls statistics to be written to the output format.
3455 : !================================================================================================
3456 :
3457 0 : subroutine stats_end_timestep_api( clubb_params, stats_metadata, &
3458 : stats_zt, stats_zm, stats_sfc, &
3459 : stats_lh_zt, stats_lh_sfc, &
3460 : stats_rad_zt, stats_rad_zm &
3461 : #ifdef NETCDF
3462 : , l_uv_nudge, &
3463 : l_tke_aniso, &
3464 : l_standard_term_ta &
3465 : #endif
3466 : )
3467 :
3468 : use stats_clubb_utilities, only : stats_end_timestep
3469 :
3470 : use parameter_indices, only: nparams
3471 :
3472 : implicit none
3473 :
3474 : ! Input Variables
3475 : real( kind = core_rknd ), dimension(nparams), intent(in) :: &
3476 : clubb_params ! Array of CLUBB's tunable parameters [units vary]
3477 :
3478 : type (stats_metadata_type), intent(in) :: &
3479 : stats_metadata
3480 :
3481 : type(stats), target, intent(inout) :: &
3482 : stats_zt, &
3483 : stats_zm, &
3484 : stats_sfc, &
3485 : stats_lh_zt, &
3486 : stats_lh_sfc, &
3487 : stats_rad_zt, &
3488 : stats_rad_zm
3489 :
3490 : #ifdef NETCDF
3491 : logical, intent(in) :: &
3492 : l_uv_nudge, & ! For wind speed nudging.
3493 : l_tke_aniso, & ! For anisotropic turbulent kinetic energy, i.e.
3494 : ! TKE = 1/2 (u'^2 + v'^2 + w'^2)
3495 : l_standard_term_ta ! Use the standard discretization for the turbulent advection terms.
3496 : ! Setting to .false. means that a_1 and a_3 are pulled outside of the
3497 : ! derivative in advance_wp2_wp3_module.F90 and in
3498 : ! advance_xp2_xpyp_module.F90.
3499 : #endif
3500 :
3501 : call stats_end_timestep( clubb_params, stats_metadata, & ! intent(in)
3502 : stats_zt, stats_zm, stats_sfc, & ! intent(inout)
3503 : stats_lh_zt, stats_lh_sfc, & ! intent(inout)
3504 : stats_rad_zt, stats_rad_zm & ! intent(inout)
3505 : #ifdef NETCDF
3506 : , l_uv_nudge, & ! Intent(in)
3507 : l_tke_aniso, & ! Intent(in)
3508 : l_standard_term_ta & ! Intent(in)
3509 : #endif
3510 0 : )
3511 :
3512 0 : if ( err_code == clubb_fatal_error ) error stop
3513 :
3514 0 : end subroutine stats_end_timestep_api
3515 :
3516 : !================================================================================================
3517 : ! stats_finalize - Close NetCDF files and deallocate scratch space and stats file structures.
3518 : !================================================================================================
3519 :
3520 0 : subroutine stats_finalize_api ( stats_metadata, &
3521 : stats_zt, stats_zm, stats_sfc, &
3522 : stats_lh_zt, stats_lh_sfc, &
3523 : stats_rad_zt, stats_rad_zm )
3524 :
3525 : use stats_clubb_utilities, only : &
3526 : stats_finalize
3527 :
3528 : implicit none
3529 :
3530 : type(stats), target, intent(inout) :: &
3531 : stats_zt, &
3532 : stats_zm, &
3533 : stats_sfc, &
3534 : stats_lh_zt, &
3535 : stats_lh_sfc, &
3536 : stats_rad_zt, &
3537 : stats_rad_zm
3538 :
3539 : type (stats_metadata_type), intent(inout) :: &
3540 : stats_metadata
3541 :
3542 : call stats_finalize ( stats_metadata, & ! intent(inout)
3543 : stats_zt, stats_zm, stats_sfc, & ! intent(inout)
3544 : stats_lh_zt, stats_lh_sfc, & ! intent(inout)
3545 0 : stats_rad_zt, stats_rad_zm ) ! intent(inout)
3546 :
3547 0 : end subroutine stats_finalize_api
3548 :
3549 :
3550 : !================================================================================================
3551 : ! calculate_spurious_source - Checks whether there is conservation within the column.
3552 : !================================================================================================
3553 0 : function calculate_spurious_source_api ( &
3554 : integral_after, integral_before, &
3555 : flux_top, flux_sfc, &
3556 : integral_forcing, dt ) result( spurious_source )
3557 :
3558 : use numerical_check, only : calculate_spurious_source
3559 :
3560 : implicit none
3561 :
3562 : ! Input Variables
3563 : real( kind = core_rknd ), intent(in) :: &
3564 : integral_after, & ! Vertically-integrated quantity after dt time [units vary]
3565 : integral_before, & ! Vertically-integrated quantity before dt time [units vary]
3566 : flux_top, & ! Total flux at the top of the domain [units vary]
3567 : flux_sfc, & ! Total flux at the bottom of the domain [units vary]
3568 : integral_forcing, & ! Vertically-integrated forcing [units vary]
3569 : dt ! Timestep size [s]
3570 :
3571 : ! Return Variable
3572 : real( kind = core_rknd ) :: spurious_source ! [units vary]
3573 :
3574 : spurious_source = calculate_spurious_source( &
3575 : integral_after, integral_before, &
3576 : flux_top, flux_sfc, &
3577 0 : integral_forcing, dt )
3578 :
3579 0 : end function calculate_spurious_source_api
3580 :
3581 : !================================================================================================
3582 : ! calculate_thlp2_rad - Computes the contribution of radiative cooling to thlp2
3583 : !================================================================================================
3584 0 : subroutine calculate_thlp2_rad_api &
3585 0 : ( nz, rcm_zm, thlprcp, radht_zm, & ! Intent(in)
3586 : clubb_params, & ! Intent(in)
3587 0 : thlp2_forcing ) ! Intent(inout)
3588 :
3589 : use clubb_precision, only: &
3590 : core_rknd ! Constant(s)
3591 :
3592 : use advance_clubb_core_module, only: &
3593 : calculate_thlp2_rad
3594 :
3595 : use parameter_indices, only: &
3596 : nparams
3597 :
3598 : implicit none
3599 :
3600 : ! Input Variables
3601 : integer, intent(in) :: &
3602 : nz ! Number of vertical levels [-]
3603 :
3604 : real( kind = core_rknd ), dimension(nz), intent(in) :: &
3605 : rcm_zm, & ! Cloud water mixing ratio on momentum grid [kg/kg]
3606 : thlprcp, & ! thl'rc' [K kg/kg]
3607 : radht_zm ! SW + LW heating rate (on momentum grid) [K/s]
3608 :
3609 : real( kind = core_rknd ), dimension(nparams), intent(in) :: &
3610 : clubb_params ! Array of CLUBB's tunable parameters [units vary]
3611 :
3612 : ! Input/Output Variables
3613 : real( kind = core_rknd ), dimension(nz), intent(inout) :: &
3614 : thlp2_forcing ! <th_l'^2> forcing (momentum levels) [K^2/s]
3615 : !----------------------------------------------------------------------
3616 :
3617 : call calculate_thlp2_rad( nz, rcm_zm, thlprcp, radht_zm, & ! intent(in)
3618 : clubb_params, & ! intent(in)
3619 0 : thlp2_forcing ) ! intent(inout)
3620 :
3621 0 : return
3622 : end subroutine calculate_thlp2_rad_api
3623 :
3624 : !================================================================================================
3625 : ! update_xp2_mc - Calculates the effects of rain evaporation on rtp2 and thlp2
3626 : !================================================================================================
3627 0 : subroutine update_xp2_mc_api_multi_col( gr, nz, ngrdcol, dt, cloud_frac, rcm, rvm, thlm, &
3628 0 : wm, exner, rrm_evap, pdf_params, &
3629 0 : rtp2_mc, thlp2_mc, wprtp_mc, wpthlp_mc, &
3630 0 : rtpthlp_mc )
3631 :
3632 : use advance_xp2_xpyp_module, only: &
3633 : update_xp2_mc
3634 :
3635 : ! Type
3636 :
3637 : implicit none
3638 :
3639 : ! -------------------- Input Variables --------------------
3640 : integer, intent(in) :: &
3641 : nz, & ! Points in the Vertical [-]
3642 : ngrdcol
3643 :
3644 : type(grid), target, intent(in) :: gr
3645 :
3646 : real( kind = core_rknd ), intent(in) :: dt ! Model timestep [s]
3647 :
3648 : real( kind = core_rknd ), dimension(ngrdcol,nz), intent(in) :: &
3649 : cloud_frac, & !Cloud fraction [-]
3650 : rcm, & !Cloud water mixing ratio [kg/kg]
3651 : rvm, & !Vapor water mixing ratio [kg/kg]
3652 : thlm, & !Liquid potential temperature [K]
3653 : wm, & !Mean vertical velocity [m/s]
3654 : exner, & !Exner function [-]
3655 : rrm_evap !Evaporation of rain [kg/kg/s]
3656 : !It is expected that this variable is negative, as
3657 : !that is the convention in Morrison microphysics
3658 :
3659 : type(pdf_parameter), intent(in) :: &
3660 : pdf_params ! PDF parameters
3661 :
3662 : ! -------------------- Input/Output Variables --------------------
3663 : real( kind = core_rknd ), dimension(ngrdcol,nz), intent(inout) :: &
3664 : rtp2_mc, & !Tendency of <rt'^2> due to evaporation [(kg/kg)^2/s]
3665 : thlp2_mc, & !Tendency of <thl'^2> due to evaporation [K^2/s]
3666 : wprtp_mc, & !Tendency of <w'rt'> due to evaporation [m*(kg/kg)/s^2]
3667 : wpthlp_mc, & !Tendency of <w'thl'> due to evaporation [m*K/s^2]
3668 : rtpthlp_mc !Tendency of <rt'thl'> due to evaporation [K*(kg/kg)/s]
3669 :
3670 : call update_xp2_mc( gr, nz, ngrdcol, dt, cloud_frac, rcm, rvm, thlm, & ! intent(in)
3671 : wm, exner, rrm_evap, pdf_params, & ! intent(in)
3672 : rtp2_mc, thlp2_mc, wprtp_mc, wpthlp_mc, & ! intent(inout)
3673 0 : rtpthlp_mc ) ! intent(inout)
3674 0 : return
3675 : end subroutine update_xp2_mc_api_multi_col
3676 :
3677 : !================================================================================================
3678 : ! update_xp2_mc - Calculates the effects of rain evaporation on rtp2 and thlp2
3679 : !================================================================================================
3680 0 : subroutine update_xp2_mc_api_single_col( gr, nz, dt, cloud_frac, rcm, rvm, thlm, &
3681 0 : wm, exner, rrm_evap, pdf_params, &
3682 0 : rtp2_mc, thlp2_mc, wprtp_mc, wpthlp_mc, &
3683 0 : rtpthlp_mc )
3684 :
3685 : use advance_xp2_xpyp_module, only: &
3686 : update_xp2_mc
3687 :
3688 : ! Type
3689 :
3690 : implicit none
3691 :
3692 : ! -------------------- Input Variables --------------------
3693 : integer, intent(in) :: &
3694 : nz ! Points in the Vertical [-]
3695 :
3696 : type(grid), target, intent(in) :: gr
3697 :
3698 : real( kind = core_rknd ), intent(in) :: dt ! Model timestep [s]
3699 :
3700 : real( kind = core_rknd ), dimension(nz), intent(in) :: &
3701 : cloud_frac, & !Cloud fraction [-]
3702 : rcm, & !Cloud water mixing ratio [kg/kg]
3703 : rvm, & !Vapor water mixing ratio [kg/kg]
3704 : thlm, & !Liquid potential temperature [K]
3705 : wm, & !Mean vertical velocity [m/s]
3706 : exner, & !Exner function [-]
3707 : rrm_evap !Evaporation of rain [kg/kg/s]
3708 : !It is expected that this variable is negative, as
3709 : !that is the convention in Morrison microphysics
3710 :
3711 : type(pdf_parameter), intent(in) :: &
3712 : pdf_params ! PDF parameters
3713 :
3714 : ! -------------------- Input/Output Variables --------------------
3715 : real( kind = core_rknd ), dimension(nz), intent(inout) :: &
3716 : rtp2_mc, & !Tendency of <rt'^2> due to evaporation [(kg/kg)^2/s]
3717 : thlp2_mc, & !Tendency of <thl'^2> due to evaporation [K^2/s]
3718 : wprtp_mc, & !Tendency of <w'rt'> due to evaporation [m*(kg/kg)/s^2]
3719 : wpthlp_mc, & !Tendency of <w'thl'> due to evaporation [m*K/s^2]
3720 : rtpthlp_mc !Tendency of <rt'thl'> due to evaporation [K*(kg/kg)/s]
3721 :
3722 : ! -------------------- Local Variables --------------------
3723 : real( kind = core_rknd ), dimension(1,nz) :: &
3724 0 : cloud_frac_col, & !Cloud fraction [-]
3725 0 : rcm_col, & !Cloud water mixing ratio [kg/kg]
3726 0 : rvm_col, & !Vapor water mixing ratio [kg/kg]
3727 0 : thlm_col, & !Liquid potential temperature [K]
3728 0 : wm_col, & !Mean vertical velocity [m/s]
3729 0 : exner_col, & !Exner function [-]
3730 0 : rrm_evap_col !Evaporation of rain [kg/kg/s]
3731 : !It is expected that this variable is negative, as
3732 : !that is the convention in Morrison microphysics
3733 :
3734 : real( kind = core_rknd ), dimension(1,nz) :: &
3735 0 : rtp2_mc_col, & !Tendency of <rt'^2> due to evaporation [(kg/kg)^2/s]
3736 0 : thlp2_mc_col, & !Tendency of <thl'^2> due to evaporation [K^2/s]
3737 0 : wprtp_mc_col, & !Tendency of <w'rt'> due to evaporation [m*(kg/kg)/s^2]
3738 0 : wpthlp_mc_col, & !Tendency of <w'thl'> due to evaporation [m*K/s^2]
3739 0 : rtpthlp_mc_col !Tendency of <rt'thl'> due to evaporation [K*(kg/kg)/s]
3740 :
3741 0 : cloud_frac_col(1,:) = cloud_frac
3742 0 : rcm_col(1,:) = rcm
3743 0 : rvm_col(1,:) = rvm
3744 0 : thlm_col(1,:) = thlm
3745 0 : wm_col(1,:) = wm
3746 0 : exner_col(1,:) = exner
3747 0 : rrm_evap_col(1,:) = rrm_evap
3748 0 : rtp2_mc_col(1,:) = rtp2_mc
3749 0 : thlp2_mc_col(1,:) = thlp2_mc
3750 0 : wprtp_mc_col(1,:) = wprtp_mc
3751 0 : wpthlp_mc_col(1,:) = wpthlp_mc
3752 0 : rtpthlp_mc_col(1,:) = rtpthlp_mc
3753 :
3754 : call update_xp2_mc( gr, nz, 1, dt, cloud_frac_col, rcm_col, rvm_col, thlm_col, & ! intent(in)
3755 : wm_col, exner_col, rrm_evap_col, pdf_params, & ! intent(in)
3756 : rtp2_mc_col, thlp2_mc_col, wprtp_mc_col, wpthlp_mc_col, & ! intent(inout)
3757 0 : rtpthlp_mc_col ) ! intent(inout)
3758 :
3759 0 : rtp2_mc = rtp2_mc_col(1,:)
3760 0 : thlp2_mc = thlp2_mc_col(1,:)
3761 0 : wprtp_mc = wprtp_mc_col(1,:)
3762 0 : wpthlp_mc = wpthlp_mc_col(1,:)
3763 0 : rtpthlp_mc = rtpthlp_mc_col(1,:)
3764 :
3765 0 : return
3766 : end subroutine update_xp2_mc_api_single_col
3767 :
3768 :
3769 :
3770 : !================================================================================================
3771 : ! set_default_parameters: Sets all CLUBB tunable parameters to a default setting
3772 : !================================================================================================
3773 1536 : subroutine set_default_parameters_api( &
3774 : C1, C1b, C1c, C2rt, C2thl, C2rtthl, &
3775 : C4, C_uu_shr, C_uu_buoy, C6rt, C6rtb, C6rtc, &
3776 : C6thl, C6thlb, C6thlc, C7, C7b, C7c, C8, C8b, C10, &
3777 : C11, C11b, C11c, C12, C13, C14, C_wp2_pr_dfsn, C_wp3_pr_tp, &
3778 : C_wp3_pr_turb, C_wp3_pr_dfsn, C_wp2_splat, &
3779 : C6rt_Lscale0, C6thl_Lscale0, C7_Lscale0, wpxp_L_thresh, &
3780 : c_K, c_K1, nu1, c_K2, nu2, c_K6, nu6, c_K8, nu8, &
3781 : c_K9, nu9, nu10, c_K_hm, c_K_hmb, K_hm_min_coef, nu_hm, &
3782 : slope_coef_spread_DG_means_w, pdf_component_stdev_factor_w, &
3783 : coef_spread_DG_means_rt, coef_spread_DG_means_thl, &
3784 : gamma_coef, gamma_coefb, gamma_coefc, mu, beta, lmin_coef, &
3785 : omicron, zeta_vrnce_rat, upsilon_precip_frac_rat, &
3786 : lambda0_stability_coef, mult_coef, taumin, taumax, &
3787 : Lscale_mu_coef, Lscale_pert_coef, alpha_corr, &
3788 : Skw_denom_coef, c_K10, c_K10h, thlp2_rad_coef, &
3789 : thlp2_rad_cloud_frac_thresh, up2_sfc_coef, &
3790 : Skw_max_mag, xp3_coef_base, xp3_coef_slope, &
3791 : altitude_threshold, rtp2_clip_coef, C_invrs_tau_bkgnd, &
3792 : C_invrs_tau_sfc, C_invrs_tau_shear, C_invrs_tau_N2, &
3793 : C_invrs_tau_N2_wp2, C_invrs_tau_N2_xp2, &
3794 : C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, &
3795 : C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, &
3796 : Cx_min, Cx_max, Richardson_num_min, Richardson_num_max, &
3797 : wpxp_Ri_exp, a3_coef_min, a_const, bv_efold, z_displace )
3798 :
3799 : use parameters_tunable, only: &
3800 : set_default_parameters ! Procedure(s)
3801 :
3802 : implicit none
3803 :
3804 : ! Output variables
3805 : real( kind = core_rknd ), intent(out) :: &
3806 : C1, C1b, C1c, C2rt, C2thl, C2rtthl, &
3807 : C4, C_uu_shr, C_uu_buoy, C6rt, C6rtb, C6rtc, C6thl, C6thlb, C6thlc, &
3808 : C7, C7b, C7c, C8, C8b, C10, &
3809 : C11, C11b, C11c, C12, C13, C14, C_wp2_pr_dfsn, C_wp3_pr_tp, &
3810 : C_wp3_pr_turb, C_wp3_pr_dfsn, C_wp2_splat, &
3811 : C6rt_Lscale0, C6thl_Lscale0, C7_Lscale0, wpxp_L_thresh, &
3812 : c_K, c_K1, nu1, c_K2, nu2, c_K6, nu6, c_K8, nu8, &
3813 : c_K9, nu9, nu10, c_K_hm, c_K_hmb, K_hm_min_coef, nu_hm, &
3814 : slope_coef_spread_DG_means_w, pdf_component_stdev_factor_w, &
3815 : coef_spread_DG_means_rt, coef_spread_DG_means_thl, &
3816 : gamma_coef, gamma_coefb, gamma_coefc, mu, beta, lmin_coef, &
3817 : omicron, zeta_vrnce_rat, upsilon_precip_frac_rat, &
3818 : lambda0_stability_coef, mult_coef, taumin, taumax, Lscale_mu_coef, &
3819 : Lscale_pert_coef, alpha_corr, Skw_denom_coef, c_K10, c_K10h, &
3820 : thlp2_rad_coef, thlp2_rad_cloud_frac_thresh, up2_sfc_coef, &
3821 : Skw_max_mag, xp3_coef_base, xp3_coef_slope, altitude_threshold, &
3822 : rtp2_clip_coef, C_invrs_tau_bkgnd, C_invrs_tau_sfc, &
3823 : C_invrs_tau_shear, C_invrs_tau_N2, C_invrs_tau_N2_wp2, &
3824 : C_invrs_tau_N2_xp2, C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, &
3825 : C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, &
3826 : Cx_min, Cx_max, Richardson_num_min, Richardson_num_max, &
3827 : wpxp_Ri_exp, a3_coef_min, a_const, bv_efold, z_displace
3828 :
3829 : call set_default_parameters( &
3830 : C1, C1b, C1c, C2rt, C2thl, C2rtthl, &
3831 : C4, C_uu_shr, C_uu_buoy, C6rt, C6rtb, C6rtc, &
3832 : C6thl, C6thlb, C6thlc, C7, C7b, C7c, C8, C8b, C10, &
3833 : C11, C11b, C11c, C12, C13, C14, C_wp2_pr_dfsn, C_wp3_pr_tp, &
3834 : C_wp3_pr_turb, C_wp3_pr_dfsn, C_wp2_splat, &
3835 : C6rt_Lscale0, C6thl_Lscale0, C7_Lscale0, wpxp_L_thresh, &
3836 : c_K, c_K1, nu1, c_K2, nu2, c_K6, nu6, c_K8, nu8, &
3837 : c_K9, nu9, nu10, c_K_hm, c_K_hmb, K_hm_min_coef, nu_hm, &
3838 : slope_coef_spread_DG_means_w, pdf_component_stdev_factor_w, &
3839 : coef_spread_DG_means_rt, coef_spread_DG_means_thl, &
3840 : gamma_coef, gamma_coefb, gamma_coefc, mu, beta, lmin_coef, &
3841 : omicron, zeta_vrnce_rat, upsilon_precip_frac_rat, &
3842 : lambda0_stability_coef, mult_coef, taumin, taumax, &
3843 : Lscale_mu_coef, Lscale_pert_coef, alpha_corr, &
3844 : Skw_denom_coef, c_K10, c_K10h, thlp2_rad_coef, &
3845 : thlp2_rad_cloud_frac_thresh, up2_sfc_coef, &
3846 : Skw_max_mag, xp3_coef_base, xp3_coef_slope, &
3847 : altitude_threshold, rtp2_clip_coef, C_invrs_tau_bkgnd, &
3848 : C_invrs_tau_sfc, C_invrs_tau_shear, C_invrs_tau_N2, &
3849 : C_invrs_tau_N2_wp2, C_invrs_tau_N2_xp2, &
3850 : C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, &
3851 : C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, &
3852 : Cx_min, Cx_max, Richardson_num_min, Richardson_num_max, &
3853 1536 : wpxp_Ri_exp, a3_coef_min, a_const, bv_efold, z_displace )
3854 :
3855 1536 : return
3856 :
3857 : end subroutine set_default_parameters_api
3858 :
3859 : !================================================================================================
3860 : ! print_clubb_config_flags: Prints the clubb_config_flags
3861 : !================================================================================================
3862 2 : subroutine print_clubb_config_flags_api( iunit, clubb_config_flags ) ! In
3863 :
3864 : use model_flags, only: &
3865 : clubb_config_flags_type, & ! Type
3866 : print_clubb_config_flags ! Procedure
3867 :
3868 : implicit none
3869 :
3870 : ! Input variables
3871 : integer, intent(in) :: &
3872 : iunit ! The file to write to
3873 :
3874 : type(clubb_config_flags_type), intent(in) :: &
3875 : clubb_config_flags ! Derived type holding all configurable CLUBB flags
3876 :
3877 2 : call print_clubb_config_flags( iunit, clubb_config_flags ) ! In
3878 :
3879 2 : end subroutine print_clubb_config_flags_api
3880 :
3881 : !================================================================================================
3882 : ! initialize_tau_sponge_damp
3883 : !================================================================================================
3884 0 : subroutine initialize_tau_sponge_damp_api( gr, dt, z, settings, damping_profile )
3885 :
3886 : use sponge_layer_damping, only: &
3887 : sponge_damp_settings, & ! Variable(s)
3888 : sponge_damp_profile, &
3889 : initialize_tau_sponge_damp ! Procedure(s)
3890 :
3891 :
3892 :
3893 : implicit none
3894 :
3895 : type(grid), target, intent(in) :: gr
3896 :
3897 : ! Input Variable(s)
3898 : real( kind = core_rknd ), intent(in) :: &
3899 : dt ! Model Timestep [s]
3900 :
3901 : real( kind = core_rknd ), dimension(gr%nz), intent(in) :: &
3902 : z ! Height of model grid levels [m]
3903 :
3904 : type(sponge_damp_settings), intent(in) :: &
3905 : settings
3906 :
3907 : ! Output Variable(s)
3908 : type(sponge_damp_profile), intent(out) :: &
3909 : damping_profile
3910 :
3911 : call initialize_tau_sponge_damp( gr, dt, z, settings, & ! intent(in)
3912 0 : damping_profile ) ! intent(inout)
3913 :
3914 0 : end subroutine initialize_tau_sponge_damp_api
3915 :
3916 : !================================================================================================
3917 : ! finalize_tau_sponge_damp
3918 : !================================================================================================
3919 0 : subroutine finalize_tau_sponge_damp_api( damping_profile )
3920 :
3921 : use sponge_layer_damping, only: &
3922 : sponge_damp_profile, & ! Variable(s)
3923 : finalize_tau_sponge_damp ! Procedure(s)
3924 :
3925 : implicit none
3926 :
3927 : ! Input/Output Variable(s)
3928 : type(sponge_damp_profile), intent(inout) :: &
3929 : damping_profile ! Information for damping the profile
3930 :
3931 0 : call finalize_tau_sponge_damp( damping_profile ) ! intent(inout)
3932 :
3933 0 : end subroutine finalize_tau_sponge_damp_api
3934 :
3935 : end module clubb_api_module
|