forked from ESCOMP/PUMAS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmicro_mg4_0.F90
4732 lines (3933 loc) · 172 KB
/
micro_mg4_0.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
module micro_mg4_0
!---------------------------------------------------------------------------------
! Purpose:
! MG microphysics version 4.0 - Update of MG microphysics with
! the Eidhammer et al. ice microphysics scheme
!
! Author: Andrew Gettelman, Hugh Morrison
!
! Version 3 history: Sep 2016: development begun for hail, graupel
!
! Version 2 history: Sep 2011: Development begun.
! Feb 2013: Added of prognostic precipitation.
! Aug 2015: Published and released version
! Contributions from: Sean Santos, Peter Caldwell, Xiaohong Liu and Steve Ghan
!
! invoked in CAM by specifying -microphys=mg4
!
! References:
!
! Gettelman, A. and H. Morrison, Advanced Two-Moment Microphysics for Global Models.
!
! Part I: Off line tests and comparisons with other schemes.
!
! J. Climate, 28, 1268-1287. doi: 10.1175/JCLI-D-14-00102.1, 2015.
!
!
!
! Gettelman, A., H. Morrison, S. Santos, P. Bogenschutz and P. H. Caldwell
!
! Advanced Two-Moment Microphysics for Global Models.
!
! Part II: Global model solutions and Aerosol-Cloud Interactions.
!
! J. Climate, 28, 1288-1307. doi:10.1175/JCLI-D-14-00103.1 , 2015.
!
! for questions contact Hugh Morrison, Andrew Gettelman
! e-mail: [email protected], [email protected]
!---------------------------------------------------------------------------------
!
! NOTE: Modified to allow other microphysics packages (e.g. CARMA) to do ice
! microphysics in cooperation with the MG liquid microphysics. This is
! controlled by the do_cldice variable.
!
! If do_cldice is false, then MG microphysics should not update CLDICE or
! NUMICE; it is assumed that the other microphysics scheme will have updated
! CLDICE and NUMICE. The other microphysics should handle the following
! processes that would have been done by MG:
! - Detrainment (liquid and ice)
! - Homogeneous ice nucleation
! - Heterogeneous ice nucleation
! - Bergeron process
! - Melting of ice
! - Freezing of cloud drops
! - Autoconversion (ice -> snow)
! - Growth/Sublimation of ice
! - Sedimentation of ice
!
! This option has not been updated since the introduction of prognostic
! precipitation, and probably should be adjusted to cover snow as well.
!
!---------------------------------------------------------------------------------
! Version 4.O based on micro_mg3_0.F90
!---------------------------------------------------------------------------------
! Based on micro_mg (restructuring of former cldwat2m_micro)
! Author: Andrew Gettelman, Hugh Morrison.
! Contributions from: Xiaohong Liu and Steve Ghan
! December 2005-May 2010
! Description in: Morrison and Gettelman, 2008. J. Climate (MG2008)
! Gettelman et al., 2010 J. Geophys. Res. - Atmospheres (G2010)
! for questions contact Hugh Morrison, Andrew Gettelman
! e-mail: [email protected], [email protected]
!---------------------------------------------------------------------------------
! Code comments added by HM, 093011
! General code structure:
!
! Code is divided into two main subroutines:
! subroutine micro_mg_init --> initializes microphysics routine, should be called
! once at start of simulation
! subroutine micro_mg_tend --> main microphysics routine to be called each time step
! this also calls several smaller subroutines to calculate
! microphysical processes and other utilities
!
! List of external functions:
! qsat_water --> for calculating saturation vapor pressure with respect to liquid water
! qsat_ice --> for calculating saturation vapor pressure with respect to ice
! gamma --> standard mathematical gamma function
! .........................................................................
! List of inputs through use statement in fortran90:
! Variable Name Description Units
! .........................................................................
! gravit acceleration due to gravity m s-2
! rair dry air gas constant for air J kg-1 K-1
! tmelt temperature of melting point for water K
! cpair specific heat at constant pressure for dry air J kg-1 K-1
! rh2o gas constant for water vapor J kg-1 K-1
! latvap latent heat of vaporization J kg-1
! latice latent heat of fusion J kg-1
! qsat_water external function for calculating liquid water
! saturation vapor pressure/humidity -
! qsat_ice external function for calculating ice
! saturation vapor pressure/humidity pa
! rhmini relative humidity threshold parameter for
! nucleating ice -
! .........................................................................
! NOTE: List of all inputs/outputs passed through the call/subroutine statement
! for micro_mg_tend is given below at the start of subroutine micro_mg_tend.
!---------------------------------------------------------------------------------
! Procedures required:
! 1) An implementation of the gamma function (if not intrinsic).
! 2) saturation vapor pressure and specific humidity over water
! 3) svp over ice
#ifndef HAVE_GAMMA_INTRINSICS
use shr_spfn_mod, only: gamma => shr_spfn_gamma
#endif
!++ag DEBUG: remove later
use cam_logfile, only: iulog
!--ag
use wv_sat_methods, only: &
qsat_water => wv_sat_qsat_water, &
qsat_ice => wv_sat_qsat_ice
! Parameters from the utilities module.
use micro_mg_utils, only: &
r8, &
pi, &
omsm, &
qsmall, &
icsmall, &
mincld, &
rhosn, &
rhoi, &
rhow, &
rhows, &
ac, bc, &
ai, bi, &
aj, bj, &
ar, br, &
as, bs, &
!++ag
ag, bg, &
ah, bh, &
rhog,rhoh, &
!--ag
mi0, &
rising_factorial
implicit none
private
save
public :: &
micro_mg_init, &
micro_mg_get_cols, &
micro_mg_tend_pre_adjust, &
micro_mg_tend
! Switches for specification rather than prediction of droplet and crystal number
! note: number will be adjusted as needed to keep mean size within bounds,
! even when specified droplet or ice number is used
!
! If constant cloud ice number is set (nicons = .true.),
! then all microphysical processes except mass transfer due to ice nucleation
! (mnuccd) are based on the fixed cloud ice number. Calculation of
! mnuccd follows from the prognosed ice crystal number ni.
logical :: nccons ! nccons = .true. to specify constant cloud droplet number
logical :: nicons ! nicons = .true. to specify constant cloud ice number
!++ag kt
logical :: ngcons = .false. ! ngcons = .true. to specify constant graupel number
!--ag kt
! specified ice and droplet number concentrations
! note: these are local in-clouse values, not grid-mean
real(r8) :: ncnst ! droplet num concentration when nccons=.true. (m-3)
real(r8) :: ninst ! ice num concentration when nicons=.true. (m-3)
!++ag
real(r8) :: ngnst = 0.1e6_r8 ! graupel num concentration when ngcons=.true. (m-3)
!--ag
!=========================================================
! Private module parameters
!=========================================================
!Range of cloudsat reflectivities (dBz) for analytic simulator
real(r8), parameter :: csmin = -30._r8
real(r8), parameter :: csmax = 26._r8
real(r8), parameter :: mindbz = -99._r8
real(r8), parameter :: minrefl = 1.26e-10_r8 ! minrefl = 10._r8**(mindbz/10._r8)
! autoconversion size threshold for cloud ice to snow (m)
real(r8) :: dcs
! minimum mass of new crystal due to freezing of cloud droplets done
! externally (kg)
real(r8), parameter :: mi0l_min = 4._r8/3._r8*pi*rhow*(4.e-6_r8)**3
!=========================================================
! Constants set in initialization
!=========================================================
! Set using arguments to micro_mg_init
real(r8) :: g ! gravity
real(r8) :: r ! dry air gas constant
real(r8) :: rv ! water vapor gas constant
real(r8) :: cpp ! specific heat of dry air
real(r8) :: tmelt ! freezing point of water (K)
! latent heats of:
real(r8) :: xxlv ! vaporization
real(r8) :: xlf ! freezing
real(r8) :: xxls ! sublimation
real(r8) :: rhmini ! Minimum rh for ice cloud fraction > 0.
! flags
logical :: microp_uniform
logical :: do_cldice
logical :: use_hetfrz_classnuc
!++ag
logical :: do_hail
logical :: do_graupel
!--ag
real(r8) :: rhosu ! typical 850mn air density
real(r8) :: icenuct ! ice nucleation temperature: currently -5 degrees C
real(r8) :: snowmelt ! what temp to melt all snow: currently 2 degrees C
real(r8) :: rainfrze ! what temp to freeze all rain: currently -5 degrees C
! additional constants to help speed up code
real(r8) :: gamma_br_plus1
real(r8) :: gamma_br_plus4
real(r8) :: gamma_bs_plus1
real(r8) :: gamma_bs_plus4
real(r8) :: gamma_bi_plus1
real(r8) :: gamma_bi_plus4
real(r8) :: gamma_bj_plus1
real(r8) :: gamma_bj_plus4
real(r8) :: xxlv_squared
real(r8) :: xxls_squared
character(len=16) :: micro_mg_precip_frac_method ! type of precipitation fraction method
real(r8) :: micro_mg_berg_eff_factor ! berg efficiency factor
! ++ Trude
real(r8) :: micro_mg_vtrmi_factor
real(r8) :: micro_mg_effi_factor
real(r8) :: micro_mg_iaccr_factor
real(r8) :: micro_mg_max_nicons
! -- Trude
logical :: allow_sed_supersat ! Allow supersaturated conditions after sedimentation loop
logical :: do_sb_physics ! do SB 2001 autoconversion or accretion physics
!===============================================================================
contains
!===============================================================================
subroutine micro_mg_init( &
kind, gravit, rair, rh2o, cpair, &
tmelt_in, latvap, latice, &
rhmini_in, micro_mg_dcs, &
!++ag
micro_mg_do_hail_in,micro_mg_do_graupel_in, &
!--ag
microp_uniform_in, do_cldice_in, use_hetfrz_classnuc_in, &
micro_mg_precip_frac_method_in, micro_mg_berg_eff_factor_in, &
! ++ trude
micro_mg_vtrmi_factor_in, micro_mg_effi_factor_in, micro_mg_iaccr_factor_in,&
micro_mg_max_nicons_in, &
!-- trude
allow_sed_supersat_in, do_sb_physics_in, &
nccons_in, nicons_in, ncnst_in, ninst_in, errstring)
use micro_mg_utils, only: micro_mg_utils_init
!-----------------------------------------------------------------------
!
! Purpose:
! initialize constants for MG microphysics
!
! Author: Andrew Gettelman Dec 2005
!
!-----------------------------------------------------------------------
integer, intent(in) :: kind ! Kind used for reals
real(r8), intent(in) :: gravit
real(r8), intent(in) :: rair
real(r8), intent(in) :: rh2o
real(r8), intent(in) :: cpair
real(r8), intent(in) :: tmelt_in ! Freezing point of water (K)
real(r8), intent(in) :: latvap
real(r8), intent(in) :: latice
real(r8), intent(in) :: rhmini_in ! Minimum rh for ice cloud fraction > 0.
real(r8), intent(in) :: micro_mg_dcs
!++ag
!MG3 dense precipitating ice. Note, only 1 can be true, or both false.
logical, intent(in) :: micro_mg_do_graupel_in ! .true. = configure with graupel
! .false. = no graupel (hail possible)
logical, intent(in) :: micro_mg_do_hail_in ! .true. = configure with hail
! .false. = no hail (graupel possible)
!--ag
logical, intent(in) :: microp_uniform_in ! .true. = configure uniform for sub-columns
! .false. = use w/o sub-columns (standard)
logical, intent(in) :: do_cldice_in ! .true. = do all processes (standard)
! .false. = skip all processes affecting
! cloud ice
logical, intent(in) :: use_hetfrz_classnuc_in ! use heterogeneous freezing
character(len=16),intent(in) :: micro_mg_precip_frac_method_in ! type of precipitation fraction method
real(r8), intent(in) :: micro_mg_berg_eff_factor_in ! berg efficiency factor
!++ trude
real(r8), intent(in) :: micro_mg_vtrmi_factor_in !factor for ice fall velocity
real(r8), intent(in) :: micro_mg_effi_factor_in !factor for ice effective radius
real(r8), intent(in) :: micro_mg_iaccr_factor_in ! ice accretion factor
real(r8), intent(in) :: micro_mg_max_nicons_in ! maximum number ice crystal allowed
! -- trude
logical, intent(in) :: allow_sed_supersat_in ! allow supersaturated conditions after sedimentation loop
logical, intent(in) :: do_sb_physics_in ! do SB autoconversion and accretion physics
logical, intent(in) :: nccons_in
logical, intent(in) :: nicons_in
real(r8), intent(in) :: ncnst_in
real(r8), intent(in) :: ninst_in
character(128), intent(out) :: errstring ! Output status (non-blank for error return)
!-----------------------------------------------------------------------
dcs = micro_mg_dcs
! Initialize subordinate utilities module.
call micro_mg_utils_init(kind, rair, rh2o, cpair, tmelt_in, latvap, latice, &
dcs, errstring)
if (trim(errstring) /= "") return
! declarations for MG code (transforms variable names)
g= gravit ! gravity
r= rair ! dry air gas constant: note units(phys_constants are in J/K/kmol)
rv= rh2o ! water vapor gas constant
cpp = cpair ! specific heat of dry air
tmelt = tmelt_in
rhmini = rhmini_in
micro_mg_precip_frac_method = micro_mg_precip_frac_method_in
micro_mg_berg_eff_factor = micro_mg_berg_eff_factor_in
allow_sed_supersat = allow_sed_supersat_in
do_sb_physics = do_sb_physics_in
!++ trude
micro_mg_vtrmi_factor = micro_mg_vtrmi_factor_in
micro_mg_effi_factor = micro_mg_effi_factor_in
micro_mg_iaccr_factor=micro_mg_iaccr_factor_in
micro_mg_max_nicons = micro_mg_max_nicons_in
! -- trude
nccons = nccons_in
nicons = nicons_in
ncnst = ncnst_in
ninst = ninst_in
! latent heats
xxlv = latvap ! latent heat vaporization
xlf = latice ! latent heat freezing
xxls = xxlv + xlf ! latent heat of sublimation
! flags
microp_uniform = microp_uniform_in
do_cldice = do_cldice_in
use_hetfrz_classnuc = use_hetfrz_classnuc_in
!++ag
do_hail = micro_mg_do_hail_in
do_graupel = micro_mg_do_graupel_in
!--ag
! typical air density at 850 mb
rhosu = 85000._r8/(rair * tmelt)
! Maximum temperature at which snow is allowed to exist
snowmelt = tmelt + 2._r8
! Minimum temperature at which rain is allowed to exist
rainfrze = tmelt - 40._r8
! Ice nucleation temperature
icenuct = tmelt - 5._r8
! Define constants to help speed up code (this limits calls to gamma function)
gamma_br_plus1=gamma(1._r8+br)
gamma_br_plus4=gamma(4._r8+br)
gamma_bs_plus1=gamma(1._r8+bs)
gamma_bs_plus4=gamma(4._r8+bs)
gamma_bi_plus1=gamma(1._r8+bi)
gamma_bi_plus4=gamma(4._r8+bi)
gamma_bj_plus1=gamma(1._r8+bj)
gamma_bj_plus4=gamma(4._r8+bj)
xxlv_squared=xxlv**2
xxls_squared=xxls**2
end subroutine micro_mg_init
!===============================================================================
!microphysics routine for each timestep goes here...
! First adjust input mixing ratios to instantaneously adjust to initial temperatures
subroutine micro_mg_tend_pre_adjust( &
mgncol, nlev, deltatin, &
t, &
qcn, qin, &
ncn, nin, &
qrn, &
nrn, &
qgr, ngr, &
tlat, &
qctend, qitend, &
nctend, nitend, &
qrtend, nrtend, &
qgtend, ngtend &
)
! input arguments
integer, intent(in) :: mgncol ! number of microphysics columns
integer, intent(in) :: nlev ! number of layers
real(r8), intent(in) :: deltatin ! time step (s)
real(r8), intent(inout) :: t(mgncol,nlev) ! input temperature (K)
! note: all input cloud variables are grid-averaged
real(r8), intent(inout) :: qcn(mgncol,nlev) ! cloud water mixing ratio (kg/kg)
real(r8), intent(inout) :: qin(mgncol,nlev) ! cloud ice mixing ratio (kg/kg)
real(r8), intent(inout) :: ncn(mgncol,nlev) ! cloud water number conc (1/kg)
real(r8), intent(inout) :: nin(mgncol,nlev) ! cloud ice number conc (1/kg)
real(r8), intent(inout) :: qrn(mgncol,nlev) ! rain mixing ratio (kg/kg)
real(r8), intent(inout) :: nrn(mgncol,nlev) ! rain number conc (1/kg)
real(r8), intent(inout) :: qgr(mgncol,nlev) ! graupel/hail mixing ratio (kg/kg)
real(r8), intent(inout) :: ngr(mgncol,nlev) ! graupel/hail number conc (1/kg)
real(r8), intent(out) :: tlat(mgncol,nlev) ! latent heating rate (W/kg)
real(r8), intent(out) :: qctend(mgncol,nlev) ! microphysical tendency qc (1/s)
real(r8), intent(out) :: qitend(mgncol,nlev) ! microphysical tendency qi (1/s)
real(r8), intent(out) :: nctend(mgncol,nlev) ! microphysical tendency nc (1/(kg*s))
real(r8), intent(out) :: nitend(mgncol,nlev) ! microphysical tendency ni (1/(kg*s))
real(r8), intent(out) :: qrtend(mgncol,nlev) ! microphysical tendency qr (1/s)
real(r8), intent(out) :: nrtend(mgncol,nlev) ! microphysical tendency nr (1/(kg*s))
real(r8), intent(out) :: qgtend(mgncol,nlev) ! microphysical tendency qg (1/s)
real(r8), intent(out) :: ngtend(mgncol,nlev) ! microphysical tendency ng (1/(kg*s))
! Locally defined variables
! loop array variables
! "i" and "k" are column/level iterators for internal (MG) variables
integer i, k
real(r8) :: deltat ! sub-time step (s)
! dummy variables
real(r8) :: dum
real(r8) :: dum1
! local copies of input variables
real(r8) :: qc(mgncol,nlev) ! cloud liquid mixing ratio (kg/kg)
real(r8) :: qi(mgncol,nlev) ! cloud ice mixing ratio (kg/kg)
real(r8) :: nc(mgncol,nlev) ! cloud liquid number concentration (1/kg)
real(r8) :: ni(mgncol,nlev) ! cloud liquid number concentration (1/kg)
real(r8) :: qr(mgncol,nlev) ! rain mixing ratio (kg/kg)
real(r8) :: nr(mgncol,nlev) ! rain number concentration (1/kg)
real(r8) :: qg(mgncol,nlev) ! graupel mixing ratio (kg/kg)
real(r8) :: ng(mgncol,nlev) ! graupel number concentration (1/kg)
! Rates/tendencies due to:
! Instantaneous snow melting
real(r8) :: minstsm(mgncol,nlev) ! mass mixing ratio
real(r8) :: ninstsm(mgncol,nlev) ! number concentration
! Instantaneous graupel melting
real(r8) :: minstgm(mgncol,nlev) ! mass mixing ratio
real(r8) :: ninstgm(mgncol,nlev) ! number concentration
! Instantaneous rain freezing
real(r8) :: minstrf(mgncol,nlev) ! mass mixing ratio
real(r8) :: ninstrf(mgncol,nlev) ! number concentration
! Copies of input concentrations that may be changed internally.
deltat = deltatin
qc = qcn
nc = ncn
qi = qin
ni = nin
qr = qrn
nr = nrn
qg = qgr
ng = ngr
qctend = 0._r8
nctend = 0._r8
qitend = 0._r8
nitend = 0._r8
qrtend = 0._r8
nrtend = 0._r8
qgtend = 0._r8
ngtend = 0._r8
minstsm = 0._r8
ninstsm = 0._r8
minstgm = 0._r8
ninstgm = 0._r8
minstrf = 0._r8
ninstrf = 0._r8
tlat=0._r8
!=============================================================================
do k=1,nlev
do i=1,mgncol
! calculate instantaneous precip processes (melting and homogeneous freezing)
!++kt
! melting of ice
if (t(i,k) > snowmelt) then
if (qi(i,k) > 0._r8) then
! make sure melting ice/snow doesn't reduce temperature below threshold
dum = -xlf/cpp*qi(i,k)
if (t(i,k)+dum < snowmelt) then
dum = (t(i,k)-snowmelt)*cpp/xlf
dum = dum/qi(i,k)
dum = max(0._r8,dum)
dum = min(1._r8,dum)
else
dum = 1._r8
end if
minstsm(i,k) = dum*qi(i,k)
ninstsm(i,k) = dum*ni(i,k)
dum1=-xlf*minstsm(i,k)/deltat
tlat(i,k)=tlat(i,k)+dum1
qi(i,k) = max(qi(i,k) - minstsm(i,k), 0._r8)
ni(i,k) = max(ni(i,k) - ninstsm(i,k), 0._r8)
!--kt
qr(i,k) = max(qr(i,k) + minstsm(i,k), 0._r8)
nr(i,k) = max(nr(i,k) + ninstsm(i,k), 0._r8)
end if
end if
end do
end do
!++ag
! melting of graupel at +2 C
do k=1,nlev
do i=1,mgncol
if (t(i,k) > snowmelt) then
if (qg(i,k) > 0._r8) then
! make sure melting graupel doesn't reduce temperature below threshold
dum = -xlf/cpp*qg(i,k)
if (t(i,k)+dum < snowmelt) then
dum = (t(i,k)-snowmelt)*cpp/xlf
dum = dum/qg(i,k)
dum = max(0._r8,dum)
dum = min(1._r8,dum)
else
dum = 1._r8
end if
minstgm(i,k) = dum*qg(i,k)
ninstgm(i,k) = dum*ng(i,k)
dum1=-xlf*minstgm(i,k)/deltat
tlat(i,k)=tlat(i,k)+dum1
qg(i,k) = max(qg(i,k) - minstgm(i,k), 0._r8)
ng(i,k) = max(ng(i,k) - ninstgm(i,k), 0._r8)
qr(i,k) = max(qr(i,k) + minstgm(i,k), 0._r8)
nr(i,k) = max(nr(i,k) + ninstgm(i,k), 0._r8)
end if
end if
end do
end do
!--ag
do k=1,nlev
do i=1,mgncol
! freezing of rain at -5 C
if (t(i,k) < rainfrze) then
if (qr(i,k) > 0._r8) then
! make sure freezing rain doesn't increase temperature above threshold
dum = xlf/cpp*qr(i,k)
if (t(i,k)+dum > rainfrze) then
dum = -(t(i,k)-rainfrze)*cpp/xlf
dum = dum/qr(i,k)
dum = max(0._r8,dum)
dum = min(1._r8,dum)
else
dum = 1._r8
end if
minstrf(i,k) = dum*qr(i,k)
ninstrf(i,k) = dum*nr(i,k)
! heating tendency
dum1 = xlf*minstrf(i,k)/deltat
tlat(i,k)=tlat(i,k)+dum1
qr(i,k) = max(qr(i,k) - minstrf(i,k), 0._r8)
nr(i,k) = max(nr(i,k) - ninstrf(i,k), 0._r8)
!++ag
! freeze rain to graupel not snow.
if(do_hail.or.do_graupel) then
qg(i,k) = max(qg(i,k) + minstrf(i,k), 0._r8)
ng(i,k) = max(ng(i,k) + ninstrf(i,k), 0._r8)
else
!++kt for mg4 freeze rain to ice, not snow, if no graupel
qi(i,k) = max(qi(i,k) + minstrf(i,k), 0._r8)
ni(i,k) = max(ni(i,k) + ninstrf(i,k), 0._r8)
!--kt
end if
!--ag
end if
end if
end do
end do
! Calculate tendencies from these instantaneous changes
qctend = (qc-qcn)/deltat
nctend = (nc-ncn)/deltat
qitend = (qi-qin)/deltat
nitend = (ni-nin)/deltat
qrtend = (qr-qrn)/deltat
nrtend = (nr-nrn)/deltat
qgtend = (qg-qgr)/deltat
ngtend = (ng-ngr)/deltat
! Output updated variables for the next microphysics step
! ktc-note: these should probably be seperate output variables
! Update temperature profile
! This could be dangerous because of a lack of checks to make
! sure that t does not go negative (for now)
do k=1,nlev
do i=1,mgncol
t(i,k) = t(i,k)+tlat(i,k)/cpp*deltat
end do
end do
! Update hydrometeors
qcn = qc
ncn = nc
qin = qi
nin = ni
qrn = qr
nrn = nr
qgr = qg
ngr = ng
if(minval(qc).lt.0._r8) &
write(iulog,*) "KTC inst qc < 0 : min=",minval(qc)
if(minval(qi).lt.0._r8) &
write(iulog,*) "KTC inst qi < 0 : min=",minval(qi)
if(minval(qr).lt.0._r8) &
write(iulog,*) "KTC inst qr < 0 : min=",minval(qr)
if(minval(qg).lt.0._r8) &
write(iulog,*) "KTC inst qg < 0 : min=",minval(qg)
if(minval(nc).lt.0._r8) &
write(iulog,*) "KTC inst nc < 0 : min=",minval(nc)
if(minval(ni).lt.0._r8) &
write(iulog,*) "KTC inst ni < 0 : min=",minval(ni)
if(minval(nr).lt.0._r8) &
write(iulog,*) "KTC inst nr < 0 : min=",minval(nr)
if(minval(ng).lt.0._r8) &
write(iulog,*) "KTC inst ng < 0 : min=",minval(ng)
end subroutine micro_mg_tend_pre_adjust
! Then call full mg_tend
subroutine micro_mg_tend ( &
mgncol, nlev, deltatin, &
t, q, &
qcn, qin, &
ncn, nin, &
qrn, qsn, &
nrn, nsn, &
!++ag
qgr, ngr, &
!--ag
relvar, accre_enhan, &
p, pdel, &
cldn, liqcldf, icecldf, qsatfac, &
qcsinksum_rate1ord, &
naai, npccn, &
rndst, nacon, &
tlat, qvlat, &
qctend, qitend, qitendresid, &
nctend, nitend, &
qrtend, qstend, &
nrtend, nstend, &
!++ag
qgtend, ngtend, &
!--ag
effc, effc_fn, effi, &
sadice, sadsnow, &
prect, preci, &
nevapr, evapsnow, &
am_evp_st, &
prain, prodsnow, &
cmeout, deffi, &
pgamrad, lamcrad, &
qsout, dsout, &
!++ag
qgout, ngout, dgout, &
!--ag
lflx, iflx, &
!++ag
gflx, &
!--ag
rflx, sflx, qrout, &
!++ag
reff_rain, reff_snow, reff_grau, &
!--ag
qcsevap, qisevap, qvres, &
cmeitot, vtrmc, vtrmi, &
umr, ums, &
!++ag
umg, qgsedten, &
!--ag
qcsedten, qisedten, &
qrsedten, qssedten, &
pratot, prctot, &
mnuccctot, mnuccttot, msacwitot, &
psacwstot, bergstot, bergtot, &
!++ktc
npsacwstot, &
!--ktc
melttot, homotot, &
qcrestot, prcitot, praitot, &
!++ag
qirestot, mnuccrtot, mnuccritot, pracstot, &
!--ag
meltsdttot, frzrdttot, mnuccdtot, &
!++ag
pracgtot, psacwgtot, pgsacwtot, &
pgracstot, prdgtot, &
qmultgtot, qmultrgtot, psacrtot, &
npracgtot, nscngtot, ngracstot, &
nmultgtot, nmultrgtot, npsacwgtot, &
!--ag
nrout, nsout, &
refl, arefl, areflz, &
frefl, csrfl, acsrfl, &
fcsrfl, rercld, &
ncai, ncal, &
qrout2, qsout2, &
nrout2, nsout2, &
drout2, dsout2, &
!++ag
qgout2, ngout2, dgout2, freqg, &
!--ag
freqs, freqr, &
nfice, qcrat, &
errstring, & ! Below arguments are "optional" (pass null pointers to omit).
tnd_qsnow, tnd_nsnow, re_ice, &
prer_evap, &
frzimm, frzcnt, frzdep, &
lamsout, n0sout , lamrout, n0rout)
! Constituent properties.
use micro_mg_utils, only: &
mg_liq_props, &
mg_ice_props, &
mg_rain_props, &
!++ag
mg_graupel_props,&
!--ag
mg_snow_props
! Size calculation functions.
use micro_mg_utils, only: &
size_dist_param_liq, &
size_dist_param_basic, &
avg_diameter
! Microphysical processes.
use micro_mg_utils, only: &
ice_deposition_sublimation, &
sb2001v2_liq_autoconversion,&
sb2001v2_accre_cld_water_rain,&
kk2000_liq_autoconversion, &
ice_autoconversion, &
immersion_freezing, &
contact_freezing, &
snow_self_aggregation, &
accrete_cloud_water_snow, &
secondary_ice_production, &
accrete_rain_snow, &
heterogeneous_rain_freezing, &
accrete_cloud_water_rain, &
self_collection_rain, &
accrete_cloud_ice_snow, &
bergeron_process_snow, &
!++ag
graupel_collecting_snow, &
graupel_collecting_rain, &
graupel_collecting_cld_water, &
graupel_riming_liquid_snow, &
graupel_rain_riming_snow, &
graupel_rime_splintering, &
! graupel_sublimate_evap
!--ag
!++kt
ice_deposition_sublimation_mg4, &
evaporate_sublimate_precip_mg4, &
evaporate_sublimate_precip_graupel_mg4, &
ice_self_aggregation, &
accrete_cloud_water_ice, &
accrete_rain_ice, &
access_lookup_table, &
access_lookup_table_coll, &
tsize, isize, jsize, rcollsize
!--kt
!Authors: Hugh Morrison, Andrew Gettelman, NCAR, Peter Caldwell, LLNL
! e-mail: [email protected], [email protected]
! input arguments
integer, intent(in) :: mgncol ! number of microphysics columns
integer, intent(in) :: nlev ! number of layers
real(r8), intent(in) :: deltatin ! time step (s)
real(r8), intent(in) :: t(mgncol,nlev) ! input temperature (K)
real(r8), intent(in) :: q(mgncol,nlev) ! input h20 vapor mixing ratio (kg/kg)
! note: all input cloud variables are grid-averaged
real(r8), intent(in) :: qcn(mgncol,nlev) ! cloud water mixing ratio (kg/kg)
real(r8), intent(in) :: qin(mgncol,nlev) ! cloud ice mixing ratio (kg/kg)
real(r8), intent(in) :: ncn(mgncol,nlev) ! cloud water number conc (1/kg)
real(r8), intent(in) :: nin(mgncol,nlev) ! cloud ice number conc (1/kg)
real(r8), intent(in) :: qrn(mgncol,nlev) ! rain mixing ratio (kg/kg)
real(r8), intent(in) :: qsn(mgncol,nlev) ! snow mixing ratio (kg/kg)
real(r8), intent(in) :: nrn(mgncol,nlev) ! rain number conc (1/kg)
real(r8), intent(in) :: nsn(mgncol,nlev) ! snow number conc (1/kg)
!++ag
real(r8), intent(in) :: qgr(mgncol,nlev) ! graupel/hail mixing ratio (kg/kg)
real(r8), intent(in) :: ngr(mgncol,nlev) ! graupel/hail number conc (1/kg)
!--ag
real(r8), intent(in) :: relvar(mgncol,nlev) ! cloud water relative variance (-)
real(r8), intent(in) :: accre_enhan(mgncol,nlev) ! optional accretion
! enhancement factor (-)
real(r8), intent(in) :: p(mgncol,nlev) ! air pressure (pa)
real(r8), intent(in) :: pdel(mgncol,nlev) ! pressure difference across level (pa)
real(r8), intent(in) :: cldn(mgncol,nlev) ! cloud fraction (no units)
real(r8), intent(in) :: liqcldf(mgncol,nlev) ! liquid cloud fraction (no units)
real(r8), intent(in) :: icecldf(mgncol,nlev) ! ice cloud fraction (no units)
real(r8), intent(in) :: qsatfac(mgncol,nlev) ! subgrid cloud water saturation scaling factor (no units)
! used for scavenging
! Inputs for aerosol activation
real(r8), intent(in) :: naai(mgncol,nlev) ! ice nucleation number (from microp_aero_ts) (1/kg)
real(r8), intent(in) :: npccn(mgncol,nlev) ! ccn activated number tendency (from microp_aero_ts) (1/kg*s)
! Note that for these variables, the dust bin is assumed to be the last index.
! (For example, in CAM, the last dimension is always size 4.)
real(r8), intent(in) :: rndst(:,:,:) ! radius of each dust bin, for contact freezing (from microp_aero_ts) (m)
real(r8), intent(in) :: nacon(:,:,:) ! number in each dust bin, for contact freezing (from microp_aero_ts) (1/m^3)
! output arguments
real(r8), intent(out) :: qcsinksum_rate1ord(mgncol,nlev) ! 1st order rate for
! direct cw to precip conversion
real(r8), intent(out) :: tlat(mgncol,nlev) ! latent heating rate (W/kg)
real(r8), intent(out) :: qvlat(mgncol,nlev) ! microphysical tendency qv (1/s)
real(r8), intent(out) :: qctend(mgncol,nlev) ! microphysical tendency qc (1/s)
real(r8), intent(out) :: qitend(mgncol,nlev) ! microphysical tendency qi (1/s)
real(r8), intent(out) :: qitendresid(mgncol,nlev)
real(r8), intent(out) :: nctend(mgncol,nlev) ! microphysical tendency nc (1/(kg*s))
real(r8), intent(out) :: nitend(mgncol,nlev) ! microphysical tendency ni (1/(kg*s))
real(r8), intent(out) :: qrtend(mgncol,nlev) ! microphysical tendency qr (1/s)
real(r8), intent(out) :: qstend(mgncol,nlev) ! microphysical tendency qs (1/s)
real(r8), intent(out) :: nrtend(mgncol,nlev) ! microphysical tendency nr (1/(kg*s))
real(r8), intent(out) :: nstend(mgncol,nlev) ! microphysical tendency ns (1/(kg*s))
!++ag
real(r8), intent(out) :: qgtend(mgncol,nlev) ! microphysical tendency qg (1/s)
real(r8), intent(out) :: ngtend(mgncol,nlev) ! microphysical tendency ng (1/(kg*s))
!--ag
real(r8), intent(out) :: effc(mgncol,nlev) ! droplet effective radius (micron)
real(r8), intent(out) :: effc_fn(mgncol,nlev) ! droplet effective radius, assuming nc = 1.e8 kg-1
real(r8), intent(out) :: effi(mgncol,nlev) ! cloud ice effective radius (micron)
real(r8), intent(out) :: sadice(mgncol,nlev) ! cloud ice surface area density (cm2/cm3)
real(r8), intent(out) :: sadsnow(mgncol,nlev) ! cloud snow surface area density (cm2/cm3)
real(r8), intent(out) :: prect(mgncol) ! surface precip rate (m/s)
real(r8), intent(out) :: preci(mgncol) ! cloud ice/snow precip rate (m/s)
real(r8), intent(out) :: nevapr(mgncol,nlev) ! evaporation rate of rain + snow (1/s)
real(r8), intent(out) :: evapsnow(mgncol,nlev) ! sublimation rate of snow (1/s)
real(r8), intent(out) :: am_evp_st(mgncol,nlev) ! stratiform evaporation area (frac)
real(r8), intent(out) :: prain(mgncol,nlev) ! production of rain + snow (1/s)
real(r8), intent(out) :: prodsnow(mgncol,nlev) ! production of snow (1/s)
real(r8), intent(out) :: cmeout(mgncol,nlev) ! evap/sub of cloud (1/s)
real(r8), intent(out) :: deffi(mgncol,nlev) ! ice effective diameter for optics (radiation) (micron)
real(r8), intent(out) :: pgamrad(mgncol,nlev) ! ice gamma parameter for optics (radiation) (no units)
real(r8), intent(out) :: lamcrad(mgncol,nlev) ! slope of droplet distribution for optics (radiation) (1/m)
real(r8), intent(out) :: qsout(mgncol,nlev) ! snow mixing ratio (kg/kg)
real(r8), intent(out) :: dsout(mgncol,nlev) ! snow diameter (m)
real(r8), intent(out) :: lflx(mgncol,nlev+1) ! grid-box average liquid condensate flux (kg m^-2 s^-1)
real(r8), intent(out) :: iflx(mgncol,nlev+1) ! grid-box average ice condensate flux (kg m^-2 s^-1)
real(r8), intent(out) :: rflx(mgncol,nlev+1) ! grid-box average rain flux (kg m^-2 s^-1)
real(r8), intent(out) :: sflx(mgncol,nlev+1) ! grid-box average snow flux (kg m^-2 s^-1)
!++ag
real(r8), intent(out) :: gflx(mgncol,nlev+1) ! grid-box average graupel/hail flux (kg m^-2 s^-1)
!--ag
real(r8), intent(out) :: qrout(mgncol,nlev) ! grid-box average rain mixing ratio (kg/kg)
real(r8), intent(out) :: reff_rain(mgncol,nlev) ! rain effective radius (micron)
real(r8), intent(out) :: reff_snow(mgncol,nlev) ! snow effective radius (micron)
!++ag
real(r8), intent(out) :: reff_grau(mgncol,nlev) ! graupel effective radius (micron)
!--ag
real(r8), intent(out) :: qcsevap(mgncol,nlev) ! cloud water evaporation due to sedimentation (1/s)
real(r8), intent(out) :: qisevap(mgncol,nlev) ! cloud ice sublimation due to sublimation (1/s)
real(r8), intent(out) :: qvres(mgncol,nlev) ! residual condensation term to ensure RH < 100% (1/s)
real(r8), intent(out) :: cmeitot(mgncol,nlev) ! grid-mean cloud ice sub/dep (1/s)
real(r8), intent(out) :: vtrmc(mgncol,nlev) ! mass-weighted cloud water fallspeed (m/s)
real(r8), intent(out) :: vtrmi(mgncol,nlev) ! mass-weighted cloud ice fallspeed (m/s)
real(r8), intent(out) :: umr(mgncol,nlev) ! mass weighted rain fallspeed (m/s)
real(r8), intent(out) :: ums(mgncol,nlev) ! mass weighted snow fallspeed (m/s)
!++ag
real(r8), intent(out) :: umg(mgncol,nlev) ! mass weighted graupel/hail fallspeed (m/s)
real(r8), intent(out) :: qgsedten(mgncol,nlev) ! qg sedimentation tendency (1/s)
!--ag
real(r8), intent(out) :: qcsedten(mgncol,nlev) ! qc sedimentation tendency (1/s)
real(r8), intent(out) :: qisedten(mgncol,nlev) ! qi sedimentation tendency (1/s)
real(r8), intent(out) :: qrsedten(mgncol,nlev) ! qr sedimentation tendency (1/s)
real(r8), intent(out) :: qssedten(mgncol,nlev) ! qs sedimentation tendency (1/s)
! microphysical process rates for output (mixing ratio tendencies) (all have units of 1/s)
real(r8), intent(out) :: pratot(mgncol,nlev) ! accretion of cloud by rain
real(r8), intent(out) :: prctot(mgncol,nlev) ! autoconversion of cloud to rain
real(r8), intent(out) :: mnuccctot(mgncol,nlev) ! mixing ratio tend due to immersion freezing
real(r8), intent(out) :: mnuccttot(mgncol,nlev) ! mixing ratio tend due to contact freezing
real(r8), intent(out) :: msacwitot(mgncol,nlev) ! mixing ratio tend due to H-M splintering
real(r8), intent(out) :: psacwstot(mgncol,nlev) ! collection of cloud water by snow
!++ktc
real(r8), intent(out) :: npsacwstot(mgncol,nlev) ! number collection of coud water by snow
!--ktc
real(r8), intent(out) :: bergstot(mgncol,nlev) ! bergeron process on snow
real(r8), intent(out) :: bergtot(mgncol,nlev) ! bergeron process on cloud ice
real(r8), intent(out) :: melttot(mgncol,nlev) ! melting of cloud ice
real(r8), intent(out) :: homotot(mgncol,nlev) ! homogeneous freezing cloud water
real(r8), intent(out) :: qcrestot(mgncol,nlev) ! residual cloud condensation due to removal of excess supersat
real(r8), intent(out) :: prcitot(mgncol,nlev) ! autoconversion of cloud ice to snow
real(r8), intent(out) :: praitot(mgncol,nlev) ! accretion of cloud ice by snow
real(r8), intent(out) :: qirestot(mgncol,nlev) ! residual ice deposition due to removal of excess supersat
real(r8), intent(out) :: mnuccrtot(mgncol,nlev) ! mixing ratio tendency due to heterogeneous freezing of rain to snow (1/s)
real(r8), intent(out) :: mnuccritot(mgncol,nlev) ! mixing ratio tendency due to heterogeneous freezing of rain to ice (1/s)
real(r8), intent(out) :: pracstot(mgncol,nlev) ! mixing ratio tendency due to accretion of rain by snow (1/s)
real(r8), intent(out) :: meltsdttot(mgncol,nlev) ! latent heating rate due to melting of snow (W/kg)
real(r8), intent(out) :: frzrdttot(mgncol,nlev) ! latent heating rate due to homogeneous freezing of rain (W/kg)
real(r8), intent(out) :: mnuccdtot(mgncol,nlev) ! mass tendency from ice nucleation
!++ag Hail/Graupel Tendencies
real(r8), intent(out) :: pracgtot(mgncol,nlev) ! change in q collection rain by graupel (precipf)
real(r8), intent(out) :: psacwgtot(mgncol,nlev) ! change in q collection droplets by graupel (lcldm)
real(r8), intent(out) :: pgsacwtot(mgncol,nlev) ! conversion q to graupel due to collection droplets by snow (lcldm)
real(r8), intent(out) :: pgracstot(mgncol,nlev) ! conversion q to graupel due to collection rain by snow (precipf)
real(r8), intent(out) :: prdgtot(mgncol,nlev) ! dep of graupel (precipf)
! real(r8), intent(out) :: eprdgtot(mgncol,nlev) ! sub of graupel (precipf)
real(r8), intent(out) :: qmultgtot(mgncol,nlev) ! change q due to ice mult droplets/graupel (lcldm)
real(r8), intent(out) :: qmultrgtot(mgncol,nlev) ! change q due to ice mult rain/graupel (precipf)
real(r8), intent(out) :: psacrtot(mgncol,nlev) ! conversion due to coll of snow by rain (precipf)
real(r8), intent(out) :: npracgtot(mgncol,nlev) ! change n collection rain by graupel (precipf)
real(r8), intent(out) :: nscngtot(mgncol,nlev) ! change n conversion to graupel due to collection droplets by snow (lcldm)
real(r8), intent(out) :: ngracstot(mgncol,nlev) ! change n conversion to graupel due to collection rain by snow (precipf)
real(r8), intent(out) :: nmultgtot(mgncol,nlev) ! ice mult due to acc droplets by graupel (lcldm)
real(r8), intent(out) :: nmultrgtot(mgncol,nlev) ! ice mult due to acc rain by graupel (precipf)
real(r8), intent(out) :: npsacwgtot(mgncol,nlev) ! change n collection droplets by graupel (lcldm?)
!--ag
real(r8), intent(out) :: nrout(mgncol,nlev) ! rain number concentration (1/m3)
real(r8), intent(out) :: nsout(mgncol,nlev) ! snow number concentration (1/m3)
real(r8), intent(out) :: refl(mgncol,nlev) ! analytic radar reflectivity
real(r8), intent(out) :: arefl(mgncol,nlev) ! average reflectivity will zero points outside valid range
real(r8), intent(out) :: areflz(mgncol,nlev) ! average reflectivity in z.
real(r8), intent(out) :: frefl(mgncol,nlev) ! fractional occurrence of radar reflectivity
real(r8), intent(out) :: csrfl(mgncol,nlev) ! cloudsat reflectivity
real(r8), intent(out) :: acsrfl(mgncol,nlev) ! cloudsat average
real(r8), intent(out) :: fcsrfl(mgncol,nlev) ! cloudsat fractional occurrence of radar reflectivity
real(r8), intent(out) :: rercld(mgncol,nlev) ! effective radius calculation for rain + cloud
real(r8), intent(out) :: ncai(mgncol,nlev) ! output number conc of ice nuclei available (1/m3)