← Back to Documentation Home
CCPP SciDoc v8.0.0  v8.0.0
Common Community Physics Package Developed at DTC
 
Loading...
Searching...
No Matches
cu_gf_driver.F90
1
3
6
7 ! DH* TODO: replace constants with arguments to cu_gf_driver_run
8 !use physcons , g => con_g, cp => con_cp, xlv => con_hvap, r_v => con_rv
9 use machine , only: kind_phys
11 use cu_gf_sh , only: cu_gf_sh_run
12
13 implicit none
14
15 private
16
17 public :: cu_gf_driver_init, cu_gf_driver_run
18
19contains
20
31 subroutine cu_gf_driver_init(imfshalcnv, imfshalcnv_gf, imfdeepcnv, &
32 imfdeepcnv_gf,mpirank, mpiroot, errmsg, errflg)
33
34 implicit none
35
36 integer, intent(in) :: imfshalcnv, imfshalcnv_gf
37 integer, intent(in) :: imfdeepcnv, imfdeepcnv_gf
38 integer, intent(in) :: mpirank
39 integer, intent(in) :: mpiroot
40 character(len=*), intent( out) :: errmsg
41 integer, intent( out) :: errflg
42
43 ! initialize ccpp error handling variables
44 errmsg = ''
45 errflg = 0
46
47 end subroutine cu_gf_driver_init
48
49!
50! t2di is temp after advection, but before physics
51! t = current temp (t2di + physics up to now)
52!===================
53
59 subroutine cu_gf_driver_run(ntracer,garea,im,km,dt,flag_init,flag_restart, gf_coldstart, &
60 cactiv,cactiv_m,g,cp,xlv,r_v,forcet,forceqv_spechum,phil,raincv, &
61 qv_spechum,t,cld1d,us,vs,t2di,w,qv2di_spechum,p2di,psuri, &
62 hbot,htop,kcnv,xland,hfx2,qfx2,aod_gf,cliw,clcw, &
63 pbl,ud_mf,dd_mf,dt_mf,cnvw_moist,cnvc,imfshalcnv, &
64 flag_for_scnv_generic_tend,flag_for_dcnv_generic_tend, &
65 dtend,dtidx,ntqv,ntiw,ntcw,index_of_temperature,index_of_x_wind, &
66 index_of_y_wind,index_of_process_scnv,index_of_process_dcnv, &
67 fhour,fh_dfi_radar,ix_dfi_radar,num_dfi_radar,cap_suppress, &
68 dfi_radar_max_intervals,ldiag3d,qci_conv,do_cap_suppress, &
69 maxupmf,maxMF,do_mynnedmf,ichoice_in,ichoicem_in,ichoice_s_in, &
70 spp_cu_deep,spp_wts_cu_deep,nchem,chem3d,fscav,wetdpc_deep, &
71 do_smoke_transport,kdt,ten_t,ten_u,ten_v,ten_q,dcliw,dclcw,errmsg,errflg)
72!-------------------------------------------------------------
73 implicit none
74 integer, parameter :: maxiens=1
75 integer, parameter :: maxens=1
76 integer, parameter :: maxens2=1
77 integer, parameter :: maxens3=16
78 integer, parameter :: ensdim=16
79 integer :: imid_gf=1 ! gf congest conv.
80 integer, parameter :: ideep=1
81 integer :: ichoice=0 ! 0 2 5 13 8
82 integer :: ichoicem=13 ! 0 2 5 13
83 integer :: ichoice_s=3 ! 0 1 2 3
84 integer, intent(in) :: spp_cu_deep ! flag for using SPP perturbations
85 real(kind_phys), dimension(:,:), optional, intent(in) :: &
86 & spp_wts_cu_deep
87 real(kind=kind_phys) :: spp_wts_cu_deep_tmp
88
89 logical, intent(in) :: do_cap_suppress, do_smoke_transport
90 real(kind=kind_phys), parameter :: aodc0=0.14
91 real(kind=kind_phys), parameter :: aodreturn=30.
92 real(kind=kind_phys) :: dts,fpi,fp
93 integer, parameter :: dicycle=0 ! diurnal cycle flag
94 integer, parameter :: dicycle_m=0 !- diurnal cycle flag
95 integer :: ishallow_g3 ! depend on imfshalcnv
96!-------------------------------------------------------------
97 integer :: its,ite, jts,jte, kts,kte
98 integer, intent(in ) :: im,km,ntracer,nchem,kdt
99 integer, intent(in ) :: ichoice_in,ichoicem_in,ichoice_s_in
100 logical, intent(in ) :: flag_init, flag_restart, do_mynnedmf, gf_coldstart
101 logical, intent(in ) :: flag_for_scnv_generic_tend,flag_for_dcnv_generic_tend
102 real (kind=kind_phys), intent(in) :: g,cp,xlv,r_v
103 logical, intent(in ) :: ldiag3d
104
105 real(kind=kind_phys), intent(inout), optional :: dtend(:,:,:)
106!$acc declare copy(dtend)
107 integer, intent(in) :: dtidx(:,:), &
108 index_of_x_wind, index_of_y_wind, index_of_temperature, &
109 index_of_process_scnv, index_of_process_dcnv, ntqv, ntcw, ntiw
110!$acc declare copyin(dtidx)
111 real(kind=kind_phys), dimension( : , : ), intent(in ), optional :: forcet,forceqv_spechum
112 real(kind=kind_phys), dimension( : , : ), intent(in ) :: w,phil
113 real(kind=kind_phys), dimension( : , : ), intent(in ) :: t,us,vs
114 real(kind=kind_phys), dimension( : , : ), intent(inout ), optional :: qci_conv
115 real(kind=kind_phys), dimension( : , : ), intent(out ) :: cnvw_moist,cnvc
116 real(kind=kind_phys), dimension( : , : ), intent(in ) :: cliw, clcw
117!$acc declare copyin(forcet,forceqv_spechum,w,phil)
118!$acc declare copy(t,us,vs,qci_conv,cliw, clcw)
119!$acc declare copyout(cnvw_moist,cnvc)
120
121 real(kind=kind_phys), allocatable :: clcw_save(:,:), cliw_save(:,:)
122
123 integer, intent(in) :: dfi_radar_max_intervals
124 real(kind=kind_phys), intent(in) :: fhour, fh_dfi_radar(:)
125 integer, intent(in) :: num_dfi_radar, ix_dfi_radar(:)
126 real(kind=kind_phys), intent(in), optional :: cap_suppress(:,:)
127!$acc declare copyin(fh_dfi_radar,ix_dfi_radar,cap_suppress)
128
129 integer, dimension (:), intent(out) :: hbot,htop,kcnv
130 integer, dimension (:), intent(in) :: xland
131 real(kind=kind_phys), dimension (:), intent(in) :: pbl
132 real(kind=kind_phys), dimension (:), intent(in) :: maxmf
133!$acc declare copyout(hbot,htop,kcnv)
134!$acc declare copyin(xland,pbl)
135 integer, dimension (im) :: tropics
136!$acc declare create(tropics)
137! ruc variable
138 real(kind=kind_phys), dimension (:), intent(in) :: hfx2,qfx2,psuri
139 real(kind=kind_phys), dimension (:,:), intent(out) :: dd_mf,dt_mf
140 real(kind=kind_phys), dimension (:,:), intent(out), optional :: ud_mf
141 real(kind=kind_phys), dimension (:), intent(out) :: raincv,cld1d
142 real(kind=kind_phys), dimension (:), intent(out), optional :: maxupmf
143 real(kind=kind_phys), dimension (:,:), intent(in) :: t2di,p2di
144!$acc declare copyin(hfx2,qfx2,psuri,t2di,p2di)
145!$acc declare copyout(ud_mf,dd_mf,dt_mf,raincv,cld1d)
146 ! Specific humidity from FV3
147 real(kind=kind_phys), dimension (:,:), intent(in) :: qv2di_spechum
148 real(kind=kind_phys), dimension (:,:), intent(in) :: qv_spechum
149 real(kind=kind_phys), dimension (:), intent(inout), optional :: aod_gf
150!$acc declare copyin(qv2di_spechum) copy(qv_spechum,aod_gf)
151 ! Local water vapor mixing ratios and cloud water mixing ratios
152 real(kind=kind_phys), dimension (im,km) :: qv2di, qv, forceqv, cnvw
153!$acc declare create(qv2di, qv, forceqv, cnvw)
154 !
155 real(kind=kind_phys), dimension(:),intent(in) :: garea
156!$acc declare copyin(garea)
157 real(kind=kind_phys), intent(in ) :: dt
158
159 integer, intent(in ) :: imfshalcnv
160 integer, dimension(:), intent(inout), optional :: cactiv,cactiv_m
161 real(kind_phys), dimension(:), intent(in) :: fscav
162!$acc declare copyin(fscav)
163 real(kind_phys), dimension(:,:,:), intent(inout), optional :: chem3d
164 real(kind_phys), dimension(:,:), intent(inout), optional :: wetdpc_deep
165!$acc declare copy(cactiv,cactiv_m,chem3d,wetdpc_deep)
166 real(kind_phys), dimension(:,:), intent(out) :: ten_t, ten_u, ten_v, dcliw, dclcw
167 real(kind_phys), dimension(:,:,:), intent(out) :: ten_q
168
169 character(len=*), intent(out) :: errmsg
170 integer, intent(out) :: errflg
171
172! local variables
173 integer, dimension(im) :: k22_shallow,kbcon_shallow,ktop_shallow
174 real(kind=kind_phys), dimension (im) :: rand_mom,rand_vmas
175 real(kind=kind_phys), dimension (im,4) :: rand_clos
176 real(kind=kind_phys), dimension (im,km,11) :: gdc,gdc2
177 real(kind=kind_phys), dimension (im) :: ht
178 real(kind=kind_phys), dimension (im) :: ccn_gf,ccn_m
179 real(kind=kind_phys) :: ccnclean
180 real(kind=kind_phys), dimension (im) :: dx
181 real(kind=kind_phys), dimension (im) :: frhm,frhd
182 real(kind=kind_phys), dimension (im,km) :: outt,outq,outqc,phh,subm,cupclw,cupclws
183 real(kind=kind_phys), dimension (im,km) :: dhdt,zu,zus,zd,phf,zum,zdm,outum,outvm
184 real(kind=kind_phys), dimension (im,km) :: outts,outqs,outqcs,outu,outv,outus,outvs
185 real(kind=kind_phys), dimension (im,km) :: outtm,outqm,outqcm,submm,cupclwm
186 real(kind=kind_phys), dimension (im,km) :: cnvwt,cnvwts,cnvwtm
187 real(kind=kind_phys), dimension (im,km) :: hco,hcdo,zdo,zdd,hcom,hcdom,zdom
188 real(kind=kind_phys), dimension (km) :: zh
189 real(kind=kind_phys), dimension (im) :: tau_ecmwf,edt,edtm,edtd,ter11,aa0,xlandi
190 real(kind=kind_phys), dimension (im) :: pret,prets,pretm,hexec
191 real(kind=kind_phys), dimension (im,10) :: forcing,forcing2
192 real(kind=kind_phys), dimension (im,nchem) :: wetdpc_mid
193
194 integer, dimension (im) :: kbcon, ktop,ierr,ierrs,ierrm,kpbli
195 integer, dimension (im) :: k22s,kbcons,ktops,k22,jmin,jminm
196 integer, dimension (im) :: kbconm,ktopm,k22m
197!$acc declare create(k22_shallow,kbcon_shallow,ktop_shallow,rand_mom,rand_vmas, &
198!$acc rand_clos,gdc,gdc2,ht,ccn_gf,ccn_m,dx,frhm,frhd,wetdpc_mid, &
199!$acc outt,outq,outqc,phh,subm,cupclw,cupclws, &
200!$acc dhdt,zu,zus,zd,phf,zum,zdm,outum,outvm, &
201!$acc outts,outqs,outqcs,outu,outv,outus,outvs, &
202!$acc outtm,outqm,outqcm,submm,cupclwm, &
203!$acc cnvwt,cnvwts,cnvwtm,hco,hcdo,zdo,zdd,hcom,hcdom,zdom, &
204!$acc tau_ecmwf,edt,edtm,edtd,ter11,aa0,xlandi, &
205!$acc pret,prets,pretm,hexec,forcing,forcing2,wetdpc_mid, &
206!$acc kbcon, ktop,ierr,ierrs,ierrm,kpbli, &
207!$acc k22s,kbcons,ktops,k22,jmin,jminm,kbconm,ktopm,k22m)
208
209 integer :: iens,ibeg,iend,jbeg,jend,n
210 integer :: ibegh,iendh,jbegh,jendh
211 integer :: ibegc,iendc,jbegc,jendc,kstop
212 real(kind=kind_phys), dimension(im,km) :: rho_dryar
213!$acc declare create(rho_dryar)
214 real(kind=kind_phys) :: pten,pqen,paph,zrho,pahfs,pqhfl,zkhvfl,pgeoh
215 integer, parameter :: ipn = 0
216
217!
218! basic environmental input includes moisture convergence (mconv)
219! omega (omeg), windspeed (us,vs), and a flag (ierr) to turn off
220! convection for this call only and at that particular gridpoint
221!
222 real(kind=kind_phys), dimension (im,km) :: qcheck,zo,t2d,q2d,po,p2d,rhoi,clw_ten,new_qv_spechum,new_cliw,new_clcw
223 real(kind=kind_phys), dimension (im,km) :: tn,qo,tshall,qshall,dz8w,omeg
224 real(kind=kind_phys), dimension (im) :: z1,psur,cuten,cutens,cutenm
225 real(kind=kind_phys), dimension (im) :: umean,vmean,pmean,mc_thresh
226 real(kind=kind_phys), dimension (im) :: xmbs,xmbs2,xmb,xmbm,xmb_dumm,mconv
227!$acc declare create(qcheck,zo,t2d,q2d,po,p2d,rhoi,clw_ten,tn,qo,tshall,qshall,dz8w,omeg, &
228!$acc z1,psur,cuten,cutens,cutenm,umean,vmean,pmean,mc_thresh, &
229!$acc xmbs,xmbs2,xmb,xmbm,xmb_dumm,mconv)
230
231 integer :: i,j,k,icldck,ipr,jpr,jpr_deep,ipr_deep,uidx,vidx,tidx,qidx
232 integer :: itf,jtf,ktf,iss,jss,nbegin,nend,cliw_idx,clcw_idx
233 integer :: high_resolution
234 real(kind=kind_phys) :: clwtot,clwtot1,excess,tcrit,tscl_kf,dp,dq,sub_spread,subcenter
235 real(kind=kind_phys) :: dsubclw,dsubclws,dsubclwm,dtime_max,ztm,ztq,hfm,qfm,rkbcon,rktop
236 real(kind=kind_phys), dimension(km) :: massflx,trcflx_in1,clw_in1,po_cup
237! real(kind=kind_phys), dimension(km) :: trcflx_in2,clw_in2,clw_ten2
238 real(kind=kind_phys), dimension (im) :: flux_tun,tun_rad_mid,tun_rad_shall,tun_rad_deep
239!$acc declare create(flux_tun,tun_rad_mid,tun_rad_shall,tun_rad_deep)
240 character*50 :: ierrc(im),ierrcm(im)
241 character*50 :: ierrcs(im)
242! ruc variable
243! hfx2 -- sensible heat flux (k m/s), positive upward from sfc
244! qfx2 -- latent heat flux (kg/kg m/s), positive upward from sfc
245! gf needs them in w/m2. define hfx and qfx after simple unit conversion
246 real(kind=kind_phys), dimension (im) :: hfx,qfx
247!$acc declare create(hfx,qfx)
248 real(kind=kind_phys) tem,tem1,tf,tcr,tcrf,psum
249 real(kind=kind_phys) :: cliw_shal,clcw_shal,tem_shal, cliw_both, weight_sum
250 real(kind=kind_phys) :: cliw_deep,clcw_deep,tem_deep, clcw_both
251 integer :: cliw_deep_idx, clcw_deep_idx, cliw_shal_idx, clcw_shal_idx
252
253 real(kind=kind_phys) :: cap_suppress_j(im)
254!$acc declare create(cap_suppress_j)
255 integer :: itime, do_cap_suppress_here
256 logical :: exit_func
257
258 !parameter (tf=243.16, tcr=270.16, tcrf=1.0/(tcr-tf)) ! FV3 original
259 !parameter (tf=263.16, tcr=273.16, tcrf=1.0/(tcr-tf))
260 !parameter (tf=233.16, tcr=263.16, tcrf=1.0/(tcr-tf))
261 parameter(tf=258.16, tcr=273.16, tcrf=1.0/(tcr-tf)) ! as fim, HCB tuning
262 ! initialize ccpp error handling variables
263 errmsg = ''
264 errflg = 0
265
266 ten_t = 0.0
267 ten_u = 0.0
268 ten_v = 0.0
269 ten_q = 0.0
270 dcliw = 0.0
271 dclcw = 0.0
272 new_clcw = clcw
273 new_cliw = cliw
274
275 ichoice = ichoice_in
276 ichoicem = ichoicem_in
277 ichoice_s = ichoice_s_in
278 if(do_cap_suppress) then
279!$acc serial
280 do itime=1,num_dfi_radar
281 if(ix_dfi_radar(itime)<1) cycle
282 if(fhour<fh_dfi_radar(itime)) cycle
283 if(fhour>=fh_dfi_radar(itime+1)) cycle
284 exit
285 enddo
286!$acc end serial
287 endif
288 if(do_cap_suppress .and. itime<=num_dfi_radar) then
289 do_cap_suppress_here = 1
290!$acc kernels
291 cap_suppress_j(:) = cap_suppress(:,itime)
292!$acc end kernels
293 else
294 do_cap_suppress_here = 0
295!$acc kernels
296 cap_suppress_j(:) = 0
297!$acc end kernels
298 endif
299
300 if(ldiag3d) then
301 if(flag_for_dcnv_generic_tend) then
302 cliw_deep_idx=0
303 clcw_deep_idx=0
304 else
305 cliw_deep_idx=dtidx(100+ntiw,index_of_process_dcnv)
306 clcw_deep_idx=dtidx(100+ntcw,index_of_process_dcnv)
307 endif
308 if(flag_for_scnv_generic_tend) then
309 cliw_shal_idx=0
310 clcw_shal_idx=0
311 else
312 cliw_shal_idx=dtidx(100+ntiw,index_of_process_scnv)
313 clcw_shal_idx=dtidx(100+ntcw,index_of_process_scnv)
314 endif
315 if(cliw_deep_idx>=1 .or. clcw_deep_idx>=1 .or. &
316 cliw_shal_idx>=1 .or. clcw_shal_idx>=1) then
317 allocate(clcw_save(im,km), cliw_save(im,km))
318!$acc enter data create(clcw_save,cliw_save)
319!$acc kernels
320 clcw_save(:,:)=clcw(:,:)
321 cliw_save(:,:)=cliw(:,:)
322!$acc end kernels
323 endif
324 endif
325
326!
327! Scale specific humidity to dry mixing ratio
328!
329!$acc kernels
330 ! state in before physics
331 qv2di = qv2di_spechum/(1.0_kind_phys-qv2di_spechum)
332 ! forcing by dynamics, based on state in
333 forceqv = forceqv_spechum/(1.0_kind_phys-qv2di_spechum)
334 ! current state (updated by preceeding physics)
335 qv = qv_spechum/(1.0_kind_phys-qv_spechum)
336!
337!
338! these should be coming in from outside
339!
340! cactiv(:) = 0
341 if (spp_cu_deep == 0) then
342 rand_mom(:) = 0.
343 rand_vmas(:) = 0.
344 rand_clos(:,:) = 0.
345 else
346 do i=1,im
347 spp_wts_cu_deep_tmp=min(max(-1.0_kind_phys, spp_wts_cu_deep(i,1)),1.0_kind_phys)
348 rand_mom(i) = spp_wts_cu_deep_tmp
349 rand_vmas(i) = spp_wts_cu_deep_tmp
350 rand_clos(i,:) = spp_wts_cu_deep_tmp
351 end do
352 end if
353!$acc end kernels
354!
355 its=1
356 ite=im
357 itf=ite
358 jts=1
359 jte=1
360 jtf=jte
361 kts=1
362 kte=km
363 ktf=kte-1
364!$acc kernels
365!
366 tropics(:)=0
367!
369!
370 tun_rad_shall(:)=.01
371 tun_rad_mid(:)=.3 !.02
372 tun_rad_deep(:)=.3 !.065
373 edt(:)=0.
374 edtm(:)=0.
375 edtd(:)=0.
376 zdd(:,:)=0.
377 flux_tun(:)=5.
378! dx for scale awareness
379!$acc end kernels
380
381 if (imfshalcnv == 3) then
382 ishallow_g3 = 1
383 else
384 ishallow_g3 = 0
385 end if
386 high_resolution=0
387 subcenter=0.
388 iens=1
389!
390! these can be set for debugging
391!
392 ipr=0
393 jpr=0
394 ipr_deep=0
395 jpr_deep= 0 !53322 ! 528196 !0 ! 1136 !0 !421755 !3536
396!
397!
398 ibeg=its
399 iend=ite
400 tcrit=258.
401
402 ztm=0.
403 ztq=0.
404 hfm=0.
405 qfm=0.
406!$acc kernels
407 ud_mf(:,:) =0.
408 dd_mf(:,:) =0.
409 dt_mf(:,:) =0.
410 tau_ecmwf(:)=0.
411!$acc end kernels
412!
413 j=1
414!$acc kernels
415 ht(:)=phil(:,1)/g
416!$acc loop private(zh)
417 do i=its,ite
418 cld1d(i)=0.
419 zo(i,:)=phil(i,:)/g
420 dz8w(i,1)=zo(i,2)-zo(i,1)
421 zh(1)=0.
422 kpbli(i)=2
423 do k=kts+1,ktf
424 dz8w(i,k)=zo(i,k+1)-zo(i,k)
425 enddo
426!$acc loop seq
427 do k=kts+1,ktf
428 zh(k)=zh(k-1)+dz8w(i,k-1)
429 if(zh(k).gt.pbl(i))then
430 kpbli(i)=max(2,k)
431 exit
432 endif
433 enddo
434 enddo
435!$acc end kernels
436
437!$acc kernels
438 do i= its,itf
439 forcing(i,:)=0.
440 forcing2(i,:)=0.
441 ccn_gf(i) = 0.
442 ccn_m(i) = 0.
443
444 ! set aod and ccn
445 if ((flag_init .and. .not.flag_restart) .or. gf_coldstart) then
446 aod_gf(i)=aodc0
447 else
448 if((cactiv(i).eq.0) .and. (cactiv_m(i).eq.0))then
449 if(aodc0>aod_gf(i)) aod_gf(i)=aod_gf(i)+((aodc0-aod_gf(i))*(dt/(aodreturn*60)))
450 if(aod_gf(i)>aodc0) aod_gf(i)=aodc0
451 endif
452 endif
453
454 ccn_gf(i)=max(5., (aod_gf(i)/0.0027)**(1/0.640))
455 ccn_m(i)=ccn_gf(i)
456
457 ccnclean=max(5., (aodc0/0.0027)**(1/0.640))
458
459 hbot(i) =kte
460 htop(i) =kts
461 raincv(i)=0.
462 xlandi(i)=real(xland(i))
463! if(abs(xlandi(i)-1.).le.1.e-3) tun_rad_shall(i)=.15
464! if(abs(xlandi(i)-1.).le.1.e-3) flux_tun(i)=1.5
465 enddo
466 do i= its,itf
467 mconv(i)=0.
468 enddo
469 do k=kts,kte
470 do i= its,itf
471 omeg(i,k)=0.
472 zu(i,k)=0.
473 zum(i,k)=0.
474 zus(i,k)=0.
475 zd(i,k)=0.
476 zdm(i,k)=0.
477 enddo
478 enddo
479
480 psur(:)=0.01*psuri(:)
481 do i=its,itf
482 ter11(i)=max(0.,ht(i))
483 enddo
484 do k=kts,kte
485 do i=its,ite
486 cnvw(i,k)=0.
487 cnvc(i,k)=0.
488 gdc(i,k,1)=0.
489 gdc(i,k,2)=0.
490 gdc(i,k,3)=0.
491 gdc(i,k,4)=0.
492 gdc(i,k,7)=0.
493 gdc(i,k,8)=0.
494 gdc(i,k,9)=0.
495 gdc(i,k,10)=0.
496 gdc2(i,k,1)=0.
497 enddo
498 enddo
499 ierr(:)=0
500 ierrm(:)=0
501 ierrs(:)=0
502 cuten(:)=0.
503 cutenm(:)=0.
504 cutens(:)=0.
505!$acc end kernels
506 ierrc(:)=" "
507!$acc kernels
508
509
510 kbcon(:)=0
511 kbcons(:)=0
512 kbconm(:)=0
513
514 ktop(:)=0
515 ktops(:)=0
516 ktopm(:)=0
517
518 xmb(:)=0.
519 xmb_dumm(:)=0.
520 xmbm(:)=0.
521 xmbs(:)=0.
522 xmbs2(:)=0.
523
524 k22s(:)=0
525 k22m(:)=0
526 k22(:)=0
527
528 jmin(:)=0
529 jminm(:)=0
530
531 pret(:)=0.
532 prets(:)=0.
533 pretm(:)=0.
534
535 umean(:)=0.
536 vmean(:)=0.
537 pmean(:)=0.
538
539 cupclw(:,:)=0.
540 cupclwm(:,:)=0.
541 cupclws(:,:)=0.
542
543 cnvwt(:,:)=0.
544 cnvwts(:,:)=0.
545 cnvwtm(:,:)=0.
546
547 hco(:,:)=0.
548 hcom(:,:)=0.
549 hcdo(:,:)=0.
550 hcdom(:,:)=0.
551
552 outt(:,:)=0.
553 outts(:,:)=0.
554 outtm(:,:)=0.
555
556 outu(:,:)=0.
557 outus(:,:)=0.
558 outum(:,:)=0.
559
560 outv(:,:)=0.
561 outvs(:,:)=0.
562 outvm(:,:)=0.
563
564 outq(:,:)=0.
565 outqs(:,:)=0.
566 outqm(:,:)=0.
567
568 outqc(:,:)=0.
569 outqcs(:,:)=0.
570 outqcm(:,:)=0.
571
572 subm(:,:)=0.
573 dhdt(:,:)=0.
574
575 frhm(:)=0.
576 frhd(:)=0.
577
578 do k=kts,ktf
579 do i=its,itf
580 p2d(i,k)=0.01*p2di(i,k)
581 po(i,k)=p2d(i,k) !*.01
582 rhoi(i,k) = 100.*p2d(i,k)/(287.04*(t2di(i,k)*(1.+0.608*qv2di(i,k))))
583 qcheck(i,k)=qv(i,k)
584 tn(i,k)=t(i,k)!+forcet(i,k)*dt
585 qo(i,k)=max(1.e-16,qv(i,k))!+forceqv(i,k)*dt
586 t2d(i,k)=t2di(i,k)-forcet(i,k)*dt
587 q2d(i,k)=max(1.e-16,qv2di(i,k)-forceqv(i,k)*dt)
588 if(qo(i,k).lt.1.e-16)qo(i,k)=1.e-16
589 tshall(i,k)=t2d(i,k)
590 qshall(i,k)=q2d(i,k)
591 enddo
592 enddo
593!$acc end kernels
594123 format(1x,i2,1x,2(1x,f8.0),1x,2(1x,f8.3),3(1x,e13.5))
595!$acc kernels
596 do i=its,itf
597 do k=kts,kpbli(i)
598 tshall(i,k)=t(i,k)
599 qshall(i,k)=max(1.e-16,qv(i,k))
600 enddo
601 enddo
602!
603! converting hfx2 and qfx2 to w/m2
604! hfx=cp*rho*hfx2
605! qfx=xlv*qfx2
606 do i=its,itf
607 hfx(i)=hfx2(i)*cp*rhoi(i,1)
608 qfx(i)=qfx2(i)*xlv*rhoi(i,1)
609 dx(i) = sqrt(garea(i))
610 mc_thresh(i)=3.25/dx(i)
611 enddo
612
613 do i=its,itf
614 do k=kts,kpbli(i)
615 tn(i,k)=t(i,k)
616 qo(i,k)=max(1.e-16,qv(i,k))
617 enddo
618 enddo
619 nbegin=0
620 nend=0
621 do i=its,itf
622 do k=kts,kpbli(i)
623 dhdt(i,k)=cp*(forcet(i,k)+(t(i,k)-t2di(i,k))/dt) + &
624 xlv*(forceqv(i,k)+(qv(i,k)-qv2di(i,k))/dt)
625! tshall(i,k)=t(i,k)
626! qshall(i,k)=qv(i,k)
627 enddo
628 enddo
629!$acc loop collapse(2) independent private(dp)
630 do k= kts+1,ktf-1
631 do i = its,itf
632 if((p2d(i,1)-p2d(i,k)).gt.150.and.p2d(i,k).gt.300)then
633 dp=-.5*(p2d(i,k+1)-p2d(i,k-1))
634!$acc atomic
635 umean(i)=umean(i)+us(i,k)*dp
636!$acc atomic
637 vmean(i)=vmean(i)+vs(i,k)*dp
638!$acc atomic
639 pmean(i)=pmean(i)+dp
640 endif
641 enddo
642 enddo
643 do i = its,itf
644 psum=0.
645 do k=kts,ktf-3
646 if (clcw(i,k) .gt. -999.0 .and. clcw(i,k+1) .gt. -999.0 )then
647 dp=(p2d(i,k)-p2d(i,k+1))
648 psum=psum+dp
649 clwtot = cliw(i,k) + clcw(i,k)
650 if(clwtot.lt.1.e-32)clwtot=0.
651 forcing(i,7)=forcing(i,7)+clwtot*dp
652 endif
653 enddo
654 if(psum.gt.0)forcing(i,7)=forcing(i,7)/psum
655 forcing2(i,7)=forcing(i,7)
656 enddo
657 do k=kts,ktf-1
658 do i = its,itf
659 omeg(i,k)= w(i,k) !-g*rhoi(i,k)*w(i,k)
660 enddo
661 enddo
662 do i = its,itf
663 if(mconv(i).lt.0.)mconv(i)=0.
664 if((dx(i)<6500.).and.do_mynnedmf.and.(maxmf(i).gt.0.))ierr(i)=555
665 enddo
666!$acc end kernels
667 if (dx(its)<6500.) then
668 imid_gf=0
669 endif
670!
671!---- call cumulus parameterization
672!
673 if(ishallow_g3.eq.1)then
674
675!$acc kernels
676 do i=its,ite
677 ierrs(i)=0
678 ierrm(i)=0
679 enddo
680!$acc end kernels
681!
683!
684 call cu_gf_sh_run (us,vs, &
685! input variables, must be supplied
686 zo,t2d,q2d,ter11,tshall,qshall,p2d,psur,dhdt,kpbli, &
687 rhoi,hfx,qfx,xlandi,ichoice_s,tcrit,dt, &
688! input variables. ierr should be initialized to zero or larger than zero for
689! turning off shallow convection for grid points
690 zus,xmbs,kbcons,ktops,k22s,ierrs,ierrcs, &
691! output tendencies
692 outts,outqs,outqcs,outus,outvs,cnvwt,prets,cupclws, &
693! dimesnional variables
694 itf,ktf,its,ite, kts,kte,ipr,tropics)
695
696!$acc kernels
697 do i=its,itf
698 if(xmbs(i).gt.0.)then
699 cutens(i)=1.
700 if (dx(i)<6500.) then
701 ierrm(i)=555
702 ierr(i)=555
703 endif
704 endif
705 enddo
706!$acc end kernels
708 call neg_check('shallow',ipn,dt,qcheck,outqs,outts,outus,outvs, &
709 outqcs,prets,its,ite,kts,kte,itf,ktf,ktops)
710 endif
711
712 ipr=0
713 jpr_deep=0 !340765
715 if(imid_gf == 1)then
716 call cu_gf_deep_run( &
717 itf,ktf,its,ite, kts,kte &
718 ,dicycle_m &
719 ,ichoicem &
720 ,ipr &
721 ,ccn_m &
722 ,ccnclean &
723 ,dt &
724 ,imid_gf &
725 ,kpbli &
726 ,dhdt &
727 ,xlandi &
728 ,zo &
729 ,forcing &
730 ,t2d &
731 ,q2d &
732 ,ter11 &
733 ,tshall &
734 ,qshall &
735 ,p2d &
736 ,psur &
737 ,us &
738 ,vs &
739 ,rhoi &
740 ,hfx &
741 ,qfx &
742 ,dx &
743 ,mconv &
744 ,omeg &
745 ,cactiv_m &
746 ,cnvwtm &
747 ,zum &
748 ,zdm & ! hli
749 ,zdd &
750 ,edtm &
751 ,edtd & ! hli
752 ,xmbm &
753 ,xmb_dumm &
754 ,xmbs &
755 ,pretm &
756 ,outum &
757 ,outvm &
758 ,outtm &
759 ,outqm &
760 ,outqcm &
761 ,kbconm &
762 ,ktopm &
763 ,cupclwm &
764 ,frhm &
765 ,ierrm &
766 ,ierrcm &
767 ,nchem &
768 ,fscav &
769 ,chem3d &
770 ,wetdpc_mid &
771 ,do_smoke_transport &
772! the following should be set to zero if not available
773 ,rand_mom & ! for stochastics mom, if temporal and spatial patterns exist
774 ,rand_vmas & ! for stochastics vertmass, if temporal and spatial patterns exist
775 ,rand_clos & ! for stochastics closures, if temporal and spatial patterns exist
776 ,spp_cu_deep & ! flag to what you want perturbed
777 ! 1 = momentum transport
778 ! 2 = normalized vertical mass flux profile
779 ! 3 = closures
780 ! more is possible, talk to developer or
781 ! implement yourself. pattern is expected to be
782 ! betwee -1 and +1
783 ,do_cap_suppress_here,cap_suppress_j &
784 ,k22m &
785 ,jminm,kdt,mc_thresh)
786!$acc kernels
787 do i=its,itf
788 do k=kts,ktf
789 qcheck(i,k)=qv(i,k) +outqs(i,k)*dt
790 enddo
791 enddo
792!$acc end kernels
794 call neg_check('mid',ipn,dt,qcheck,outqm,outtm,outum,outvm, &
795 outqcm,pretm,its,ite,kts,kte,itf,ktf,ktopm)
796 endif
798 if(ideep.eq.1)then
799 call cu_gf_deep_run( &
800 itf,ktf,its,ite, kts,kte &
801
802 ,dicycle &
803 ,ichoice &
804 ,ipr &
805 ,ccn_gf &
806 ,ccnclean &
807 ,dt &
808 ,0 &
809
810 ,kpbli &
811 ,dhdt &
812 ,xlandi &
813
814 ,zo &
815 ,forcing2 &
816 ,t2d &
817 ,q2d &
818 ,ter11 &
819 ,tn &
820 ,qo &
821 ,p2d &
822 ,psur &
823 ,us &
824 ,vs &
825 ,rhoi &
826 ,hfx &
827 ,qfx &
828 ,dx &
829 ,mconv &
830 ,omeg &
831 ,cactiv &
832 ,cnvwt &
833 ,zu &
834 ,zd &
835 ,zdm & ! hli
836 ,edt &
837 ,edtm & ! hli
838 ,xmb &
839 ,xmbm &
840 ,xmbs &
841 ,pret &
842 ,outu &
843 ,outv &
844 ,outt &
845 ,outq &
846 ,outqc &
847 ,kbcon &
848 ,ktop &
849 ,cupclw &
850 ,frhd &
851 ,ierr &
852 ,ierrc &
853 ,nchem &
854 ,fscav &
855 ,chem3d &
856 ,wetdpc_deep &
857 ,do_smoke_transport &
858! the following should be set to zero if not available
859 ,rand_mom & ! for stochastics mom, if temporal and spatial patterns exist
860 ,rand_vmas & ! for stochastics vertmass, if temporal and spatial patterns exist
861 ,rand_clos & ! for stochastics closures, if temporal and spatial patterns exist
862 ,spp_cu_deep & ! flag to what you want perturbed
863 ! 1 = momentum transport
864 ! 2 = normalized vertical mass flux profile
865 ! 3 = closures
866 ! more is possible, talk to developer or
867 ! implement yourself. pattern is expected to be
868 ! betwee -1 and +1
869 ,do_cap_suppress_here,cap_suppress_j &
870 ,k22 &
871 ,jmin,kdt,mc_thresh)
872 jpr=0
873 ipr=0
874!$acc kernels
875 do i=its,itf
876 do k=kts,ktf
877 qcheck(i,k)=qv(i,k) +(outqs(i,k)+outqm(i,k))*dt
878 enddo
879 enddo
880!$acc end kernels
882 call neg_check('deep',ipn,dt,qcheck,outq,outt,outu,outv, &
883 outqc,pret,its,ite,kts,kte,itf,ktf,ktop)
884!
885 endif
886!$acc kernels
887 do i=its,itf
888 kcnv(i)=0
889 if(pretm(i).gt.0.)then
890 kcnv(i)= 1 !jmin(i)
891 cutenm(i)=1.
892 else
893 kbconm(i)=0
894 ktopm(i)=0
895 cutenm(i)=0.
896 endif ! pret > 0
897
898 maxupmf(i)=0.
899 if(forcing2(i,6).gt.0.)then
900 maxupmf(i)=maxval(xmb(i)*zu(i,kts:ktf)/forcing2(i,6))
901 endif
902 if (xland(i)==0)then ! cu precip rate (mm/h)
903 if((maxupmf(i).lt.0.1) .or. (pret(i)*3600.lt.0.05)) pret(i)=0.
904 endif
905 if(pret(i).gt.0.)then
906 cuten(i)=1.
907 cutenm(i)=0.
908 pretm(i)=0.
909 kcnv(i)= 1 !jmin(i)
910 ktopm(i)=0
911 kbconm(i)=0
912 else
913 kbcon(i)=0
914 ktop(i)=0
915 cuten(i)=0.
916 endif ! pret > 0
917 enddo
918!$acc end kernels
919!
920!$acc parallel loop private(kstop,dtime_max,massflx,trcflx_in1,clw_in1,po_cup)
921 do i=its,itf
922 massflx(:)=0.
923 trcflx_in1(:)=0.
924 clw_in1(:)=0.
925 do k=kts,ktf
926 clw_ten(i, k)=0.
927 enddo
928 po_cup(:)=0.
929 kstop=kts
930 if(ktopm(i).gt.kts .or. ktop(i).gt.kts)kstop=max(ktopm(i),ktop(i))
931 if(ktops(i).gt.kts)kstop=max(kstop,ktops(i))
932 if(kstop.gt.2)then
933 htop(i)=kstop
934 if(kbcon(i).gt.2 .or. kbconm(i).gt.2)then
935 hbot(i)=max(kbconm(i),kbcon(i)) !jmin(i)
936 endif
937
938 dtime_max=dt
939 forcing2(i,3)=0.
940 do k=kts,kstop
941 cnvc(i,k) = 0.04 * log(1. + 675. * zu(i,k) * xmb(i)) + &
942 0.04 * log(1. + 675. * zum(i,k) * xmbm(i)) + &
943 0.04 * log(1. + 675. * zus(i,k) * xmbs(i))
944 cnvc(i,k) = min(cnvc(i,k), 0.6)
945 cnvc(i,k) = max(cnvc(i,k), 0.0)
946 cnvw(i,k)=cnvwt(i,k)*xmb(i)*dt+cnvwts(i,k)*xmbs(i)*dt+cnvwtm(i,k)*xmbm(i)*dt
947 ud_mf(i,k)=cuten(i)*zu(i,k)*xmb(i)*dt
948 dd_mf(i,k)=cuten(i)*zd(i,k)*edt(i)*xmb(i)*dt
949
950 ten_t(i,k) = (cutens(i)*outts(i,k)+cutenm(i)*outtm(i,k)+outt(i,k)*cuten(i))
951 qv(i,k)=max(1.e-16,qv(i,k)+dt*(cutens(i)*outqs(i,k)+cutenm(i)*outqm(i,k)+outq(i,k)*cuten(i)))
952 gdc(i,k,7)=sqrt(us(i,k)**2 +vs(i,k)**2)
953 ten_u(i,k) = outu(i,k)*cuten(i) +outum(i,k)*cutenm(i) +outus(i,k)*cutens(i)
954 ten_v(i,k) = outv(i,k)*cuten(i) +outvm(i,k)*cutenm(i) +outvs(i,k)*cutens(i)
955
956 gdc(i,k,1)= max(0.,tun_rad_shall(i)*cupclws(i,k)*cutens(i)) ! my mod
957 !gdc2(i,k,1)=max(0.,tun_rad_deep(i)*(cupclwm(i,k)*cutenm(i)+cupclw(i,k)*cuten(i)))
958 gdc2(i,k,1)=max(0.,tun_rad_mid(i)*cupclwm(i,k)*cutenm(i)+frhd(i)*cupclw(i,k)*cuten(i)+tun_rad_shall(i)*cupclws(i,k)*cutens(i))
959 !gdc2(i,k,1) = min(0.1, max(0.01, tun_rad_mid(i)*frhm(i)))*cupclwm(i,k)*cutenm(i) + min(0.1, max(0.01, tun_rad_deep(i)*(frhd(i))))*cupclw(i,k)*cuten(i) + tun_rad_shall(i)*cupclws(i,k)*cutens(i)
960 qci_conv(i,k)=gdc2(i,k,1)
961 gdc(i,k,2)=(outt(i,k))*86400.
962 gdc(i,k,3)=(outtm(i,k))*86400.
963 gdc(i,k,4)=(outts(i,k))*86400.
964 gdc(i,k,7)=-(gdc(i,k,7)-sqrt(us(i,k)**2 +vs(i,k)**2))/dt
965 !gdc(i,k,8)=(outq(i,k))*86400.*xlv/cp
966 gdc(i,k,8)=(outqm(i,k)+outqs(i,k)+outq(i,k))*86400.*xlv/cp
967 gdc(i,k,9)=gdc(i,k,2)+gdc(i,k,3)+gdc(i,k,4)
968
970 dp=100.*(p2d(i,k)-p2d(i,k+1))
971 dtime_max=min(dtime_max,.5*dp)
972 po_cup(k)=.5*(p2d(i,k)+p2d(i,k+1))
973 if (clcw(i,k) .gt. -999.0 .and. clcw(i,k+1) .gt. -999.0 )then
974 clwtot = cliw(i,k) + clcw(i,k)
975 if(clwtot.lt.1.e-32)clwtot=0.
976 clwtot1= cliw(i,k+1) + clcw(i,k+1)
977 if(clwtot1.lt.1.e-32)clwtot1=0.
978 clw_in1(k)=clwtot
979 massflx(k)=-(xmb(i) *( zu(i,k)- edt(i)* zd(i,k))) &
980 -(xmbm(i)*(zdm(i,k)-edtm(i)*zdm(i,k))) &
981 -(xmbs(i)*zus(i,k))
982 trcflx_in1(k)=massflx(k)*.5*(clwtot+clwtot1)
983 forcing2(i,3)=forcing2(i,3)+clwtot
984 endif
985 enddo
986
987 massflx(1)=0.
988 trcflx_in1(1)=0.
989 call fct1d3 (kstop,kte,dtime_max,po_cup, &
990 clw_in1,massflx,trcflx_in1,clw_ten(i,:),g)
991
992 do k=1,kstop
993 tem = dt*(outqcs(i,k)*cutens(i)+outqc(i,k)*cuten(i) &
994 +outqcm(i,k)*cutenm(i) &
995 +clw_ten(i,k) &
996 )
997 tem1 = max(0.0, min(1.0, (tcr-t(i,k))*tcrf))
998 if (clcw(i,k) .gt. -999.0) then
999 new_cliw(i,k) = max(0.,cliw(i,k) + tem * tem1) ! ice
1000 new_clcw(i,k) = max(0.,clcw(i,k) + tem *(1.0-tem1)) ! water
1001 dcliw(i,k) = (new_cliw(i,k) - cliw(i,k))/dt
1002 dclcw(i,k) = (new_clcw(i,k) - clcw(i,k))/dt
1003 else
1004 new_cliw(i,k) = max(0.,cliw(i,k) + tem)
1005 dcliw(i,k) = (new_cliw(i,k) - cliw(i,k))/dt
1006 endif
1007
1008 enddo
1009
1010 gdc(i,1,10)=forcing(i,1)
1011 gdc(i,2,10)=forcing(i,2)
1012 gdc(i,3,10)=forcing(i,3)
1013 gdc(i,4,10)=forcing(i,4)
1014 gdc(i,5,10)=forcing(i,5)
1015 gdc(i,6,10)=forcing(i,6)
1016 gdc(i,7,10)=forcing(i,7)
1017 gdc(i,8,10)=forcing(i,8)
1018 gdc(i,10,10)=xmb(i)
1019 gdc(i,11,10)=xmbm(i)
1020 gdc(i,12,10)=xmbs(i)
1021 gdc(i,13,10)=hfx(i)
1022 gdc(i,15,10)=qfx(i)
1023 gdc(i,16,10)=pret(i)*3600.
1024
1025
1026 if(ktop(i).gt.2 .and.pret(i).gt.0.)dt_mf(i,ktop(i)-1)=ud_mf(i,ktop(i))
1027 endif
1028 enddo
1029!$acc end parallel
1030!$acc kernels
1031 do i=its,itf
1032 if(pret(i).gt.0.)then
1033 cactiv(i)=1
1034 raincv(i)=.001*(cutenm(i)*pretm(i)+cutens(i)*prets(i)+cuten(i)*pret(i))*dt
1035 else
1036 cactiv(i)=0
1037 if(pretm(i).gt.0)raincv(i)=.001*cutenm(i)*pretm(i)*dt
1038 endif ! pret > 0
1039
1040 if(pretm(i).gt.0)then
1041 cactiv_m(i)=1
1042 else
1043 cactiv_m(i)=0
1044 endif
1045
1046 ! Unify ccn
1047 if(ccn_m(i).lt.ccn_gf(i))then
1048 ccn_gf(i)=ccn_m(i)
1049 endif
1050
1051 if(ccn_gf(i)<0) ccn_gf(i)=0
1052
1053 ! Convert ccn back to aod
1054 aod_gf(i)=0.0027*(ccn_gf(i)**0.64)
1055 if(aod_gf(i)<0.007)then
1056 aod_gf(i)=0.007
1057 ccn_gf(i)=(aod_gf(i)/0.0027)**(1/0.640)
1058 elseif(aod_gf(i)>aodc0)then
1059 aod_gf(i)=aodc0
1060 ccn_gf(i)=(aod_gf(i)/0.0027)**(1/0.640)
1061 endif
1062 enddo
1063!$acc end kernels
1064 100 continue
1065!
1066! Scale dry mixing ratios for water wapor and cloud water to specific humidy / moist mixing ratios
1067!
1068!$acc kernels
1069 new_qv_spechum = qv/(1.0_kind_phys+qv)
1070 cnvw_moist = cnvw/(1.0_kind_phys+qv)
1071!$acc end kernels
1072 do i=its,ite
1073 do k=kts,kte
1074 ten_q(i,k,ntqv) = (new_qv_spechum(i,k) - qv_spechum(i,k))/dt
1075 end do
1076 end do
1077!
1078! Diagnostic tendency updates
1079!
1080 if(ldiag3d) then
1081 if(ishallow_g3.eq.1 .and. .not.flag_for_scnv_generic_tend) then
1082 uidx=dtidx(index_of_x_wind,index_of_process_scnv)
1083 vidx=dtidx(index_of_y_wind,index_of_process_scnv)
1084 tidx=dtidx(index_of_temperature,index_of_process_scnv)
1085 qidx=dtidx(100+ntqv,index_of_process_scnv)
1086 if(uidx>=1) then
1087!$acc kernels
1088 do k=kts,ktf
1089 dtend(:,k,uidx) = dtend(:,k,uidx) + cutens(:)*outus(:,k) * dt
1090 enddo
1091!$acc end kernels
1092 endif
1093 if(vidx>=1) then
1094!$acc kernels
1095 do k=kts,ktf
1096 dtend(:,k,vidx) = dtend(:,k,vidx) + cutens(:)*outvs(:,k) * dt
1097 enddo
1098!$acc end kernels
1099 endif
1100 if(tidx>=1) then
1101!$acc kernels
1102 do k=kts,ktf
1103 dtend(:,k,tidx) = dtend(:,k,tidx) + cutens(:)*outts(:,k) * dt
1104 enddo
1105!$acc end kernels
1106 endif
1107 if(qidx>=1) then
1108!$acc kernels
1109 do k=kts,ktf
1110 do i=its,itf
1111 tem = cutens(i)*outqs(i,k)* dt
1112 tem = tem/(1.0_kind_phys+tem)
1113 dtend(i,k,qidx) = dtend(i,k,qidx) + tem
1114 enddo
1115 enddo
1116!$acc end kernels
1117 endif
1118 endif
1119 if((ideep.eq.1. .or. imid_gf.eq.1) .and. .not.flag_for_dcnv_generic_tend) then
1120 uidx=dtidx(index_of_x_wind,index_of_process_dcnv)
1121 vidx=dtidx(index_of_y_wind,index_of_process_dcnv)
1122 tidx=dtidx(index_of_temperature,index_of_process_dcnv)
1123 if(uidx>=1) then
1124!$acc kernels
1125 do k=kts,ktf
1126 dtend(:,k,uidx) = dtend(:,k,uidx) + (cuten*outu(:,k)+cutenm*outum(:,k)) * dt
1127 enddo
1128!$acc end kernels
1129 endif
1130 if(vidx>=1) then
1131!$acc kernels
1132 do k=kts,ktf
1133 dtend(:,k,vidx) = dtend(:,k,vidx) + (cuten*outv(:,k)+cutenm*outvm(:,k)) * dt
1134 enddo
1135!$acc end kernels
1136 endif
1137 if(tidx>=1) then
1138!$acc kernels
1139 do k=kts,ktf
1140 dtend(:,k,tidx) = dtend(:,k,tidx) + (cuten*outt(:,k)+cutenm*outtm(:,k)) * dt
1141 enddo
1142!$acc end kernels
1143 endif
1144
1145 qidx=dtidx(100+ntqv,index_of_process_dcnv)
1146 if(qidx>=1) then
1147!$acc kernels
1148 do k=kts,ktf
1149 do i=its,itf
1150 tem = (cuten(i)*outq(i,k) + cutenm(i)*outqm(i,k))* dt
1151 tem = tem/(1.0_kind_phys+tem)
1152 dtend(i,k,qidx) = dtend(i,k,qidx) + tem
1153 enddo
1154 enddo
1155!$acc end kernels
1156 endif
1157 endif
1158 if(allocated(clcw_save)) then
1159!$acc parallel loop collapse(2) private(tem_shal,tem_deep,tem,tem1,weight_sum,cliw_both,clcw_both)
1160 do k=kts,ktf
1161 do i=its,itf
1162 tem_shal = dt*(outqcs(i,k)*cutens(i)+outqcm(i,k)*cutenm(i))
1163 tem_deep = dt*(outqc(i,k)*cuten(i)+clw_ten(i,k))
1164 tem = tem_shal+tem_deep
1165 tem1 = max(0.0, min(1.0, (tcr-t(i,k))*tcrf))
1166 weight_sum = abs(tem_shal)+abs(tem_deep)
1167 if(weight_sum<1e-12) then
1168 cycle
1169 endif
1170
1171 if (clcw_save(i,k) .gt. -999.0) then
1172 cliw_both = max(0.,cliw_save(i,k) + tem * tem1) - cliw_save(i,k)
1173 clcw_both = max(0.,clcw_save(i,k) + tem) - clcw_save(i,k)
1174 else if(cliw_idx>=1) then
1175 cliw_both = max(0.,cliw_save(i,k) + tem) - cliw_save(i,k)
1176 clcw_both = 0
1177 endif
1178 if(cliw_deep_idx>=1) then
1179 dtend(i,k,cliw_deep_idx) = dtend(i,k,cliw_deep_idx) + abs(tem_deep)/weight_sum*cliw_both
1180 endif
1181 if(clcw_deep_idx>=1) then
1182 dtend(i,k,clcw_deep_idx) = dtend(i,k,clcw_deep_idx) + abs(tem_deep)/weight_sum*clcw_both
1183 endif
1184 if(cliw_shal_idx>=1) then
1185 dtend(i,k,cliw_shal_idx) = dtend(i,k,cliw_shal_idx) + abs(tem_shal)/weight_sum*cliw_both
1186 endif
1187 if(clcw_shal_idx>=1) then
1188 dtend(i,k,clcw_shal_idx) = dtend(i,k,clcw_shal_idx) + abs(tem_shal)/weight_sum*clcw_both
1189 endif
1190 enddo
1191 enddo
1192!$acc end parallel
1193 endif
1194 endif
1195 end subroutine cu_gf_driver_run
1197end module cu_gf_driver
subroutine fct1d3(ktop, n, dt, z, tracr, massflx, trflx_in, dellac, g)
Calculates tracer fluxes due to subsidence, only up-stream differencing is currently used but flux co...
subroutine cu_gf_deep_run(itf, ktf, its, ite, kts, kte, dicycle, ichoice, ipr, ccn, ccnclean, dtime, imid, kpbl, dhdt, xland, zo, forcing, t, q, z1, tn, qo, po, psur, us, vs, rho, hfx, qfx, dx, mconv, omeg, csum, cnvwt, zuo, zdo, zdm, edto, edtm, xmb_out, xmbm_in, xmbs_in, pre, outu, outv, outt, outq, outqc, kbcon, ktop, cupclw, frh_out, ierr, ierrc, nchem, fscav, chem3d, wetdpc_deep, do_smoke_transport, rand_mom, rand_vmas, rand_clos, nranflag, do_capsuppress, cap_suppress_j, k22, jmin, kdt, mc_thresh)
Driver for the deep or congestus GF routine.
subroutine neg_check(name, j, dt, q, outq, outt, outu, outv, outqc, pret, its, ite, kts, kte, itf, ktf, ktop)
Checks for negative or excessive tendencies and corrects in a mass conversing way by adjusting the cl...
subroutine, public cu_gf_driver_run(ntracer, garea, im, km, dt, flag_init, flag_restart, gf_coldstart, cactiv, cactiv_m, g, cp, xlv, r_v, forcet, forceqv_spechum, phil, raincv, qv_spechum, t, cld1d, us, vs, t2di, w, qv2di_spechum, p2di, psuri, hbot, htop, kcnv, xland, hfx2, qfx2, aod_gf, cliw, clcw, pbl, ud_mf, dd_mf, dt_mf, cnvw_moist, cnvc, imfshalcnv, flag_for_scnv_generic_tend, flag_for_dcnv_generic_tend, dtend, dtidx, ntqv, ntiw, ntcw, index_of_temperature, index_of_x_wind, index_of_y_wind, index_of_process_scnv, index_of_process_dcnv, fhour, fh_dfi_radar, ix_dfi_radar, num_dfi_radar, cap_suppress, dfi_radar_max_intervals, ldiag3d, qci_conv, do_cap_suppress, maxupmf, maxmf, do_mynnedmf, ichoice_in, ichoicem_in, ichoice_s_in, spp_cu_deep, spp_wts_cu_deep, nchem, chem3d, fscav, wetdpc_deep, do_smoke_transport, kdt, ten_t, ten_u, ten_v, ten_q, dcliw, dclcw, errmsg, errflg)
This is the Grell-Freitas convection scheme driver module.
subroutine cu_gf_sh_run(us, vs, zo, t, q, z1, tn, qo, po, psur, dhdt, kpbl, rho, hfx, qfx, xland, ichoice, tcrit, dtime, zuo, xmb_out, kbcon, ktop, k22, ierr, ierrc, outt, outq, outqc, outu, outv, cnvwt, pre, cupclw, itf, ktf, its, ite, kts, kte, ipr, tropics)
Definition cu_gf_sh.F90:71
This module contains the Grell_Freitas deep convection scheme.
Definition cu_gf_deep.F90:5
This module contains the scale-aware Grell-Freitas cumulus scheme driver.
This module contains the Grell-Freitas shallow convection scheme.
Definition cu_gf_sh.F90:5