forked from ESCOMP/CLUBB_CESM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pdf_closure_module.F90
3126 lines (2606 loc) · 135 KB
/
pdf_closure_module.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!---------------------------------------------------------------------------
! $Id$
!===============================================================================
module pdf_closure_module
implicit none
public :: pdf_closure, &
calc_wp4_pdf, &
calc_wp2xp_pdf, &
calc_wpxp2_pdf, &
calc_wpxpyp_pdf, &
calc_vert_avg_cf_component
! Options for the two component normal (double Gaussian) PDF type to use for
! the w, rt, and theta-l (or w, chi, and eta) portion of CLUBB's multivariate,
! two-component PDF.
integer, parameter, public :: &
iiPDF_ADG1 = 1, & ! ADG1 PDF
iiPDF_ADG2 = 2, & ! ADG2 PDF
iiPDF_3D_Luhar = 3, & ! 3D Luhar PDF
iiPDF_new = 4, & ! new PDF
iiPDF_TSDADG = 5, & ! new TSDADG PDF
iiPDF_LY93 = 6, & ! Lewellen and Yoh (1993)
iiPDF_new_hybrid = 7 ! new hybrid PDF
! The selected two component normal PDF for w, rt, and theta-l.
integer, parameter, public :: &
iiPDF_type = iiPDF_ADG1
private ! Set Default Scope
contains
!------------------------------------------------------------------------
!#######################################################################
!#######################################################################
! If you change the argument list of pdf_closure you also have to
! change the calls to this function in the host models CAM, WRF, SAM
! and GFDL.
!#######################################################################
!#######################################################################
subroutine pdf_closure( hydromet_dim, p_in_Pa, exner, thv_ds, &
wm, wp2, wp3, sigma_sqd_w, &
Skw, Skthl_in, Skrt_in, Sku_in, Skv_in, &
rtm, rtp2, wprtp, &
thlm, thlp2, wpthlp, &
um, up2, upwp, &
vm, vp2, vpwp, &
rtpthlp, &
sclrm, wpsclrp, sclrp2, &
sclrprtp, sclrpthlp, Sksclr_in, &
#ifdef GFDL
RH_crit, do_liquid_only_in_clubb, & ! h1g, 2010-06-15
#endif
wphydrometp, wp2hmp, &
rtphmp, thlphmp, &
wp4, wprtp2, wp2rtp, &
wpthlp2, wp2thlp, wprtpthlp, &
cloud_frac, ice_supersat_frac, &
rcm, wpthvp, wp2thvp, rtpthvp, &
thlpthvp, wprcp, wp2rcp, rtprcp, &
thlprcp, rcp2, &
uprcp, vprcp, &
pdf_params, pdf_implicit_coefs_terms, &
F_w, F_rt, F_thl, &
min_F_w, max_F_w, &
min_F_rt, max_F_rt, &
min_F_thl, max_F_thl, &
wpsclrprtp, wpsclrp2, sclrpthvp, &
wpsclrpthlp, sclrprcp, wp2sclrp, &
rc_coef )
! Description:
! Subroutine that computes pdf parameters analytically.
!
! Based of the original formulation, but with some tweaks
! to remove some of the less realistic assumptions and
! improve transport terms.
! Corrected version that should remove inconsistency
! References:
! The shape of CLUBB's PDF is given by the expression in
! https://arxiv.org/pdf/1711.03675v1.pdf#nameddest=url:clubb_pdf
! Eqn. 29, 30, 31, 32 & 33 on p. 3547 of
! ``A PDF-Based Model for Boundary Layer Clouds. Part I:
! Method and Model Description'' Golaz, et al. (2002)
! JAS, Vol. 59, pp. 3540--3551.
!----------------------------------------------------------------------
use grid_class, only: &
gr ! Variable type(s)
use constants_clubb, only: & ! Constants
three, & ! 3
two, & ! 2
one, & ! 1
one_half, & ! 1/2
zero, & ! 0
Cp, & ! Dry air specific heat at constant p [J/kg/K]
Lv, & ! Latent heat of vaporization [J/kg]
Rd, & ! Dry air gas constant [J/kg/K]
ep, & ! Rd / Rv; ep = 0.622 [-]
ep1, & ! (1.0-ep)/ep; ep1 = 0.61 [-]
ep2, & ! 1.0/ep; ep2 = 1.61 [-]
rt_tol, & ! Tolerance for r_t [kg/kg]
thl_tol, & ! Tolerance for th_l [K]
T_freeze_K, & ! Freezing point of water [K]
fstderr, &
zero_threshold, &
chi_tol, &
eta_tol, &
max_mag_correlation, &
eps, &
w_tol
use parameters_model, only: &
mixt_frac_max_mag, & ! Variable(s)
sclr_dim ! Number of passive scalar variables
use parameters_tunable, only: &
Skw_denom_coef ! Variable(s)
use pdf_parameter_module, only: &
pdf_parameter, & ! Variable Type
implicit_coefs_terms
use new_pdf_main, only: &
new_pdf_driver ! Procedure(s)
use new_hybrid_pdf_main, only: &
new_hybrid_pdf_driver ! Procedure(s)
use adg1_adg2_3d_luhar_pdf, only: &
ADG1_pdf_driver, & ! Procedure(s)
ADG2_pdf_driver, &
Luhar_3D_pdf_driver
use new_tsdadg_pdf, only: &
tsdadg_pdf_driver ! Procedure(s)
use LY93_pdf, only: &
LY93_driver ! Procedure(s)
use pdf_utilities, only: &
calc_comp_corrs_binormal, & ! Procedure(s)
calc_corr_chi_x, &
calc_corr_eta_x
use array_index, only: &
l_mix_rat_hm ! Variable(s)
use model_flags, only: &
l_explicit_turbulent_adv_wp3, & ! Variable(s)
l_explicit_turbulent_adv_xpyp
use numerical_check, only: &
pdf_closure_check ! Procedure(s)
use saturation, only: &
sat_mixrat_liq, & ! Procedure(s)
sat_mixrat_ice
use stats_variables, only: &
iwp4, & ! Variables
ircp2, &
iwprtp2, &
iwprtpthlp, &
iwpthlp2
use clubb_precision, only: &
core_rknd ! Variable(s)
use error_code, only: &
clubb_at_least_debug_level, & ! Procedure
err_code, & ! Error Indicator
clubb_fatal_error ! Constant
implicit none
intrinsic :: sqrt, exp, min, max, abs, present
! Input Variables
integer, intent(in) :: &
hydromet_dim ! Number of hydrometeor species [#]
real( kind = core_rknd ), dimension(gr%nz), intent(in) :: &
p_in_Pa, & ! Pressure [Pa]
exner, & ! Exner function [-]
thv_ds, & ! Dry, base-state theta_v (ref. th_l here) [K]
wm, & ! mean w-wind component (vertical velocity) [m/s]
wp2, & ! w'^2 [m^2/s^2]
wp3, & ! w'^3 [m^3/s^3]
Skw, & ! Skewness of w [-]
Skthl_in, & ! Skewness of thl [-]
Skrt_in, & ! Skewness of rt [-]
Sku_in, & ! Skewness of u [-]
Skv_in, & ! Skewness of v [-]
rtm, & ! Mean total water mixing ratio [kg/kg]
rtp2, & ! r_t'^2 [(kg/kg)^2]
wprtp, & ! w'r_t' [(kg/kg)(m/s)]
thlm, & ! Mean liquid water potential temperature [K]
thlp2, & ! th_l'^2 [K^2]
wpthlp, & ! w'th_l' [K(m/s)]
rtpthlp ! r_t'th_l' [K(kg/kg)]
real( kind = core_rknd ), dimension(gr%nz), intent(in) :: &
um, & ! Grid-mean eastward wind [m/s]
up2, & ! u'^2 [(m/s)^2]
upwp, & ! u'w' [(m/s)^2]
vm, & ! Grid-mean northward wind [m/s]
vp2, & ! v'^2 [(m/s)^2]
vpwp ! v'w' [(m/s)^2]
real( kind = core_rknd ), dimension(gr%nz, sclr_dim), intent(in) :: &
sclrm, & ! Mean passive scalar [units vary]
wpsclrp, & ! w' sclr' [units vary]
sclrp2, & ! sclr'^2 [units vary]
sclrprtp, & ! sclr' r_t' [units vary]
sclrpthlp, & ! sclr' th_l' [units vary]
Sksclr_in ! Skewness of sclr [-]
#ifdef GFDL
! critial relative humidity for nucleation
real( kind = core_rknd ), dimension( min(1,sclr_dim), 2 ), intent(in) :: & ! h1g, 2010-06-15
RH_crit ! critical relative humidity for droplet and ice nucleation
! ---> h1g, 2012-06-14
logical, intent(in) :: do_liquid_only_in_clubb
! <--- h1g, 2012-06-14
#endif
real( kind = core_rknd ), dimension(gr%nz, hydromet_dim), intent(in) :: &
wphydrometp, & ! Covariance of w and a hydrometeor [(m/s) <hm units>]
wp2hmp, & ! Third-order moment: < w'^2 hm' > [(m/s)^2 <hm units>]
rtphmp, & ! Covariance of rt and a hydrometeor [(kg/kg) <hm units>]
thlphmp ! Covariance of thl and a hydrometeor [K <hm units>]
real( kind = core_rknd ), dimension(gr%nz), intent(inout) :: &
! If iiPDF_type == iiPDF_ADG2, this gets overwritten. Therefore,
! intent(inout). Otherwise it should be intent(in)
sigma_sqd_w ! Width of individual w plumes [-]
! Output Variables
real( kind = core_rknd ), dimension(gr%nz), intent(out) :: &
wp4, & ! w'^4 [m^4/s^4]
wprtp2, & ! w' r_t' [(m kg)/(s kg)]
wp2rtp, & ! w'^2 r_t' [(m^2 kg)/(s^2 kg)]
wpthlp2, & ! w' th_l'^2 [(m K^2)/s]
wp2thlp, & ! w'^2 th_l' [(m^2 K)/s^2]
cloud_frac, & ! Cloud fraction [-]
ice_supersat_frac, & ! Ice cloud fracion [-]
rcm, & ! Mean liquid water [kg/kg]
wpthvp, & ! Buoyancy flux [(K m)/s]
wp2thvp, & ! w'^2 th_v' [(m^2 K)/s^2]
rtpthvp, & ! r_t' th_v' [(kg K)/kg]
thlpthvp, & ! th_l' th_v' [K^2]
wprcp, & ! w' r_c' [(m kg)/(s kg)]
wp2rcp, & ! w'^2 r_c' [(m^2 kg)/(s^2 kg)]
rtprcp, & ! r_t' r_c' [(kg^2)/(kg^2)]
thlprcp, & ! th_l' r_c' [(K kg)/kg]
rcp2, & ! r_c'^2 [(kg^2)/(kg^2)]
wprtpthlp ! w' r_t' th_l' [(m kg K)/(s kg)]
real( kind = core_rknd ), dimension(gr%nz), intent(out) :: &
uprcp, & ! u' r_c' [(m kg)/(s kg)]
vprcp ! v' r_c' [(m kg)/(s kg)]
type(pdf_parameter), intent(inout) :: &
pdf_params ! pdf paramters [units vary]
type(implicit_coefs_terms), intent(out) :: &
pdf_implicit_coefs_terms ! Implicit coefs / explicit terms [units vary]
! Parameters output only for recording statistics (new PDF).
real( kind = core_rknd ), dimension(gr%nz), intent(out) :: &
F_w, & ! Parameter for the spread of the PDF component means of w [-]
F_rt, & ! Parameter for the spread of the PDF component means of rt [-]
F_thl ! Parameter for the spread of the PDF component means of thl [-]
real( kind = core_rknd ), dimension(gr%nz), intent(out) :: &
min_F_w, & ! Minimum allowable value of parameter F_w [-]
max_F_w, & ! Maximum allowable value of parameter F_w [-]
min_F_rt, & ! Minimum allowable value of parameter F_rt [-]
max_F_rt, & ! Maximum allowable value of parameter F_rt [-]
min_F_thl, & ! Minimum allowable value of parameter F_thl [-]
max_F_thl ! Maximum allowable value of parameter F_thl [-]
! Output (passive scalar variables)
real( kind = core_rknd ), intent(out), dimension(gr%nz, sclr_dim) :: &
sclrpthvp, &
sclrprcp, &
wpsclrp2, &
wpsclrprtp, &
wpsclrpthlp, &
wp2sclrp
! Local Variables
! Variables that are stored in derived data type pdf_params.
real( kind = core_rknd ), dimension(gr%nz) :: &
u_1, & ! Mean of eastward wind (1st PDF component) [m/s]
u_2, & ! Mean of eastward wind (2nd PDF component) [m/s]
varnce_u_1, & ! Variance of u (1st PDF component) [m^2/s^2]
varnce_u_2, & ! Variance of u (2nd PDF component) [m^2/s^2]
v_1, & ! Mean of northward wind (1st PDF component) [m/s]
v_2, & ! Mean of northward wind (2nd PDF component) [m/s]
varnce_v_1, & ! Variance of v (1st PDF component) [m^2/s^2]
varnce_v_2, & ! Variance of v (2nd PDF component) [m^2/s^2]
alpha_u, & ! Factor relating to normalized variance for u [-]
alpha_v ! Factor relating to normalized variance for v [-]
real( kind = core_rknd ), dimension(gr%nz) :: &
corr_u_w_1, & ! Correlation of u and w (1st PDF component) [-]
corr_u_w_2, & ! Correlation of u and w (2nd PDF component) [-]
corr_v_w_1, & ! Correlation of v and w (1st PDF component) [-]
corr_v_w_2 ! Correlation of v and w (2nd PDF component) [-]
! Note: alpha coefficients = 0.5 * ( 1 - correlations^2 ).
! These are used to calculate the scalar widths
! varnce_thl_1, varnce_thl_2, varnce_rt_1, and varnce_rt_2 as in
! Eq. (34) of Larson and Golaz (2005)
! Passive scalar local variables
real( kind = core_rknd ), dimension(gr%nz,sclr_dim) :: &
sclr1, sclr2, &
varnce_sclr1, varnce_sclr2, &
alpha_sclr, &
corr_sclr_thl_1, corr_sclr_thl_2, &
corr_sclr_rt_1, corr_sclr_rt_2, &
corr_w_sclr_1, corr_w_sclr_2
logical :: &
l_scalar_calc, & ! True if sclr_dim > 0
l_calc_ice_supersat_frac ! True if we should calculate ice_supersat_frac
! Quantities needed to predict higher order moments
real( kind = core_rknd ), dimension(gr%nz) :: &
tl1, tl2
real( kind = core_rknd ), dimension(gr%nz) :: &
sqrt_wp2, & ! Square root of wp2 [m/s]
Skthl, & ! Skewness of thl [-]
Skrt, & ! Skewness of rt [-]
Sku, & ! Skewness of u [-]
Skv ! Skewness of v [-]
real( kind = core_rknd ), dimension(gr%nz,sclr_dim) :: &
Sksclr ! Skewness of rt [-]
! Thermodynamic quantity
real( kind = core_rknd ), dimension(gr%nz), intent(out) :: &
rc_coef ! Coefficient on X'r_c' in X'th_v' equation [K/(kg/kg)]
real( kind = core_rknd ), dimension(gr%nz) :: &
wprcp_contrib_comp_1, & ! <w'rc'> contrib. (1st PDF comp.) [m/s(kg/kg)]
wprcp_contrib_comp_2, & ! <w'rc'> contrib. (2nd PDF comp.) [m/s(kg/kg)]
wp2rcp_contrib_comp_1, & ! <w'^2rc'> contrib. (1st comp) [m^2/s^2(kg/kg)]
wp2rcp_contrib_comp_2, & ! <w'^2rc'> contrib. (2nd comp) [m^2/s^2(kg/kg)]
rtprcp_contrib_comp_1, & ! <rt'rc'> contrib. (1st PDF comp.) [kg^2/kg^2]
rtprcp_contrib_comp_2, & ! <rt'rc'> contrib. (2nd PDF comp.) [kg^2/kg^2]
thlprcp_contrib_comp_1, & ! <thl'rc'> contrib. (1st PDF comp.) [K(kg/kg)]
thlprcp_contrib_comp_2, & ! <thl'rc'> contrib. (2nd PDF comp.) [K(kg/kg)]
uprcp_contrib_comp_1, & ! <u'rc'> contrib. (1st PDF comp.) [m/s(kg/kg)]
uprcp_contrib_comp_2, & ! <u'rc'> contrib. (2nd PDF comp.) [m/s(kg/kg)]
vprcp_contrib_comp_1, & ! <v'rc'> contrib. (1st PDF comp.) [m/s(kg/kg)]
vprcp_contrib_comp_2 ! <v'rc'> contrib. (2nd PDF comp.) [m/s(kg/kg)]
! variables for computing ice cloud fraction
real( kind = core_rknd), dimension(gr%nz) :: &
rc_1_ice, rc_2_ice
! To test pdf parameters
real( kind = core_rknd ), dimension(gr%nz) :: &
wm_clubb_pdf, &
rtm_clubb_pdf, &
thlm_clubb_pdf, &
wp2_clubb_pdf, &
rtp2_clubb_pdf, &
thlp2_clubb_pdf, &
wp3_clubb_pdf, &
rtp3_clubb_pdf, &
thlp3_clubb_pdf, &
Skw_clubb_pdf, &
Skrt_clubb_pdf, &
Skthl_clubb_pdf
real( kind = core_rknd ) :: &
chi_at_ice_sat1, chi_at_ice_sat2
logical, parameter :: &
l_liq_ice_loading_test = .false. ! Temp. flag liq./ice water loading test
real( kind = core_rknd ), dimension(gr%nz) :: &
zeros ! Vector of 0s (size gr%nz) [-]
real( kind = core_rknd ), dimension(gr%nz,sclr_dim) :: &
zero_array ! Array of 0s (size gr%nz x sclr_dim) [-]
integer :: k, i, hm_idx ! Indices
! Value of chi at saturation for liquid water; always 0
real ( kind = core_rknd ), parameter :: chi_at_liq_sat = 0.0_core_rknd
#ifdef GFDL
real ( kind = core_rknd ), parameter :: t1_combined = 273.16, &
t2_combined = 268.16, &
t3_combined = 238.16
#endif
!------------------------ Code Begins ----------------------------------
! Check whether the passive scalars are present.
if ( sclr_dim > 0 ) then
l_scalar_calc = .true.
else
l_scalar_calc = .false.
end if
! Initialize to default values to prevent a runtime error
if ( ( iiPDF_type /= iiPDF_ADG1 ) .and. ( iiPDF_type /= iiPDF_ADG2 ) ) then
pdf_params%alpha_thl = one_half
pdf_params%alpha_rt = one_half
if ( l_scalar_calc ) then
alpha_sclr = one_half
endif
! This allows for skewness to be clipped locally without passing the updated
! value back out.
Skrt = Skrt_in
Skthl = Skthl_in
Sku = Sku_in
Skv = Skv_in
Sksclr = Sksclr_in
endif
! Initialize to 0 to prevent a runtime error
if ( iiPDF_type /= iiPDF_new .and. iiPDF_type /= iiPDF_new_hybrid ) then
! Set up a vector of 0s and an array of 0s to help write results back to
! type variable pdf_implicit_coefs_terms.
zeros = zero
zero_array = zero
pdf_implicit_coefs_terms%coef_wp4_implicit = zeros
pdf_implicit_coefs_terms%coef_wp2rtp_implicit = zeros
pdf_implicit_coefs_terms%term_wp2rtp_explicit = zeros
pdf_implicit_coefs_terms%coef_wp2thlp_implicit = zeros
pdf_implicit_coefs_terms%term_wp2thlp_explicit = zeros
pdf_implicit_coefs_terms%coef_wp2up_implicit = zeros
pdf_implicit_coefs_terms%term_wp2up_explicit = zeros
pdf_implicit_coefs_terms%coef_wp2vp_implicit = zeros
pdf_implicit_coefs_terms%term_wp2vp_explicit = zeros
pdf_implicit_coefs_terms%coef_wprtp2_implicit = zeros
pdf_implicit_coefs_terms%term_wprtp2_explicit = zeros
pdf_implicit_coefs_terms%coef_wpthlp2_implicit = zeros
pdf_implicit_coefs_terms%term_wpthlp2_explicit = zeros
pdf_implicit_coefs_terms%coef_wprtpthlp_implicit = zeros
pdf_implicit_coefs_terms%term_wprtpthlp_explicit = zeros
pdf_implicit_coefs_terms%coef_wpup2_implicit = zeros
pdf_implicit_coefs_terms%term_wpup2_explicit = zeros
pdf_implicit_coefs_terms%coef_wpvp2_implicit = zeros
pdf_implicit_coefs_terms%term_wpvp2_explicit = zeros
if ( sclr_dim > 0 ) then
pdf_implicit_coefs_terms%coef_wp2sclrp_implicit = zero_array
pdf_implicit_coefs_terms%term_wp2sclrp_explicit = zero_array
pdf_implicit_coefs_terms%coef_wpsclrp2_implicit = zero_array
pdf_implicit_coefs_terms%term_wpsclrp2_explicit = zero_array
pdf_implicit_coefs_terms%coef_wprtpsclrp_implicit = zero_array
pdf_implicit_coefs_terms%term_wprtpsclrp_explicit = zero_array
pdf_implicit_coefs_terms%coef_wpthlpsclrp_implicit = zero_array
pdf_implicit_coefs_terms%term_wpthlpsclrp_explicit = zero_array
endif ! sclr_dim > 0
F_w = zero
F_rt = zero
F_thl = zero
min_F_w = zero
max_F_w = zero
min_F_rt = zero
max_F_rt = zero
min_F_thl = zero
max_F_thl = zero
endif
! To avoid recomputing
sqrt_wp2 = sqrt( wp2 )
! Select the PDF closure method for the two-component PDF used by CLUBB for
! w, rt, theta-l, and passive scalar variables.
! Calculate the mixture fraction for the multivariate PDF, as well as both
! PDF component means and both PDF component variances for each of w, rt,
! theta-l, and passive scalar variables.
if ( iiPDF_type == iiPDF_ADG1 ) then ! use ADG1
call ADG1_pdf_driver( wm, rtm, thlm, um, vm, & ! In
wp2, rtp2, thlp2, up2, vp2, & ! In
Skw, wprtp, wpthlp, upwp, vpwp, sqrt_wp2, & ! In
sigma_sqd_w, mixt_frac_max_mag, & ! In
sclrm, sclrp2, wpsclrp, l_scalar_calc, & ! In
pdf_params%w_1, pdf_params%w_2, & ! Out
pdf_params%rt_1, pdf_params%rt_2, & ! Out
pdf_params%thl_1, pdf_params%thl_2, & ! Out
u_1, u_2, v_1, v_2, & ! Out
pdf_params%varnce_w_1, pdf_params%varnce_w_2, & ! Out
pdf_params%varnce_rt_1, pdf_params%varnce_rt_2, & ! Out
pdf_params%varnce_thl_1, pdf_params%varnce_thl_2, & ! Out
varnce_u_1, varnce_u_2, & ! Out
varnce_v_1, varnce_v_2, & ! Out
pdf_params%mixt_frac, & ! Out
pdf_params%alpha_rt, pdf_params%alpha_thl, & ! Out
alpha_u, alpha_v, & ! Out
sclr1, sclr2, varnce_sclr1, & ! Out
varnce_sclr2, alpha_sclr ) ! Out
elseif ( iiPDF_type == iiPDF_ADG2 ) then ! use ADG2
call ADG2_pdf_driver( wm, rtm, thlm, wp2, rtp2, thlp2, & ! In
Skw, wprtp, wpthlp, sqrt_wp2, & ! In
sclrm, sclrp2, wpsclrp, l_scalar_calc, & ! In
pdf_params%w_1, pdf_params%w_2, & ! Out
pdf_params%rt_1, pdf_params%rt_2, & ! Out
pdf_params%thl_1, pdf_params%thl_2, & ! Out
pdf_params%varnce_w_1, pdf_params%varnce_w_2, & ! Out
pdf_params%varnce_rt_1, pdf_params%varnce_rt_2, & ! Out
pdf_params%varnce_thl_1, pdf_params%varnce_thl_2, & ! Out
pdf_params%mixt_frac, & ! Out
pdf_params%alpha_rt, pdf_params%alpha_thl, & ! Out
sigma_sqd_w, sclr1, sclr2, & ! Out
varnce_sclr1, varnce_sclr2, alpha_sclr ) ! Out
elseif ( iiPDF_type == iiPDF_3D_Luhar ) then ! use 3D Luhar
call Luhar_3D_pdf_driver( wm, rtm, thlm, wp2, rtp2, thlp2, & ! In
Skw, Skrt, Skthl, wprtp, wpthlp, & ! In
pdf_params%w_1, pdf_params%w_2, & ! Out
pdf_params%rt_1, pdf_params%rt_2, & ! Out
pdf_params%thl_1, pdf_params%thl_2, & ! Out
pdf_params%varnce_w_1, pdf_params%varnce_w_2, & ! Out
pdf_params%varnce_rt_1, pdf_params%varnce_rt_2, & ! Out
pdf_params%varnce_thl_1, pdf_params%varnce_thl_2, & ! Out
pdf_params%mixt_frac ) ! Out
elseif ( iiPDF_type == iiPDF_new ) then ! use new PDF
call new_pdf_driver( wm, rtm, thlm, wp2, rtp2, thlp2, Skw, & ! In
wprtp, wpthlp, rtpthlp, & ! In
Skrt, Skthl, & ! In/Out
pdf_params%w_1, pdf_params%w_2, & ! Out
pdf_params%rt_1, pdf_params%rt_2, & ! Out
pdf_params%thl_1, pdf_params%thl_2, & ! Out
pdf_params%varnce_w_1, pdf_params%varnce_w_2, & ! Out
pdf_params%varnce_rt_1, pdf_params%varnce_rt_2, & ! Out
pdf_params%varnce_thl_1, pdf_params%varnce_thl_2, & ! Out
pdf_params%mixt_frac, & ! Out
pdf_implicit_coefs_terms, & ! Out
F_w, F_rt, F_thl, min_F_w, max_F_w, & ! Out
min_F_rt, max_F_rt, min_F_thl, max_F_thl ) ! Out
elseif ( iiPDF_type == iiPDF_TSDADG ) then
call tsdadg_pdf_driver( wm, rtm, thlm, wp2, rtp2, thlp2, & ! In
Skw, Skrt, Skthl, wprtp, wpthlp, & ! In
pdf_params%w_1, pdf_params%w_2, & ! Out
pdf_params%rt_1, pdf_params%rt_2, & ! Out
pdf_params%thl_1, pdf_params%thl_2, & ! Out
pdf_params%varnce_w_1, pdf_params%varnce_w_2, & ! Out
pdf_params%varnce_rt_1, pdf_params%varnce_rt_2, & ! Out
pdf_params%varnce_thl_1, pdf_params%varnce_thl_2, & ! Out
pdf_params%mixt_frac ) ! Out
elseif ( iiPDF_type == iiPDF_LY93 ) then ! use LY93
call LY93_driver( wm, rtm, thlm, wp2, rtp2, & ! In
thlp2, Skw, Skrt, Skthl, & ! In
pdf_params%w_1, pdf_params%w_2, & ! Out
pdf_params%rt_1, pdf_params%rt_2, & ! Out
pdf_params%thl_1, pdf_params%thl_2, & ! Out
pdf_params%varnce_w_1, pdf_params%varnce_w_2, & ! Out
pdf_params%varnce_rt_1, pdf_params%varnce_rt_2, & ! Out
pdf_params%varnce_thl_1, pdf_params%varnce_thl_2, & ! Out
pdf_params%mixt_frac ) ! Out
elseif ( iiPDF_type == iiPDF_new_hybrid ) then ! use new hybrid PDF
call new_hybrid_pdf_driver( wm, rtm, thlm, um, vm, & ! In
wp2, rtp2, thlp2, up2, vp2, & ! In
Skw, wprtp, wpthlp, upwp, vpwp, & ! In
sclrm, sclrp2, wpsclrp, & ! In
Skrt, Skthl, Sku, Skv, Sksclr, & ! I/O
pdf_params%w_1, pdf_params%w_2, & ! Out
pdf_params%rt_1, pdf_params%rt_2, & ! Out
pdf_params%thl_1, pdf_params%thl_2, & ! Out
u_1, u_2, v_1, v_2, & ! Out
pdf_params%varnce_w_1, & ! Out
pdf_params%varnce_w_2, & ! Out
pdf_params%varnce_rt_1, & ! Out
pdf_params%varnce_rt_2, & ! Out
pdf_params%varnce_thl_1, & ! Out
pdf_params%varnce_thl_2, & ! Out
varnce_u_1, varnce_u_2, & ! Out
varnce_v_1, varnce_v_2, & ! Out
sclr1, sclr2, & ! Out
varnce_sclr1, varnce_sclr2, & ! Out
pdf_params%mixt_frac, & ! Out
pdf_implicit_coefs_terms, & ! Out
F_w, min_F_w, max_F_w ) ! Out
! The calculation of skewness of rt, thl, u, v, and scalars is hard-wired
! for use with the ADG1 code, which contains the variable sigma_sqd_w.
! In order to use an equivalent expression for these skewnesses using the
! new hybrid PDF (without doing more recoding), set the value of
! sigma_sqd_w to 1 - F_w.
sigma_sqd_w = one - F_w
endif ! iiPDF_type
! Calculate the PDF component correlations of rt and thl.
call calc_comp_corrs_binormal( rtpthlp, rtm, thlm, & ! In
pdf_params%rt_1, pdf_params%rt_2, & ! In
pdf_params%thl_1, pdf_params%thl_2, & ! In
pdf_params%varnce_rt_1, pdf_params%varnce_rt_2, & ! In
pdf_params%varnce_thl_1, pdf_params%varnce_thl_2, & ! In
pdf_params%mixt_frac, & ! In
pdf_params%corr_rt_thl_1, pdf_params%corr_rt_thl_2 ) ! Out
if ( iiPDF_type == iiPDF_ADG1 .or. iiPDF_type == iiPDF_ADG2 &
.or. iiPDF_type == iiPDF_new_hybrid ) then
! These PDF types define corr_w_rt_1, corr_w_rt_2, corr_w_thl_1, and
! corr_w_thl_2 to all have a value of 0, so skip the calculation.
! The values of corr_u_w_1, corr_u_w_2, corr_v_w_1, and corr_v_w_2 are
! all defined to be 0, as well.
pdf_params%corr_w_rt_1 = zero
pdf_params%corr_w_rt_2 = zero
pdf_params%corr_w_thl_1 = zero
pdf_params%corr_w_thl_2 = zero
corr_u_w_1 = zero
corr_u_w_2 = zero
corr_v_w_1 = zero
corr_v_w_2 = zero
else
! Calculate the PDF component correlations of w and rt.
call calc_comp_corrs_binormal( wprtp, wm, rtm, & ! In
pdf_params%w_1, pdf_params%w_2, & ! In
pdf_params%rt_1, pdf_params%rt_2, & ! In
pdf_params%varnce_w_1, pdf_params%varnce_w_2, & ! In
pdf_params%varnce_rt_1, pdf_params%varnce_rt_2, & ! In
pdf_params%mixt_frac, & ! In
pdf_params%corr_w_rt_1, pdf_params%corr_w_rt_2 ) ! Out
! Calculate the PDF component correlations of w and thl.
call calc_comp_corrs_binormal( wpthlp, wm, thlm, & ! In
pdf_params%w_1, pdf_params%w_2, & ! In
pdf_params%thl_1, pdf_params%thl_2, & ! In
pdf_params%varnce_w_1, pdf_params%varnce_w_2, & ! In
pdf_params%varnce_thl_1, pdf_params%varnce_thl_2, & ! In
pdf_params%mixt_frac, & ! In
pdf_params%corr_w_thl_1, pdf_params%corr_w_thl_2 ) ! Out
endif
if ( l_scalar_calc ) then
do i = 1, sclr_dim
! Calculate the PDF component correlations of a passive scalar and thl.
call calc_comp_corrs_binormal( sclrpthlp(:,i), sclrm(:,i), thlm, & ! In
sclr1(:,i), sclr2(:,i), & ! In
pdf_params%thl_1, pdf_params%thl_2, & ! In
varnce_sclr1(:,i), varnce_sclr2(:,i), & ! In
pdf_params%varnce_thl_1, pdf_params%varnce_thl_2, & ! In
pdf_params%mixt_frac, & ! In
corr_sclr_thl_1(:,i), corr_sclr_thl_2(:,i) ) ! Out
! Calculate the PDF component correlations of a passive scalar and rt.
call calc_comp_corrs_binormal( sclrprtp(:,i), sclrm(:,i), rtm, & ! In
sclr1(:,i), sclr2(:,i), & ! In
pdf_params%rt_1, pdf_params%rt_2, & ! In
varnce_sclr1(:,i), varnce_sclr2(:,i), & ! In
pdf_params%varnce_rt_1, pdf_params%varnce_rt_2, & ! In
pdf_params%mixt_frac, & ! In
corr_sclr_rt_1(:,i), corr_sclr_rt_2(:,i) ) ! Out
if ( iiPDF_type == iiPDF_ADG1 .or. iiPDF_type == iiPDF_ADG2 &
.or. iiPDF_type == iiPDF_new_hybrid ) then
! These PDF types define all PDF component correlations involving w
! to have a value of 0, so skip the calculation.
corr_w_sclr_1(:,i) = zero
corr_w_sclr_2(:,i) = zero
else
! Calculate the PDF component correlations of w and a passive
! scalar.
call calc_comp_corrs_binormal( wpsclrp(:,i), wm, sclrm(:,i), & ! In
pdf_params%w_1, pdf_params%w_2, & ! In
sclr1(:,i), sclr2(:,i), & ! In
pdf_params%varnce_w_1, pdf_params%varnce_w_2, & ! In
varnce_sclr1(:,i), varnce_sclr2(:,i), & ! In
pdf_params%mixt_frac, & ! In
corr_w_sclr_1(:,i), corr_w_sclr_2(:,i) ) ! Out
endif
enddo
endif
! Compute higher order moments (these are interactive)
wp2rtp = calc_wp2xp_pdf( wm, rtm, pdf_params%w_1, pdf_params%w_2, &
pdf_params%rt_1, pdf_params%rt_2, &
pdf_params%varnce_w_1, pdf_params%varnce_w_2, &
pdf_params%varnce_rt_1, pdf_params%varnce_rt_2, &
pdf_params%corr_w_rt_1, pdf_params%corr_w_rt_2, &
pdf_params%mixt_frac )
wp2thlp = calc_wp2xp_pdf( wm, thlm, pdf_params%w_1, pdf_params%w_2, &
pdf_params%thl_1, pdf_params%thl_2, &
pdf_params%varnce_w_1, pdf_params%varnce_w_2, &
pdf_params%varnce_thl_1, pdf_params%varnce_thl_2, &
pdf_params%corr_w_thl_1, pdf_params%corr_w_thl_2, &
pdf_params%mixt_frac )
! Compute higher order moments (these may be interactive)
if ( l_explicit_turbulent_adv_wp3 .or. iwp4 > 0 ) then
wp4 = calc_wp4_pdf( wm, pdf_params%w_1, pdf_params%w_2, &
pdf_params%varnce_w_1, pdf_params%varnce_w_2, &
pdf_params%mixt_frac )
endif
if ( l_explicit_turbulent_adv_xpyp .or. iwprtp2 > 0 ) then
wprtp2 = calc_wpxp2_pdf( wm, rtm, pdf_params%w_1, pdf_params%w_2, &
pdf_params%rt_1, pdf_params%rt_2, &
pdf_params%varnce_w_1, pdf_params%varnce_w_2, &
pdf_params%varnce_rt_1, pdf_params%varnce_rt_2, &
pdf_params%corr_w_rt_1, pdf_params%corr_w_rt_2, &
pdf_params%mixt_frac )
endif
if ( l_explicit_turbulent_adv_xpyp .or. iwpthlp2 > 0 ) then
wpthlp2 = calc_wpxp2_pdf( wm, thlm, pdf_params%w_1, pdf_params%w_2, &
pdf_params%thl_1, pdf_params%thl_2, &
pdf_params%varnce_w_1, pdf_params%varnce_w_2, &
pdf_params%varnce_thl_1, pdf_params%varnce_thl_2, &
pdf_params%corr_w_thl_1, pdf_params%corr_w_thl_2, &
pdf_params%mixt_frac )
endif
if ( l_explicit_turbulent_adv_xpyp .or. iwprtpthlp > 0 ) then
wprtpthlp = calc_wpxpyp_pdf( wm, rtm, thlm, pdf_params%w_1, pdf_params%w_2, &
pdf_params%rt_1, pdf_params%rt_2, &
pdf_params%thl_1, pdf_params%thl_2, &
pdf_params%varnce_w_1, pdf_params%varnce_w_2, &
pdf_params%varnce_rt_1, pdf_params%varnce_rt_2, &
pdf_params%varnce_thl_1, pdf_params%varnce_thl_2, &
pdf_params%corr_w_rt_1, pdf_params%corr_w_rt_2, &
pdf_params%corr_w_thl_1, pdf_params%corr_w_thl_2, &
pdf_params%corr_rt_thl_1, pdf_params%corr_rt_thl_2, &
pdf_params%mixt_frac )
endif
! Scalar Addition to higher order moments
if ( l_scalar_calc ) then
do i = 1, sclr_dim
wp2sclrp(:,i) &
= calc_wp2xp_pdf( wm, sclrm(:,i), pdf_params%w_1, pdf_params%w_2, &
sclr1(:,i), sclr2(:,i), &
pdf_params%varnce_w_1, pdf_params%varnce_w_2, &
varnce_sclr1(:,i), varnce_sclr2(:,i), &
corr_w_sclr_1(:,i), corr_w_sclr_2(:,i), &
pdf_params%mixt_frac )
wpsclrp2(:,i) &
= calc_wpxp2_pdf( wm, sclrm(:,i), pdf_params%w_1, pdf_params%w_2, &
sclr1(:,i), sclr2(:,i), &
pdf_params%varnce_w_1, pdf_params%varnce_w_2, &
varnce_sclr1(:,i), varnce_sclr2(:,i), &
corr_w_sclr_1(:,i), corr_w_sclr_2(:,i), &
pdf_params%mixt_frac )
wpsclrprtp(:,i) &
= calc_wpxpyp_pdf( wm, sclrm(:,i), rtm, pdf_params%w_1, pdf_params%w_2, &
sclr1(:,i), sclr2(:,i), &
pdf_params%rt_1, pdf_params%rt_2, &
pdf_params%varnce_w_1, pdf_params%varnce_w_2, &
varnce_sclr1(:,i), varnce_sclr2(:,i), &
pdf_params%varnce_rt_1, pdf_params%varnce_rt_2, &
corr_w_sclr_1(:,i), corr_w_sclr_2(:,i), &
pdf_params%corr_w_rt_1, pdf_params%corr_w_rt_2, &
corr_sclr_rt_1(:,i), corr_sclr_rt_2(:,i), &
pdf_params%mixt_frac )
wpsclrpthlp(:,i) &
= calc_wpxpyp_pdf( wm, sclrm(:,i), thlm, pdf_params%w_1, pdf_params%w_2, &
sclr1(:,i), sclr2(:,i), &
pdf_params%thl_1, pdf_params%thl_2, &
pdf_params%varnce_w_1, pdf_params%varnce_w_2, &
varnce_sclr1(:,i), varnce_sclr2(:,i), &
pdf_params%varnce_thl_1, pdf_params%varnce_thl_2, &
corr_w_sclr_1(:,i), corr_w_sclr_2(:,i), &
pdf_params%corr_w_thl_1, pdf_params%corr_w_thl_2, &
corr_sclr_thl_1(:,i), corr_sclr_thl_2(:,i), &
pdf_params%mixt_frac )
enddo
endif
! Compute higher order moments that include theta_v.
! First compute some preliminary quantities.
! "1" denotes first Gaussian; "2" denotes 2nd Gaussian
! liq water temp (Sommeria & Deardorff 1977 (SD), eqn. 3)
tl1 = pdf_params%thl_1*exner
tl2 = pdf_params%thl_2*exner
#ifdef GFDL
if ( sclr_dim > 0 .and. (.not. do_liquid_only_in_clubb) ) then ! h1g, 2010-06-16 begin mod
where ( tl1 > t1_combined )
pdf_params%rsatl_1 = sat_mixrat_liq( p_in_Pa, tl1 )
elsewhere ( tl1 > t2_combined )
pdf_params%rsatl_1 = sat_mixrat_liq( p_in_Pa, tl1 ) &
* (tl1 - t2_combined)/(t1_combined - t2_combined) &
+ sat_mixrat_ice( p_in_Pa, tl1 ) &
* (t1_combined - tl1)/(t1_combined - t2_combined)
elsewhere ( tl1 > t3_combined )
pdf_params%rsatl_1 = sat_mixrat_ice( p_in_Pa, tl1 ) &
+ sat_mixrat_ice( p_in_Pa, tl1 ) * (RH_crit(1, 1) -one ) &
* ( t2_combined -tl1)/(t2_combined - t3_combined)
elsewhere
pdf_params%rsatl_1 = sat_mixrat_ice( p_in_Pa, tl1 ) * RH_crit(1, 1)
endwhere
where ( tl2 > t1_combined )
pdf_params%rsatl_2 = sat_mixrat_liq( p_in_Pa, tl2 )
elsewhere ( tl2 > t2_combined )
pdf_params%rsatl_2 = sat_mixrat_liq( p_in_Pa, tl2 ) &
* (tl2 - t2_combined)/(t1_combined - t2_combined) &
+ sat_mixrat_ice( p_in_Pa, tl2 ) &
* (t1_combined - tl2)/(t1_combined - t2_combined)
elsewhere ( tl2 > t3_combined )
pdf_params%rsatl_2 = sat_mixrat_ice( p_in_Pa, tl2 ) &
+ sat_mixrat_ice( p_in_Pa, tl2 )* (RH_crit(1, 2) -one) &
* ( t2_combined -tl2)/(t2_combined - t3_combined)
elsewhere
pdf_params%rsatl_2 = sat_mixrat_ice( p_in_Pa, tl2 ) * RH_crit(1, 2)
endwhere
else ! sclr_dim <= 0 or do_liquid_only_in_clubb = .T.
pdf_params%rsatl_1 = sat_mixrat_liq( p_in_Pa, tl1 )
pdf_params%rsatl_2 = sat_mixrat_liq( p_in_Pa, tl2 )
endif !sclr_dim > 0
! Determine whether to compute ice_supersat_frac. We do not compute
! ice_supersat_frac for GFDL (unless do_liquid_only_in_clubb is true),
! because liquid and ice are both fed into rtm, ruining the calculation.
if (do_liquid_only_in_clubb) then
l_calc_ice_supersat_frac = .true.
else
l_calc_ice_supersat_frac = .false.
end if
#else
pdf_params%rsatl_1 = sat_mixrat_liq( p_in_Pa, tl1 )
pdf_params%rsatl_2 = sat_mixrat_liq( p_in_Pa, tl2 ) ! h1g, 2010-06-16 end mod
l_calc_ice_supersat_frac = .true.
#endif
call transform_pdf_chi_eta_component( tl1, pdf_params%rsatl_1, pdf_params%rt_1, exner, & ! In
pdf_params%varnce_thl_1, pdf_params%varnce_rt_1, & ! In
pdf_params%corr_rt_thl_1, pdf_params%chi_1, & ! In
pdf_params%crt_1, pdf_params%cthl_1, & ! Out
pdf_params%stdev_chi_1, pdf_params%stdev_eta_1, & ! Out
pdf_params%covar_chi_eta_1, & ! Out
pdf_params%corr_chi_eta_1 ) ! Out
! Calculate cloud fraction component for pdf 1
call calc_liquid_cloud_frac_component( pdf_params%chi_1, pdf_params%stdev_chi_1, & ! In
pdf_params%cloud_frac_1, pdf_params%rc_1 ) ! Out
! Calc ice_supersat_frac
if ( l_calc_ice_supersat_frac ) then
do i = 1, gr%nz
if ( tl1(i) <= T_freeze_K ) then
! Temperature is freezing, we must compute chi_at_ice_sat and
! calculate the new cloud_frac_component
chi_at_ice_sat1 = ( sat_mixrat_ice( p_in_Pa(i), tl1(i) ) - pdf_params%rsatl_1(i) ) &
* pdf_params%crt_1(i)
call calc_cloud_frac_component( pdf_params%chi_1(i), pdf_params%stdev_chi_1(i), &
chi_at_ice_sat1, &
pdf_params%ice_supersat_frac_1(i), rc_1_ice(i) )
else
! Temperature is warmer than freezing, the ice_supersat_frac calculation is
! the same as cloud_frac
pdf_params%ice_supersat_frac_1(i) = pdf_params%cloud_frac_1(i)
rc_1_ice(i) = pdf_params%rc_1(i)
end if
end do
end if
call transform_pdf_chi_eta_component( tl2, pdf_params%rsatl_2, pdf_params%rt_2, exner, & ! In
pdf_params%varnce_thl_2, pdf_params%varnce_rt_2, & ! In
pdf_params%corr_rt_thl_2, pdf_params%chi_2, & ! In
pdf_params%crt_2, pdf_params%cthl_2, & ! Out
pdf_params%stdev_chi_2, pdf_params%stdev_eta_2, & ! Out
pdf_params%covar_chi_eta_2, & ! Out
pdf_params%corr_chi_eta_2 ) ! Out
! Calculate cloud fraction component for pdf 2
call calc_liquid_cloud_frac_component( pdf_params%chi_2, pdf_params%stdev_chi_2, & ! In
pdf_params%cloud_frac_2, pdf_params%rc_2 ) ! Out
! Calc ice_supersat_frac
if ( l_calc_ice_supersat_frac ) then
do i = 1, gr%nz
if ( tl2(i) <= T_freeze_K ) then
! Temperature is freezing, we must compute chi_at_ice_sat and
! calculate the new cloud_frac_component
chi_at_ice_sat2 = ( sat_mixrat_ice( p_in_Pa(i), tl2(i) ) - pdf_params%rsatl_2(i) ) &
* pdf_params%crt_2(i)
call calc_cloud_frac_component( pdf_params%chi_2(i), pdf_params%stdev_chi_2(i), &
chi_at_ice_sat2, &
pdf_params%ice_supersat_frac_2(i), rc_2_ice(i) )
else
! Temperature is warmer than freezing, the ice_supersat_frac calculation is
! the same as cloud_frac
pdf_params%ice_supersat_frac_2(i) = pdf_params%cloud_frac_2(i)
rc_2_ice(i) = pdf_params%rc_2(i)
end if
end do
! Compute ice cloud fraction, ice_supersat_frac
ice_supersat_frac = pdf_params%mixt_frac * pdf_params%ice_supersat_frac_1 &
+ ( one - pdf_params%mixt_frac ) * pdf_params%ice_supersat_frac_2
else
! ice_supersat_frac will be garbage if computed as above
ice_supersat_frac = 0.0_core_rknd
if (clubb_at_least_debug_level( 1 )) then
write(fstderr,*) "Warning: ice_supersat_frac has garbage values if &
& do_liquid_only_in_clubb = .false."
end if
end if ! l_calc_ice_supersat_frac
! Compute cloud fraction and mean cloud water mixing ratio.
! Reference:
! https://arxiv.org/pdf/1711.03675v1.pdf#nameddest=url:anl_int_cloud_terms
cloud_frac = pdf_params%mixt_frac * pdf_params%cloud_frac_1 &
+ ( one - pdf_params%mixt_frac ) * pdf_params%cloud_frac_2
rcm = pdf_params%mixt_frac * pdf_params%rc_1 + ( one - pdf_params%mixt_frac ) * pdf_params%rc_2
rcm = max( zero_threshold, rcm )