-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzm_conv_intr.F90
705 lines (558 loc) · 29.6 KB
/
zm_conv_intr.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
module zm_conv_intr
!---------------------------------------------------------------------------------
! Purpose:
!
! CAM interface to the Zhang-McFarlane deep convection scheme
!
! Author: D.B. Coleman
! January 2010 modified by J. Kay to add COSP simulator fields to physics buffer
!---------------------------------------------------------------------------------
use shr_kind_mod, only: r8=>shr_kind_r8
use physconst, only: cpair
use ppgrid, only: pver, pcols, pverp, begchunk, endchunk
use zm_conv, only: zm_conv_evap, zm_convr, convtran, momtran
use cam_history, only: outfld, addfld, add_default, phys_decomp
use perf_mod
use cam_logfile, only: iulog
implicit none
private
save
! Public methods
public ::&
zm_conv_register, &! register fields in physics buffer
zm_conv_init, &! initialize donner_deep module
zm_conv_tend, &! return tendencies
zm_conv_tend_2 ! return tendencies
! Private module data
real(r8), allocatable, dimension(:,:,:) :: mu !(pcols,pver,begchunk:endchunk)
real(r8), allocatable, dimension(:,:,:) :: eu !(pcols,pver,begchunk:endchunk)
real(r8), allocatable, dimension(:,:,:) :: du !(pcols,pver,begchunk:endchunk)
real(r8), allocatable, dimension(:,:,:) :: md !(pcols,pver,begchunk:endchunk)
real(r8), allocatable, dimension(:,:,:) :: ed !(pcols,pver,begchunk:endchunk)
real(r8), allocatable, dimension(:,:,:) :: dp !(pcols,pver,begchunk:endchunk)
! wg layer thickness in mbs (between upper/lower interface).
real(r8), allocatable, dimension(:,:) :: dsubcld !(pcols,begchunk:endchunk)
! wg layer thickness in mbs between lcl and maxi.
!FA
real(r8), allocatable, dimension(:,:,:) :: eps !(pcols,pver,begchunk:endchunk)
real(r8), allocatable, dimension(:,:) :: eps0 !(pcols,begchunk:endchunk)
!
integer, allocatable, dimension(:,:) :: jt !(pcols,begchunk:endchunk)
! wg top level index of deep cumulus convection.
integer, allocatable, dimension(:,:) :: maxg !(pcols,begchunk:endchunk)
! wg gathered values of maxi.
integer, allocatable, dimension(:,:) :: ideep !(pcols,begchunk:endchunk)
! w holds position of gathered points vs longitude index
integer, allocatable, dimension(:) :: lengath !(begchunk:endchunk)
integer ::& ! indices for fields in the physics buffer
dp_flxprc_idx, &
dp_flxsnw_idx, &
dp_cldliq_idx, &
dp_cldice_idx, &
prec_dp_idx, &
snow_dp_idx
! indices for fields in the physics buffer
integer :: cld_idx = 0
integer :: icwmrdp_idx = 0
integer :: rprddp_idx = 0
integer :: fracis_idx = 0
integer :: nevapr_dpcu_idx = 0
!=========================================================================================
contains
!=========================================================================================
subroutine zm_conv_register
!----------------------------------------
! Purpose: register fields with the physics buffer
!----------------------------------------
use physics_buffer, only : pbuf_add_field, dtype_r8
implicit none
integer idx
! Flux of precipitation from deep convection (kg/m2/s)
call pbuf_add_field('DP_FLXPRC','global',dtype_r8,(/pcols,pverp/),dp_flxprc_idx)
! Flux of snow from deep convection (kg/m2/s)
call pbuf_add_field('DP_FLXSNW','global',dtype_r8,(/pcols,pverp/),dp_flxsnw_idx)
! deep gbm cloud liquid water (kg/kg)
call pbuf_add_field('DP_CLDLIQ','global',dtype_r8,(/pcols,pver/), dp_cldliq_idx)
! deep gbm cloud liquid water (kg/kg)
call pbuf_add_field('DP_CLDICE','global',dtype_r8,(/pcols,pver/), dp_cldice_idx)
end subroutine zm_conv_register
!=========================================================================================
subroutine zm_conv_init(pref_edge)
!----------------------------------------
! Purpose: declare output fields, initialize variables needed by convection
!----------------------------------------
use cam_history, only: outfld, addfld, add_default, phys_decomp
use ppgrid, only: pcols, pver
use zm_conv, only: zm_convi
use pmgrid, only: plev,plevp
use spmd_utils, only: masterproc
use error_messages, only: alloc_err
use phys_control, only: phys_deepconv_pbl, phys_getopts, cam_physpkg_is
use physics_buffer, only: pbuf_get_index
implicit none
real(r8),intent(in) :: pref_edge(plevp) ! reference pressures at interfaces
logical :: no_deep_pbl ! if true, no deep convection in PBL
integer limcnv ! top interface level limit for convection
integer k, istat
logical :: history_budget ! output tendencies and state variables for CAM4
! temperature, water vapor, cloud ice and cloud
! liquid budgets.
integer :: history_budget_histfile_num ! output history file number for budget fields
!
! Allocate space for arrays private to this module
!
allocate( mu(pcols,pver,begchunk:endchunk), stat=istat )
call alloc_err( istat, 'zm_conv_tend', 'mu', &
pcols*pver*((endchunk-begchunk)+1) )
!FA
allocate( eps(pcols,pver,begchunk:endchunk), stat=istat )
call alloc_err( istat, 'zm_conv_tend', 'eps', &
pcols*pver*((endchunk-begchunk)+1) )
allocate( eps0(pcols,begchunk:endchunk), stat=istat )
call alloc_err( istat, 'zm_conv_tend', 'eps0', &
pcols*((endchunk-begchunk)+1) )
!FA
allocate( eu(pcols,pver,begchunk:endchunk), stat=istat )
call alloc_err( istat, 'zm_conv_tend', 'eu', &
pcols*pver*((endchunk-begchunk)+1) )
allocate( du(pcols,pver,begchunk:endchunk), stat=istat )
call alloc_err( istat, 'zm_conv_tend', 'du', &
pcols*pver*((endchunk-begchunk)+1) )
allocate( md(pcols,pver,begchunk:endchunk), stat=istat )
call alloc_err( istat, 'zm_conv_tend', 'md', &
pcols*pver*((endchunk-begchunk)+1) )
allocate( ed(pcols,pver,begchunk:endchunk), stat=istat )
call alloc_err( istat, 'zm_conv_tend', 'ed', &
pcols*pver*((endchunk-begchunk)+1) )
allocate( dp(pcols,pver,begchunk:endchunk), stat=istat )
call alloc_err( istat, 'zm_conv_tend', 'dp', &
pcols*pver*((endchunk-begchunk)+1) )
allocate( dsubcld(pcols,begchunk:endchunk), stat=istat )
call alloc_err( istat, 'zm_conv_tend', 'dsubcld', &
pcols*((endchunk-begchunk)+1) )
allocate( jt(pcols,begchunk:endchunk), stat=istat )
call alloc_err( istat, 'zm_conv_tend', 'jt', &
pcols*((endchunk-begchunk)+1) )
allocate( maxg(pcols,begchunk:endchunk), stat=istat )
call alloc_err( istat, 'zm_conv_tend', 'maxg', &
pcols*((endchunk-begchunk)+1) )
allocate( ideep(pcols,begchunk:endchunk), stat=istat )
call alloc_err( istat, 'zm_conv_tend', 'ideep', &
pcols*((endchunk-begchunk)+1) )
allocate( lengath(begchunk:endchunk), stat=istat )
call alloc_err( istat, 'zm_conv_tend', 'lengath', &
((endchunk-begchunk)+1) )
!
! Register fields with the output buffer
!
call addfld ('PRECZ ','m/s ',1, 'A','total precipitation from ZM convection', phys_decomp)
call addfld ('ZMDT ','K/s ',pver, 'A','T tendency - Zhang-McFarlane moist convection', phys_decomp)
call addfld ('ZMDQ ','kg/kg/s ',pver, 'A','Q tendency - Zhang-McFarlane moist convection', phys_decomp)
call addfld ('ZMDICE ','kg/kg/s ',pver, 'A','Cloud ice tendency - Zhang-McFarlane convection',phys_decomp)
call addfld ('ZMDLIQ ','kg/kg/s ',pver, 'A','Cloud liq tendency - Zhang-McFarlane convection',phys_decomp)
call addfld ('EVAPTZM ','K/s ',pver, 'A','T tendency - Evaporation/snow prod from Zhang convection',phys_decomp)
call addfld ('FZSNTZM ','K/s ',pver, 'A','T tendency - Rain to snow conversion from Zhang convection',phys_decomp)
call addfld ('EVSNTZM ','K/s ',pver, 'A','T tendency - Snow to rain prod from Zhang convection',phys_decomp)
call addfld ('EVAPQZM ','kg/kg/s ',pver, 'A','Q tendency - Evaporation from Zhang-McFarlane moist convection',phys_decomp)
call addfld ('ZMFLXPRC','kg/m2/s ',pverp, 'A','Flux of precipitation from ZM convection' ,phys_decomp)
call addfld ('ZMFLXSNW','kg/m2/s ',pverp, 'A','Flux of snow from ZM convection' ,phys_decomp)
call addfld ('ZMNTPRPD','kg/kg/s ',pver , 'A','Net precipitation production from ZM convection',phys_decomp)
call addfld ('ZMNTSNPD','kg/kg/s ',pver , 'A','Net snow production from ZM convection' ,phys_decomp)
call addfld ('ZMEIHEAT','W/kg' ,pver , 'A','Heating by ice and evaporation in ZM convection',phys_decomp)
call addfld ('CMFMCDZM','kg/m2/s ',pverp,'A','Convection mass flux from ZM deep ',phys_decomp)
call addfld ('PRECCDZM','m/s ',1, 'A','Convective precipitation rate from ZM deep',phys_decomp)
call addfld ('PCONVB','Pa' ,1 , 'A','convection base pressure',phys_decomp)
call addfld ('PCONVT','Pa' ,1 , 'A','convection top pressure',phys_decomp)
call addfld ('CAPE', 'J/kg', 1, 'A', 'Convectively available potential energy', phys_decomp)
call addfld ('UCAPE', 'J/kg', 1, 'A', 'Undilute convectively available potential energy', phys_decomp)
call addfld ('FREQZM ','fraction ', 1, 'A', 'Fractional occurance of ZM convection',phys_decomp)
call addfld ('ZMMTT ', 'K/s', pver, 'A', 'T tendency - ZM convective momentum transport',phys_decomp)
call addfld ('ZMMTU', 'm/s2', pver, 'A', 'U tendency - ZM convective momentum transport', phys_decomp)
call addfld ('ZMMTV', 'm/s2', pver, 'A', 'V tendency - ZM convective momentum transport', phys_decomp)
call addfld ('ZMMU', 'kg/m2/s', pver, 'A', 'ZM convection updraft mass flux', phys_decomp)
call addfld ('ZMMD', 'kg/m2/s', pver, 'A', 'ZM convection downdraft mass flux', phys_decomp)
call addfld ('ZMEPS', 'fraction', pver, 'A', 'ZM convection entrainment profile lamda', phys_decomp)
call addfld ('ZMEPS0', 'fraction', pver, 'A', 'ZM convection entrainment parameter lamda0', phys_decomp)
call addfld ('ZMUPGU', 'm/s2', pver, 'A', 'zonal force from ZM updraft pressure gradient term', phys_decomp)
call addfld ('ZMUPGD', 'm/s2', pver, 'A', 'zonal force from ZM downdraft pressure gradient term', phys_decomp)
call addfld ('ZMVPGU', 'm/s2', pver, 'A', 'meridional force from ZM updraft pressure gradient term', phys_decomp)
call addfld ('ZMVPGD', 'm/s2', pver, 'A', 'merdional force from ZM downdraft pressure gradient term', phys_decomp)
call addfld ('ZMICUU', 'm/s', pver, 'A', 'ZM in-cloud U updrafts', phys_decomp)
call addfld ('ZMICUD', 'm/s', pver, 'A', 'ZM in-cloud U downdrafts', phys_decomp)
call addfld ('ZMICVU', 'm/s', pver, 'A', 'ZM in-cloud V updrafts', phys_decomp)
call addfld ('ZMICVD', 'm/s', pver, 'A', 'ZM in-cloud V downdrafts', phys_decomp)
call phys_getopts( history_budget_out = history_budget, &
history_budget_histfile_num_out = history_budget_histfile_num)
if ( history_budget ) then
call add_default('EVAPTZM ', history_budget_histfile_num, ' ')
call add_default('EVAPQZM ', history_budget_histfile_num, ' ')
call add_default('ZMDT ', history_budget_histfile_num, ' ')
call add_default('ZMDQ ', history_budget_histfile_num, ' ')
call add_default('ZMDLIQ ', history_budget_histfile_num, ' ')
call add_default('ZMDICE ', history_budget_histfile_num, ' ')
if( cam_physpkg_is('cam4') .or. cam_physpkg_is('cam5') ) then
call add_default('ZMMTT ', history_budget_histfile_num, ' ')
end if
end if
!
! Limit deep convection to regions below 40 mb
! Note this calculation is repeated in the shallow convection interface
!
limcnv = 0 ! null value to check against below
if (pref_edge(1) >= 4.e3_r8) then
limcnv = 1
else
do k=1,plev
if (pref_edge(k) < 4.e3_r8 .and. pref_edge(k+1) >= 4.e3_r8) then
limcnv = k
exit
end if
end do
if ( limcnv == 0 ) limcnv = plevp
end if
if (masterproc) then
write(iulog,*)'ZM_CONV_INIT: Deep convection will be capped at intfc ',limcnv, &
' which is ',pref_edge(limcnv),' pascals'
end if
no_deep_pbl = phys_deepconv_pbl()
call zm_convi(limcnv,no_deep_pbl_in = no_deep_pbl)
cld_idx = pbuf_get_index('CLD')
icwmrdp_idx = pbuf_get_index('ICWMRDP')
rprddp_idx = pbuf_get_index('RPRDDP')
fracis_idx = pbuf_get_index('FRACIS')
nevapr_dpcu_idx = pbuf_get_index('NEVAPR_DPCU')
prec_dp_idx = pbuf_get_index('PREC_DP')
snow_dp_idx = pbuf_get_index('SNOW_DP')
end subroutine zm_conv_init
!=========================================================================================
!subroutine zm_conv_tend(state, ptend, tdt)
subroutine zm_conv_tend(pblh ,mcon ,cme , &
tpert ,dlf ,pflx ,zdu , &
rliq , &
ztodt , &
jctop ,jcbot , &
state ,ptend_all ,landfrac, pbuf)
use cam_history, only: outfld
use physics_types, only: physics_state, physics_ptend
use physics_types, only: physics_ptend_init, physics_update
use physics_types, only: physics_state_copy, physics_state_dealloc
use physics_types, only: physics_ptend_sum, physics_ptend_dealloc
use phys_grid, only: get_lat_p, get_lon_p
use time_manager, only: get_nstep, is_first_step
use physics_buffer, only : pbuf_get_field, physics_buffer_desc, pbuf_old_tim_idx
use constituents, only: pcnst, cnst_get_ind, cnst_is_convtran1
use check_energy, only: check_energy_chng
use physconst, only: gravit
use phys_control, only: cam_physpkg_is
! Arguments
type(physics_state), intent(in ) :: state ! Physics state variables
type(physics_ptend), intent(out) :: ptend_all ! individual parameterization tendencies
type(physics_buffer_desc), pointer :: pbuf(:)
real(r8), intent(in) :: ztodt ! 2 delta t (model time increment)
real(r8), intent(in) :: pblh(pcols) ! Planetary boundary layer height
real(r8), intent(in) :: tpert(pcols) ! Thermal temperature excess
real(r8), intent(in) :: landfrac(pcols) ! RBN - Landfrac
real(r8), intent(out) :: mcon(pcols,pverp) ! Convective mass flux--m sub c
real(r8), intent(out) :: dlf(pcols,pver) ! scattrd version of the detraining cld h2o tend
real(r8), intent(out) :: pflx(pcols,pverp) ! scattered precip flux at each level
real(r8), intent(out) :: cme(pcols,pver) ! cmf condensation - evaporation
real(r8), intent(out) :: zdu(pcols,pver) ! detraining mass flux
real(r8), intent(out) :: rliq(pcols) ! reserved liquid (not yet in cldliq) for energy integrals
! Local variables
integer :: i,k,m
integer :: ilon ! global longitude index of a column
integer :: ilat ! global latitude index of a column
integer :: nstep
integer :: ixcldice, ixcldliq ! constituent indices for cloud liquid and ice water.
integer :: lchnk ! chunk identifier
integer :: ncol ! number of atmospheric columns
integer :: itim ! for physics buffer fields
real(r8) :: ftem(pcols,pver) ! Temporary workspace for outfld variables
real(r8) :: ntprprd(pcols,pver) ! evap outfld: net precip production in layer
real(r8) :: ntsnprd(pcols,pver) ! evap outfld: net snow production in layer
real(r8) :: tend_s_snwprd (pcols,pver) ! Heating rate of snow production
real(r8) :: tend_s_snwevmlt(pcols,pver) ! Heating rate of evap/melting of snow
real(r8) :: fake_dpdry(pcols,pver) ! used in convtran call
! physics types
type(physics_state) :: state1 ! locally modify for evaporation to use, not returned
type(physics_ptend) :: ptend_loc ! package tendencies
! physics buffer fields
real(r8), pointer, dimension(:) :: prec ! total precipitation
real(r8), pointer, dimension(:) :: snow ! snow from ZM convection
real(r8), pointer, dimension(:,:) :: cld
real(r8), pointer, dimension(:,:) :: ql ! wg grid slice of cloud liquid water.
real(r8), pointer, dimension(:,:) :: rprd ! rain production rate
real(r8), pointer, dimension(:,:,:) :: fracis ! fraction of transported species that are insoluble
real(r8), pointer, dimension(:,:) :: evapcdp ! Evaporation of deep convective precipitation
real(r8), pointer, dimension(:,:) :: flxprec ! Convective-scale flux of precip at interfaces (kg/m2/s)
real(r8), pointer, dimension(:,:) :: flxsnow ! Convective-scale flux of snow at interfaces (kg/m2/s)
real(r8), pointer, dimension(:,:) :: dp_cldliq
real(r8), pointer, dimension(:,:) :: dp_cldice
real(r8) :: jctop(pcols) ! o row of top-of-deep-convection indices passed out.
real(r8) :: jcbot(pcols) ! o row of base of cloud indices passed out.
real(r8) :: pcont(pcols), pconb(pcols), freqzm(pcols)
! history output fields
real(r8) :: cape(pcols) ! w convective available potential energy.
real(r8) :: cape_undilute(pcols) ! FA : undilute convective available potential energy.
real(r8) :: mu_out(pcols,pver),eps_out(pcols,pver),eps0_out(pcols)
real(r8) :: md_out(pcols,pver)
! used in momentum transport calculation
real(r8) :: winds(pcols, pver, 2)
real(r8) :: wind_tends(pcols, pver, 2)
real(r8) :: pguall(pcols, pver, 2)
real(r8) :: pgdall(pcols, pver, 2)
real(r8) :: icwu(pcols,pver, 2)
real(r8) :: icwd(pcols,pver, 2)
real(r8) :: seten(pcols, pver)
logical :: l_windt(2)
real(r8) :: tfinal1, tfinal2
integer :: ii
logical :: lq(pcnst)
!----------------------------------------------------------------------
! initialize
lchnk = state%lchnk
ncol = state%ncol
nstep = get_nstep()
ftem = 0._r8
mu_out(:,:) = 0._r8
md_out(:,:) = 0._r8
wind_tends(:ncol,:pver,:) = 0.0_r8
call physics_state_copy(state,state1) ! copy state to local state1.
lq(:) = .FALSE.
lq(1) = .TRUE.
call physics_ptend_init(ptend_loc, state%psetcols, 'zm_convr', ls=.true., lq=lq)! initialize local ptend type
!
! Associate pointers with physics buffer fields
!
itim = pbuf_old_tim_idx()
call pbuf_get_field(pbuf, cld_idx, cld, start=(/1,1,itim/), kount=(/pcols,pver,1/) )
call pbuf_get_field(pbuf, icwmrdp_idx, ql )
call pbuf_get_field(pbuf, rprddp_idx, rprd )
call pbuf_get_field(pbuf, fracis_idx, fracis, start=(/1,1,1/), kount=(/pcols, pver, pcnst/) )
call pbuf_get_field(pbuf, nevapr_dpcu_idx, evapcdp )
call pbuf_get_field(pbuf, prec_dp_idx, prec )
call pbuf_get_field(pbuf, snow_dp_idx, snow )
!
! Begin with Zhang-McFarlane (1996) convection parameterization
!
call t_startf ('zm_convr')
call zm_convr( lchnk ,ncol , &
state%t ,state%q(:,:,1) ,prec ,jctop ,jcbot , &
pblh ,state%zm ,state%phis ,state%zi ,ptend_loc%q(:,:,1) , &
ptend_loc%s ,state%pmid ,state%pint ,state%pdel , &
.5_r8*ztodt ,mcon ,cme , cape, cape_undilute , &
tpert ,dlf ,pflx ,zdu ,rprd , &
mu(:,:,lchnk),md(:,:,lchnk),du(:,:,lchnk),eu(:,:,lchnk),ed(:,:,lchnk) , &
dp(:,:,lchnk) ,dsubcld(:,lchnk) ,jt(:,lchnk),maxg(:,lchnk),ideep(:,lchnk) , &
lengath(lchnk) ,ql ,rliq ,landfrac, eps0(:,lchnk),eps(:,:,lchnk) )
call outfld('CAPE', cape, pcols, lchnk) ! RBN - CAPE output
call outfld('UCAPE', cape_undilute, pcols, lchnk) ! FA - Undilute CAPE output
!
! Output fractional occurance of ZM convection
!
freqzm(:) = 0._r8
do i = 1,lengath(lchnk)
freqzm(ideep(i,lchnk)) = 1.0_r8
end do
call outfld('FREQZM ',freqzm ,pcols ,lchnk )
!
! Convert mass flux from reported mb/s to kg/m^2/s
!
mcon(:ncol,:pver) = mcon(:ncol,:pver) * 100._r8/gravit
! Store upward and downward mass fluxes in un-gathered arrays
! + convert from mb/s to kg/m^2/s
!FA
do i=1,lengath(lchnk)
ii = ideep(i,lchnk)
eps0_out(ii) = eps0(i,lchnk)
do k=1,pver
mu_out(ii,k) = mu(i,k,lchnk) * 100._r8/gravit
md_out(ii,k) = md(i,k,lchnk) * 100._r8/gravit
eps_out(ii,k) = eps(i,k,lchnk)
end do
end do
call outfld('ZMMU', mu_out(1,1), pcols, lchnk)
call outfld('ZMMD', md_out(1,1), pcols, lchnk)
call outfld('ZMEPS', eps_out(1,1), pcols, lchnk)
call outfld('ZMEPS0', eps0_out, pcols, lchnk)
ftem(:ncol,:pver) = ptend_loc%s(:ncol,:pver)/cpair
call outfld('ZMDT ',ftem ,pcols ,lchnk )
call outfld('ZMDQ ',ptend_loc%q(1,1,1) ,pcols ,lchnk )
call t_stopf ('zm_convr')
! do i = 1,pcols
! do i = 1,nco
pcont(:ncol) = state%ps(:ncol)
pconb(:ncol) = state%ps(:ncol)
do i = 1,lengath(lchnk)
if (maxg(i,lchnk).gt.jt(i,lchnk)) then
pcont(ideep(i,lchnk)) = state%pmid(ideep(i,lchnk),jt(i,lchnk)) ! gathered array (or jctop ungathered)
pconb(ideep(i,lchnk)) = state%pmid(ideep(i,lchnk),maxg(i,lchnk))! gathered array
endif
! write(iulog,*) ' pcont, pconb ', pcont(i), pconb(i), cnt(i), cnb(i)
end do
call outfld('PCONVT ',pcont ,pcols ,lchnk )
call outfld('PCONVB ',pconb ,pcols ,lchnk )
! This name triggers a special case in physics_types.F90:physics_update()
call physics_ptend_init(ptend_all, state%psetcols, 'convect_deep')
! add tendency from this process to tendencies from other processes
call physics_ptend_sum(ptend_loc,ptend_all, ncol)
! update physics state type state1 with ptend_loc
call physics_update(state1, ptend_loc, ztodt)
! initialize ptend for next process
lq(:) = .FALSE.
lq(1) = .TRUE.
call physics_ptend_init(ptend_loc, state1%psetcols, 'zm_conv_evap', ls=.true., lq=lq)
call t_startf ('zm_conv_evap')
!
! Determine the phase of the precipitation produced and add latent heat of fusion
! Evaporate some of the precip directly into the environment (Sundqvist)
! Allow this to use the updated state1 and the fresh ptend_loc type
! heating and specific humidity tendencies produced
!
call pbuf_get_field(pbuf, dp_flxprc_idx, flxprec )
call pbuf_get_field(pbuf, dp_flxsnw_idx, flxsnow )
call pbuf_get_field(pbuf, dp_cldliq_idx, dp_cldliq )
call pbuf_get_field(pbuf, dp_cldice_idx, dp_cldice )
dp_cldliq(:ncol,:) = 0._r8
dp_cldice(:ncol,:) = 0._r8
call zm_conv_evap(state1%ncol,state1%lchnk, &
state1%t,state1%pmid,state1%pdel,state1%q(:pcols,:pver,1), &
ptend_loc%s, tend_s_snwprd, tend_s_snwevmlt, ptend_loc%q(:pcols,:pver,1), &
rprd, cld, ztodt, &
prec, snow, ntprprd, ntsnprd , flxprec, flxsnow)
evapcdp(:ncol,:pver) = ptend_loc%q(:ncol,:pver,1)
!
! Write out variables from zm_conv_evap
!
ftem(:ncol,:pver) = ptend_loc%s(:ncol,:pver)/cpair
call outfld('EVAPTZM ',ftem ,pcols ,lchnk )
ftem(:ncol,:pver) = tend_s_snwprd (:ncol,:pver)/cpair
call outfld('FZSNTZM ',ftem ,pcols ,lchnk )
ftem(:ncol,:pver) = tend_s_snwevmlt(:ncol,:pver)/cpair
call outfld('EVSNTZM ',ftem ,pcols ,lchnk )
call outfld('EVAPQZM ',ptend_loc%q(1,1,1) ,pcols ,lchnk )
call outfld('ZMFLXPRC', flxprec, pcols, lchnk)
call outfld('ZMFLXSNW', flxsnow, pcols, lchnk)
call outfld('ZMNTPRPD', ntprprd, pcols, lchnk)
call outfld('ZMNTSNPD', ntsnprd, pcols, lchnk)
call outfld('ZMEIHEAT', ptend_loc%s, pcols, lchnk)
call outfld('CMFMCDZM ',mcon , pcols ,lchnk )
call outfld('PRECCDZM ',prec, pcols ,lchnk )
call t_stopf ('zm_conv_evap')
call outfld('PRECZ ', prec , pcols, lchnk)
! add tendency from this process to tend from other processes here
call physics_ptend_sum(ptend_loc,ptend_all, ncol)
! update physics state type state1 with ptend_loc
call physics_update(state1, ptend_loc, ztodt)
! Momentum Transport (non-cam3 physics)
if ( .not. cam_physpkg_is('cam3')) then
call physics_ptend_init(ptend_loc, state1%psetcols, 'momtran', ls=.true., lu=.true., lv=.true.)
winds(:ncol,:pver,1) = state1%u(:ncol,:pver)
winds(:ncol,:pver,2) = state1%v(:ncol,:pver)
l_windt(1) = .true.
l_windt(2) = .true.
call t_startf ('momtran')
call momtran (lchnk, ncol, &
l_windt,winds, 2, mu(1,1,lchnk), md(1,1,lchnk), &
du(1,1,lchnk), eu(1,1,lchnk), ed(1,1,lchnk), dp(1,1,lchnk), dsubcld(1,lchnk), &
jt(1,lchnk),maxg(1,lchnk), ideep(1,lchnk), 1, lengath(lchnk), &
nstep, wind_tends, pguall, pgdall, icwu, icwd, ztodt, seten )
call t_stopf ('momtran')
ptend_loc%u(:ncol,:pver) = wind_tends(:ncol,:pver,1)
ptend_loc%v(:ncol,:pver) = wind_tends(:ncol,:pver,2)
ptend_loc%s(:ncol,:pver) = seten(:ncol,:pver)
call physics_ptend_sum(ptend_loc,ptend_all, ncol)
! update physics state type state1 with ptend_loc
call physics_update(state1, ptend_loc, ztodt)
ftem(:ncol,:pver) = seten(:ncol,:pver)/cpair
call outfld('ZMMTT', ftem , pcols, lchnk)
call outfld('ZMMTU', wind_tends(1,1,1), pcols, lchnk)
call outfld('ZMMTV', wind_tends(1,1,2), pcols, lchnk)
! Output apparent force from pressure gradient
call outfld('ZMUPGU', pguall(1,1,1), pcols, lchnk)
call outfld('ZMUPGD', pgdall(1,1,1), pcols, lchnk)
call outfld('ZMVPGU', pguall(1,1,2), pcols, lchnk)
call outfld('ZMVPGD', pgdall(1,1,2), pcols, lchnk)
! Output in-cloud winds
call outfld('ZMICUU', icwu(1,1,1), pcols, lchnk)
call outfld('ZMICUD', icwd(1,1,1), pcols, lchnk)
call outfld('ZMICVU', icwu(1,1,2), pcols, lchnk)
call outfld('ZMICVD', icwd(1,1,2), pcols, lchnk)
end if
! Transport cloud water and ice only
call cnst_get_ind('CLDLIQ', ixcldliq)
call cnst_get_ind('CLDICE', ixcldice)
lq(:) = .FALSE.
lq(2:) = cnst_is_convtran1(2:)
call physics_ptend_init(ptend_loc, state1%psetcols, 'convtran1', lq=lq)
! dpdry is not used in this call to convtran since the cloud liquid and ice mixing
! ratios are moist
fake_dpdry(:,:) = 0._r8
call t_startf ('convtran1')
call convtran (lchnk, &
ptend_loc%lq,state1%q, pcnst, mu(:,:,lchnk), md(:,:,lchnk), &
du(:,:,lchnk), eu(:,:,lchnk), ed(:,:,lchnk), dp(:,:,lchnk), dsubcld(:,lchnk), &
jt(:,lchnk),maxg(:,lchnk), ideep(:,lchnk), 1, lengath(lchnk), &
nstep, fracis, ptend_loc%q, fake_dpdry)
call t_stopf ('convtran1')
call outfld('ZMDICE ',ptend_loc%q(1,1,ixcldice) ,pcols ,lchnk )
call outfld('ZMDLIQ ',ptend_loc%q(1,1,ixcldliq) ,pcols ,lchnk )
! add tendency from this process to tend from other processes here
call physics_ptend_sum(ptend_loc,ptend_all, ncol)
call physics_state_dealloc(state1)
call physics_ptend_dealloc(ptend_loc)
end subroutine zm_conv_tend
!=========================================================================================
subroutine zm_conv_tend_2( state, ptend, ztodt, pbuf)
use physics_types, only: physics_state, physics_ptend, physics_ptend_init
use time_manager, only: get_nstep
use physics_buffer, only: pbuf_get_index, pbuf_get_field, physics_buffer_desc
use constituents, only: pcnst, cnst_get_ind, cnst_is_convtran1
use error_messages, only: alloc_err
! Arguments
type(physics_state), intent(in ) :: state ! Physics state variables
type(physics_ptend), intent(out) :: ptend ! indivdual parameterization tendencies
type(physics_buffer_desc), pointer :: pbuf(:)
real(r8), intent(in) :: ztodt ! 2 delta t (model time increment)
! Local variables
integer :: i, lchnk, istat
integer :: nstep
real(r8), dimension(pcols,pver) :: dpdry
! physics buffer fields
integer itim, ifld
real(r8), pointer, dimension(:,:,:) :: fracis ! fraction of transported species that are insoluble
logical :: lq(pcnst)
!
! Initialize
!
lq(:) = .FALSE.
lq(:) = .not. cnst_is_convtran1(:)
call physics_ptend_init(ptend, state%psetcols, 'convtran2', lq=lq )
!
! Associate pointers with physics buffer fields
!
ifld = pbuf_get_index('FRACIS')
call pbuf_get_field(pbuf, fracis_idx, fracis, start=(/1,1,1/), kount=(/pcols, pver, pcnst/) )
!
! Transport all constituents except cloud water and ice
!
lchnk = state%lchnk
nstep = get_nstep()
if (any(ptend%lq(:))) then
! initialize dpdry for call to convtran
! it is used for tracers of dry mixing ratio type
dpdry = 0._r8
do i = 1,lengath(lchnk)
dpdry(i,:) = state%pdeldry(ideep(i,lchnk),:)/100._r8
end do
call t_startf ('convtran2')
call convtran (lchnk, &
ptend%lq,state%q, pcnst, mu(:,:,lchnk), md(:,:,lchnk), &
du(:,:,lchnk), eu(:,:,lchnk), ed(:,:,lchnk), dp(:,:,lchnk), dsubcld(:,lchnk), &
jt(:,lchnk),maxg(:,lchnk),ideep(:,lchnk), 1, lengath(lchnk), &
nstep, fracis, ptend%q, dpdry)
call t_stopf ('convtran2')
end if
end subroutine zm_conv_tend_2
!=========================================================================================
end module zm_conv_intr