forked from wrf-model/WRF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule_cumulus_driver.F
1936 lines (1767 loc) · 93.1 KB
/
module_cumulus_driver.F
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
!WRF:MEDIATION_LAYER:PHYSICS
!
MODULE module_cumulus_driver
CONTAINS
SUBROUTINE cumulus_driver(grid &
! Order dependent args for domain, mem, and tile dims
,ids,ide, jds,jde, kds,kde &
,ims,ime, jms,jme, kms,kme &
,ips,ipe, jps,jpe, kps,kpe &
,i_start,i_end,j_start,j_end,kts,kte,num_tiles &
! Order independent args (use VAR= in call)
! --Prognostic
,u,v,th,t,w &
,p,pi,rho &
! --Other arguments
,itimestep,dt,dx,dx2d,area2d &
,cudt,curr_secs,adapt_step_flag &
,cudtacttime &
,ccldfra,convcld,qcconv,qiconv &
,bmj_rad_feedback &
,rainc,raincv,pratec,nca &
,cldfra_dp,cldfra_sh &
,udr_kf,ddr_kf,uer_kf,der_kf,timec_kf,kf_edrates & !kf_edrates
,QC_CU,QI_CU &
,z,z_at_w,dz8w,mavail,pblh,p8w,psfc,tsk &
,tke_pbl, ust &
,ZOL & !ckay
,forcet,forceq,w0avg,stepcu,gsw &
,cldefi,lowlyr,xland,cu_act_flag,warm_rain &
,hfx,qfx,cldfra,cldfra_mp_all,tpert2d &
,htop,hbot,kpbl,ht &
,ensdim,maxiens,maxens,maxens2,maxens3 &
,shall & !CuP, wig 18-Sep-2006
#if (EM_CORE == 1)
!BSINGH - For WRFCuP Scheme
,akpbl, br,regime,t2,q2 & !CuP, wig 3-Aug-2006
,slopeSfc, slopeEZ, sigmaSfc, sigmaEZ & !CuP, wig 7-Aug-2006
,cupflag, cldfra_cup, cldfratend_cup & !CuP, wig 18-Sep-2006
,taucloud, tactive & !CuP, wig 18-Sep-2006
,activeFrac & !CuP, lkb 4-May-2010
,tstar, lnterms, lnint & !CuP, wig 4-Oct-2006
,numBins, thBinSize, rBinSize & !CUP, lkb 4-Nov-2009
,minDeepFreq, minShallowFreq & !CUP, lkb 4-Nov-2009
,wCloudBase & !CuP, lkb 29-April-2010
,wact_cup & !CuP, rce 10-may-2012
,wulcl_cup & !CuP, rce 10-may-2012
,wup_cup & !CuP, rce 15-mar-2013 !BSINGH (12/06/2013)
,qc_ic_cup & !CuP, rce 10-may-2012
,qndrop_ic_cup & !CuP, rce 10-may-2012
,qc_iu_cup & !CuP, rce 10-may-2012
,fcvt_qc_to_pr_cup & !CuP, rce 10-may-2012
,fcvt_qc_to_qi_cup & !CuP, rce 10-may-2012
,fcvt_qi_to_pr_cup & !CuP, rce 10-may-2012
,mfup_cup & !CuP, rce 10-may-2012
,mfup_ent_cup & !CuP, rce 10-may-2012
,mfdn_cup & !CuP, rce 10-may-2012
,mfdn_ent_cup & !CuP, rce 10-may-2012
,updfra_cup & !CuP, rce 10-may-2012
,tcloud_cup & !CuP, rce 10-may-2012
!BSINGH -ENDS
#endif
,periodic_x,periodic_y &
,is_CAMMGMP_used &
,evapcdp3d,icwmrdp3d,rprddp3d & !Balwinder.Singh@pnnl.gov: Used for CAM's wet scavenging
! Package selection variables
,cu_physics, bl_pbl_physics, sf_sfclay_physics &
#if (EM_CORE == 1)
!BSINGH - For WRFCuP Scheme
,shcu_aerosols_opt & !CuP, rce 10-may-2012
,chem_opt & !CuP, rce 10-may-2012
!BSINGH - ENDS
#endif
! Optional moisture tracers
,qv_curr, qc_curr, qr_curr &
,qi_curr, qs_curr, qg_curr &
,qv_prev, qc_prev, qr_prev &
,qi_prev, qs_prev, qg_prev &
! Optional arguments for GD scheme
,apr_gr,apr_w,apr_mc,apr_st,apr_as,apr_capma &
,apr_capme,apr_capmi,edt_out,clos_choice &
,mass_flux,xf_ens,pr_ens,cugd_avedx,imomentum &
,ishallow,cugd_tten,cugd_qvten,cugd_qcten &
,cugd_ttens,cugd_qvtens &
,gd_cloud,gd_cloud2 &
! Optional output arguments for CAMZM scheme
,cape, zmmu, zmmd, zmdt, zmdq, dlf, rliq &
,pconvb, pconvt &
,evaptzm, fzsntzm, evsntzm, evapqzm, zmflxprc &
,zmflxsnw, zmntprpd, zmntsnpd, zmeiheat &
,cmfmc, cmfmcdzm, preccdzm, precz &
,zmmtu, zmmtv, zmupgu, zmupgd, zmvpgu, zmvpgd &
,zmicuu, zmicud, zmicvu, zmicvd, zmdice, zmdliq &
,dp3d, du3d, ed3d, eu3d, md3d, mu3d, dsubcld2d &
,ideep2d, jt2d, maxg2d, lengath2d &
,k22_shallow,kbcon_shallow,ktop_shallow,xmb_shallow &
,ktop_deep &
! Optional arguments for SAS scheme
,pgcon,sas_mass_flux &
,pert_sas,ens_random_seed &
,ens_sasamp &
,shalconv,shal_pgcon &
,HPBL2D,EVAP2D,HEAT2D & !Kwon for SAS2010 shallow convection
,DYNMM & ! For scale-aware SAS
,SCALEFUN,SCALEFUN1 & ! scale functions
,SIGMU,SIGMU1 & ! updraft fraction
! Optional arguments for NSAS scheme
,mp_physics &
,hpbl_hold &
! Optional moisture and other tendencies
,rqvcuten,rqccuten,rqrcuten &
,rqicuten,rqscuten,rqgcuten &
,rqcncuten,rqincuten &
,rqvblten,rqvften &
,rucuten,rvcuten &
,rthcuten,rthraten,rthblten,rthften &
,mommix,store_rand &
! Optional variables for tiedtke scheme - add by ZCX&YQW
,znu &
! Optional moisture tracer flags
,f_qv,f_qc,f_qr &
,f_qi,f_qs,f_qg &
,CFU1,CFD1,DFU1,EFU1,DFD1,EFD1,f_flux &
! Optional trigger function activation variable
,kfeta_trigger &
,nsas_dx_factor &
#if ( WRF_DFI_RADAR == 1 )
! Optional CAP suppress option --- 3.2 CLEANUP TODO -- THESE SHOULD BE OPTIONAL, NOT #IF/#ENDIF
,do_capsuppress &
#endif
#if ( WRF_CHEM == 1 )
,traceropt,conv_tr_wetscav &
,conv_tr_aqchem,chem_conv_tr &
#endif
#if (EM_CORE == 1)
,QR_CU,QS_CU,NC_CU,NI_CU,NR_CU,NS_CU,CCN_CU,CU_UAF &
,alevsiz_cu,num_months,no_src_types_cu,aercu_opt,aercu_fct &
,aeromcu,aerocu,aeropcu,id,JULDAY,JULIAN,aerovar &
,EFCS,EFIS,EFSS &
#endif
)
!----------------------------------------------------------------------
USE module_model_constants
USE module_state_description, ONLY: KFSCHEME,BMJSCHEME &
,KFETASCHEME,GDSCHEME &
,G3SCHEME,GFSCHEME &
,P_QC,P_QI,Param_FIRST_SCALAR &
,CAMZMSCHEME, SASSCHEME &
,OSASSCHEME &
,SCALESASSCHEME & ! scale-sware sas
,KSASSCHEME, NSASSCHEME &
#if (EM_CORE == 1)
,MSKFSCHEME &
,CAMMGMPSCHEME &
,KFCUPSCHEME & !CuP, wig 3-Aug-2006 !BSINGH - For WRFCuP scheme
,num_chem & !CuP, rce 10-may-2012 !BSINGH - For WRFCuP scheme
#endif
#if ( WRF_CHEM == 1)
,num_tracer &
#endif
,TIEDTKESCHEME &
,NTIEDTKESCHEME
#if ( WRF_CHEM == 1 )
USE module_chem_share, only: get_last_gas
#endif
#if ( WRFPLUS == 1 )
USE module_state_description, ONLY: DUCUSCHEME
#endif
! *** add new modules of schemes here
USE module_cu_kf , ONLY : kfcps
USE module_cu_bmj , ONLY : bmjdrv
#ifdef DM_PARALLEL
USE module_dm , ONLY : ntasks_x,ntasks_y,local_communicator,mytask,ntasks
#if (EM_CORE == 1)
USE module_comm_dm , ONLY : halo_cup_g3_in_sub, halo_cup_g3_out_sub
#endif
#endif
USE module_domain , ONLY: domain
USE module_cu_kfeta , ONLY : kf_eta_cps
#if (EM_CORE==1)
USE module_cu_mskf , ONLY : mskf_cps
#endif
USE module_cu_gd , ONLY : grelldrv
USE module_cu_gf_wrfdrv , ONLY : gfdrv
USE module_cu_g3 , ONLY : g3drv,conv_grell_spread3d
#if ( WRFPLUS == 1 )
USE module_cu_du , ONLY : DUCU
#endif
USE module_cu_sas , ONLY : cu_sas
USE module_cu_scalesas , ONLY : cu_scalesas
#if (EM_CORE == 1)
USE module_cu_kfcup , ONLY : KF_CUP_CPS !wig, 3-Aug-2006 !BSINGH - For WRFCuP scheme
#endif
USE module_cu_osas , ONLY : cu_osas
USE module_cu_camzm_driver, ONLY : camzm_driver
USE module_cu_tiedtke, ONLY : cu_tiedtke
USE module_cu_ntiedtke,ONLY : cu_ntiedtke_driver
USE module_cu_ksas , ONLY : cu_ksas
USE module_cu_nsas , ONLY : cu_nsas
USE module_wrf_error , ONLY : wrf_err_message
! This driver calls subroutines for the cumulus parameterizations.
!
! 1. Kain & Fritsch (1993)
! 2. Betts-Miller-Janjic (Janjic, 1994)
! 3. Grell-Devenyi (Grell and Devenyi, 2002)
! 4. Simplified Arakawa-Schubert scheme (NCEP)
! (adapted by Zhang and Wang to work with ARW in V3.3)
! 5. Grell 3D ensemble scheme
! 6. Modified Tiedtke scheme (Zhang and Wang 2010)
! 14. New simplified Arakawa-Schubert scheme (NCEP, YSU)
! 16. New Tiedtke scheme (Bechtold et al. 2004, 2008, 2014)
!
!----------------------------------------------------------------------
IMPLICIT NONE
!======================================================================
! Grid structure in physics part of WRF
!----------------------------------------------------------------------
! The horizontal velocities used in the physics are unstaggered
! relative to temperature/moisture variables. All predicted
! variables are carried at half levels except w, which is at full
! levels. Some arrays with names (*8w) are at w (full) levels.
!
!----------------------------------------------------------------------
! In WRF, kms (smallest number) is the bottom level and kme (largest
! number) is the top level. In your scheme, if 1 is at the top level,
! then you have to reverse the order in the k direction.
!
! kme - half level (no data at this level)
! kme ----- full level
! kme-1 - half level
! kme-1 ----- full level
! .
! .
! .
! kms+2 - half level
! kms+2 ----- full level
! kms+1 - half level
! kms+1 ----- full level
! kms - half level
! kms ----- full level
!
!======================================================================
! Definitions
!-----------
! Rho_d dry density (kg/m^3)
! Theta_m moist potential temperature (K)
! Qv water vapor mixing ratio (kg/kg)
! Qc cloud water mixing ratio (kg/kg)
! Qr rain water mixing ratio (kg/kg)
! Qi cloud ice mixing ratio (kg/kg)
! Qs snow mixing ratio (kg/kg)
! QCCONV convective cloud mixing ratio (kg/kg)
! QICONV convective ice mixing ratio (kg/kg)
!-----------------------------------------------------------------
!-- DT time step (second)
!-- CUDT cumulus time step (minute)
!-- curr_secs current forecast time (seconds)
!-- itimestep number of time step (integer)
!-- DX horizontal space interval (m)
!-- rr dry air density (kg/m^3)
!
!-- RUCUTEN Zonal wind tendency due to
! cumulus scheme precipitation (m/s/s)
!-- RVCUTEN Meridional wind tendency due to
! cumulus scheme precipitation (m/s/s)
!-- RTHCUTEN Theta tendency due to
! cumulus scheme precipitation (K/s)
!-- RQVCUTEN Qv tendency due to
! cumulus scheme precipitation (kg/kg/s)
!-- RQRCUTEN Qr tendency due to
! cumulus scheme precipitation (kg/kg/s)
!-- RQCCUTEN Qc tendency due to
! cumulus scheme precipitation (kg/kg/s)
!-- RQSCUTEN Qs tendency due to
! cumulus scheme precipitation (kg/kg/s)
!-- RQICUTEN Qi tendency due to
! cumulus scheme precipitation (kg/kg/s)
!
!-- RAINC accumulated total cumulus scheme precipitation (mm)
!-- RAINCV time-step cumulus scheme precipitation (mm)
!-- PRATEC precipitiation rate from cumulus scheme (mm/s)
!-- NCA counter of the cloud relaxation
! time in KF cumulus scheme (integer)
!-- u_phy u-velocity interpolated to theta points (m/s)
!-- v_phy v-velocity interpolated to theta points (m/s)
!-- th_phy potential temperature (K)
!-- t_phy temperature (K)
!-- tsk skin temperature (K)
!-- tke_pbl turbulent kinetic energy from PBL scheme (m2/s2)
!-- ust u* in similarity theory (m/s)
!-- w vertical velocity (m/s)
!-- moist moisture array (4D - last index is species) (kg/kg)
!-- z height above sea level at middle of layers (m)
!-- z_at_w height above sea level at layer interfaces (m)
!-- dz8w dz between full levels (m)
!-- pblh planetary boundary layer height (m)
!-- mavail soil moisture availability
!-- p8w pressure at full levels (Pa)
!-- psfc surface pressure (Pa)
!-- p_phy pressure (Pa)
!-- pi_phy exner function (dimensionless)
! points (dimensionless)
!-- hfx upward heat flux at surface (W/m2)
!-- qfx upward moisture flux at surface (kg/m2/s)
!-- RTHRATEN radiative temp forcing for Grell-Devenyi scheme
!-- RTHBLTEN PBL temp forcing for Grell-Devenyi scheme
!-- RQVBLTEN PBL moisture forcing for Grell-Devenyi scheme
!-- RTHFTEN Advective tendency for theta
!-- RQVFTEN Advective tendency for vapor
!-- MASS_FLUX
!-- XF_ENS
!-- PR_ENS
!-- warm_rain
!-- cldfra cloud fraction
!-- cldfra_mp_all cloud fraction
!-- CU_ACT_FLAG
!-- W0AVG average vertical velocity, (for KF scheme) (m/s)
!-- kfeta_trigger namelist for KF trigger (=1, default; =2, moisture-advection-dependent trigger)
!-- nsas_dx_factor namelist for NSAS deep scheme to have some dependency on grid sizes
!-- rho density (kg/m^3)
!-- CONVCLD Convective cloud (for BMJ scheme) (kg/m^2)
!-- CCLDFRA convective cloud fraction (for BMJ scheme)
!-- CLDEFI precipitation efficiency (for BMJ scheme) (dimensionless)
!-- STEPCU # of fundamental timesteps between convection calls
!-- XLAND land-sea mask (1.0 for land; 2.0 for water)
!-- LOWLYR index of lowest model layer above the ground
!-- XLV0 latent heat of vaporization constant
! used in temperature dependent formula (J/kg)
!-- XLV1 latent heat of vaporization constant
! used in temperature dependent formula (J/kg/K)
!-- XLS0 latent heat of sublimation constant
! used in temperature dependent formula (J/kg)
!-- XLS1 latent heat of sublimation constant
! used in temperature dependent formula (J/kg/K)
!-- R_d gas constant for dry air ( 287. J/kg/K)
!-- R_v gas constant for water vapor (461 J/k/kg)
!-- Cp specific heat at constant pressure (1004 J/k/kg)
!-- rvovrd R_v divided by R_d (dimensionless)
!-- G acceleration due to gravity (m/s^2)
!-- EP_1 constant for virtual temperature
! (R_v/R_d - 1) (dimensionless)
!-- pi_phy the exner function, (p/p0)**(R/Cp) (none unit)
!-- evapcdp3d Evaporation of deep convective precipitation (kg/kg/s)
!-- icwmrdp3d Deep Convection in-cloud water mixing ratio (kg/m2)
!-- rprddp3d dq/dt due to deep convective rainout (kg/kg/s)
!-- ids start index for i in domain
!-- ide end index for i in domain
!-- jds start index for j in domain
!-- jde end index for j in domain
!-- kds start index for k in domain
!-- kde end index for k in domain
!-- ims start index for i in memory
!-- ime end index for i in memory
!-- jms start index for j in memory
!-- jme end index for j in memory
!-- kms start index for k in memory
!-- kme end index for k in memory
!-- i_start start indices for i in tile
!-- i_end end indices for i in tile
!-- j_start start indices for j in tile
!-- j_end end indices for j in tile
!-- kts start index for k in tile
!-- kte end index for k in tile
!-- num_tiles number of tiles
!-- HBOT index of lowest model layer with convection
!-- HTOP index of highest model layer with convection
!-- LBOT index of lowest model layer with convection
!-- LTOP index of highest model layer with convection
!-- KPBL layer index of the PBL
!-- periodic_x T/F this is using periodic lateral boundaries in the X direction
!-- periodic_y T/F this is using periodic lateral boundaries in the Y-direction
!
!======================================================================
INTEGER, INTENT(IN ) :: &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
kts,kte, &
itimestep, num_tiles
LOGICAL periodic_x, periodic_y
TYPE(domain) , INTENT(INOUT) :: grid
INTEGER, DIMENSION(num_tiles), INTENT(IN) :: &
& i_start,i_end,j_start,j_end
INTEGER, INTENT(IN ) :: &
ensdim,maxiens,maxens,maxens2,maxens3
INTEGER, OPTIONAL, INTENT(IN ) :: &
cugd_avedx,clos_choice,bl_pbl_physics,sf_sfclay_physics
#if (EM_CORE == 1)
!BSINGH - For WRFCuP scheme
INTEGER, OPTIONAL, INTENT(IN ) :: &
shcu_aerosols_opt !CuP, rce 10-may-2012
!BSINGH - ENDS
#endif
INTEGER, INTENT(IN ) :: cu_physics
INTEGER, INTENT(IN ) :: STEPCU
LOGICAL, INTENT(IN ) :: warm_rain
LOGICAL, INTENT(IN ) :: is_CAMMGMP_used !BSINGH:01/31/2013: Added for CAMZM
REAL, INTENT(IN), OPTIONAL :: pgcon,shal_pgcon,sas_mass_flux
logical,intent(in),optional :: pert_sas
integer,intent(in),optional :: ens_random_seed
real,intent(in),optional :: ens_sasamp
INTEGER, INTENT(IN), OPTIONAL :: shalconv
INTEGER,DIMENSION( ims:ime, jms:jme ), &
INTENT(IN ) :: LOWLYR
!BSINGH - For WRFCuP scheme
REAL,DIMENSION( ims:ime, jms:jme ), &
INTENT(INOUT) :: shall !CuP, wig 18-Sep-2006
#if (EM_CORE == 1)
!BSINGH - For WRFCuP scheme
REAL,DIMENSION( ims:ime, jms:jme ), &
INTENT(INOUT) :: taucloud, & !CuP, wig 1-Oct-2006
tactive, & !CuP, wig 1-Oct-2006
activeFrac, & !CuP, lkb 5-May-2010
wCloudBase !CuP, lkb 29-April-2010
!BSINGH - ENDS
#endif
REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
INTENT(IN ) :: &
z &
, dz8w &
, p8w &
, p &
, pi &
, u &
, v &
, th &
, t &
, rho ! ckay
!ckay
REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
INTENT(INout ) :: w
REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), INTENT(OUT ), OPTIONAL :: evapcdp3d, icwmrdp3d, rprddp3d
REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
INTENT(IN ),OPTIONAL :: z_at_w &
, cldfra &
, cldfra_mp_all &
, tke_pbl
REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
INTENT(INOUT) :: &
W0AVG &
, CCLDFRA &
, QCCONV &
, QICONV
!ckay
REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
INTENT(INOUT) :: cldfra_dp &
, cldfra_sh
!kf_edrates
REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
INTENT(INOUT) :: udr_kf &
, ddr_kf &
, uer_kf &
, der_kf
REAL, DIMENSION( ims:ime , jms:jme ), INTENT(INOUT) :: &
timec_kf
INTEGER, INTENT(IN ) :: kf_edrates
REAL, DIMENSION( ims:ime , jms:jme ), INTENT(IN) :: &
GSW,HT,XLAND
#if (EM_CORE == 1)
!BSINGH - For WRFCuP scheme
REAL, DIMENSION( ims:ime , jms:jme ), INTENT(IN) :: &
br, & !CuP, wig 3-Aug-2006
regime, & !CuP, wig 3-Aug-2006
t2, & !CuP, wig 3-Aug-2006
q2 !CuP, wig 3-Aug-2006
!BSINGH - ENDS
#endif
REAL, DIMENSION( ims:ime , jms:jme ), &
INTENT(INOUT) :: RAINC &
, RAINCV &
, NCA &
, HTOP &
, HBOT &
, CLDEFI &
, CONVCLD
#if (EM_CORE == 1)
REAL, DIMENSION( ims:ime , jms:jme ), INTENT(INOUT) :: akpbl !CuP, wig 6-Oct-2006 testing !BSINGH - For WRFCuP scheme
#endif
REAL, DIMENSION( kms:kme ), OPTIONAL, INTENT(IN ) :: &
znu
REAL, DIMENSION( ims:ime , jms:jme ),INTENT(INOUT),OPTIONAL :: &
PRATEC,MAVAIL,PBLH,PSFC,TSK,TPERT2D,UST,HFX,QFX
REAL, DIMENSION( ims:ime , jms:jme ),INTENT(INOUT) :: &
HPBL_HOLD
!ckay
REAL, DIMENSION( ims:ime , jms:jme ), &
OPTIONAL, INTENT(INOUT) :: ZOL
REAL, DIMENSION( ims:ime , jms:jme ) :: tmppratec
INTEGER, DIMENSION( ims:ime , jms:jme ), &
INTENT(IN) :: KPBL
LOGICAL, DIMENSION( ims:ime , jms:jme ), &
INTENT(INOUT) :: CU_ACT_FLAG
INTEGER, INTENT(IN ), OPTIONAL :: kfeta_trigger
INTEGER, INTENT(IN ), OPTIONAL :: nsas_dx_factor
REAL, INTENT(IN ) :: DT, DX
REAL, DIMENSION( ims:ime , jms:jme ), OPTIONAL, &
INTENT(IN) :: DX2D, AREA2D
INTEGER, INTENT(IN ),OPTIONAL :: &
ips,ipe, jps,jpe, kps,kpe,imomentum,ishallow
REAL, INTENT(IN ),OPTIONAL :: CUDT
REAL, INTENT(IN ),OPTIONAL :: CURR_SECS
LOGICAL,INTENT(IN ),OPTIONAL :: adapt_step_flag
LOGICAL,INTENT(IN ) :: bmj_rad_feedback
REAL, INTENT(INOUT ),OPTIONAL :: cudtacttime
REAL :: cudt_pass, curr_secs_pass,cudtacttime_pass
LOGICAL :: adapt_step_flag_pass
INTEGER, INTENT(IN ), OPTIONAL :: mp_physics
REAL, DIMENSION( ims:ime , jms:jme ), OPTIONAL, INTENT(IN) :: STORE_RAND
!
REAL, OPTIONAL, INTENT(INOUT) :: mommix
REAL, OPTIONAL, INTENT(IN) :: DYNMM ! For scale-aware SAS
REAL, DIMENSION( ims:ime , jms:jme ), OPTIONAL,INTENT(INOUT) :: &
SCALEFUN,SCALEFUN1,SIGMU,SIGMU1
REAL, DIMENSION( ims:ime , jms:jme ), OPTIONAL, & !Kwon for sas2010 shallow convection
INTENT(INOUT) :: HPBL2D, EVAP2D, HEAT2D
!
REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
INTENT(INOUT) :: rucuten,rvcuten
!
! optional arguments
!
INTEGER, DIMENSION( ims:ime, jms:jme ), &
OPTIONAL, INTENT(INOUT) :: &
k22_shallow,kbcon_shallow,ktop_shallow,ideep2d,jt2d,maxg2d, &
lengath2d
INTEGER, DIMENSION( ims:ime, jms:jme ), &
OPTIONAL, INTENT( OUT) :: ktop_deep
REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
OPTIONAL, INTENT(INOUT) :: &
! optional moisture tracers
! 2 time levels; if only one then use CURR
qv_curr, qc_curr, qr_curr &
,qi_curr, qs_curr, qg_curr &
,qv_prev, qc_prev, qr_prev &
,qi_prev, qs_prev, qg_prev &
! optional moisture and other tendencies
,rqvcuten,rqccuten,rqrcuten &
,rqicuten,rqscuten,rqgcuten &
,rqcncuten,rqincuten &
,rqvblten,rqvften &
,rthraten,rthblten &
,cugd_tten,cugd_qvten,cugd_qcten &
,cugd_ttens,cugd_qvtens &
,forcet, forceq &
,rthften,rthcuten
REAL, DIMENSION( ims:ime , jms:jme ), &
OPTIONAL, &
INTENT(INOUT) :: &
apr_gr,apr_w,apr_mc,apr_st,apr_as,apr_capma &
,apr_capme,apr_capmi,edt_out,xmb_shallow &
, MASS_FLUX &
,cape, pconvb, pconvt, preccdzm, precz, rliq &
,dsubcld2d
REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
OPTIONAL, INTENT(INOUT) :: &
GD_CLOUD,GD_CLOUD2, &
zmmd, zmmu, zmdt, zmdq, dlf, &
evaptzm, fzsntzm, evsntzm, evapqzm, zmflxprc, &
zmflxsnw, zmntprpd, zmntsnpd, zmeiheat, &
cmfmc, cmfmcdzm, &
zmmtu, zmmtv, zmupgu, zmupgd, zmvpgu, zmvpgd, &
zmicuu, zmicud, zmicvu, zmicvd, zmdice, zmdliq,&
dp3d, du3d, ed3d, eu3d, md3d, mu3d
REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
INTENT(INOUT) :: &
QC_CU,QI_CU
#if (EM_CORE == 1)
REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
INTENT(INOUT) :: &
QR_CU,QS_CU, &
NC_CU,NI_CU,NR_CU,NS_CU,CCN_CU, &
EFCS,EFIS,EFSS
REAL, DIMENSION( ims:ime, jms:jme ), &
INTENT(INOUT) :: &
CU_UAF
#endif
REAL, DIMENSION( ims:ime , jms:jme , 1:ensdim ), &
OPTIONAL, &
INTENT(INOUT) :: XF_ENS, PR_ENS
#if (EM_CORE == 1)
!BSINGH - For WRFCuP Scheme
REAL, DIMENSION( ims:ime , jms:jme ), &
INTENT(OUT) :: slopeSfc, slopeEZ, & !CuP, wig 7-Aug-2006
sigmaSfc, SigmaEZ, & !CuP, wig 7-Aug-2006
tstar, & !CuP, wig 4-Oct-2006
lnint !CuP, wig 4-Oct-2006
REAL, DIMENSION( ims:ime , kms:kme, jms:jme ), &
INTENT(OUT) :: &
lnterms, & !CuP, wig 4-Oct-2006
cldfra_cup, & !CuP, wig 18-Sep-2006
cldfratend_cup !CuP, wig 18-Sep-2006
REAL, DIMENSION( ims:ime , jms:jme ), &
INTENT(INOUT) :: wact_cup, & !CuP, rce 10-may-2012
wulcl_cup, & !CuP, rce 10-may-2012
tcloud_cup !CuP, rce 10-may-2012
REAL, DIMENSION( ims:ime , kms:kme, jms:jme ), &
INTENT(INOUT) :: &
wup_cup, & !CuP, rce 15-mar-2013 !BSINGH (12/06/2013)
qc_ic_cup, & !CuP, rce 10-may-2012
qndrop_ic_cup, & !CuP, rce 10-may-2012
qc_iu_cup, & !CuP, rce 10-may-2012
fcvt_qc_to_pr_cup, & !CuP, rce 10-may-2012
fcvt_qc_to_qi_cup, & !CuP, rce 10-may-2012
fcvt_qi_to_pr_cup, & !CuP, rce 10-may-2012
mfup_cup, & !CuP, rce 10-may-2012
mfup_ent_cup, & !CuP, rce 10-may-2012
mfdn_cup, & !CuP, rce 10-may-2012
mfdn_ent_cup, & !CuP, rce 10-may-2012
updfra_cup !CuP, rce 10-may-2012
INTEGER, OPTIONAL, INTENT(IN) :: chem_opt !CuP, rce 10-may-2012
#if ( WRF_CHEM == 1 )
INTEGER, OPTIONAL, INTENT(IN) :: traceropt, &
conv_tr_wetscav, &
conv_tr_aqchem, &
chem_conv_tr
INTEGER :: numgas
#endif
LOGICAL, DIMENSION( ims:ime, jms:jme ), &
INTENT(OUT) :: cupflag !CuP, wig 9-Oct-2006
REAL, INTENT(IN ) :: thBinSize, rBinSize
INTEGER, INTENT(IN ) :: numBins
REAL, INTENT(IN ) :: minDeepFreq, minShallowFreq
!BSINGH - ENDS
#endif
REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), &
OPTIONAL, &
INTENT(INOUT) :: &
CFU1, &
CFD1, &
DFU1, &
EFU1, &
DFD1, &
EFD1
!
! Flags relating to the optional tendency arrays declared above
! Models that carry the optional tendencies will provdide the
! optional arguments at compile time; these flags all the model
! to determine at run-time whether a particular tracer is in
! use or not.
!
LOGICAL, INTENT(IN), OPTIONAL :: &
f_qv &
,f_qc &
,f_qr &
,f_qi &
,f_qs &
,f_qg
LOGICAL, INTENT(IN), OPTIONAL :: f_flux
!beka - random pattern arrays, if not existing, set to zero
!
! REAL, DIMENSION( ims:ime, kms:kme, jms:jme ),INTENT(INOUT),OPTIONAL :: &
! pattern_spp_conv,field_conv
! INTEGER, OPTIONAL :: spp_conv
REAL, DIMENSION( ims:ime, kms:kme, jms:jme ) :: &
pattern_spp_conv,field_conv
INTEGER :: spp_conv
#if ( WRF_DFI_RADAR == 1 )
!
! option of cap suppress:
! do_capsuppress = 1 do
! do_capsuppress = other don't
!
!
INTEGER, INTENT(IN ) ,OPTIONAL :: do_capsuppress
REAL, DIMENSION( ims:ime, jms:jme ) :: cap_suppress_loc
#endif
! LOCAL VAR
INTEGER :: i,j,k,its,ite,jts,jte,ij,trigger_kf,dx_factor_nsas
logical :: l_flux
LOGICAL :: decided , run_param , doing_adapt_dt
#if (EM_CORE == 1)
INTEGER, INTENT(IN) :: alevsiz_cu, num_months, no_src_types_cu
INTEGER, INTENT(IN) :: aercu_opt
REAL, INTENT(IN) :: aercu_fct
REAL, DIMENSION( ims:ime, alevsiz_cu, jms:jme, num_months, no_src_types_cu) :: aeromcu
REAL, DIMENSION( ims:ime, alevsiz_cu, jms:jme, no_src_types_cu) :: aerotcu
REAL, DIMENSION( ims:ime, alevsiz_cu, jms:jme, num_months) :: aeropcu
REAL, DIMENSION( ims:ime, alevsiz_cu, jms:jme ) :: aeroptcu
REAL, DIMENSION( ims:ime, kms:kme, jms:jme, no_src_types_cu) :: aerocu
REAL, DIMENSION( ims:ime, kms:kme, jms:jme) :: aerovar
REAL, INTENT(IN) :: JULIAN
INTEGER, INTENT(IN) :: id
INTEGER, INTENT(IN) :: JULDAY
#endif
! To accommodate shared physics
character*256 :: errmsg
integer :: errflg
!-----------------------------------------------------------------
pattern_spp_conv=0.
field_conv=0.
spp_conv=0
l_flux=.FALSE.
if (present(f_flux)) l_flux=f_flux
if (.not. PRESENT(CURR_SECS)) then
curr_secs_pass = -1
else
curr_secs_pass = curr_secs
endif
if (.not. PRESENT(CUDT)) then
cudt_pass = -1
cudtacttime_pass = -1
else
cudt_pass = cudt
cudtacttime_pass = cudtacttime
endif
if (.not. PRESENT(adapt_step_flag)) then
adapt_step_flag_pass = .false.
else
adapt_step_flag_pass = adapt_step_flag
endif
! Initialize tmppratec to pratec
if ( PRESENT ( pratec ) ) then
tmppratec(:,:) = pratec(:,:)
else
tmppratec(:,:) = 0.
end if
if (.not. PRESENT(kfeta_trigger)) then
trigger_kf = 1
else
trigger_kf = kfeta_trigger
endif
if (.not. PRESENT(nsas_dx_factor)) then
dx_factor_nsas = 0
else
dx_factor_nsas = nsas_dx_factor
endif
IF (cu_physics .eq. 0) return
! Initialization for adaptive time step.
IF ( adapt_step_flag_pass ) THEN
doing_adapt_dt = .TRUE.
IF ( cudtacttime_pass .EQ. 0. ) THEN
cudtacttime_pass = curr_secs_pass + cudt_pass*60.
END IF
ELSE
doing_adapt_dt = .FALSE.
END IF
! Do we run through this scheme or not?
! Test 1: If this is the initial model time, then yes.
! ITIMESTEP=1
! Test 2: If the user asked for the cumulus to be run every time step, then yes.
! CUDT=0 or STEPCU=1
! Test 3: If not adaptive dt, and this is on the requested cumulus frequency, then yes.
! MOD(ITIMESTEP,STEPCU)=0
! Test 4: If using adaptive dt and the current time is past the last requested activate cumulus time, then yes.
! CURR_SECS >= CUDTACTTIME
! If we do run through the scheme, we set the flag run_param to TRUE and we set the decided flag
! to TRUE. The decided flag says that one of these tests was able to say "yes", run the scheme.
! We only proceed to other tests if the previous tests all have left decided as FALSE.
! If we set run_param to TRUE and this is adaptive time stepping, we set the time to the next
! cumulus run.
decided = .FALSE.
run_param = .FALSE.
IF ( ( .NOT. decided ) .AND. &
( itimestep .EQ. 1 ) ) THEN
run_param = .TRUE.
decided = .TRUE.
END IF
IF ( ( .NOT. decided ) .AND. &
( ( cudt_pass .EQ. 0. ) .OR. ( stepcu .EQ. 1 ) ) ) THEN
run_param = .TRUE.
decided = .TRUE.
END IF
IF ( ( .NOT. decided ) .AND. &
( .NOT. doing_adapt_dt ) .AND. &
( MOD(itimestep,stepcu) .EQ. 0 ) ) THEN
run_param = .TRUE.
decided = .TRUE.
END IF
IF ( ( .NOT. decided ) .AND. &
( doing_adapt_dt ) .AND. &
( curr_secs_pass .GE. cudtacttime_pass ) ) THEN
run_param = .TRUE.
decided = .TRUE.
cudtacttime_pass = curr_secs_pass + cudt_pass*60
END IF
IF ( run_param ) THEN
!print *,'calling CU scheme'
ELSE
!print *,'NOT calling CU scheme'
RETURN
END IF
#if ( EM_CORE == 1 )
if(cu_physics == G3SCHEME .or. cu_physics == NTIEDTKESCHEME) then
!$OMP PARALLEL DO &
!$OMP PRIVATE ( ij,i,j,k,its,ite,jts,jte )
DO ij = 1 , num_tiles
its = i_start(ij)
ite = i_end(ij)
jts = j_start(ij)
jte = j_end(ij)
do j=jts,min(jte,jde-1)
do k=kts,kte
do i=its,min(ite,ide-1)
RTHFTEN(i,k,j)=(RTHFTEN(i,k,j)+RTHRATEN(i,k,j) &
+RTHBLTEN(i,k,j))*pi(i,k,j)
RQVFTEN(i,k,j)=RQVFTEN(i,k,j)+RQVBLTEN(i,k,j)
enddo
enddo
enddo
ENDDO
!$OMP END PARALLEL DO
endif
IF ( cu_physics == G3SCHEME .OR. cu_physics == GFSCHEME .OR. &
cu_physics == KFETASCHEME .OR. cu_physics == MSKFSCHEME) THEN
#ifdef DM_PARALLEL
#include "HALO_CUP_G3_IN.inc"
#endif
ENDIF
#endif
! DON'T JUDGE TIME STEP HERE, SINCE KF NEEDS ACCUMULATED W FIELD.
! DO IT INSIDE THE INDIVIDUAL CUMULUS SCHEME
! SET START AND END POINTS FOR TILES
!$OMP PARALLEL DO &
!$OMP PRIVATE ( ij ,its,ite,jts,jte, i,j,k)
DO ij = 1 , num_tiles
its = i_start(ij)
ite = i_end(ij)
jts = j_start(ij)
jte = j_end(ij)
#if (EM_CORE == 1)
!BSINGH - For WRFCuP scheme
!wig, beg: testing for kpbl to get output to wrfout since kpbl won't output as an integer
do j=jts,jte
do i=its,ite
akpbl(i,j) = kpbl(i,j)
end do
end do
!wig, end.
!BSINGH - ENDS
!The following is for introducing aerosol data into the MSKF scheme !
!If the flag is set, the aerosol data will be interpolated in !
!time and then pressure to the current state.
IF ( aercu_opt .GT. 0 ) THEN
IF ( aercu_opt .GT. 0 .AND. id .EQ. 1 ) THEN
call aer_time_int_cu(julday,julian,aeromcu,aerotcu,alevsiz_cu,num_months,no_src_types_cu,&
ids , ide , jds , jde , kds , kde , &
ims , ime , jms , jme , kms , kme , &
its , ite , jts , jte , kts , kte )
! INTERPOLATE PRESSURE IN TIME
call aer_time_int_cu(julday,julian,aeropcu,aeroptcu,alevsiz_cu,num_months,1, &
ids , ide , jds , jde , kds , kde , &
ims , ime , jms , jme , kms , kme , &
its , ite , jts , jte , kts , kte )
call aer_p_int_cu(p ,aeroptcu, alevsiz_cu, aerotcu, aerocu, no_src_types_cu, p8w, &
ids , ide , jds , jde , kds , kde , &
ims , ime , jms , jme , kms , kme , &
its , ite , jts , jte , kts , kte )
do j=jts,jte
do k=kts,kte
do i=its,ite
aerovar(i,k,j)=aerocu(i,k,j,2)
end do
end do
end do
ENDIF
ENDIF
#endif
cps_select: SELECT CASE(cu_physics)
CASE (KFSCHEME)
CALL wrf_debug(100,'in kfcps')
CALL KFCPS( &
! order independent arguments
DT=dt ,KTAU=itimestep ,DX=dx , CUDT=cudt_pass &
,ADAPT_STEP_FLAG=adapt_step_flag_pass &
,RHO=rho &
,U=u ,V=v ,TH=th ,T=t ,W=w &
,PCPS=p ,PI=pi &
,XLV0=xlv0 ,XLV1=xlv1 ,XLS0=xls0 ,XLS1=xls1 &
,RAINCV=raincv, PRATEC=tmppratec, NCA=nca &
,DZ8W=dz8w &
,W0AVG=w0avg &
,CP=cp ,R=r_d ,G=g ,EP1=ep_1 ,EP2=ep_2 &
,SVP1=svp1 ,SVP2=svp2 ,SVP3=svp3 ,SVPT0=svpt0 &
,STEPCU=stepcu &
,CU_ACT_FLAG=cu_act_flag &
,WARM_RAIN=warm_rain &
,QV=qv_curr &
,IDS=ids,IDE=ide,JDS=jds,JDE=jde,KDS=kds,KDE=kde &
,IMS=ims,IME=ime,JMS=jms,JME=jme,KMS=kms,KME=kme &
,ITS=its,ITE=ite,JTS=jts,JTE=jte,KTS=kts,KTE=kte &
! optionals
,RTHCUTEN=rthcuten ,RQVCUTEN=rqvcuten &
,RQCCUTEN=rqccuten ,RQRCUTEN=rqrcuten &
,RQICUTEN=rqicuten ,RQSCUTEN=rqscuten &
,F_QV=f_qv,F_QC=f_qc,F_QR=f_qr &
,F_QI=f_qi,F_QS=f_qs &
,UDR_KF=udr_kf,DDR_KF=ddr_kf & !kf_edrates
,UER_KF=uer_kf,DER_KF=der_kf &
,TIMEC_KF=timec_kf,KF_EDRATES=kf_edrates &
)
CASE (BMJSCHEME)
CALL wrf_debug(100,'in bmj_cps')
CALL BMJDRV( &
TH=th,T=T ,RAINCV=raincv, PRATEC=tmppratec &
,RHO=rho &
,DT=dt ,ITIMESTEP=itimestep ,STEPCU=stepcu &
,CUTOP=htop, CUBOT=hbot, KPBL=kpbl &
,DZ8W=dz8w ,PINT=p8w, PMID=p, PI=pi &
,CP=cp ,R=r_d ,ELWV=xlv ,ELIV=xls ,G=g &