This repository has been archived by the owner on Nov 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
/
module_cu_mskf.F
3431 lines (3285 loc) · 121 KB
/
module_cu_mskf.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
MODULE module_cu_mskf
USE module_wrf_error
!
!ckay=Kiran Alapaty, EPA
!CGM = Chris Marciano, NCSU
!
!multi-scale KF scheme
! (1) With diagnosed deep and shallow KF cloud fraction using
! CAM3-CAM5 methodology, along with captured liquid and ice condensates.
! and linking with the RRTMG & Other radiation schemes
! (2) Scale-dependent Dynamic adjustment timescale for KF clouds (both shallow and deep)
! (3) Scale-dependent LCL-based entrainment Methodology that avoids 2-km cloud radius method
! (4) Scale-dependent Fallout Rate
! (5) Scale-dependent Stabilization Capacity
! (6) Elimination of "double counting" when environment is saturated
!
! Alapaty et al., 2012: Introducing subgrid-scale cloud feedbacks to radiation
! for regional meteorological and climate modeling. GRL, V39, I24.
!
! Alapaty et al., 2013: The Kain-Fritsch Scheme: Science Updates and revisiting
! gray-scale issues from the NWP and regional climate perspectives. 2013 WRF
! workshop: URL: http://www.mmm.ucar.edu/wrf/users/workshops/WS2013/ppts/9.2.pdf
!
! Herwehe et al., 2014: Increasing the credibility of regional climate simulations
! by introducing subgrid-scale cloud-radiation interactions. JGR, 119,
! 5317-5330, doi:10.1002/2014JD021504.
!
! Zheng et al., 2015: Improving High-Resolution Weather Forecasts using the
! Weather Research and Forecasting (WRF) Model with an Updated Kain-Fritsch
! Scheme. Revision - Mon. Wea. Rev.
!ckay
!--------------------------------------------------------------------
! Lookup table variables:
INTEGER, PARAMETER :: KFNT=250,KFNP=220
REAL, DIMENSION(KFNT,KFNP),PRIVATE, SAVE :: TTAB,QSTAB
REAL, DIMENSION(KFNP),PRIVATE, SAVE :: THE0K
REAL, DIMENSION(200),PRIVATE, SAVE :: ALU
REAL, PRIVATE, SAVE :: RDPR,RDTHK,PLUTOP
! Note: KF Lookup table is used by subroutines KF_eta_PARA, TPMIX2,
! TPMIX2DD, ENVIRTHT
! End of Lookup table variables:
CONTAINS
SUBROUTINE MSKF_CPS( &
ids,ide, jds,jde, kds,kde &
,ims,ime, jms,jme, kms,kme &
,its,ite, jts,jte, kts,kte &
,trigger &
,DT,KTAU,DX,CUDT,ADAPT_STEP_FLAG &
,rho,RAINCV,PRATEC,NCA &
,U,V,TH,T,W,dz8w,Pcps,pi &
,W0AVG,XLV0,XLV1,XLS0,XLS1,CP,R,G,EP1 &
,EP2,SVP1,SVP2,SVP3,SVPT0 &
,STEPCU,CU_ACT_FLAG,warm_rain,CUTOP,CUBOT &
,QV &
! optionals
,F_QV ,F_QC ,F_QR ,F_QI ,F_QS &
,RTHCUTEN,RQVCUTEN,RQCCUTEN,RQRCUTEN &
,RQICUTEN,RQSCUTEN, RQVFTEN &
!ckay
,cldfra_dp_KF,cldfra_sh_KF,w_up &
,qc_KF,qi_KF &
!kf_edrates
,UDR_KF,DDR_KF &
,UER_KF,DER_KF &
,TIMEC_KF,KF_EDRATES &
,ZOL,WSTAR,UST,PBLH & !ckay
)
!
!-------------------------------------------------------------
IMPLICIT NONE
!-------------------------------------------------------------
INTEGER, INTENT(IN ) :: &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte
INTEGER, INTENT(IN ) :: trigger
INTEGER, INTENT(IN ) :: STEPCU
LOGICAL, INTENT(IN ) :: warm_rain
REAL, INTENT(IN ) :: XLV0,XLV1,XLS0,XLS1
REAL, INTENT(IN ) :: CP,R,G,EP1,EP2
REAL, INTENT(IN ) :: SVP1,SVP2,SVP3,SVPT0
INTEGER, INTENT(IN ) :: KTAU
REAL, DIMENSION( ims:ime , kms:kme , jms:jme ) , &
INTENT(IN ) :: &
U, &
V, &
!ckay W, &
TH, &
T, &
QV, &
dz8w, &
Pcps, &
rho, &
pi
!
REAL, DIMENSION( ims:ime , kms:kme , jms:jme ) , &
INTENT(INOUT) :: &
W0AVG
REAL, INTENT(IN ) :: DT, DX
REAL, INTENT(IN ) :: CUDT
LOGICAL,OPTIONAL,INTENT(IN ) :: ADAPT_STEP_FLAG
!
REAL, DIMENSION( ims:ime , jms:jme ), &
INTENT(INOUT) :: RAINCV
REAL, DIMENSION( ims:ime , jms:jme ), &
INTENT(INOUT) :: PRATEC
REAL, DIMENSION( ims:ime , jms:jme ), &
INTENT(INOUT) :: NCA
REAL, DIMENSION( ims:ime , jms:jme ), &
INTENT(OUT) :: CUBOT, &
CUTOP
LOGICAL, DIMENSION( ims:ime , jms:jme ), &
INTENT(INOUT) :: CU_ACT_FLAG
!
! Optional arguments
!
REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), &
OPTIONAL, &
INTENT(INOUT) :: &
RTHCUTEN, &
RQVCUTEN, &
RQCCUTEN, &
RQRCUTEN, &
RQICUTEN, &
RQSCUTEN, &
RQVFTEN
!
! 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, OPTIONAL :: &
F_QV &
,F_QC &
,F_QR &
,F_QI &
,F_QS
!ckay
REAL, DIMENSION( ims:ime , kms:kme , jms:jme ) , &
INTENT(INOUT) :: &
cldfra_dp_KF, &
cldfra_sh_KF, &
qc_KF, &
qi_KF, &
W
!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
!ckay
REAL, DIMENSION( ims:ime, jms:jme ) , &
INTENT( IN) :: ZOL, &
WSTAR, &
UST, &
PBLH
!ckaywup
REAL, DIMENSION( ims:ime, kms:kme , jms:jme ) , &
INTENT(INOUT) :: w_up
! LOCAL VARS
LOGICAL :: flag_qr, flag_qi, flag_qs
REAL, DIMENSION( kts:kte ) :: &
U1D, &
V1D, &
T1D, &
DZ1D, &
QV1D, &
P1D, &
RHO1D, &
tpart_v1D, &
tpart_h1D, &
W0AVG1D
REAL, DIMENSION( kts:kte ):: &
DQDT, &
DQIDT, &
DQCDT, &
DQRDT, &
DQSDT, &
DTDT
REAL, DIMENSION (its-1:ite+1,kts:kte,jts-1:jte+1) :: aveh_t, aveh_q
REAL, DIMENSION (its:ite,kts:kte,jts:jte) :: aveh_qmax, aveh_qmin
REAL, DIMENSION (its:ite,kts:kte,jts:jte) :: avev_t, avev_q
REAL, DIMENSION (its:ite,kts:kte,jts:jte) :: avev_qmax, avev_qmin
REAL, DIMENSION (its:ite,kts:kte,jts:jte) :: coef_v, coef_h, tpart_h, tpart_v
INTEGER :: ii,jj,kk
REAL :: ttop
REAL, DIMENSION (kts:kte) :: z0
REAL :: TST,tv,PRS,RHOE,W0,SCR1,DXSQ,tmp
integer :: ibegh,iendh,jbegh,jendh
integer :: istart,iend,jstart,jend
INTEGER :: i,j,k,NTST
REAL :: lastdt = -1.0
REAL :: W0AVGfctr, W0fctr, W0den
!
DXSQ=DX*DX
!----------------------
NTST=STEPCU
TST=float(NTST*2)
flag_qr = .FALSE.
flag_qi = .FALSE.
flag_qs = .FALSE.
IF ( PRESENT(F_QR) ) flag_qr = F_QR
IF ( PRESENT(F_QI) ) flag_qi = F_QI
IF ( PRESENT(F_QS) ) flag_qs = F_QS
!
if (lastdt < 0) then
lastdt = dt
endif
if (ADAPT_STEP_FLAG) then
W0AVGfctr = 2 * MAX(CUDT*60,dt) - dt
W0fctr = dt
W0den = 2 * MAX(CUDT*60,dt)
else
W0AVGfctr = (TST-1.)
W0fctr = 1.
W0den = TST
endif
DO J = jts,jte
DO K=kts,kte
DO I= its,ite
! SCR1=-5.0E-4*G*rho(I,K,J)*(w(I,K,J)+w(I,K+1,J))
! TV=T(I,K,J)*(1.+EP1*QV(I,K,J))
! RHOE=Pcps(I,K,J)/(R*TV)
! W0=-101.9368*SCR1/RHOE
W0=0.5*(w(I,K,J)+w(I,K+1,J))
! Old:
!
! W0AVG(I,K,J)=(W0AVG(I,K,J)*(TST-1.)+W0)/TST
!
! New, to support adaptive time step:
!
W0AVG(I,K,J) = ( W0AVG(I,K,J) * W0AVGfctr + W0 * W0fctr ) / W0den
!ckaywup
! w(I,K,J)=w(I,K,J)+w_up(i,K,j)
ENDDO
ENDDO
ENDDO
lastdt = dt
! New trigger function
IF (trigger.eq.2) THEN
!
! calculate 9-point average of moisture advection and temperature using halo (Horizontal)
!
aveh_t=-999 ! horizontal 9-point ave
aveh_q=-999
avev_t=0 ! vertical 3-level ave
avev_q=0
avev_qmax=0
avev_qmin=0
aveh_qmax=0
aveh_qmin=0
tpart_h=0
tpart_v=0
coef_h=0
coef_v=0
ibegh=max(its-1, ids+1) ! start from 2
jbegh=max(jts-1, jds+1)
iendh=min(ite+1, ide-2) ! end at ide-2
jendh=min(jte+1, jde-2)
DO J = jbegh,jendh
DO K = kts,kte
DO I = ibegh,iendh
aveh_t(i,k,j)=(T(i-1,k,j-1)+T(i-1,k,j) +T(i-1,k,j+1)+ &
T(i,k,j-1) +T(i,k,j) +T(i,k,j+1)+ &
T(i+1,k,j-1) +T(i+1,k,j) +T(i+1,k,j+1))/9.
aveh_q(i,k,j)=(rqvften(i-1,k,j-1)+rqvften(i-1,k,j) +rqvften(i-1,k,j+1)+ &
rqvften(i,k,j-1) +rqvften(i,k,j) +rqvften(i,k,j+1)+ &
rqvften(i+1,k,j-1) +rqvften(i+1,k,j) +rqvften(i+1,k,j+1))/9.
ENDDO
ENDDO
ENDDO
! boundary value ( all processors will do the following? Or just those processsors handling sub-area including boundary)
DO K = kts,kte
DO J = jts-1,jte+1
DO I = its-1,ite+1
if(i.eq.ids) then
aveh_t(i,k,j)=aveh_t(i+1,k,j)
aveh_q(i,k,j)=aveh_q(i+1,k,j)
elseif(i.eq.ide-1) then
aveh_t(i,k,j)=aveh_t(i-1,k,j)
aveh_q(i,k,j)=aveh_q(i-1,k,j)
endif
if(j.eq.jds) then
aveh_t(i,k,j)=aveh_t(i,k,j+1)
aveh_q(i,k,j)=aveh_q(i,k,j+1)
elseif(j.eq.jde-1) then
aveh_t(i,k,j)=aveh_t(i,k,j-1)
aveh_q(i,k,j)=aveh_q(i,k,j-1)
endif
if(j.eq.jds.and.i.eq.ids) then
aveh_q(i,k,j)=aveh_q(i+1,k,j+1)
aveh_t(i,k,j)=aveh_t(i+1,k,j+1)
endif
if(j.eq.jde-1.and.i.eq.ids) then
aveh_q(i,k,j)=aveh_q(i+1,k,j-1)
aveh_t(i,k,j)=aveh_t(i+1,k,j-1)
endif
if(j.eq.jde-1.and.i.eq.ide-1) then
aveh_q(i,k,j)=aveh_q(i-1,k,j-1)
aveh_t(i,k,j)=aveh_t(i-1,k,j-1)
endif
if(j.eq.jds.and.i.eq.ide-1) then
aveh_q(i,k,j)=aveh_q(i-1,k,j+1)
aveh_t(i,k,j)=aveh_t(i-1,k,j+1)
endif
ENDDO
ENDDO
ENDDO
! search for max/min moisture advection in 9-point range, calculate horizontal T-perturbation (tpart_h)
istart=max(its, ids+1) ! start from 2
jstart=max(jts, jds+1)
iend=min(ite, ide-2) ! end at ide-2
jend=min(jte, jde-2)
DO K = kts,kte
DO J = jstart,jend
DO I = istart,iend
aveh_qmax(i,k,j)=aveh_q(i,k,j)
aveh_qmin(i,k,j)=aveh_q(i,k,j)
DO ii=-1, 1
DO jj=-1,1
if(aveh_q(i+II,k,j+JJ).gt.aveh_qmax(i,k,j)) aveh_qmax(i,k,j)=aveh_q(i+II,k,j+JJ)
if(aveh_q(i+II,k,j+JJ).lt.aveh_qmin(i,k,j)) aveh_qmin(i,k,j)=aveh_q(i+II,k,j+JJ)
ENDDO
ENDDO
if(aveh_qmax(i,k,j).gt.aveh_qmin(i,k,j))then
coef_h(i,k,j)=(aveh_q(i,k,j)-aveh_qmin(i,k,j))/(aveh_qmax(i,k,j)-aveh_qmin(i,k,j))
else
coef_h(i,k,j)=0.
endif
coef_h(i,k,j)=amin1(coef_h(i,k,j),1.0)
coef_h(i,k,j)=amax1(coef_h(i,k,j),0.0)
tpart_h(i,k,j)=coef_h(i,k,j)*(T(i,k,j)-aveh_t(i,k,j))
ENDDO
ENDDO
ENDDO
89 continue
! vertical 3-layer calculation
DO J = jts, jte
DO I = its, ite
z0(1) = 0.5 * dz8w(i,1,j)
DO K = 2, kte
Z0(K) = Z0(K-1) + .5 * (DZ8W(i,K,j) + DZ8W(i,K-1,j))
ENDDO
DO K = kts+1,kte-1
ttop = t(i,k,j) + ((t(i,k,j) - t(i,k+1,j)) / (z0(k) - z0(k+1))) * (z0(k)-z0(k-1))
avev_t(i,k,j)=(T(i,k-1,j) + T(i,k,j) + ttop)/3.
! avev_t(i,k,j)=(T(i,k-1,j)+T(i,k,j) + T(i,k+1,j))/3.
avev_q(i,k,j)=(rqvften(i,k-1,j)+rqvften(i,k,j) + rqvften(i,k+1,j))/3.
ENDDO
avev_t(i,kts,j)=avev_t(i,kts+1,j) ! lowest level value, is it the same as avev_t(i,kds,j)=avev_t(i,kds+1,j)?
avev_q(i,kts,j)=avev_q(i,kts+1,j)
avev_t(i,kte,j)=avev_t(i,kte-1,j) ! highest level value
avev_q(i,kte,j)=avev_q(i,kte-1,j)
ENDDO
ENDDO
! max /min value
DO J = jts, jte
DO I = its, ite
DO K = kts+1,kte-1
avev_qmax(i,k,j)=avev_q(i,k,j)
avev_qmin(i,k,j)=avev_q(i,k,j)
DO kk=-1,1
if(avev_q(i,k+kk,j).gt.avev_qmax(i,k,j)) avev_qmax(i,k,j)=avev_q(i,k+kk,j)
if(avev_q(i,k+kk,j).lt.avev_qmin(i,k,j)) avev_qmin(i,k,j)=avev_q(i,k+kk,j)
ENDDO
if(avev_qmax(i,k,j).gt.avev_qmin(i,k,j)) then
coef_v(i,k,j)=(avev_q(i,k,j)-avev_qmin(i,k,j))/(avev_qmax(i,k,j)-avev_qmin(i,k,j))
else
coef_v(i,k,j)=0
endif
tpart_v(i,k,j)=coef_v(i,k,j)*(T(i,k,j)-avev_t(i,k,j))
ENDDO
tpart_v(i,kts,j)= tpart_v(i,kts+1,j) ! lowest level
tpart_v(i,kte,j)= tpart_v(i,kte-1,j) ! highest level
ENDDO
ENDDO
ENDIF ! endif (trigger.eq.2)
!
DO J = jts,jte
DO I= its,ite
CU_ACT_FLAG(i,j) = .true.
ENDDO
ENDDO
DO J = jts,jte
DO I=its,ite
IF ( NCA(I,J) .ge. 0.5*DT ) then
CU_ACT_FLAG(i,j) = .false.
ELSE
DO k=kts,kte
DQDT(k)=0.
DQIDT(k)=0.
DQCDT(k)=0.
DQRDT(k)=0.
DQSDT(k)=0.
DTDT(k)=0.
!ckay
cldfra_dp_KF(I,k,J)=0.
cldfra_sh_KF(I,k,J)=0.
qc_KF(I,k,J)=0.
qi_KF(I,k,J)=0.
w_up(I,k,J)=0.
ENDDO
IF (KF_EDRATES == 1) THEN
DO k=kts,kte
UDR_KF(I,k,J)=0.
DDR_KF(I,k,J)=0.
UER_KF(I,k,J)=0.
DER_KF(I,k,J)=0.
ENDDO
TIMEC_KF(I,J)=0.
ENDIF
RAINCV(I,J)=0.
CUTOP(I,J)=KTS
CUBOT(I,J)=KTE+1
PRATEC(I,J)=0.
!
! assign vars from 3D to 1D
DO K=kts,kte
U1D(K) =U(I,K,J)
V1D(K) =V(I,K,J)
T1D(K) =T(I,K,J)
RHO1D(K) =rho(I,K,J)
QV1D(K)=QV(I,K,J)
P1D(K) =Pcps(I,K,J)
W0AVG1D(K) =W0AVG(I,K,J)
DZ1D(k)=dz8w(I,K,J)
IF (trigger.eq.2) THEN
tpart_h1D(K) =tpart_h(I,K,J)
tpart_v1D(K) =tpart_v(I,K,J)
ELSE
tpart_h1D(K) = 0.
tpart_v1D(K) = 0.
ENDIF
ENDDO
CALL KF_eta_PARA(I, J, &
U1D,V1D,T1D,QV1D,P1D,DZ1D,W0AVG1D, &
tpart_h1D,tpart_v1D, &
trigger, &
DT,DX,DXSQ,RHO1D, &
XLV0,XLV1,XLS0,XLS1,CP,R,G, &
EP2,SVP1,SVP2,SVP3,SVPT0, &
DQDT,DQIDT,DQCDT,DQRDT,DQSDT,DTDT, &
RAINCV,PRATEC,NCA, &
flag_QI,flag_QS,warm_rain, &
CUTOP,CUBOT,CUDT, &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte, &
!ckay
cldfra_dp_KF,cldfra_sh_KF,w_up, &
qc_KF,qi_KF, &
!kf_edrates
UDR_KF,DDR_KF, &
UER_KF,DER_KF, &
TIMEC_KF,KF_EDRATES, &
ZOL,WSTAR,UST,PBLH )
IF(PRESENT(rthcuten).AND.PRESENT(rqvcuten)) THEN
DO K=kts,kte
RTHCUTEN(I,K,J)=DTDT(K)/pi(I,K,J)
RQVCUTEN(I,K,J)=DQDT(K)
ENDDO
ENDIF
IF(PRESENT(rqrcuten).AND.PRESENT(rqccuten)) THEN
IF( F_QR )THEN
DO K=kts,kte
RQRCUTEN(I,K,J)=DQRDT(K)
RQCCUTEN(I,K,J)=DQCDT(K)
ENDDO
ELSE
! This is the case for Eta microphysics without 3d rain field
DO K=kts,kte
RQRCUTEN(I,K,J)=0.
RQCCUTEN(I,K,J)=DQRDT(K)+DQCDT(K)
ENDDO
ENDIF
ENDIF
!...... QSTEN STORES GRAUPEL TENDENCY IF IT EXISTS, OTHERISE SNOW (V2)
IF(PRESENT( rqicuten )) THEN
IF ( F_QI ) THEN
DO K=kts,kte
RQICUTEN(I,K,J)=DQIDT(K)
ENDDO
ENDIF
ENDIF
IF(PRESENT( rqscuten )) THEN
IF ( F_QS ) THEN
DO K=kts,kte
RQSCUTEN(I,K,J)=DQSDT(K)
ENDDO
ENDIF
ENDIF
!
ENDIF
ENDDO ! i-loop
ENDDO ! j-loop
!
END SUBROUTINE MSKF_CPS
! ****************************************************************************
!-----------------------------------------------------------
SUBROUTINE KF_eta_PARA (I, J, &
U0,V0,T0,QV0,P0,DZQ,W0AVG1D, &
TPART_H0,TPART_V0, &
trigger, &
DT,DX,DXSQ,rhoe, &
XLV0,XLV1,XLS0,XLS1,CP,R,G, &
EP2,SVP1,SVP2,SVP3,SVPT0, &
DQDT,DQIDT,DQCDT,DQRDT,DQSDT,DTDT, &
RAINCV,PRATEC,NCA, &
F_QI,F_QS,warm_rain, &
CUTOP,CUBOT,CUDT, &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte, &
!ckay
cldfra_dp_KF,cldfra_sh_KF,w_up, &
qc_KF,qi_KF, &
!kf_edrates
UDR_KF,DDR_KF, &
UER_KF,DER_KF, &
TIMEC_KF,KF_EDRATES, &
ZOL,WSTAR,UST,PBLH )
!-----------------------------------------------------------
!***** The KF scheme that is currently used in experimental runs of EMCs
!***** Eta model....jsk 8/00
!
IMPLICIT NONE
!-----------------------------------------------------------
INTEGER, INTENT(IN ) :: ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte, &
I,J
! ,P_QI,P_QS,P_FIRST_SCALAR
INTEGER, INTENT(IN ) :: trigger
LOGICAL, INTENT(IN ) :: F_QI, F_QS
LOGICAL, INTENT(IN ) :: warm_rain
!
REAL, DIMENSION( kts:kte ), &
INTENT(IN ) :: U0, &
V0, &
TPART_H0, &
TPART_V0, &
T0, &
QV0, &
P0, &
rhoe, &
DZQ, &
W0AVG1D
!
REAL, INTENT(IN ) :: DT,DX,DXSQ
!
REAL, INTENT(IN ) :: XLV0,XLV1,XLS0,XLS1,CP,R,G
REAL, INTENT(IN ) :: EP2,SVP1,SVP2,SVP3,SVPT0
!ckay
REAL, DIMENSION( ims:ime, jms:jme ), &
INTENT( IN) :: ZOL, &
WSTAR, &
UST, &
PBLH
!
REAL, DIMENSION( kts:kte ), INTENT(INOUT) :: &
DQDT, &
DQIDT, &
DQCDT, &
DQRDT, &
DQSDT, &
DTDT
REAL, DIMENSION( ims:ime , jms:jme ), &
INTENT(INOUT) :: NCA
!ckay
REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), &
INTENT(INOUT) :: cldfra_dp_KF, &
cldfra_sh_KF, &
qc_KF, &
qi_KF
!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(INOUT) :: RAINCV
REAL, DIMENSION( ims:ime , jms:jme ), &
INTENT(INOUT) :: PRATEC
REAL, DIMENSION( ims:ime , jms:jme ), &
INTENT(OUT) :: CUBOT, &
CUTOP
REAL, INTENT(IN ) :: CUDT
!ckaywup
REAL, DIMENSION( ims:ime, kms:kme , jms:jme ) , &
INTENT( OUT) :: w_up
!
!...DEFINE LOCAL VARIABLES...
!
REAL, DIMENSION( kts:kte ) :: &
Q0,Z0,TV0,TU,TVU,QU,TZ,TVD, &
QD,QES,THTES,TG,TVG,QG,WU,WD,W0,EMS,EMSD, &
UMF,UER,UDR,DMF,DER,DDR,UMF2,UER2, &
UDR2,DMF2,DER2,DDR2,DZA,THTA0,THETEE, &
THTAU,THETEU,THTAD,THETED,QLIQ,QICE, &
QLQOUT,QICOUT,PPTLIQ,PPTICE,DETLQ,DETIC, &
DETLQ2,DETIC2,RATIO,RATIO2
REAL, DIMENSION( kts:kte ) :: &
DOMGDP,EXN,TVQU,DP,RH,EQFRC,WSPD, &
QDT,FXM,THTAG,THPA,THFXOUT, &
THFXIN,QPA,QFXOUT,QFXIN,QLPA,QLFXIN, &
QLFXOUT,QIPA,QIFXIN,QIFXOUT,QRPA, &
QRFXIN,QRFXOUT,QSPA,QSFXIN,QSFXOUT, &
QL0,QLG,QI0,QIG,QR0,QRG,QS0,QSG
REAL, DIMENSION( kts:kte+1 ) :: OMG
REAL, DIMENSION( kts:kte ) :: RAINFB,SNOWFB
REAL, DIMENSION( kts:kte ) :: &
CLDHGT,QSD,DILFRC,DDILFRC,TKE,TGU,QGU,THTEEG
! LOCAL VARS
REAL :: P00,T00,RLF,RHIC,RHBC,PIE, &
TTFRZ,TBFRZ,C5,RATE
REAL :: GDRY,ROCP,ALIQ,BLIQ, &
CLIQ,DLIQ
REAL :: FBFRC,P300,DPTHMX,THMIX,QMIX,ZMIX,PMIX, &
ROCPQ,TMIX,EMIX,TLOG,TDPT,TLCL,TVLCL, &
CPORQ,PLCL,ES,DLP,TENV,QENV,TVEN,TVBAR, &
ZLCL,WKL,WABS,TRPPT,WSIGNE,DTLCL,GDT,WLCL,&
TVAVG,QESE,WTW,RHOLCL,AU0,VMFLCL,UPOLD, &
UPNEW,ABE,WKLCL,TTEMP,FRC1, &
QNEWIC,RL,R1,QNWFRZ,EFFQ,BE,BOTERM,ENTERM,&
DZZ,UDLBE,REI,EE2,UD2,TTMP,F1,F2, &
THTTMP,QTMP,TMPLIQ,TMPICE,TU95,TU10,EE1, &
UD1,DPTT,QNEWLQ,DUMFDP,EE,TSAT, &
THTA,VCONV,TIMEC,SHSIGN,VWS,PEF, &
CBH,RCBH,PEFCBH,PEFF,PEFF2,TDER,THTMIN, &
DTMLTD,QS,TADVEC,DPDD,FRC,DPT,RDD,A1, &
DSSDT,DTMP,T1RH,QSRH,PPTFLX,CPR,CNDTNF, &
UPDINC,AINCM2,DEVDMF,PPR,RCED,DPPTDF, &
DMFLFS,DMFLFS2,RCED2,DDINC,AINCMX,AINCM1, &
AINC,TDER2,PPTFL2,FABE,STAB,DTT,DTT1, &
DTIME,TMA,TMB,TMM,BCOEFF,ACOEFF,QVDIFF, &
TOPOMG,CPM,DQ,ABEG,DABE,DFDA,FRC2,DR, &
UDFRC,TUC,QGS,RH0,RHG,QINIT,QFNL,ERR2, &
RELERR,RLC,RLS,RNC,FABEOLD,AINCOLD,UEFRC, &
DDFRC,TDC,DEFRC,RHBAR,DMFFRC,DPMIN,DILBE
REAL :: ASTRT,TP,VALUE,AINTRP,TKEMAX,QFRZ,&
QSS,PPTMLT,DTMELT,RHH,EVAC,BINC
!
INTEGER :: INDLU,NU,NUCHM,NNN,KLFS
REAL :: CHMIN,PM15,CHMAX,DTRH,RAD,DPPP
REAL :: TVDIFF,DTTOT,ABSOMG,ABSOMGTC,FRDP
!ckay
REAL :: xcldfra,UMF_new,DMF_new,FXM_new
REAL :: sourceht, Scale_Fac, TOKIOKA, RATE_kay
REAL :: capeDX, tempKay
REAL :: SCLvel, ZLCL_KAY, zz_kay
!ckaywup
REAL :: envEsat, envQsat, envRH, envRHavg, denSplume
REAL :: updil, Drag
INTEGER :: KX,K,KL
!
INTEGER :: NCHECK
INTEGER, DIMENSION (kts:kte) :: KCHECK
INTEGER :: ISTOP,ML,L5,KMIX,LOW, &
LC,MXLAYR,LLFC,NLAYRS,NK, &
KPBL,KLCL,LCL,LET,IFLAG, &
NK1,LTOP,NJ,LTOP1, &
LTOPM1,LVF,KSTART,KMIN,LFS, &
ND,NIC,LDB,LDT,ND1,NDK, &
NM,LMAX,NCOUNT,NOITR, &
NSTEP,NTC,NCHM,ISHALL,NSHALL
LOGICAL :: IPRNT
REAL :: u00,qslcl,rhlcl,dqssdt !jfb
CHARACTER*1024 message
!
DATA P00,T00/1.E5,273.16/
DATA RLF/3.339E5/
DATA RHIC,RHBC/1.,0.90/
DATA PIE,TTFRZ,TBFRZ,C5/3.141592654,268.16,248.16,1.0723E-3/
DATA RATE/0.03/ ! wrf default
! DATA RATE/0.01/ ! value used in NRCM
! DATA RATE/0.001/ ! effectively turn off autoconversion
!-----------------------------------------------------------
IPRNT=.FALSE.
GDRY=-G/CP
ROCP=R/CP
NSHALL = 0
KL=kte
KX=kte
!
! ALIQ = 613.3
! BLIQ = 17.502
! CLIQ = 4780.8
! DLIQ = 32.19
ALIQ = SVP1*1000.
BLIQ = SVP2
CLIQ = SVP2*SVPT0
DLIQ = SVP3
!
IF(DX.GE.24.999E3) THEN
Scale_Fac = 1.0
capeDX = 0.1
ELSE
Scale_Fac = 1.0 + (log(25.E3/DX))
capeDX = 0.1 *SQRT(Scale_Fac)
END IF
!
!****************************************************************************
! ! PPT FB MODS
!...OPTION TO FEED CONVECTIVELY GENERATED RAINWATER ! PPT FB MODS
!...INTO GRID-RESOLVED RAINWATER (OR SNOW/GRAUPEL) ! PPT FB MODS
!...FIELD. "FBFRC" IS THE FRACTION OF AVAILABLE ! PPT FB MODS
!...PRECIPITATION TO BE FED BACK (0.0 - 1.0)... ! PPT FB MODS
FBFRC=0.0 ! PPT FB MODS
!...mods to allow shallow convection...
NCHM = 0
ISHALL = 0
DPMIN = 5.E3
!...
P300=P0(1)-30000.
!
!...PRESSURE PERTURBATION TERM IS ONLY DEFINED AT MID-POINT OF
!...VERTICAL LAYERS...SINCE TOTAL PRESSURE IS NEEDED AT THE TOP AND
!...BOTTOM OF LAYERS BELOW, DO AN INTERPOLATION...
!
!...INPUT A VERTICAL SOUNDING ... NOTE THAT MODEL LAYERS ARE NUMBERED
!...FROM BOTTOM-UP IN THE KF SCHEME...
!
ML=0
!SUE tmprpsb=1./PSB(I,J)
!SUE CELL=PTOP*tmprpsb
!
DO K=1,KX
!
! Saturation vapor pressure (ES) is calculated following Buck (1981)
!...IF Q0 IS ABOVE SATURATION VALUE, REDUCE IT TO SATURATION LEVEL...
!
ES=ALIQ*EXP((BLIQ*T0(K)-CLIQ)/(T0(K)-DLIQ))
QES(K)=0.622*ES/(P0(K)-ES)
Q0(K)=AMIN1(QES(K),QV0(K))
Q0(K)=AMAX1(0.000001,Q0(K))
QL0(K)=0.
QI0(K)=0.
QR0(K)=0.
QS0(K)=0.
RH(K) = Q0(K)/QES(K)
DILFRC(K) = 1.
TV0(K)=T0(K)*(1.+0.608*Q0(K))
! RHOE(K)=P0(K)/(R*TV0(K))
! DP IS THE PRESSURE INTERVAL BETWEEN FULL SIGMA LEVELS...
DP(K)=rhoe(k)*g*DZQ(k)
! IF Turbulent Kinetic Energy (TKE) is available from turbulent mixing scheme
! use it for shallow convection...For now, assume it is not available....
! TKE(K) = Q2(I,J,NK)
TKE(K) = 0.
CLDHGT(K) = 0.
! IF(P0(K).GE.500E2)L5=K
IF(P0(K).GE.0.5*P0(1))L5=K
IF(P0(K).GE.P300)LLFC=K
ENDDO
!
!...DZQ IS DZ BETWEEN SIGMA SURFACES, DZA IS DZ BETWEEN MODEL HALF LEVEL
Z0(1)=.5*DZQ(1)
!cdir novector
DO K=2,KL
Z0(K)=Z0(K-1)+.5*(DZQ(K)+DZQ(K-1))
DZA(K-1)=Z0(K)-Z0(K-1)
ENDDO
DZA(KL)=0.
!
!
! To save time, specify a pressure interval to move up in sequential
! check of different ~50 mb deep groups of adjacent model layers in
! the process of identifying updraft source layer (USL). Note that
! this search is terminated as soon as a buoyant parcel is found and
! this parcel can produce a cloud greater than specifed minimum depth
! (CHMIN)...For now, set interval at 15 mb...
!
NCHECK = 1
KCHECK(NCHECK)=1
PM15 = P0(1)-15.E2
DO K=2,LLFC
IF(P0(K).LT.PM15)THEN
NCHECK = NCHECK+1
KCHECK(NCHECK) = K
PM15 = PM15-15.E2
ENDIF
ENDDO
!
NU=0
NUCHM=0
usl: DO
NU = NU+1
IF(NU.GT.NCHECK)THEN
IF(ISHALL.EQ.1)THEN
CHMAX = 0.
NCHM = 0
DO NK = 1,NCHECK
NNN=KCHECK(NK)
IF(CLDHGT(NNN).GT.CHMAX)THEN
NCHM = NNN
NUCHM = NK
CHMAX = CLDHGT(NNN)
ENDIF
ENDDO
NU = NUCHM-1
FBFRC=1.
CYCLE usl
ELSE
RETURN
ENDIF
ENDIF
KMIX = KCHECK(NU)
LOW=KMIX
!...
LC = LOW
!
!...ASSUME THAT IN ORDER TO SUPPORT A DEEP UPDRAFT YOU NEED A LAYER OF
!...UNSTABLE AIR AT LEAST 50 mb DEEP...TO APPROXIMATE THIS, ISOLATE A
!...GROUP OF ADJACENT INDIVIDUAL MODEL LAYERS, WITH THE BASE AT LEVEL
!...LC, SUCH THAT THE COMBINED DEPTH OF THESE LAYERS IS AT LEAST 50 mb..
!
NLAYRS=0
DPTHMX=0.
NK=LC-1
IF ( NK+1 .LT. KTS ) THEN
WRITE(message,*)'WOULD GO OFF BOTTOM: MSKF_PARA I,J,NK',I,J,NK
CALL wrf_message (TRIM(message))
ELSE
DO
NK=NK+1
IF ( NK .GT. KTE ) THEN
WRITE(message,*)'WOULD GO OFF TOP: MSKF_PARA I,J,DPTHMX,DPMIN',I,J,DPTHMX,DPMIN
CALL wrf_message (TRIM(message))
EXIT
ENDIF
DPTHMX=DPTHMX+DP(NK)
NLAYRS=NLAYRS+1
IF(DPTHMX.GT.DPMIN)THEN
EXIT
ENDIF
END DO
ENDIF
IF(DPTHMX.LT.DPMIN)THEN
RETURN
ENDIF
KPBL=LC+NLAYRS-1
!
!...********************************************************
!...for computational simplicity without much loss in accuracy,
!...mix temperature instead of theta for evaluating convective
!...initiation (triggering) potential...
! THMIX=0.
TMIX=0.
QMIX=0.
ZMIX=0.
PMIX=0.
!
!...FIND THE THERMODYNAMIC CHARACTERISTICS OF THE LAYER BY
!...MASS-WEIGHTING THE CHARACTERISTICS OF THE INDIVIDUAL MODEL
!...LAYERS...
!
!cdir novector
DO NK=LC,KPBL
TMIX=TMIX+DP(NK)*T0(NK)
QMIX=QMIX+DP(NK)*Q0(NK)
ZMIX=ZMIX+DP(NK)*Z0(NK)
PMIX=PMIX+DP(NK)*P0(NK)
ENDDO
! THMIX=THMIX/DPTHMX
TMIX=TMIX/DPTHMX
QMIX=QMIX/DPTHMX
ZMIX=ZMIX/DPTHMX
PMIX=PMIX/DPTHMX
EMIX=QMIX*PMIX/(0.622+QMIX)
!
!...FIND THE TEMPERATURE OF THE MIXTURE AT ITS LCL...
!
! TLOG=ALOG(EMIX/ALIQ)
! ...calculate dewpoint using lookup table...
!
astrt=1.e-3
ainc=0.075
a1=emix/aliq
tp=(a1-astrt)/ainc
indlu=int(tp)+1
value=(indlu-1)*ainc+astrt
aintrp=(a1-value)/ainc
tlog=aintrp*alu(indlu+1)+(1-aintrp)*alu(indlu)
TDPT=(CLIQ-DLIQ*TLOG)/(BLIQ-TLOG)
TLCL=TDPT-(.212+1.571E-3*(TDPT-T00)-4.36E-4*(TMIX-T00))*(TMIX-TDPT)
TLCL=AMIN1(TLCL,TMIX)
TVLCL=TLCL*(1.+0.608*QMIX)
ZLCL = ZMIX+(TLCL-TMIX)/GDRY
! NK = LC-1
! DO
! NK = NK+1
! KLCL=NK
! IF(ZLCL.LE.Z0(NK) .or. NK.GT.KL)THEN
! EXIT
! ENDIF
! ENDDO
! IF(NK.GT.KL)THEN
! RETURN
! ENDIF
DO NK = LC, KL
KLCL = NK
IF ( ZLCL.LE.Z0(NK) ) EXIT
END DO
IF ( ZLCL.GT.Z0(KL) ) RETURN
K=KLCL-1
! calculate DLP using Z instead of log(P)
DLP=(ZLCL-Z0(K))/(Z0(KLCL)-Z0(K))
!