forked from ESCOMP/PUMAS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmicro_mg_cam.F90
3996 lines (3447 loc) · 192 KB
/
micro_mg_cam.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_mg_cam
!---------------------------------------------------------------------------------
!
! CAM Interfaces for MG microphysics
!
!---------------------------------------------------------------------------------
!
! How to add new packed MG inputs to micro_mg_cam_tend:
!
! If you have an input with first dimension [psetcols, pver], the procedure
! for adding inputs is as follows:
!
! 1) In addition to any variables you need to declare for the "unpacked"
! (CAM format) version, you must declare an array for the "packed"
! (MG format) version.
!
! 2) Add a call similar to the following line (look before the
! micro_mg_tend calls to see similar lines):
!
! packed_array = packer%pack(original_array)
!
! The packed array can then be passed into any of the MG schemes.
!
! This same procedure will also work for 1D arrays of size psetcols, 3-D
! arrays with psetcols and pver as the first dimensions, and for arrays of
! dimension [psetcols, pverp]. You only have to modify the allocation of
! the packed array before the "pack" call.
!
!---------------------------------------------------------------------------------
!
! How to add new packed MG outputs to micro_mg_cam_tend:
!
! 1) As with inputs, in addition to the unpacked outputs you must declare
! an array for packed data. The unpacked and packed arrays must *also*
! be targets or pointers (but cannot be both).
!
! 2) Add the field to post-processing as in the following line (again,
! there are many examples before the micro_mg_tend calls):
!
! call post_proc%add_field(p(final_array),p(packed_array))
!
! *** IMPORTANT ** If the fields are only being passed to a certain version of
! MG, you must only add them if that version is being called (see
! the "if (micro_mg_version >1)" sections below
!
! This registers the field for post-MG averaging, and to scatter to the
! final, unpacked version of the array.
!
! By default, any columns/levels that are not operated on by MG will be
! set to 0 on output; this value can be adjusted using the "fillvalue"
! optional argument to post_proc%add_field.
!
! Also by default, outputs from multiple substeps will be averaged after
! MG's substepping is complete. Passing the optional argument
! "accum_method=accum_null" will change this behavior so that the last
! substep is always output.
!
! This procedure works on 1-D and 2-D outputs. Note that the final,
! unpacked arrays are not set until the call to
! "post_proc%process_and_unpack", which sets every single field that was
! added with post_proc%add_field.
!
!---------------------------------------------------------------------------------
use shr_kind_mod, only: r8=>shr_kind_r8
use spmd_utils, only: masterproc
use ppgrid, only: pcols, pver, pverp, psubcols
use physconst, only: gravit, rair, tmelt, cpair, rh2o, rhoh2o, &
latvap, latice, mwh2o
use phys_control, only: phys_getopts, use_hetfrz_classnuc
use physics_types, only: physics_state, physics_ptend, &
physics_ptend_init, physics_state_copy, &
physics_update, physics_state_dealloc, &
physics_ptend_sum, physics_ptend_scale
use physics_buffer, only: physics_buffer_desc, pbuf_add_field, dyn_time_lvls, &
pbuf_old_tim_idx, pbuf_get_index, dtype_r8, dtype_i4, &
pbuf_get_field, pbuf_set_field, col_type_subcol, &
pbuf_register_subcol
use constituents, only: cnst_add, cnst_get_ind, &
cnst_name, cnst_longname, sflxnam, apcnst, bpcnst, pcnst
use cldfrc2m, only: rhmini=>rhmini_const
use cam_history, only: addfld, add_default, outfld, horiz_only
use cam_logfile, only: iulog
use cam_abortutils, only: endrun
use scamMod, only: single_column
use error_messages, only: handle_errmsg
use ref_pres, only: top_lev=>trop_cloud_top_lev
use subcol_utils, only: subcol_get_scheme
implicit none
private
save
public :: &
micro_mg_cam_readnl, &
micro_mg_cam_register, &
micro_mg_cam_init_cnst, &
micro_mg_cam_implements_cnst, &
micro_mg_cam_init, &
micro_mg_cam_tend, &
micro_mg_version, &
massless_droplet_destroyer
integer :: micro_mg_version = 1 ! Version number for MG.
integer :: micro_mg_sub_version = 0 ! Second part of version number.
real(r8) :: micro_mg_dcs = -1._r8
logical :: microp_uniform = .false.
logical :: micro_mg_adjust_cpt = .false.
logical :: micro_do_massless_droplet_destroyer ! turn on/off destruction of massless droplets
character(len=16) :: micro_mg_precip_frac_method = 'max_overlap' ! type of precipitation fraction method
real(r8) :: micro_mg_berg_eff_factor = 1.0_r8 ! berg efficiency factor
logical, public :: do_cldliq ! Prognose cldliq flag
logical, public :: do_cldice ! Prognose cldice flag
integer :: num_steps ! Number of MG substeps
integer :: ncnst = 4 ! Number of constituents
! Namelist variables for option to specify constant cloud droplet/ice number
logical :: micro_mg_nccons = .false. ! set .true. to specify constant cloud droplet number
logical :: micro_mg_nicons = .false. ! set .true. to specify constant cloud ice number
logical :: micro_mg_ngcons = .false. ! set .true. to specify constant graupel/hail number
! parameters for specified ice and droplet number concentration
! note: these are local in-cloud values, not grid-mean
real(r8) :: micro_mg_ncnst = 100.e6_r8 ! constant droplet num concentration (m-3)
real(r8) :: micro_mg_ninst = 0.1e6_r8 ! constant ice num concentration (m-3)
real(r8) :: micro_mg_ngnst = 0.1e6_r8 ! constant graupel/hail num concentration (m-3)
logical, public :: micro_mg_do_graupel
logical, public :: micro_mg_do_hail
character(len=256) :: micro_mg_lkuptbl_filename = '.'
character(len=10), parameter :: & ! Constituent names
cnst_names(10) = (/'CLDLIQ', 'CLDICE','NUMLIQ','NUMICE', &
'RAINQM', 'SNOWQM','NUMRAI','NUMSNO','GRAUQM','NUMGRA'/)
integer :: &
ixcldliq = -1, &! cloud liquid amount index
ixcldice = -1, &! cloud ice amount index
ixnumliq = -1, &! cloud liquid number index
ixnumice = -1, &! cloud ice water index
ixrain = -1, &! rain index
ixsnow = -1, &! snow index
ixnumrain = -1, &! rain number index
ixnumsnow = -1, &! snow number index
ixgraupel = -1, &! graupel index
ixnumgraupel = -1 ! graupel number index
! Physics buffer indices for fields registered by this module
integer :: &
cldo_idx, &
qme_idx, &
prain_idx, &
nevapr_idx, &
wsedl_idx, &
rei_idx, &
sadice_idx, &
sadsnow_idx, &
rel_idx, &
dei_idx, &
mu_idx, &
prer_evap_idx, &
lambdac_idx, &
iciwpst_idx, &
iclwpst_idx, &
des_idx, &
icswp_idx, &
cldfsnow_idx, &
degrau_idx, &
icgrauwp_idx, &
cldfgrau_idx, &
rate1_cw2pr_st_idx = -1, &
ls_flxprc_idx, &
ls_flxsnw_idx, &
relvar_idx, &
cmeliq_idx, &
accre_enhan_idx
! Fields for UNICON
integer :: &
am_evp_st_idx, &! Evaporation area of stratiform precipitation
evprain_st_idx, &! Evaporation rate of stratiform rain [kg/kg/s]. >= 0.
evpsnow_st_idx ! Evaporation rate of stratiform snow [kg/kg/s]. >= 0.
! Fields needed as inputs to COSP
integer :: &
ls_mrprc_idx, ls_mrsnw_idx, &
ls_reffrain_idx, ls_reffsnow_idx, &
cv_reffliq_idx, cv_reffice_idx
! Fields needed by Park macrophysics
integer :: &
cc_t_idx, cc_qv_idx, &
cc_ql_idx, cc_qi_idx, &
cc_nl_idx, cc_ni_idx, &
cc_qlst_idx
! Used to replace aspects of MG microphysics
! (e.g. by CARMA)
integer :: &
tnd_qsnow_idx = -1, &
tnd_nsnow_idx = -1, &
re_ice_idx = -1
! Index fields for precipitation efficiency.
integer :: &
acpr_idx = -1, &
acgcme_idx = -1, &
acnum_idx = -1
! Physics buffer indices for fields registered by other modules
integer :: &
ast_idx = -1, &
cld_idx = -1, &
concld_idx = -1, &
qsatfac_idx = -1
! Pbuf fields needed for subcol_SILHS
integer :: &
qrain_idx=-1, qsnow_idx=-1, &
nrain_idx=-1, nsnow_idx=-1
integer :: &
naai_idx = -1, &
naai_hom_idx = -1, &
npccn_idx = -1, &
rndst_idx = -1, &
nacon_idx = -1, &
prec_str_idx = -1, &
snow_str_idx = -1, &
prec_pcw_idx = -1, &
snow_pcw_idx = -1, &
prec_sed_idx = -1, &
snow_sed_idx = -1
! pbuf fields for heterogeneous freezing
integer :: &
frzimm_idx = -1, &
frzcnt_idx = -1, &
frzdep_idx = -1
logical :: allow_sed_supersat ! allow supersaturated conditions after sedimentation loop
logical :: micro_do_sb_physics = .false. ! do SB 2001 autoconversion and accretion
interface p
module procedure p1
module procedure p2
end interface p
!===============================================================================
contains
!===============================================================================
subroutine micro_mg_cam_readnl(nlfile)
use namelist_utils, only: find_group_name
use units, only: getunit, freeunit
use spmd_utils, only: mpicom, mstrid=>masterprocid, mpi_integer, mpi_real8, &
mpi_logical, mpi_character
character(len=*), intent(in) :: nlfile ! filepath for file containing namelist input
! Namelist variables
logical :: micro_mg_do_cldice = .true. ! do_cldice = .true., MG microphysics is prognosing cldice
logical :: micro_mg_do_cldliq = .true. ! do_cldliq = .true., MG microphysics is prognosing cldliq
integer :: micro_mg_num_steps = 1 ! Number of substepping iterations done by MG (1.5 only for now).
! Local variables
integer :: unitn, ierr
character(len=*), parameter :: sub = 'micro_mg_cam_readnl'
namelist /micro_mg_nl/ micro_mg_version, micro_mg_sub_version, &
micro_mg_do_cldice, micro_mg_do_cldliq, micro_mg_num_steps, &
microp_uniform, micro_mg_dcs, micro_mg_precip_frac_method, &
micro_mg_berg_eff_factor, micro_do_sb_physics, micro_mg_adjust_cpt, &
micro_mg_do_hail, micro_mg_do_graupel,micro_mg_ngcons, micro_mg_ngnst,&
micro_mg_nccons, micro_mg_nicons, micro_mg_ncnst, micro_mg_ninst,&
micro_mg_lkuptbl_filename, micro_do_massless_droplet_destroyer
!-----------------------------------------------------------------------------
if (masterproc) then
unitn = getunit()
open( unitn, file=trim(nlfile), status='old' )
call find_group_name(unitn, 'micro_mg_nl', status=ierr)
if (ierr == 0) then
read(unitn, micro_mg_nl, iostat=ierr)
if (ierr /= 0) then
call endrun(sub // ':: ERROR reading namelist')
end if
end if
close(unitn)
call freeunit(unitn)
! set local variables
do_cldice = micro_mg_do_cldice
do_cldliq = micro_mg_do_cldliq
num_steps = micro_mg_num_steps
! Verify that version numbers are valid.
select case (micro_mg_version)
case (1)
select case (micro_mg_sub_version)
case(0)
! MG version 1.0
case default
call bad_version_endrun()
end select
case (2)
select case (micro_mg_sub_version)
case(0)
! MG version 2.0
case default
call bad_version_endrun()
end select
case (3)
select case (micro_mg_sub_version)
case(0)
! MG version 3.0
case default
call bad_version_endrun()
end select
case (4)
select case (micro_mg_sub_version)
case(0)
! MG version 4.0
case default
call bad_version_endrun()
end select
case default
call bad_version_endrun()
end select
if (micro_mg_dcs < 0._r8) call endrun( "micro_mg_cam_readnl: &
µ_mg_dcs has not been set to a valid value.")
if (micro_mg_version < 3) then
if(micro_mg_do_graupel .or. micro_mg_do_hail ) then
call endrun ("micro_mg_cam_readnl: Micro_mg_do_graupel and micro_mg_do_hail &
&must be false for MG versions before MG3.")
end if
else ! micro_mg_version = 3 or greater
if(micro_mg_do_graupel .and. micro_mg_do_hail ) then
call endrun ("micro_mg_cam_readnl: Only one of micro_mg_do_graupel or &
µ_mg_do_hail may be true at a time.")
end if
end if
end if
! Broadcast namelist variables
call mpi_bcast(micro_mg_version, 1, mpi_integer, mstrid, mpicom, ierr)
if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: micro_mg_version")
call mpi_bcast(micro_mg_sub_version, 1, mpi_integer, mstrid, mpicom, ierr)
if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: micro_mg_sub_version")
call mpi_bcast(do_cldice, 1, mpi_logical, mstrid, mpicom, ierr)
if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: do_cldice")
call mpi_bcast(do_cldliq, 1, mpi_logical, mstrid, mpicom, ierr)
if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: do_cldliq")
call mpi_bcast(num_steps, 1, mpi_integer, mstrid, mpicom, ierr)
if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: num_steps")
call mpi_bcast(microp_uniform, 1, mpi_logical, mstrid, mpicom, ierr)
if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: microp_uniform")
call mpi_bcast(micro_mg_dcs, 1, mpi_real8, mstrid, mpicom, ierr)
if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: micro_mg_dcs")
call mpi_bcast(micro_mg_berg_eff_factor, 1, mpi_real8, mstrid, mpicom, ierr)
if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: micro_mg_berg_eff_factor")
call mpi_bcast(micro_mg_precip_frac_method, 16, mpi_character, mstrid, mpicom, ierr)
if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: micro_mg_precip_frac_method")
call mpi_bcast(micro_do_sb_physics, 1, mpi_logical, mstrid, mpicom, ierr)
if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: micro_do_sb_physics")
call mpi_bcast(micro_mg_adjust_cpt, 1, mpi_logical, mstrid, mpicom, ierr)
if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: micro_mg_adjust_cpt")
call mpi_bcast(micro_mg_nccons, 1, mpi_logical, mstrid, mpicom, ierr)
if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: micro_mg_nccons")
call mpi_bcast(micro_mg_nicons, 1, mpi_logical, mstrid, mpicom, ierr)
if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: micro_mg_nicons")
call mpi_bcast(micro_mg_ncnst, 1, mpi_real8, mstrid, mpicom, ierr)
if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: micro_mg_ncnst")
call mpi_bcast(micro_mg_ninst, 1, mpi_real8, mstrid, mpicom, ierr)
if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: micro_mg_ninst")
call mpi_bcast(micro_mg_do_hail, 1, mpi_logical, mstrid, mpicom, ierr)
if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: micro_mg_do_hail")
call mpi_bcast(micro_mg_do_graupel, 1, mpi_logical, mstrid, mpicom, ierr)
if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: micro_mg_do_graupel")
call mpi_bcast(micro_mg_ngcons, 1, mpi_logical, mstrid, mpicom, ierr)
if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: micro_mg_ngcons")
call mpi_bcast(micro_mg_ngnst, 1, mpi_real8, mstrid, mpicom, ierr)
if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: micro_mg_ngnst")
call mpi_bcast(micro_mg_lkuptbl_filename, 256, mpi_character, mstrid, mpicom, ierr)
if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: micro_mg_lkuptbl_filename")
call mpi_bcast(micro_do_massless_droplet_destroyer, 1, mpi_logical, mstrid, mpicom, ierr)
if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: micro_do_massless_droplet_destroyer")
if (masterproc) then
write(iulog,*) 'MG microphysics namelist:'
write(iulog,*) ' micro_mg_version = ', micro_mg_version
write(iulog,*) ' micro_mg_sub_version = ', micro_mg_sub_version
write(iulog,*) ' micro_mg_do_cldice = ', do_cldice
write(iulog,*) ' micro_mg_do_cldliq = ', do_cldliq
write(iulog,*) ' micro_mg_num_steps = ', num_steps
write(iulog,*) ' microp_uniform = ', microp_uniform
write(iulog,*) ' micro_mg_dcs = ', micro_mg_dcs
write(iulog,*) ' micro_mg_berg_eff_factor = ', micro_mg_berg_eff_factor
write(iulog,*) ' micro_mg_precip_frac_method = ', micro_mg_precip_frac_method
write(iulog,*) ' micro_do_sb_physics = ', micro_do_sb_physics
write(iulog,*) ' micro_mg_adjust_cpt = ', micro_mg_adjust_cpt
write(iulog,*) ' micro_mg_nccons = ', micro_mg_nccons
write(iulog,*) ' micro_mg_nicons = ', micro_mg_nicons
write(iulog,*) ' micro_mg_ncnst = ', micro_mg_ncnst
write(iulog,*) ' micro_mg_ninst = ', micro_mg_ninst
write(iulog,*) ' micro_mg_ngcons = ', micro_mg_ngcons
write(iulog,*) ' micro_mg_ngnst = ', micro_mg_ngnst
write(iulog,*) ' micro_mg_do_hail = ', micro_mg_do_hail
write(iulog,*) ' micro_mg_do_graupel = ', micro_mg_do_graupel
write(iulog,*) ' micro_mg_lkuptbl_filename = ', micro_mg_lkuptbl_filename
write(iulog,*) ' micro_do_massless_droplet_destroyer = ', micro_do_massless_droplet_destroyer
end if
contains
subroutine bad_version_endrun
! Endrun wrapper with a more useful error message.
character(len=128) :: errstring
write(errstring,*) "Invalid version number specified for MG microphysics: ", &
micro_mg_version,".",micro_mg_sub_version
call endrun(errstring)
end subroutine bad_version_endrun
end subroutine micro_mg_cam_readnl
!================================================================================================
subroutine micro_mg_cam_register
! Register microphysics constituents and fields in the physics buffer.
!-----------------------------------------------------------------------
logical :: prog_modal_aero
logical :: use_subcol_microp ! If true, then are using subcolumns in microphysics
call phys_getopts(use_subcol_microp_out = use_subcol_microp, &
prog_modal_aero_out = prog_modal_aero)
! Register microphysics constituents and save indices.
call cnst_add(cnst_names(1), mwh2o, cpair, 0._r8, ixcldliq, &
longname='Grid box averaged cloud liquid amount', is_convtran1=.true.)
call cnst_add(cnst_names(2), mwh2o, cpair, 0._r8, ixcldice, &
longname='Grid box averaged cloud ice amount', is_convtran1=.true.)
call cnst_add(cnst_names(3), mwh2o, cpair, 0._r8, ixnumliq, &
longname='Grid box averaged cloud liquid number', is_convtran1=.true.)
call cnst_add(cnst_names(4), mwh2o, cpair, 0._r8, ixnumice, &
longname='Grid box averaged cloud ice number', is_convtran1=.true.)
! Note is_convtran1 is set to .true.
if (micro_mg_version > 1) then
call cnst_add(cnst_names(5), mwh2o, cpair, 0._r8, ixrain, &
longname='Grid box averaged rain amount', is_convtran1=.true.)
call cnst_add(cnst_names(6), mwh2o, cpair, 0._r8, ixsnow, &
longname='Grid box averaged snow amount', is_convtran1=.true.)
call cnst_add(cnst_names(7), mwh2o, cpair, 0._r8, ixnumrain, &
longname='Grid box averaged rain number', is_convtran1=.true.)
call cnst_add(cnst_names(8), mwh2o, cpair, 0._r8, ixnumsnow, &
longname='Grid box averaged snow number', is_convtran1=.true.)
end if
if (micro_mg_version > 2) then
call cnst_add(cnst_names(9), mwh2o, cpair, 0._r8, ixgraupel, &
longname='Grid box averaged graupel/hail amount', is_convtran1=.true.)
call cnst_add(cnst_names(10), mwh2o, cpair, 0._r8, ixnumgraupel, &
longname='Grid box averaged graupel/hail number', is_convtran1=.true.)
end if
! Request physics buffer space for fields that persist across timesteps.
call pbuf_add_field('CLDO','global',dtype_r8,(/pcols,pver,dyn_time_lvls/), cldo_idx)
! Physics buffer variables for convective cloud properties.
call pbuf_add_field('QME', 'physpkg',dtype_r8,(/pcols,pver/), qme_idx)
call pbuf_add_field('PRAIN', 'physpkg',dtype_r8,(/pcols,pver/), prain_idx)
call pbuf_add_field('NEVAPR', 'physpkg',dtype_r8,(/pcols,pver/), nevapr_idx)
call pbuf_add_field('PRER_EVAP', 'global', dtype_r8,(/pcols,pver/), prer_evap_idx)
call pbuf_add_field('WSEDL', 'physpkg',dtype_r8,(/pcols,pver/), wsedl_idx)
call pbuf_add_field('REI', 'physpkg',dtype_r8,(/pcols,pver/), rei_idx)
call pbuf_add_field('SADICE', 'physpkg',dtype_r8,(/pcols,pver/), sadice_idx)
call pbuf_add_field('SADSNOW', 'physpkg',dtype_r8,(/pcols,pver/), sadsnow_idx)
call pbuf_add_field('REL', 'physpkg',dtype_r8,(/pcols,pver/), rel_idx)
! Mitchell ice effective diameter for radiation
call pbuf_add_field('DEI', 'physpkg',dtype_r8,(/pcols,pver/), dei_idx)
! Size distribution shape parameter for radiation
call pbuf_add_field('MU', 'physpkg',dtype_r8,(/pcols,pver/), mu_idx)
! Size distribution shape parameter for radiation
call pbuf_add_field('LAMBDAC', 'physpkg',dtype_r8,(/pcols,pver/), lambdac_idx)
! Stratiform only in cloud ice water path for radiation
call pbuf_add_field('ICIWPST', 'physpkg',dtype_r8,(/pcols,pver/), iciwpst_idx)
! Stratiform in cloud liquid water path for radiation
call pbuf_add_field('ICLWPST', 'physpkg',dtype_r8,(/pcols,pver/), iclwpst_idx)
! Snow effective diameter for radiation
call pbuf_add_field('DES', 'physpkg',dtype_r8,(/pcols,pver/), des_idx)
! In cloud snow water path for radiation
call pbuf_add_field('ICSWP', 'physpkg',dtype_r8,(/pcols,pver/), icswp_idx)
! Cloud fraction for liquid drops + snow
call pbuf_add_field('CLDFSNOW ', 'physpkg',dtype_r8,(/pcols,pver,dyn_time_lvls/), cldfsnow_idx)
if ((micro_mg_version > 2).and.(micro_mg_do_graupel.or.micro_mg_do_hail)) then
! Graupel effective diameter for radiation
call pbuf_add_field('DEGRAU', 'physpkg',dtype_r8,(/pcols,pver/), degrau_idx)
! In cloud snow water path for radiation
call pbuf_add_field('ICGRAUWP', 'physpkg',dtype_r8,(/pcols,pver/), icgrauwp_idx)
! Cloud fraction for liquid drops + graupel
call pbuf_add_field('CLDFGRAU', 'physpkg',dtype_r8,(/pcols,pver/), cldfgrau_idx)
end if
if (prog_modal_aero) then
call pbuf_add_field('RATE1_CW2PR_ST','physpkg',dtype_r8,(/pcols,pver/), rate1_cw2pr_st_idx)
endif
call pbuf_add_field('LS_FLXPRC', 'physpkg',dtype_r8,(/pcols,pverp/), ls_flxprc_idx)
call pbuf_add_field('LS_FLXSNW', 'physpkg',dtype_r8,(/pcols,pverp/), ls_flxsnw_idx)
! Fields needed as inputs to COSP
call pbuf_add_field('LS_MRPRC', 'physpkg',dtype_r8,(/pcols,pver/), ls_mrprc_idx)
call pbuf_add_field('LS_MRSNW', 'physpkg',dtype_r8,(/pcols,pver/), ls_mrsnw_idx)
call pbuf_add_field('LS_REFFRAIN','physpkg',dtype_r8,(/pcols,pver/), ls_reffrain_idx)
call pbuf_add_field('LS_REFFSNOW','physpkg',dtype_r8,(/pcols,pver/), ls_reffsnow_idx)
call pbuf_add_field('CV_REFFLIQ', 'physpkg',dtype_r8,(/pcols,pver/), cv_reffliq_idx)
call pbuf_add_field('CV_REFFICE', 'physpkg',dtype_r8,(/pcols,pver/), cv_reffice_idx)
! CC_* Fields needed by Park macrophysics
call pbuf_add_field('CC_T', 'global', dtype_r8, (/pcols,pver,dyn_time_lvls/), cc_t_idx)
call pbuf_add_field('CC_qv', 'global', dtype_r8, (/pcols,pver,dyn_time_lvls/), cc_qv_idx)
call pbuf_add_field('CC_ql', 'global', dtype_r8, (/pcols,pver,dyn_time_lvls/), cc_ql_idx)
call pbuf_add_field('CC_qi', 'global', dtype_r8, (/pcols,pver,dyn_time_lvls/), cc_qi_idx)
call pbuf_add_field('CC_nl', 'global', dtype_r8, (/pcols,pver,dyn_time_lvls/), cc_nl_idx)
call pbuf_add_field('CC_ni', 'global', dtype_r8, (/pcols,pver,dyn_time_lvls/), cc_ni_idx)
call pbuf_add_field('CC_qlst', 'global', dtype_r8, (/pcols,pver,dyn_time_lvls/), cc_qlst_idx)
! Fields for UNICON
call pbuf_add_field('am_evp_st', 'global', dtype_r8, (/pcols,pver/), am_evp_st_idx)
call pbuf_add_field('evprain_st', 'global', dtype_r8, (/pcols,pver/), evprain_st_idx)
call pbuf_add_field('evpsnow_st', 'global', dtype_r8, (/pcols,pver/), evpsnow_st_idx)
! Register subcolumn pbuf fields
if (use_subcol_microp) then
! Global pbuf fields
call pbuf_register_subcol('CLDO', 'micro_mg_cam_register', cldo_idx)
! CC_* Fields needed by Park macrophysics
call pbuf_register_subcol('CC_T', 'micro_mg_cam_register', cc_t_idx)
call pbuf_register_subcol('CC_qv', 'micro_mg_cam_register', cc_qv_idx)
call pbuf_register_subcol('CC_ql', 'micro_mg_cam_register', cc_ql_idx)
call pbuf_register_subcol('CC_qi', 'micro_mg_cam_register', cc_qi_idx)
call pbuf_register_subcol('CC_nl', 'micro_mg_cam_register', cc_nl_idx)
call pbuf_register_subcol('CC_ni', 'micro_mg_cam_register', cc_ni_idx)
call pbuf_register_subcol('CC_qlst', 'micro_mg_cam_register', cc_qlst_idx)
! Physpkg pbuf fields
! Physics buffer variables for convective cloud properties.
call pbuf_register_subcol('QME', 'micro_mg_cam_register', qme_idx)
call pbuf_register_subcol('PRAIN', 'micro_mg_cam_register', prain_idx)
call pbuf_register_subcol('NEVAPR', 'micro_mg_cam_register', nevapr_idx)
call pbuf_register_subcol('PRER_EVAP', 'micro_mg_cam_register', prer_evap_idx)
call pbuf_register_subcol('WSEDL', 'micro_mg_cam_register', wsedl_idx)
call pbuf_register_subcol('REI', 'micro_mg_cam_register', rei_idx)
call pbuf_register_subcol('SADICE', 'micro_mg_cam_register', sadice_idx)
call pbuf_register_subcol('SADSNOW', 'micro_mg_cam_register', sadsnow_idx)
call pbuf_register_subcol('REL', 'micro_mg_cam_register', rel_idx)
! Mitchell ice effective diameter for radiation
call pbuf_register_subcol('DEI', 'micro_mg_cam_register', dei_idx)
! Size distribution shape parameter for radiation
call pbuf_register_subcol('MU', 'micro_mg_cam_register', mu_idx)
! Size distribution shape parameter for radiation
call pbuf_register_subcol('LAMBDAC', 'micro_mg_cam_register', lambdac_idx)
! Stratiform only in cloud ice water path for radiation
call pbuf_register_subcol('ICIWPST', 'micro_mg_cam_register', iciwpst_idx)
! Stratiform in cloud liquid water path for radiation
call pbuf_register_subcol('ICLWPST', 'micro_mg_cam_register', iclwpst_idx)
! Snow effective diameter for radiation
call pbuf_register_subcol('DES', 'micro_mg_cam_register', des_idx)
! In cloud snow water path for radiation
call pbuf_register_subcol('ICSWP', 'micro_mg_cam_register', icswp_idx)
! Cloud fraction for liquid drops + snow
call pbuf_register_subcol('CLDFSNOW ', 'micro_mg_cam_register', cldfsnow_idx)
if((micro_mg_version > 2).and.(micro_mg_do_graupel.or.micro_mg_do_hail)) then
! Graupel effective diameter for radiation
call pbuf_register_subcol('DEGRAU', 'micro_mg_cam_register', degrau_idx)
! In cloud snow water path for radiation
call pbuf_register_subcol('ICGRAUWP', 'micro_mg_cam_register', icgrauwp_idx)
! Cloud fraction for liquid drops + snow
call pbuf_register_subcol('CLDFGRAU', 'micro_mg_cam_register', cldfgrau_idx)
end if
if (prog_modal_aero) then
call pbuf_register_subcol('RATE1_CW2PR_ST', 'micro_mg_cam_register', rate1_cw2pr_st_idx)
end if
call pbuf_register_subcol('LS_FLXPRC', 'micro_mg_cam_register', ls_flxprc_idx)
call pbuf_register_subcol('LS_FLXSNW', 'micro_mg_cam_register', ls_flxsnw_idx)
! Fields needed as inputs to COSP
call pbuf_register_subcol('LS_MRPRC', 'micro_mg_cam_register', ls_mrprc_idx)
call pbuf_register_subcol('LS_MRSNW', 'micro_mg_cam_register', ls_mrsnw_idx)
call pbuf_register_subcol('LS_REFFRAIN', 'micro_mg_cam_register', ls_reffrain_idx)
call pbuf_register_subcol('LS_REFFSNOW', 'micro_mg_cam_register', ls_reffsnow_idx)
call pbuf_register_subcol('CV_REFFLIQ', 'micro_mg_cam_register', cv_reffliq_idx)
call pbuf_register_subcol('CV_REFFICE', 'micro_mg_cam_register', cv_reffice_idx)
end if
! Additional pbuf for CARMA interface
if (.not. do_cldice) then
call pbuf_add_field('TND_QSNOW', 'physpkg',dtype_r8,(/pcols,pver/), tnd_qsnow_idx)
call pbuf_add_field('TND_NSNOW', 'physpkg',dtype_r8,(/pcols,pver/), tnd_nsnow_idx)
call pbuf_add_field('RE_ICE', 'physpkg',dtype_r8,(/pcols,pver/), re_ice_idx)
end if
! Precipitation efficiency fields across timesteps.
call pbuf_add_field('ACPRECL', 'global',dtype_r8,(/pcols/), acpr_idx) ! accumulated precip
call pbuf_add_field('ACGCME', 'global',dtype_r8,(/pcols/), acgcme_idx) ! accumulated condensation
call pbuf_add_field('ACNUM', 'global',dtype_i4,(/pcols/), acnum_idx) ! counter for accumulated # timesteps
! SGS variability -- These could be reset by CLUBB so they need to be grid only
call pbuf_add_field('RELVAR', 'global',dtype_r8,(/pcols,pver/), relvar_idx)
call pbuf_add_field('ACCRE_ENHAN','global',dtype_r8,(/pcols,pver/), accre_enhan_idx)
! Diagnostic fields needed for subcol_SILHS, need to be grid-only
if (subcol_get_scheme() == 'SILHS') then
call pbuf_add_field('QRAIN', 'global',dtype_r8,(/pcols,pver/), qrain_idx)
call pbuf_add_field('QSNOW', 'global',dtype_r8,(/pcols,pver/), qsnow_idx)
call pbuf_add_field('NRAIN', 'global',dtype_r8,(/pcols,pver/), nrain_idx)
call pbuf_add_field('NSNOW', 'global',dtype_r8,(/pcols,pver/), nsnow_idx)
end if
end subroutine micro_mg_cam_register
!===============================================================================
function micro_mg_cam_implements_cnst(name)
! Return true if specified constituent is implemented by the
! microphysics package
character(len=*), intent(in) :: name ! constituent name
logical :: micro_mg_cam_implements_cnst ! return value
!-----------------------------------------------------------------------
micro_mg_cam_implements_cnst = any(name == cnst_names)
end function micro_mg_cam_implements_cnst
!===============================================================================
subroutine micro_mg_cam_init_cnst(name, latvals, lonvals, mask, q)
! Initialize the microphysics constituents, if they are
! not read from the initial file.
character(len=*), intent(in) :: name ! constituent name
real(r8), intent(in) :: latvals(:) ! lat in degrees (ncol)
real(r8), intent(in) :: lonvals(:) ! lon in degrees (ncol)
logical, intent(in) :: mask(:) ! Only initialize where .true.
real(r8), intent(out) :: q(:,:) ! kg tracer/kg dry air (gcol, plev
!-----------------------------------------------------------------------
integer :: k
if (micro_mg_cam_implements_cnst(name)) then
do k = 1, size(q, 2)
where(mask)
q(:, k) = 0.0_r8
end where
end do
end if
end subroutine micro_mg_cam_init_cnst
!===============================================================================
subroutine micro_mg_cam_init(pbuf2d)
use time_manager, only: is_first_step
use micro_mg_utils, only: micro_mg_utils_init, init_lookup_table
use micro_mg1_0, only: micro_mg_init1_0 => micro_mg_init
use micro_mg3_0, only: micro_mg_init3_0 => micro_mg_init
!++ktc
use micro_mg4_0, only: micro_mg_init4_0 => micro_mg_init
!--ktc
!-----------------------------------------------------------------------
!
! Initialization for MG microphysics
!
!-----------------------------------------------------------------------
type(physics_buffer_desc), pointer :: pbuf2d(:,:)
integer :: m, mm
logical :: history_amwg ! output the variables used by the AMWG diag package
logical :: history_budget ! Output tendencies and state variables for CAM4
! temperature, water vapor, cloud ice and cloud
! liquid budgets.
logical :: use_subcol_microp
logical :: do_clubb_sgs
integer :: budget_histfile ! output history file number for budget fields
integer :: ierr
character(128) :: errstring ! return status (non-blank for error return)
! MG4 required for reading lookup table
integer :: i,j,k,ii,jj,kk, tt
real(r8):: dum
call phys_getopts(use_subcol_microp_out=use_subcol_microp, &
do_clubb_sgs_out =do_clubb_sgs)
if (do_clubb_sgs) then
allow_sed_supersat = .false.
else
allow_sed_supersat = .true.
endif
if (masterproc) then
write(iulog,"(A,I2,A,I2)") "Initializing MG version ",micro_mg_version,".",micro_mg_sub_version
if (.not. do_cldliq) &
write(iulog,*) "MG prognostic cloud liquid has been turned off via namelist."
if (.not. do_cldice) &
write(iulog,*) "MG prognostic cloud ice has been turned off via namelist."
write(iulog,*) "Number of microphysics substeps is: ",num_steps
end if
select case (micro_mg_version)
case (1)
! Set constituent number for later loops.
ncnst = 4
select case (micro_mg_sub_version)
case (0)
! MG 1 does not initialize micro_mg_utils, so have to do it here.
call micro_mg_utils_init(r8, rair, rh2o, cpair, tmelt, latvap, latice, &
micro_mg_dcs, errstring)
call handle_errmsg(errstring, subname="micro_mg_utils_init")
call micro_mg_init1_0( &
r8, gravit, rair, rh2o, cpair, &
rhoh2o, tmelt, latvap, latice, &
rhmini, micro_mg_dcs, use_hetfrz_classnuc, &
micro_mg_precip_frac_method, micro_mg_berg_eff_factor, &
micro_mg_nccons, micro_mg_nicons, micro_mg_ncnst, &
micro_mg_ninst, errstring)
end select
case (2:3)
! Set constituent number for later loops.
if(micro_mg_version == 2) then
ncnst = 8
else
ncnst = 10
end if
call micro_mg_init3_0( &
r8, gravit, rair, rh2o, cpair, &
tmelt, latvap, latice, rhmini, &
micro_mg_dcs, &
micro_mg_do_hail,micro_mg_do_graupel, &
microp_uniform, do_cldice, use_hetfrz_classnuc, &
micro_mg_precip_frac_method, micro_mg_berg_eff_factor, &
allow_sed_supersat, micro_do_sb_physics, &
micro_mg_nccons, micro_mg_nicons, micro_mg_ncnst, &
micro_mg_ninst, micro_mg_ngcons, micro_mg_ngnst, errstring)
!++ktc
case (4)
! Set constituent number for later loops.
ncnst = 10
!Selectable if not using hail or graupel?
! if (micro_mg_do_hail .or. micro_mg_do_graupel) then
! ncnst = 10
! else if ((.not.micro_mg_do_hail) .and. (.not.micro_mg_do_graupel)) then
! ncnst = 8
! else if (micro_mg_do_hail .and. micro_mg_do_graupel) then
! call endrun( "micro_mg_cam_init: &
! &Cannot have both hail and graupel. Pick one or none.")
! endif
select case (micro_mg_sub_version)
case (0)
!-----------------------------------------------------------------------
! Read in ice microphysics lookup table - it is stored and accessed through
! micro_mg_utils - Can I move this into micro_mg_init4?
call init_lookup_table(micro_mg_lkuptbl_filename)
call micro_mg_init4_0( &
r8, gravit, rair, rh2o, cpair, &
tmelt, latvap, latice, rhmini, &
micro_mg_dcs, &
micro_mg_do_hail,micro_mg_do_graupel, &
microp_uniform, do_cldice, use_hetfrz_classnuc, &
micro_mg_precip_frac_method, micro_mg_berg_eff_factor, &
allow_sed_supersat, micro_do_sb_physics, &
micro_mg_nccons, micro_mg_nicons, micro_mg_ncnst, &
micro_mg_ninst, errstring)
end select
!--ktc
end select
call handle_errmsg(errstring, subname="micro_mg_init")
! Register history variables
do m = 1, ncnst
call cnst_get_ind(cnst_names(m), mm)
if ( any(mm == (/ ixcldliq, ixcldice, ixrain, ixsnow, ixgraupel /)) ) then
! mass mixing ratios
call addfld(cnst_name(mm), (/ 'lev' /), 'A', 'kg/kg', cnst_longname(mm) )
call addfld(sflxnam(mm), horiz_only, 'A', 'kg/m2/s', trim(cnst_name(mm))//' surface flux')
else if ( any(mm == (/ ixnumliq, ixnumice, ixnumrain, ixnumsnow, ixnumgraupel /)) ) then
! number concentrations
call addfld(cnst_name(mm), (/ 'lev' /), 'A', '1/kg', cnst_longname(mm) )
call addfld(sflxnam(mm), horiz_only, 'A', '1/m2/s', trim(cnst_name(mm))//' surface flux')
else
call endrun( "micro_mg_cam_init: &
&Could not call addfld for constituent with unknown units.")
endif
end do
call addfld(apcnst(ixcldliq), (/ 'lev' /), 'A', 'kg/kg', trim(cnst_name(ixcldliq))//' after physics' )
call addfld(apcnst(ixcldice), (/ 'lev' /), 'A', 'kg/kg', trim(cnst_name(ixcldice))//' after physics' )
call addfld(bpcnst(ixcldliq), (/ 'lev' /), 'A', 'kg/kg', trim(cnst_name(ixcldliq))//' before physics' )
call addfld(bpcnst(ixcldice), (/ 'lev' /), 'A', 'kg/kg', trim(cnst_name(ixcldice))//' before physics' )
if (micro_mg_version > 1) then
call addfld(apcnst(ixrain), (/ 'lev' /), 'A', 'kg/kg', trim(cnst_name(ixrain))//' after physics' )
call addfld(apcnst(ixsnow), (/ 'lev' /), 'A', 'kg/kg', trim(cnst_name(ixsnow))//' after physics' )
call addfld(bpcnst(ixrain), (/ 'lev' /), 'A', 'kg/kg', trim(cnst_name(ixrain))//' before physics' )
call addfld(bpcnst(ixsnow), (/ 'lev' /), 'A', 'kg/kg', trim(cnst_name(ixsnow))//' before physics' )
end if
if (micro_mg_version > 2) then
if (micro_mg_do_hail .or. micro_mg_do_graupel) then
call addfld(apcnst(ixgraupel), (/ 'lev' /), 'A', 'kg/kg', trim(cnst_name(ixgraupel))//' after physics' )
call addfld(bpcnst(ixgraupel), (/ 'lev' /), 'A', 'kg/kg', trim(cnst_name(ixgraupel))//' before physics' )
endif
end if
call addfld ('CME', (/ 'lev' /), 'A', 'kg/kg/s', 'Rate of cond-evap within the cloud' )
call addfld ('PRODPREC', (/ 'lev' /), 'A', 'kg/kg/s', 'Rate of conversion of condensate to precip' )
call addfld ('EVAPPREC', (/ 'lev' /), 'A', 'kg/kg/s', 'Rate of evaporation of falling precip' )
call addfld ('EVAPSNOW', (/ 'lev' /), 'A', 'kg/kg/s', 'Rate of evaporation of falling snow' )
call addfld ('HPROGCLD', (/ 'lev' /), 'A', 'W/kg' , 'Heating from prognostic clouds' )
call addfld ('FICE', (/ 'lev' /), 'A', 'fraction', 'Fractional ice content within cloud' )
call addfld ('CLDFSNOW', (/ 'lev' /), 'A', '1', 'Cloud fraction adjusted for snow' )
call addfld ('ICWMRST', (/ 'lev' /), 'A', 'kg/kg', 'Prognostic in-stratus water mixing ratio' )
call addfld ('ICIMRST', (/ 'lev' /), 'A', 'kg/kg', 'Prognostic in-stratus ice mixing ratio' )
! MG microphysics diagnostics
call addfld ('QCSEVAP', (/ 'lev' /), 'A', 'kg/kg/s', 'Rate of evaporation of falling cloud water' )
call addfld ('QISEVAP', (/ 'lev' /), 'A', 'kg/kg/s', 'Rate of sublimation of falling cloud ice' )
call addfld ('QVRES', (/ 'lev' /), 'A', 'kg/kg/s', 'Rate of residual condensation term' )
call addfld ('CMEIOUT', (/ 'lev' /), 'A', 'kg/kg/s', 'Rate of deposition/sublimation of cloud ice' )
call addfld ('VTRMC', (/ 'lev' /), 'A', 'm/s', 'Mass-weighted cloud water fallspeed' )
call addfld ('VTRMI', (/ 'lev' /), 'A', 'm/s', 'Mass-weighted cloud ice fallspeed' )
call addfld ('QCSEDTEN', (/ 'lev' /), 'A', 'kg/kg/s', 'Cloud water mixing ratio tendency from sedimentation' )
call addfld ('QISEDTEN', (/ 'lev' /), 'A', 'kg/kg/s', 'Cloud ice mixing ratio tendency from sedimentation' )
call addfld ('PRAO', (/ 'lev' /), 'A', 'kg/kg/s', 'Accretion of cloud water by rain' )
call addfld ('PRCO', (/ 'lev' /), 'A', 'kg/kg/s', 'Autoconversion of cloud water' )
call addfld ('MNUCCCO', (/ 'lev' /), 'A', 'kg/kg/s', 'Immersion freezing of cloud water' )
call addfld ('MNUCCTO', (/ 'lev' /), 'A', 'kg/kg/s', 'Contact freezing of cloud water' )
call addfld ('MNUCCDO', (/ 'lev' /), 'A', 'kg/kg/s', 'Homogeneous and heterogeneous nucleation from vapor' )
call addfld ('MNUCCDOhet', (/ 'lev' /), 'A', 'kg/kg/s', 'Heterogeneous nucleation from vapor' )
call addfld ('MSACWIO', (/ 'lev' /), 'A', 'kg/kg/s', 'Conversion of cloud water from rime-splintering' )
call addfld ('PSACWSO', (/ 'lev' /), 'A', 'kg/kg/s', 'Accretion of cloud water by snow' )
call addfld ('NPSACWSO', (/ 'lev' /), 'A', 'kg/kg/s', 'Number Accretion of cloud water by snow' )
call addfld ('BERGSO', (/ 'lev' /), 'A', 'kg/kg/s', 'Conversion of cloud water to snow from bergeron' )
call addfld ('BERGO', (/ 'lev' /), 'A', 'kg/kg/s', 'Conversion of cloud water to cloud ice from bergeron' )
call addfld ('MELTO', (/ 'lev' /), 'A', 'kg/kg/s', 'Melting of cloud ice' )
call addfld ('HOMOO', (/ 'lev' /), 'A', 'kg/kg/s', 'Homogeneous freezing of cloud water' )
call addfld ('QCRESO', (/ 'lev' /), 'A', 'kg/kg/s', 'Residual condensation term for cloud water' )
call addfld ('PRCIO', (/ 'lev' /), 'A', 'kg/kg/s', 'Autoconversion of cloud ice to snow' )
call addfld ('PRAIO', (/ 'lev' /), 'A', 'kg/kg/s', 'Accretion of cloud ice to snow' )
call addfld ('QIRESO', (/ 'lev' /), 'A', 'kg/kg/s', 'Residual deposition term for cloud ice' )
call addfld ('MNUCCRO', (/ 'lev' /), 'A', 'kg/kg/s', 'Heterogeneous freezing of rain to snow' )
call addfld ('MNUCCRIO', (/ 'lev' /), 'A', 'kg/kg/s', 'Heterogeneous freezing of rain to ice' )
call addfld ('PRACSO', (/ 'lev' /), 'A', 'kg/kg/s', 'Accretion of rain by snow' )
call addfld ('MELTSDT', (/ 'lev' /), 'A', 'W/kg', 'Latent heating rate due to melting of snow' )
call addfld ('FRZRDT', (/ 'lev' /), 'A', 'W/kg', 'Latent heating rate due to homogeneous freezing of rain' )
if (micro_mg_version > 1) then
call addfld ('QRSEDTEN', (/ 'lev' /), 'A', 'kg/kg/s', 'Rain mixing ratio tendency from sedimentation' )
call addfld ('QSSEDTEN', (/ 'lev' /), 'A', 'kg/kg/s', 'Snow mixing ratio tendency from sedimentation' )
end if
if (micro_mg_version > 2) then
call addfld ('PSACRO', (/ 'lev' /), 'A', 'kg/kg/s', 'Collisions between rain & snow (Graupel collecting snow)')
call addfld ('PRACGO', (/ 'lev' /), 'A', 'kg/kg/s', 'Change in q collection rain by graupel' )
call addfld ('PSACWGO', (/ 'lev' /), 'A', 'kg/kg/s', 'Change in q collection droplets by graupel' )
call addfld ('PGSACWO', (/ 'lev' /), 'A', 'kg/kg/s', 'Q conversion to graupel due to collection droplets by snow')
call addfld ('PGRACSO', (/ 'lev' /), 'A', 'kg/kg/s', 'Q conversion to graupel due to collection rain by snow')
call addfld ('PRDGO', (/ 'lev' /), 'A', 'kg/kg/s', 'Deposition of graupel')
call addfld ('QMULTGO', (/ 'lev' /), 'A', 'kg/kg/s', 'Q change due to ice mult droplets/graupel')
call addfld ('QMULTRGO', (/ 'lev' /), 'A', 'kg/kg/s', 'Q change due to ice mult rain/graupel')
call addfld ('QGSEDTEN', (/ 'lev' /), 'A', 'kg/kg/s', 'Graupel/Hail mixing ratio tendency from sedimentation')
call addfld ('NPRACGO', (/ 'lev' /), 'A', 'kg/kg/s', 'Change N collection rain by graupel')
call addfld ('NSCNGO', (/'lev'/),'A','kg/kg/s','Change N conversion to graupel due to collection droplets by snow')
call addfld ('NGRACSO',(/'lev'/),'A','kg/kg/s','Change N conversion to graupel due to collection rain by snow')
call addfld ('NMULTGO', (/ 'lev' /), 'A', 'kg/kg/s', 'Ice mult due to acc droplets by graupel ')
call addfld ('NMULTRGO', (/ 'lev' /), 'A', 'kg/kg/s', 'Ice mult due to acc rain by graupel')
call addfld ('NPSACWGO', (/ 'lev' /), 'A', 'kg/kg/s', 'Change N collection droplets by graupel')
call addfld ('CLDFGRAU', (/ 'lev' /), 'A', '1', 'Cloud fraction adjusted for graupel' )
end if
if (micro_mg_version > 3) then
call addfld ('LAMSMG4', (/ 'lev' /), 'A', '1', 'Falling ice particle distribution lams' )
call addfld ('N0SMG4', (/ 'lev' /), 'A', '1', 'Falling ice particle distribution n0')
call addfld ('LAMRMG4', (/ 'lev' /), 'A', '1', 'Falling ice particle distribution lamr' )
call addfld ('N0RMG4', (/ 'lev' /), 'A', '1', 'Falling ice particle distribution n0')
call addfld ('QISTARTMG', (/ 'lev' /), 'A', 'kg/kg', 'Starting ice mixing ratio MG (debug)')
call addfld ('QIENDMG', (/ 'lev' /), 'A', 'kg/kg', 'Ending ice mixing ratio MG (debug)' )
!call addfld ('QIPTEND', (/ 'lev' /), 'A', 'kg/kg/s', 'Ptend value of qi tendency (debug)' )
end if
! History variables for CAM5 microphysics
call addfld ('MPDT', (/ 'lev' /), 'A', 'W/kg', 'Heating tendency - Morrison microphysics' )
call addfld ('MPDQ', (/ 'lev' /), 'A', 'kg/kg/s', 'Q tendency - Morrison microphysics' )
call addfld ('MPDLIQ', (/ 'lev' /), 'A', 'kg/kg/s', 'CLDLIQ tendency - Morrison microphysics' )
call addfld ('MPDICE', (/ 'lev' /), 'A', 'kg/kg/s', 'CLDICE tendency - Morrison microphysics' )
call addfld ('MPDICERES', (/ 'lev' /), 'A', 'kg/kg/s', 'CLDICE tendency residual debugging' )
call addfld ('MPDICEPRE', (/ 'lev' /), 'A', 'kg/kg/s', 'CLDICE tendency residual due to pre-adjustment' )
call addfld ('MPDNLIQ', (/ 'lev' /), 'A', '1/kg/s', 'NUMLIQ tendency - Morrison microphysics' )
call addfld ('MPDNICE', (/ 'lev' /), 'A', '1/kg/s', 'NUMICE tendency - Morrison microphysics' )
call addfld ('MPDW2V', (/ 'lev' /), 'A', 'kg/kg/s', 'Water <--> Vapor tendency - Morrison microphysics' )
call addfld ('MPDW2I', (/ 'lev' /), 'A', 'kg/kg/s', 'Water <--> Ice tendency - Morrison microphysics' )
call addfld ('MPDW2P', (/ 'lev' /), 'A', 'kg/kg/s', 'Water <--> Precip tendency - Morrison microphysics' )
call addfld ('MPDI2V', (/ 'lev' /), 'A', 'kg/kg/s', 'Ice <--> Vapor tendency - Morrison microphysics' )
call addfld ('MPDI2W', (/ 'lev' /), 'A', 'kg/kg/s', 'Ice <--> Water tendency - Morrison microphysics' )
call addfld ('MPDI2P', (/ 'lev' /), 'A', 'kg/kg/s', 'Ice <--> Precip tendency - Morrison microphysics' )
call addfld ('ICWNC', (/ 'lev' /), 'A', 'm-3', 'Prognostic in-cloud water number conc' )
call addfld ('ICINC', (/ 'lev' /), 'A', 'm-3', 'Prognostic in-cloud ice number conc' )
call addfld ('EFFLIQ_IND', (/ 'lev' /), 'A','Micron', 'Prognostic droplet effective radius (indirect effect)' )
call addfld ('CDNUMC', horiz_only, 'A', '1/m2', 'Vertically-integrated droplet concentration' )
call addfld ('MPICLWPI', horiz_only, 'A', 'kg/m2', 'Vertically-integrated &
&in-cloud Initial Liquid WP (Before Micro)' )
call addfld ('MPICIWPI', horiz_only, 'A', 'kg/m2', 'Vertically-integrated &
&in-cloud Initial Ice WP (Before Micro)' )