forked from NCAR/ccpp-physics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule_mp_thompson.F90
6466 lines (5855 loc) · 244 KB
/
module_mp_thompson.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
!>\file module_mp_thompson.F90
!! This file contains the entity of Thompson MP scheme.
!>\ingroup aathompson
!! This module computes the moisture tendencies of water vapor,
!! cloud droplets, rain, cloud ice (pristine), snow, and graupel.
!! Prior to WRFv2.2 this code was based on Reisner et al (1998), but
!! few of those pieces remain. A complete description is now found in
!! Thompson, G., P. R. Field, R. M. Rasmussen, and W. D. Hall, 2008:
!! Explicit Forecasts of winter precipitation using an improved bulk
!! microphysics scheme. Part II: Implementation of a new snow
!! parameterization. Mon. Wea. Rev., 136, 5095-5115.
!!
!! Prior to WRFv3.1, this code was single-moment rain prediction as
!! described in the reference above, but in v3.1 and higher, the
!! scheme is two-moment rain (predicted rain number concentration).
!!
!! Beginning with WRFv3.6, this is also the "aerosol-aware" scheme as
!! described in Thompson, G. and T. Eidhammer, 2014: A study of
!! aerosol impacts on clouds and precipitation development in a large
!! winter cyclone. J. Atmos. Sci., 71, 3636-3658. Setting WRF
!! namelist option mp_physics=8 utilizes the older one-moment cloud
!! water with constant droplet concentration set as Nt_c (found below)
!! while mp_physics=28 uses double-moment cloud droplet number
!! concentration, which is not permitted to exceed Nt_c_max below.
!!
!! Most importantly, users may wish to modify the prescribed number of
!! cloud droplets (Nt_c; see guidelines mentioned below). Otherwise,
!! users may alter the rain and graupel size distribution parameters
!! to use exponential (Marshal-Palmer) or generalized gamma shape.
!! The snow field assumes a combination of two gamma functions (from
!! Field et al. 2005) and would require significant modifications
!! throughout the entire code to alter its shape as well as accretion
!! rates. Users may also alter the constants used for density of rain,
!! graupel, ice, and snow, but the latter is not constant when using
!! Paul Field's snow distribution and moments methods. Other values
!! users can modify include the constants for mass and/or velocity
!! power law relations and assumed capacitances used in deposition/
!! sublimation/evaporation/melting.
!! Remaining values should probably be left alone.
!!
!!\author Greg Thompson, NCAR-RAL, gthompsn@ucar.edu, 303-497-2805
!!
!! - Last modified: 24 Jan 2018 Aerosol additions to v3.5.1 code 9/2013
!! Cloud fraction additions 11/2014 part of pre-v3.7
!! - Imported in CCPP by: Dom Heinzeller, NOAA/ESRL/GSD, dom.heinzeller@noaa.gov
!! - Last modified: 6 Aug 2018 Update of initial import to WRFV4.0
!! - Last modified: 13 Mar 2020 Add logic to turtn on/off the calculation
!! of melting layer in radar reflectivity routine
!! - Last modified: 2 Jun 2020 Add option to rollback to version 3.8.1
!! used in RAPv5/HRRRv4, include stochastic physics
!! perturbations to the graupel intercept parameter,
!! the cloud water shape parameter, and the number
!! concentration of nucleated aerosols.
!! - Last modified: 12 Feb 2021 G. Thompson updated to align more closely
!! with his WRF version, including bug fixes and designed
!! changes.
MODULE module_mp_thompson
USE machine, only : kind_phys
USE module_mp_radar
#ifdef MPI
use mpi
#endif
IMPLICIT NONE
LOGICAL, PARAMETER, PRIVATE:: iiwarm = .false.
LOGICAL, PRIVATE:: is_aerosol_aware = .false.
LOGICAL, PRIVATE:: merra2_aerosol_aware = .false.
LOGICAL, PARAMETER, PRIVATE:: dustyIce = .true.
LOGICAL, PARAMETER, PRIVATE:: homogIce = .true.
INTEGER, PARAMETER, PRIVATE:: IFDRY = 0
REAL, PARAMETER, PRIVATE:: T_0 = 273.15
REAL, PARAMETER, PRIVATE:: PI = 3.1415926536
!..Densities of rain, snow, graupel, and cloud ice.
REAL, PARAMETER, PRIVATE:: rho_w = 1000.0
REAL, PARAMETER, PRIVATE:: rho_s = 100.0
REAL, PARAMETER, PRIVATE:: rho_g = 500.0
REAL, PARAMETER, PRIVATE:: rho_i = 890.0
!..Prescribed number of cloud droplets. Set according to known data or
!.. roughly 100 per cc (100.E6 m^-3) for Maritime cases and
!.. 300 per cc (300.E6 m^-3) for Continental. Gamma shape parameter,
!.. mu_c, calculated based on Nt_c is important in autoconversion
!.. scheme. In 2-moment cloud water, Nt_c represents a maximum of
!.. droplet concentration and nu_c is also variable depending on local
!.. droplet number concentration.
REAL, PARAMETER :: Nt_c_o = 50.E6
REAL, PARAMETER :: Nt_c_l = 100.E6
REAL, PARAMETER, PRIVATE:: Nt_c_max = 1999.E6
!..Declaration of constants for assumed CCN/IN aerosols when none in
!.. the input data. Look inside the init routine for modifications
!.. due to surface land-sea points or vegetation characteristics.
REAL, PARAMETER :: naIN0 = 1.5E6
REAL, PARAMETER :: naIN1 = 0.5E6
REAL, PARAMETER :: naCCN0 = 300.0E6
REAL, PARAMETER :: naCCN1 = 50.0E6
!..Generalized gamma distributions for rain, graupel and cloud ice.
!.. N(D) = N_0 * D**mu * exp(-lamda*D); mu=0 is exponential.
REAL, PARAMETER, PRIVATE:: mu_r = 0.0
REAL, PARAMETER, PRIVATE:: mu_g = 0.0
REAL, PARAMETER, PRIVATE:: mu_i = 0.0
REAL, PRIVATE:: mu_c_o, mu_c_l
!..Sum of two gamma distrib for snow (Field et al. 2005).
!.. N(D) = M2**4/M3**3 * [Kap0*exp(-M2*Lam0*D/M3)
!.. + Kap1*(M2/M3)**mu_s * D**mu_s * exp(-M2*Lam1*D/M3)]
!.. M2 and M3 are the (bm_s)th and (bm_s+1)th moments respectively
!.. calculated as function of ice water content and temperature.
REAL, PARAMETER, PRIVATE:: mu_s = 0.6357
REAL, PARAMETER, PRIVATE:: Kap0 = 490.6
REAL, PARAMETER, PRIVATE:: Kap1 = 17.46
REAL, PARAMETER, PRIVATE:: Lam0 = 20.78
REAL, PARAMETER, PRIVATE:: Lam1 = 3.29
!..Y-intercept parameter for graupel is not constant and depends on
!.. mixing ratio. Also, when mu_g is non-zero, these become equiv
!.. y-intercept for an exponential distrib and proper values are
!.. computed based on same mixing ratio and total number concentration.
REAL, PARAMETER, PRIVATE:: gonv_min = 1.E2
REAL, PARAMETER, PRIVATE:: gonv_max = 1.E6
!..Mass power law relations: mass = am*D**bm
!.. Snow from Field et al. (2005), others assume spherical form.
REAL, PARAMETER, PRIVATE:: am_r = PI*rho_w/6.0
REAL, PARAMETER, PRIVATE:: bm_r = 3.0
REAL, PARAMETER, PRIVATE:: am_s = 0.069
REAL, PARAMETER, PRIVATE:: bm_s = 2.0
REAL, PARAMETER, PRIVATE:: am_g = PI*rho_g/6.0
REAL, PARAMETER, PRIVATE:: bm_g = 3.0
REAL, PARAMETER, PRIVATE:: am_i = PI*rho_i/6.0
REAL, PARAMETER, PRIVATE:: bm_i = 3.0
!..Fallspeed power laws relations: v = (av*D**bv)*exp(-fv*D)
!.. Rain from Ferrier (1994), ice, snow, and graupel from
!.. Thompson et al (2008). Coefficient fv is zero for graupel/ice.
REAL, PARAMETER, PRIVATE:: av_r = 4854.0
REAL, PARAMETER, PRIVATE:: bv_r = 1.0
REAL, PARAMETER, PRIVATE:: fv_r = 195.0
REAL, PARAMETER, PRIVATE:: av_s = 40.0
REAL, PARAMETER, PRIVATE:: bv_s = 0.55
REAL, PARAMETER, PRIVATE:: fv_s = 100.0
REAL, PARAMETER, PRIVATE:: av_g = 442.0
REAL, PARAMETER, PRIVATE:: bv_g = 0.89
REAL, PARAMETER, PRIVATE:: bv_i = 1.0
REAL, PARAMETER, PRIVATE:: av_c = 0.316946E8
REAL, PARAMETER, PRIVATE:: bv_c = 2.0
!..Capacitance of sphere and plates/aggregates: D**3, D**2
REAL, PARAMETER, PRIVATE:: C_cube = 0.5
REAL, PARAMETER, PRIVATE:: C_sqrd = 0.15
!..Collection efficiencies. Rain/snow/graupel collection of cloud
!.. droplets use variables (Ef_rw, Ef_sw, Ef_gw respectively) and
!.. get computed elsewhere because they are dependent on stokes
!.. number.
REAL, PARAMETER, PRIVATE:: Ef_si = 0.05
REAL, PARAMETER, PRIVATE:: Ef_rs = 0.95
REAL, PARAMETER, PRIVATE:: Ef_rg = 0.75
REAL, PARAMETER, PRIVATE:: Ef_ri = 0.95
!..Minimum microphys values
!.. R1 value, 1.E-12, cannot be set lower because of numerical
!.. problems with Paul Field's moments and should not be set larger
!.. because of truncation problems in snow/ice growth.
REAL, PARAMETER, PRIVATE:: R1 = 1.E-12
REAL, PARAMETER, PRIVATE:: R2 = 1.E-6
REAL, PARAMETER :: eps = 1.E-15
!..Constants in Cooper curve relation for cloud ice number.
REAL, PARAMETER, PRIVATE:: TNO = 5.0
REAL, PARAMETER, PRIVATE:: ATO = 0.304
!..Rho_not used in fallspeed relations (rho_not/rho)**.5 adjustment.
REAL, PARAMETER, PRIVATE:: rho_not = 101325.0/(287.05*298.0)
!..Schmidt number
REAL, PARAMETER, PRIVATE:: Sc = 0.632
REAL, PRIVATE:: Sc3
!..Homogeneous freezing temperature
REAL, PARAMETER, PRIVATE:: HGFR = 235.16
!..Water vapor and air gas constants at constant pressure
REAL, PARAMETER, PRIVATE:: Rv = 461.5
REAL, PARAMETER, PRIVATE:: oRv = 1./Rv
REAL, PARAMETER, PRIVATE:: R = 287.04
REAL, PARAMETER, PRIVATE:: Cp = 1004.0
REAL, PARAMETER, PRIVATE:: R_uni = 8.314 !< J (mol K)-1
DOUBLE PRECISION, PARAMETER, PRIVATE:: k_b = 1.38065E-23 !< Boltzmann constant [J/K]
DOUBLE PRECISION, PARAMETER, PRIVATE:: M_w = 18.01528E-3 !< molecular mass of water [kg/mol]
DOUBLE PRECISION, PARAMETER, PRIVATE:: M_a = 28.96E-3 !< molecular mass of air [kg/mol]
DOUBLE PRECISION, PARAMETER, PRIVATE:: N_avo = 6.022E23 !< Avogadro number [1/mol]
DOUBLE PRECISION, PARAMETER, PRIVATE:: ma_w = M_w / N_avo !< mass of water molecule [kg]
REAL, PARAMETER, PRIVATE:: ar_volume = 4./3.*PI*(2.5e-6)**3 !< assume radius of 0.025 micrometer, 2.5e-6 cm
!..Enthalpy of sublimation, vaporization, and fusion at 0C.
REAL, PARAMETER, PRIVATE:: lsub = 2.834E6
REAL, PARAMETER, PRIVATE:: lvap0 = 2.5E6
REAL, PARAMETER, PRIVATE:: lfus = lsub - lvap0
REAL, PARAMETER, PRIVATE:: olfus = 1./lfus
!..Ice initiates with this mass (kg), corresponding diameter calc.
!..Min diameters and mass of cloud, rain, snow, and graupel (m, kg).
REAL, PARAMETER, PRIVATE:: xm0i = 1.E-12
REAL, PARAMETER, PRIVATE:: D0c = 1.E-6
REAL, PARAMETER, PRIVATE:: D0r = 50.E-6
REAL, PARAMETER, PRIVATE:: D0s = 300.E-6
REAL, PARAMETER, PRIVATE:: D0g = 350.E-6
REAL, PRIVATE:: D0i, xm0s, xm0g
!..Min and max radiative effective radius of cloud water, cloud ice, and snow;
!.. performed by subroutine calc_effectRad. On purpose, these should stay PUBLIC.
REAL, PARAMETER:: re_qc_min = 2.50E-6 ! 2.5 microns
REAL, PARAMETER:: re_qc_max = 50.0E-6 ! 50 microns
REAL, PARAMETER:: re_qi_min = 2.50E-6 ! 2.5 microns
REAL, PARAMETER:: re_qi_max = 125.0E-6 ! 125 microns
REAL, PARAMETER:: re_qs_min = 5.00E-6 ! 5 microns
REAL, PARAMETER:: re_qs_max = 999.0E-6 ! 999 microns (1 mm)
!..Lookup table dimensions
INTEGER, PARAMETER, PRIVATE:: nbins = 100
INTEGER, PARAMETER, PRIVATE:: nbc = nbins
INTEGER, PARAMETER, PRIVATE:: nbi = nbins
INTEGER, PARAMETER, PRIVATE:: nbr = nbins
INTEGER, PARAMETER, PRIVATE:: nbs = nbins
INTEGER, PARAMETER, PRIVATE:: nbg = nbins
INTEGER, PARAMETER, PRIVATE:: ntb_c = 37
INTEGER, PARAMETER, PRIVATE:: ntb_i = 64
INTEGER, PARAMETER, PRIVATE:: ntb_r = 37
INTEGER, PARAMETER, PRIVATE:: ntb_s = 28
INTEGER, PARAMETER, PRIVATE:: ntb_g = 28
INTEGER, PARAMETER, PRIVATE:: ntb_g1 = 37
INTEGER, PARAMETER, PRIVATE:: ntb_r1 = 37
INTEGER, PARAMETER, PRIVATE:: ntb_i1 = 55
INTEGER, PARAMETER, PRIVATE:: ntb_t = 9
INTEGER, PRIVATE:: nic1, nic2, nii2, nii3, nir2, nir3, nis2, nig2, nig3
INTEGER, PARAMETER, PRIVATE:: ntb_arc = 7
INTEGER, PARAMETER, PRIVATE:: ntb_arw = 9
INTEGER, PARAMETER, PRIVATE:: ntb_art = 7
INTEGER, PARAMETER, PRIVATE:: ntb_arr = 5
INTEGER, PARAMETER, PRIVATE:: ntb_ark = 4
INTEGER, PARAMETER, PRIVATE:: ntb_IN = 55
INTEGER, PRIVATE:: niIN2
DOUBLE PRECISION, DIMENSION(nbins+1):: xDx
DOUBLE PRECISION, DIMENSION(nbc):: Dc, dtc
DOUBLE PRECISION, DIMENSION(nbi):: Di, dti
DOUBLE PRECISION, DIMENSION(nbr):: Dr, dtr
DOUBLE PRECISION, DIMENSION(nbs):: Ds, dts
DOUBLE PRECISION, DIMENSION(nbg):: Dg, dtg
DOUBLE PRECISION, DIMENSION(nbc):: t_Nc
!> Lookup tables for cloud water content (kg/m**3).
REAL, DIMENSION(ntb_c), PARAMETER, PRIVATE:: &
r_c = (/1.e-6,2.e-6,3.e-6,4.e-6,5.e-6,6.e-6,7.e-6,8.e-6,9.e-6, &
1.e-5,2.e-5,3.e-5,4.e-5,5.e-5,6.e-5,7.e-5,8.e-5,9.e-5, &
1.e-4,2.e-4,3.e-4,4.e-4,5.e-4,6.e-4,7.e-4,8.e-4,9.e-4, &
1.e-3,2.e-3,3.e-3,4.e-3,5.e-3,6.e-3,7.e-3,8.e-3,9.e-3, &
1.e-2/)
!> Lookup tables for cloud ice content (kg/m**3).
REAL, DIMENSION(ntb_i), PARAMETER, PRIVATE:: &
r_i = (/1.e-10,2.e-10,3.e-10,4.e-10, &
5.e-10,6.e-10,7.e-10,8.e-10,9.e-10, &
1.e-9,2.e-9,3.e-9,4.e-9,5.e-9,6.e-9,7.e-9,8.e-9,9.e-9, &
1.e-8,2.e-8,3.e-8,4.e-8,5.e-8,6.e-8,7.e-8,8.e-8,9.e-8, &
1.e-7,2.e-7,3.e-7,4.e-7,5.e-7,6.e-7,7.e-7,8.e-7,9.e-7, &
1.e-6,2.e-6,3.e-6,4.e-6,5.e-6,6.e-6,7.e-6,8.e-6,9.e-6, &
1.e-5,2.e-5,3.e-5,4.e-5,5.e-5,6.e-5,7.e-5,8.e-5,9.e-5, &
1.e-4,2.e-4,3.e-4,4.e-4,5.e-4,6.e-4,7.e-4,8.e-4,9.e-4, &
1.e-3/)
!> Lookup tables for rain content (kg/m**3).
REAL, DIMENSION(ntb_r), PARAMETER, PRIVATE:: &
r_r = (/1.e-6,2.e-6,3.e-6,4.e-6,5.e-6,6.e-6,7.e-6,8.e-6,9.e-6, &
1.e-5,2.e-5,3.e-5,4.e-5,5.e-5,6.e-5,7.e-5,8.e-5,9.e-5, &
1.e-4,2.e-4,3.e-4,4.e-4,5.e-4,6.e-4,7.e-4,8.e-4,9.e-4, &
1.e-3,2.e-3,3.e-3,4.e-3,5.e-3,6.e-3,7.e-3,8.e-3,9.e-3, &
1.e-2/)
!> Lookup tables for graupel content (kg/m**3).
REAL, DIMENSION(ntb_g), PARAMETER, PRIVATE:: &
r_g = (/1.e-5,2.e-5,3.e-5,4.e-5,5.e-5,6.e-5,7.e-5,8.e-5,9.e-5, &
1.e-4,2.e-4,3.e-4,4.e-4,5.e-4,6.e-4,7.e-4,8.e-4,9.e-4, &
1.e-3,2.e-3,3.e-3,4.e-3,5.e-3,6.e-3,7.e-3,8.e-3,9.e-3, &
1.e-2/)
!> Lookup tables for snow content (kg/m**3).
REAL, DIMENSION(ntb_s), PARAMETER, PRIVATE:: &
r_s = (/1.e-5,2.e-5,3.e-5,4.e-5,5.e-5,6.e-5,7.e-5,8.e-5,9.e-5, &
1.e-4,2.e-4,3.e-4,4.e-4,5.e-4,6.e-4,7.e-4,8.e-4,9.e-4, &
1.e-3,2.e-3,3.e-3,4.e-3,5.e-3,6.e-3,7.e-3,8.e-3,9.e-3, &
1.e-2/)
!> Lookup tables for rain y-intercept parameter (/m**4).
REAL, DIMENSION(ntb_r1), PARAMETER, PRIVATE:: &
N0r_exp = (/1.e6,2.e6,3.e6,4.e6,5.e6,6.e6,7.e6,8.e6,9.e6, &
1.e7,2.e7,3.e7,4.e7,5.e7,6.e7,7.e7,8.e7,9.e7, &
1.e8,2.e8,3.e8,4.e8,5.e8,6.e8,7.e8,8.e8,9.e8, &
1.e9,2.e9,3.e9,4.e9,5.e9,6.e9,7.e9,8.e9,9.e9, &
1.e10/)
!> Lookup tables for graupel y-intercept parameter (/m**4).
REAL, DIMENSION(ntb_g1), PARAMETER, PRIVATE:: &
N0g_exp = (/1.e2,2.e2,3.e2,4.e2,5.e2,6.e2,7.e2,8.e2,9.e2, &
1.e3,2.e3,3.e3,4.e3,5.e3,6.e3,7.e3,8.e3,9.e3, &
1.e4,2.e4,3.e4,4.e4,5.e4,6.e4,7.e4,8.e4,9.e4, &
1.e5,2.e5,3.e5,4.e5,5.e5,6.e5,7.e5,8.e5,9.e5, &
1.e6/)
!> Lookup tables for ice number concentration (/m**3).
REAL, DIMENSION(ntb_i1), PARAMETER, PRIVATE:: &
Nt_i = (/1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0, &
1.e1,2.e1,3.e1,4.e1,5.e1,6.e1,7.e1,8.e1,9.e1, &
1.e2,2.e2,3.e2,4.e2,5.e2,6.e2,7.e2,8.e2,9.e2, &
1.e3,2.e3,3.e3,4.e3,5.e3,6.e3,7.e3,8.e3,9.e3, &
1.e4,2.e4,3.e4,4.e4,5.e4,6.e4,7.e4,8.e4,9.e4, &
1.e5,2.e5,3.e5,4.e5,5.e5,6.e5,7.e5,8.e5,9.e5, &
1.e6/)
!..Aerosol table parameter: Number of available aerosols, vertical
!.. velocity, temperature, aerosol mean radius, and hygroscopicity.
REAL, DIMENSION(ntb_arc), PARAMETER, PRIVATE:: &
ta_Na = (/10.0, 31.6, 100.0, 316.0, 1000.0, 3160.0, 10000.0/)
REAL, DIMENSION(ntb_arw), PARAMETER, PRIVATE:: &
ta_Ww = (/0.01, 0.0316, 0.1, 0.316, 1.0, 3.16, 10.0, 31.6, 100.0/)
REAL, DIMENSION(ntb_art), PARAMETER, PRIVATE:: &
ta_Tk = (/243.15, 253.15, 263.15, 273.15, 283.15, 293.15, 303.15/)
REAL, DIMENSION(ntb_arr), PARAMETER, PRIVATE:: &
ta_Ra = (/0.01, 0.02, 0.04, 0.08, 0.16/)
REAL, DIMENSION(ntb_ark), PARAMETER, PRIVATE:: &
ta_Ka = (/0.2, 0.4, 0.6, 0.8/)
!> Lookup tables for IN concentration (/m**3) from 0.001 to 1000/Liter.
REAL, DIMENSION(ntb_IN), PARAMETER, PRIVATE:: &
Nt_IN = (/1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0, &
1.e1,2.e1,3.e1,4.e1,5.e1,6.e1,7.e1,8.e1,9.e1, &
1.e2,2.e2,3.e2,4.e2,5.e2,6.e2,7.e2,8.e2,9.e2, &
1.e3,2.e3,3.e3,4.e3,5.e3,6.e3,7.e3,8.e3,9.e3, &
1.e4,2.e4,3.e4,4.e4,5.e4,6.e4,7.e4,8.e4,9.e4, &
1.e5,2.e5,3.e5,4.e5,5.e5,6.e5,7.e5,8.e5,9.e5, &
1.e6/)
!> For snow moments conversions (from Field et al. 2005)
REAL, DIMENSION(10), PARAMETER, PRIVATE:: &
sa = (/ 5.065339, -0.062659, -3.032362, 0.029469, -0.000285, &
0.31255, 0.000204, 0.003199, 0.0, -0.015952/)
REAL, DIMENSION(10), PARAMETER, PRIVATE:: &
sb = (/ 0.476221, -0.015896, 0.165977, 0.007468, -0.000141, &
0.060366, 0.000079, 0.000594, 0.0, -0.003577/)
!> Temperatures (5 C interval 0 to -40) used in lookup tables.
REAL, DIMENSION(ntb_t), PARAMETER, PRIVATE:: &
Tc = (/-0.01, -5., -10., -15., -20., -25., -30., -35., -40./)
!..Lookup tables for various accretion/collection terms.
!.. ntb_x refers to the number of elements for rain, snow, graupel,
!.. and temperature array indices. Variables beginning with t-p/c/m/n
!.. represent lookup tables. Save compile-time memory by making
!.. allocatable (2009Jun12, J. Michalakes).
!..To permit possible creation of new lookup tables as variables expand/change,
!.. specify a name of external file(s) including version number for pre-computed
!.. Thompson tables.
character(len=*), parameter :: thomp_table_file = 'thompson_tables_precomp_v2.sl'
character(len=*), parameter :: qr_acr_qg_file = 'qr_acr_qgV2.dat'
character(len=*), parameter :: qr_acr_qs_file = 'qr_acr_qsV2.dat'
character(len=*), parameter :: freeze_h2o_file = 'freezeH2O.dat'
INTEGER, PARAMETER, PRIVATE:: R8SIZE = 8
INTEGER, PARAMETER, PRIVATE:: R4SIZE = 4
REAL (KIND=R8SIZE), ALLOCATABLE, DIMENSION(:,:,:,:):: &
tcg_racg, tmr_racg, tcr_gacr, tmg_gacr, &
tnr_racg, tnr_gacr
REAL (KIND=R8SIZE), ALLOCATABLE, DIMENSION(:,:,:,:):: &
tcs_racs1, tmr_racs1, tcs_racs2, tmr_racs2, &
tcr_sacr1, tms_sacr1, tcr_sacr2, tms_sacr2, &
tnr_racs1, tnr_racs2, tnr_sacr1, tnr_sacr2
REAL (KIND=R8SIZE), ALLOCATABLE, DIMENSION(:,:,:,:):: &
tpi_qcfz, tni_qcfz
REAL (KIND=R8SIZE), ALLOCATABLE, DIMENSION(:,:,:,:):: &
tpi_qrfz, tpg_qrfz, tni_qrfz, tnr_qrfz
REAL (KIND=R8SIZE), ALLOCATABLE, DIMENSION(:,:):: &
tps_iaus, tni_iaus, tpi_ide
REAL (KIND=R8SIZE), ALLOCATABLE, DIMENSION(:,:):: t_Efrw
REAL (KIND=R8SIZE), ALLOCATABLE, DIMENSION(:,:):: t_Efsw
REAL (KIND=R8SIZE), ALLOCATABLE, DIMENSION(:,:,:):: tnr_rev
REAL (KIND=R8SIZE), ALLOCATABLE, DIMENSION(:,:,:):: &
tpc_wev, tnc_wev
REAL (KIND=R4SIZE), ALLOCATABLE, DIMENSION(:,:,:,:,:):: tnccn_act
!..Variables holding a bunch of exponents and gamma values (cloud water,
!.. cloud ice, rain, snow, then graupel).
REAL, DIMENSION(5,15), PRIVATE:: cce, ccg
REAL, DIMENSION(15), PRIVATE:: ocg1, ocg2
REAL, DIMENSION(7), PRIVATE:: cie, cig
REAL, PRIVATE:: oig1, oig2, obmi
REAL, DIMENSION(13), PRIVATE:: cre, crg
REAL, PRIVATE:: ore1, org1, org2, org3, obmr
REAL, DIMENSION(18), PRIVATE:: cse, csg
REAL, PRIVATE:: oams, obms, ocms
REAL, DIMENSION(12), PRIVATE:: cge, cgg
REAL, PRIVATE:: oge1, ogg1, ogg2, ogg3, oamg, obmg, ocmg
!..Declaration of precomputed constants in various rate eqns.
REAL:: t1_qr_qc, t1_qr_qi, t2_qr_qi, t1_qg_qc, t1_qs_qc, t1_qs_qi
REAL:: t1_qr_ev, t2_qr_ev
REAL:: t1_qs_sd, t2_qs_sd, t1_qg_sd, t2_qg_sd
REAL:: t1_qs_me, t2_qs_me, t1_qg_me, t2_qg_me
!..MPI communicator
INTEGER:: mpi_communicator
!..Write tables with master MPI task after computing them in thompson_init
LOGICAL:: thompson_table_writer
!+---+
!+---+-----------------------------------------------------------------+
!..END DECLARATIONS
!+---+-----------------------------------------------------------------+
!+---+
!ctrlL
CONTAINS
!>\ingroup aathompson
!! This subroutine calculates simplified cloud species equations and create
!! lookup tables in Thomspson scheme.
!>\section gen_thompson_init thompson_init General Algorithm
!> @{
SUBROUTINE thompson_init(is_aerosol_aware_in, &
merra2_aerosol_aware_in, &
mpicomm, mpirank, mpiroot, &
threads, errmsg, errflg)
IMPLICIT NONE
LOGICAL, INTENT(IN) :: is_aerosol_aware_in
LOGICAL, INTENT(IN) :: merra2_aerosol_aware_in
INTEGER, INTENT(IN) :: mpicomm, mpirank, mpiroot
INTEGER, INTENT(IN) :: threads
CHARACTER(len=*), INTENT(INOUT) :: errmsg
INTEGER, INTENT(INOUT) :: errflg
INTEGER:: i, j, k, l, m, n
LOGICAL:: micro_init
real :: stime, etime
LOGICAL, PARAMETER :: precomputed_tables = .FALSE.
! Set module variable is_aerosol_aware/merra2_aerosol_aware
is_aerosol_aware = is_aerosol_aware_in
merra2_aerosol_aware = merra2_aerosol_aware_in
if (is_aerosol_aware .and. merra2_aerosol_aware) then
errmsg = 'Logic error in thompson_init: only one of the two options can be true, ' // &
'not both: is_aerosol_aware or merra2_aerosol_aware'
errflg = 1
return
end if
if (mpirank==mpiroot) then
if (is_aerosol_aware) then
write (0,'(a)') 'Using aerosol-aware version of Thompson microphysics'
else if(merra2_aerosol_aware) then
write (0,'(a)') 'Using merra2 aerosol-aware version of Thompson microphysics'
else
write (0,'(a)') 'Using non-aerosol-aware version of Thompson microphysics'
end if
end if
micro_init = .FALSE.
!> - Allocate space for lookup tables (J. Michalakes 2009Jun08).
if (.NOT. ALLOCATED(tcg_racg) ) then
ALLOCATE(tcg_racg(ntb_g1,ntb_g,ntb_r1,ntb_r))
micro_init = .TRUE.
endif
if (.NOT. ALLOCATED(tmr_racg)) ALLOCATE(tmr_racg(ntb_g1,ntb_g,ntb_r1,ntb_r))
if (.NOT. ALLOCATED(tcr_gacr)) ALLOCATE(tcr_gacr(ntb_g1,ntb_g,ntb_r1,ntb_r))
if (.NOT. ALLOCATED(tmg_gacr)) ALLOCATE(tmg_gacr(ntb_g1,ntb_g,ntb_r1,ntb_r))
if (.NOT. ALLOCATED(tnr_racg)) ALLOCATE(tnr_racg(ntb_g1,ntb_g,ntb_r1,ntb_r))
if (.NOT. ALLOCATED(tnr_gacr)) ALLOCATE(tnr_gacr(ntb_g1,ntb_g,ntb_r1,ntb_r))
if (.NOT. ALLOCATED(tcs_racs1)) ALLOCATE(tcs_racs1(ntb_s,ntb_t,ntb_r1,ntb_r))
if (.NOT. ALLOCATED(tmr_racs1)) ALLOCATE(tmr_racs1(ntb_s,ntb_t,ntb_r1,ntb_r))
if (.NOT. ALLOCATED(tcs_racs2)) ALLOCATE(tcs_racs2(ntb_s,ntb_t,ntb_r1,ntb_r))
if (.NOT. ALLOCATED(tmr_racs2)) ALLOCATE(tmr_racs2(ntb_s,ntb_t,ntb_r1,ntb_r))
if (.NOT. ALLOCATED(tcr_sacr1)) ALLOCATE(tcr_sacr1(ntb_s,ntb_t,ntb_r1,ntb_r))
if (.NOT. ALLOCATED(tms_sacr1)) ALLOCATE(tms_sacr1(ntb_s,ntb_t,ntb_r1,ntb_r))
if (.NOT. ALLOCATED(tcr_sacr2)) ALLOCATE(tcr_sacr2(ntb_s,ntb_t,ntb_r1,ntb_r))
if (.NOT. ALLOCATED(tms_sacr2)) ALLOCATE(tms_sacr2(ntb_s,ntb_t,ntb_r1,ntb_r))
if (.NOT. ALLOCATED(tnr_racs1)) ALLOCATE(tnr_racs1(ntb_s,ntb_t,ntb_r1,ntb_r))
if (.NOT. ALLOCATED(tnr_racs2)) ALLOCATE(tnr_racs2(ntb_s,ntb_t,ntb_r1,ntb_r))
if (.NOT. ALLOCATED(tnr_sacr1)) ALLOCATE(tnr_sacr1(ntb_s,ntb_t,ntb_r1,ntb_r))
if (.NOT. ALLOCATED(tnr_sacr2)) ALLOCATE(tnr_sacr2(ntb_s,ntb_t,ntb_r1,ntb_r))
if (.NOT. ALLOCATED(tpi_qcfz)) ALLOCATE(tpi_qcfz(ntb_c,nbc,45,ntb_IN))
if (.NOT. ALLOCATED(tni_qcfz)) ALLOCATE(tni_qcfz(ntb_c,nbc,45,ntb_IN))
if (.NOT. ALLOCATED(tpi_qrfz)) ALLOCATE(tpi_qrfz(ntb_r,ntb_r1,45,ntb_IN))
if (.NOT. ALLOCATED(tpg_qrfz)) ALLOCATE(tpg_qrfz(ntb_r,ntb_r1,45,ntb_IN))
if (.NOT. ALLOCATED(tni_qrfz)) ALLOCATE(tni_qrfz(ntb_r,ntb_r1,45,ntb_IN))
if (.NOT. ALLOCATED(tnr_qrfz)) ALLOCATE(tnr_qrfz(ntb_r,ntb_r1,45,ntb_IN))
if (.NOT. ALLOCATED(tps_iaus)) ALLOCATE(tps_iaus(ntb_i,ntb_i1))
if (.NOT. ALLOCATED(tni_iaus)) ALLOCATE(tni_iaus(ntb_i,ntb_i1))
if (.NOT. ALLOCATED(tpi_ide)) ALLOCATE(tpi_ide(ntb_i,ntb_i1))
if (.NOT. ALLOCATED(t_Efrw)) ALLOCATE(t_Efrw(nbr,nbc))
if (.NOT. ALLOCATED(t_Efsw)) ALLOCATE(t_Efsw(nbs,nbc))
if (.NOT. ALLOCATED(tnr_rev)) ALLOCATE(tnr_rev(nbr, ntb_r1, ntb_r))
if (.NOT. ALLOCATED(tpc_wev)) ALLOCATE(tpc_wev(nbc,ntb_c,nbc))
if (.NOT. ALLOCATED(tnc_wev)) ALLOCATE(tnc_wev(nbc,ntb_c,nbc))
if (.NOT. ALLOCATED(tnccn_act)) &
ALLOCATE(tnccn_act(ntb_arc,ntb_arw,ntb_art,ntb_arr,ntb_ark))
if_micro_init: if (micro_init) then
!> - From Martin et al. (1994), assign gamma shape parameter mu for cloud
!! drops according to general dispersion characteristics (disp=~0.25
!! for maritime and 0.45 for continental)
!.. disp=SQRT((mu+2)/(mu+1) - 1) so mu varies from 15 for Maritime
!.. to 2 for really dirty air. This not used in 2-moment cloud water
!.. scheme and nu_c used instead and varies from 2 to 15 (integer-only).
mu_c_l = MIN(15., (1000.E6/Nt_c_l + 2.))
mu_c_o = MIN(15., (1000.E6/Nt_c_o + 2.))
!> - Compute Schmidt number to one-third used numerous times
Sc3 = Sc**(1./3.)
!> - Compute minimum ice diam from mass, min snow/graupel mass from diam
D0i = (xm0i/am_i)**(1./bm_i)
xm0s = am_s * D0s**bm_s
xm0g = am_g * D0g**bm_g
!> - Compute constants various exponents and gamma() associated with cloud,
!! rain, snow, and graupel
do n = 1, 15
cce(1,n) = n + 1.
cce(2,n) = bm_r + n + 1.
cce(3,n) = bm_r + n + 4.
cce(4,n) = n + bv_c + 1.
cce(5,n) = bm_r + n + bv_c + 1.
ccg(1,n) = WGAMMA(cce(1,n))
ccg(2,n) = WGAMMA(cce(2,n))
ccg(3,n) = WGAMMA(cce(3,n))
ccg(4,n) = WGAMMA(cce(4,n))
ccg(5,n) = WGAMMA(cce(5,n))
ocg1(n) = 1./ccg(1,n)
ocg2(n) = 1./ccg(2,n)
enddo
cie(1) = mu_i + 1.
cie(2) = bm_i + mu_i + 1.
cie(3) = bm_i + mu_i + bv_i + 1.
cie(4) = mu_i + bv_i + 1.
cie(5) = mu_i + 2.
cie(6) = bm_i*0.5 + mu_i + bv_i + 1.
cie(7) = bm_i*0.5 + mu_i + 1.
cig(1) = WGAMMA(cie(1))
cig(2) = WGAMMA(cie(2))
cig(3) = WGAMMA(cie(3))
cig(4) = WGAMMA(cie(4))
cig(5) = WGAMMA(cie(5))
cig(6) = WGAMMA(cie(6))
cig(7) = WGAMMA(cie(7))
oig1 = 1./cig(1)
oig2 = 1./cig(2)
obmi = 1./bm_i
cre(1) = bm_r + 1.
cre(2) = mu_r + 1.
cre(3) = bm_r + mu_r + 1.
cre(4) = bm_r*2. + mu_r + 1.
cre(5) = mu_r + bv_r + 1.
cre(6) = bm_r + mu_r + bv_r + 1.
cre(7) = bm_r*0.5 + mu_r + bv_r + 1.
cre(8) = bm_r + mu_r + bv_r + 3.
cre(9) = mu_r + bv_r + 3.
cre(10) = mu_r + 2.
cre(11) = 0.5*(bv_r + 5. + 2.*mu_r)
cre(12) = bm_r*0.5 + mu_r + 1.
cre(13) = bm_r*2. + mu_r + bv_r + 1.
do n = 1, 13
crg(n) = WGAMMA(cre(n))
enddo
obmr = 1./bm_r
ore1 = 1./cre(1)
org1 = 1./crg(1)
org2 = 1./crg(2)
org3 = 1./crg(3)
cse(1) = bm_s + 1.
cse(2) = bm_s + 2.
cse(3) = bm_s*2.
cse(4) = bm_s + bv_s + 1.
cse(5) = bm_s*2. + bv_s + 1.
cse(6) = bm_s*2. + 1.
cse(7) = bm_s + mu_s + 1.
cse(8) = bm_s + mu_s + 2.
cse(9) = bm_s + mu_s + 3.
cse(10) = bm_s + mu_s + bv_s + 1.
cse(11) = bm_s*2. + mu_s + bv_s + 1.
cse(12) = bm_s*2. + mu_s + 1.
cse(13) = bv_s + 2.
cse(14) = bm_s + bv_s
cse(15) = mu_s + 1.
cse(16) = 1.0 + (1.0 + bv_s)/2.
cse(17) = cse(16) + mu_s + 1.
cse(18) = bv_s + mu_s + 3.
do n = 1, 18
csg(n) = WGAMMA(cse(n))
enddo
oams = 1./am_s
obms = 1./bm_s
ocms = oams**obms
cge(1) = bm_g + 1.
cge(2) = mu_g + 1.
cge(3) = bm_g + mu_g + 1.
cge(4) = bm_g*2. + mu_g + 1.
cge(5) = bm_g*2. + mu_g + bv_g + 1.
cge(6) = bm_g + mu_g + bv_g + 1.
cge(7) = bm_g + mu_g + bv_g + 2.
cge(8) = bm_g + mu_g + bv_g + 3.
cge(9) = mu_g + bv_g + 3.
cge(10) = mu_g + 2.
cge(11) = 0.5*(bv_g + 5. + 2.*mu_g)
cge(12) = 0.5*(bv_g + 5.) + mu_g
do n = 1, 12
cgg(n) = WGAMMA(cge(n))
enddo
oamg = 1./am_g
obmg = 1./bm_g
ocmg = oamg**obmg
oge1 = 1./cge(1)
ogg1 = 1./cgg(1)
ogg2 = 1./cgg(2)
ogg3 = 1./cgg(3)
!+---+-----------------------------------------------------------------+
!> - Simplify various rate equations
!+---+-----------------------------------------------------------------+
!> - Compute rain collecting cloud water and cloud ice
t1_qr_qc = PI*.25*av_r * crg(9)
t1_qr_qi = PI*.25*av_r * crg(9)
t2_qr_qi = PI*.25*am_r*av_r * crg(8)
!> - Compute graupel collecting cloud water
t1_qg_qc = PI*.25*av_g * cgg(9)
!> - Compute snow collecting cloud water
t1_qs_qc = PI*.25*av_s
!> - Compute snow collecting cloud ice
t1_qs_qi = PI*.25*av_s
!> - Compute evaporation of rain; ignore depositional growth of rain
t1_qr_ev = 0.78 * crg(10)
t2_qr_ev = 0.308*Sc3*SQRT(av_r) * crg(11)
!> - Compute sublimation/depositional growth of snow
t1_qs_sd = 0.86
t2_qs_sd = 0.28*Sc3*SQRT(av_s)
!> - Compute melting of snow
t1_qs_me = PI*4.*C_sqrd*olfus * 0.86
t2_qs_me = PI*4.*C_sqrd*olfus * 0.28*Sc3*SQRT(av_s)
!> - Compute sublimation/depositional growth of graupel
t1_qg_sd = 0.86 * cgg(10)
t2_qg_sd = 0.28*Sc3*SQRT(av_g) * cgg(11)
!> - Compute melting of graupel
t1_qg_me = PI*4.*C_cube*olfus * 0.86 * cgg(10)
t2_qg_me = PI*4.*C_cube*olfus * 0.28*Sc3*SQRT(av_g) * cgg(11)
!> - Compute constants for helping find lookup table indexes
nic2 = NINT(ALOG10(r_c(1)))
nii2 = NINT(ALOG10(r_i(1)))
nii3 = NINT(ALOG10(Nt_i(1)))
nir2 = NINT(ALOG10(r_r(1)))
nir3 = NINT(ALOG10(N0r_exp(1)))
nis2 = NINT(ALOG10(r_s(1)))
nig2 = NINT(ALOG10(r_g(1)))
nig3 = NINT(ALOG10(N0g_exp(1)))
niIN2 = NINT(ALOG10(Nt_IN(1)))
!> - Create bins of cloud water (from min diameter up to 100 microns)
Dc(1) = D0c*1.0d0
dtc(1) = D0c*1.0d0
do n = 2, nbc
Dc(n) = Dc(n-1) + 1.0D-6
dtc(n) = (Dc(n) - Dc(n-1))
enddo
!> - Create bins of cloud ice (from min diameter up to 5x min snow size)
xDx(1) = D0i*1.0d0
xDx(nbi+1) = 5.0d0*D0s
do n = 2, nbi
xDx(n) = DEXP(DFLOAT(n-1)/DFLOAT(nbi) &
*DLOG(xDx(nbi+1)/xDx(1)) +DLOG(xDx(1)))
enddo
do n = 1, nbi
Di(n) = DSQRT(xDx(n)*xDx(n+1))
dti(n) = xDx(n+1) - xDx(n)
enddo
!> - Create bins of rain (from min diameter up to 5 mm)
xDx(1) = D0r*1.0d0
xDx(nbr+1) = 0.005d0
do n = 2, nbr
xDx(n) = DEXP(DFLOAT(n-1)/DFLOAT(nbr) &
*DLOG(xDx(nbr+1)/xDx(1)) +DLOG(xDx(1)))
enddo
do n = 1, nbr
Dr(n) = DSQRT(xDx(n)*xDx(n+1))
dtr(n) = xDx(n+1) - xDx(n)
enddo
!> - Create bins of snow (from min diameter up to 2 cm)
xDx(1) = D0s*1.0d0
xDx(nbs+1) = 0.02d0
do n = 2, nbs
xDx(n) = DEXP(DFLOAT(n-1)/DFLOAT(nbs) &
*DLOG(xDx(nbs+1)/xDx(1)) +DLOG(xDx(1)))
enddo
do n = 1, nbs
Ds(n) = DSQRT(xDx(n)*xDx(n+1))
dts(n) = xDx(n+1) - xDx(n)
enddo
!> - Create bins of graupel (from min diameter up to 5 cm)
xDx(1) = D0g*1.0d0
xDx(nbg+1) = 0.05d0
do n = 2, nbg
xDx(n) = DEXP(DFLOAT(n-1)/DFLOAT(nbg) &
*DLOG(xDx(nbg+1)/xDx(1)) +DLOG(xDx(1)))
enddo
do n = 1, nbg
Dg(n) = DSQRT(xDx(n)*xDx(n+1))
dtg(n) = xDx(n+1) - xDx(n)
enddo
!> - Create bins of cloud droplet number concentration (1 to 3000 per cc)
xDx(1) = 1.0d0
xDx(nbc+1) = 3000.0d0
do n = 2, nbc
xDx(n) = DEXP(DFLOAT(n-1)/DFLOAT(nbc) &
*DLOG(xDx(nbc+1)/xDx(1)) +DLOG(xDx(1)))
enddo
do n = 1, nbc
t_Nc(n) = DSQRT(xDx(n)*xDx(n+1)) * 1.D6
enddo
nic1 = DLOG(t_Nc(nbc)/t_Nc(1))
!+---+-----------------------------------------------------------------+
!> - Create lookup tables for most costly calculations
!+---+-----------------------------------------------------------------+
! Assign mpicomm to module variable
mpi_communicator = mpicomm
! Standard tables are only written by master MPI task;
! (physics init cannot be called by multiple threads,
! hence no need to test for a specific thread number)
if (mpirank==mpiroot) then
thompson_table_writer = .true.
else
thompson_table_writer = .false.
end if
precomputed_tables_1: if (.not.precomputed_tables) then
call cpu_time(stime)
do m = 1, ntb_r
do k = 1, ntb_r1
do j = 1, ntb_g
do i = 1, ntb_g1
tcg_racg(i,j,k,m) = 0.0d0
tmr_racg(i,j,k,m) = 0.0d0
tcr_gacr(i,j,k,m) = 0.0d0
tmg_gacr(i,j,k,m) = 0.0d0
tnr_racg(i,j,k,m) = 0.0d0
tnr_gacr(i,j,k,m) = 0.0d0
enddo
enddo
enddo
enddo
do m = 1, ntb_r
do k = 1, ntb_r1
do j = 1, ntb_t
do i = 1, ntb_s
tcs_racs1(i,j,k,m) = 0.0d0
tmr_racs1(i,j,k,m) = 0.0d0
tcs_racs2(i,j,k,m) = 0.0d0
tmr_racs2(i,j,k,m) = 0.0d0
tcr_sacr1(i,j,k,m) = 0.0d0
tms_sacr1(i,j,k,m) = 0.0d0
tcr_sacr2(i,j,k,m) = 0.0d0
tms_sacr2(i,j,k,m) = 0.0d0
tnr_racs1(i,j,k,m) = 0.0d0
tnr_racs2(i,j,k,m) = 0.0d0
tnr_sacr1(i,j,k,m) = 0.0d0
tnr_sacr2(i,j,k,m) = 0.0d0
enddo
enddo
enddo
enddo
do m = 1, ntb_IN
do k = 1, 45
do j = 1, ntb_r1
do i = 1, ntb_r
tpi_qrfz(i,j,k,m) = 0.0d0
tni_qrfz(i,j,k,m) = 0.0d0
tpg_qrfz(i,j,k,m) = 0.0d0
tnr_qrfz(i,j,k,m) = 0.0d0
enddo
enddo
do j = 1, nbc
do i = 1, ntb_c
tpi_qcfz(i,j,k,m) = 0.0d0
tni_qcfz(i,j,k,m) = 0.0d0
enddo
enddo
enddo
enddo
do j = 1, ntb_i1
do i = 1, ntb_i
tps_iaus(i,j) = 0.0d0
tni_iaus(i,j) = 0.0d0
tpi_ide(i,j) = 0.0d0
enddo
enddo
do j = 1, nbc
do i = 1, nbr
t_Efrw(i,j) = 0.0
enddo
do i = 1, nbs
t_Efsw(i,j) = 0.0
enddo
enddo
do k = 1, ntb_r
do j = 1, ntb_r1
do i = 1, nbr
tnr_rev(i,j,k) = 0.0d0
enddo
enddo
enddo
do k = 1, nbc
do j = 1, ntb_c
do i = 1, nbc
tpc_wev(i,j,k) = 0.0d0
tnc_wev(i,j,k) = 0.0d0
enddo
enddo
enddo
do m = 1, ntb_ark
do l = 1, ntb_arr
do k = 1, ntb_art
do j = 1, ntb_arw
do i = 1, ntb_arc
tnccn_act(i,j,k,l,m) = 1.0
enddo
enddo
enddo
enddo
enddo
if (mpirank==mpiroot) write (*,*)'creating microphysics lookup tables ... '
if (mpirank==mpiroot) write (*,'(a, f5.2, a, f5.2, a, f5.2, a, f5.2)') &
' using: mu_c_o=',mu_c_o,' mu_i=',mu_i,' mu_r=',mu_r,' mu_g=',mu_g
!> - Call table_ccnact() to read a static file containing CCN activation of aerosols. The
!! data were created from a parcel model by Feingold & Heymsfield with
!! further changes by Eidhammer and Kriedenweis
if (mpirank==mpiroot) write(0,*) ' calling table_ccnAct routine'
call table_ccnAct(errmsg,errflg)
if (.not. errflg==0) return
!> - Call table_efrw() and table_efsw() to creat collision efficiency table
!! between rain/snow and cloud water
if (mpirank==mpiroot) write(0,*) ' creating qc collision eff tables'
call table_Efrw
call table_Efsw
!> - Call table_dropevap() to creat rain drop evaporation table
if (mpirank==mpiroot) write(0,*) ' creating rain evap table'
call table_dropEvap
!> - Call qi_aut_qs() to create conversion of some ice mass into snow category
if (mpirank==mpiroot) write(0,*) ' creating ice converting to snow table'
call qi_aut_qs
call cpu_time(etime)
if (mpirank==mpiroot) print '("Calculating Thompson tables part 1 took ",f10.3," seconds.")', etime-stime
end if precomputed_tables_1
!> - Call radar_init() to initialize various constants for computing radar reflectivity
call cpu_time(stime)
xam_r = am_r
xbm_r = bm_r
xmu_r = mu_r
xam_s = am_s
xbm_s = bm_s
xmu_s = mu_s
xam_g = am_g
xbm_g = bm_g
xmu_g = mu_g
call radar_init
call cpu_time(etime)
if (mpirank==mpiroot) print '("Calling radar_init took ",f10.3," seconds.")', etime-stime
if_not_iiwarm: if (.not. iiwarm) then
precomputed_tables_2: if (.not.precomputed_tables) then
call cpu_time(stime)
!> - Call qr_acr_qg() to create rain collecting graupel & graupel collecting rain table
if (mpirank==mpiroot) write(0,*) ' creating rain collecting graupel table'
call cpu_time(stime)
call qr_acr_qg
call cpu_time(etime)
if (mpirank==mpiroot) print '("Computing rain collecting graupel table took ",f10.3," seconds.")', etime-stime
!> - Call qr_acr_qs() to create rain collecting snow & snow collecting rain table
if (mpirank==mpiroot) write (*,*) ' creating rain collecting snow table'
call cpu_time(stime)
call qr_acr_qs
call cpu_time(etime)
if (mpirank==mpiroot) print '("Computing rain collecting snow table took ",f10.3," seconds.")', etime-stime
!> - Call freezeh2o() to create cloud water and rain freezing (Bigg, 1953) table
if (mpirank==mpiroot) write(0,*) ' creating freezing of water drops table'
call cpu_time(stime)
call freezeH2O(threads)
call cpu_time(etime)
if (mpirank==mpiroot) print '("Computing freezing of water drops table took ",f10.3," seconds.")', etime-stime
call cpu_time(etime)
if (mpirank==mpiroot) print '("Calculating Thompson tables part 2 took ",f10.3," seconds.")', etime-stime
end if precomputed_tables_2
endif if_not_iiwarm
if (mpirank==mpiroot) write(0,*) ' ... DONE microphysical lookup tables'
endif if_micro_init
END SUBROUTINE thompson_init
!> @}
!>\ingroup aathompson
!!This is a wrapper routine designed to transfer values from 3D to 1D.
!!\section gen_mpgtdriver Thompson mp_gt_driver General Algorithm
!> @{
SUBROUTINE mp_gt_driver(qv, qc, qr, qi, qs, qg, ni, nr, nc, &
nwfa, nifa, nwfa2d, nifa2d, &
tt, th, pii, &
p, w, dz, dt_in, dt_inner, &
sedi_semi, decfl, lsm, &
RAINNC, RAINNCV, &
SNOWNC, SNOWNCV, &
ICENC, ICENCV, &
GRAUPELNC, GRAUPELNCV, SR, &
#if ( WRF_CHEM == 1 )
rainprod, evapprod, &
#endif
refl_10cm, diagflag, do_radar_ref, &
vt_dbz_wt, first_time_step, &
re_cloud, re_ice, re_snow, &
has_reqc, has_reqi, has_reqs, &
aero_ind_fdb, rand_perturb_on, &
kme_stoch, &
rand_pert, spp_prt_list, spp_var_list, &