forked from wrf-model/WRF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule_cu_gd.F
executable file
·4561 lines (4243 loc) · 157 KB
/
module_cu_gd.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:MODEL_LAYER:PHYSICS
!
MODULE module_cu_gd
CONTAINS
!-------------------------------------------------------------
SUBROUTINE GRELLDRV( &
DT,itimestep,DX &
,rho,RAINCV,PRATEC &
,U,V,t,W,q,p,pi &
,dz8w,p8w,XLV,CP,G,r_v &
,htop,hbot,ktop_deep &
,CU_ACT_FLAG,warm_rain &
,APR_GR,APR_W,APR_MC,APR_ST,APR_AS &
,APR_CAPMA,APR_CAPME,APR_CAPMI &
,MASS_FLUX,XF_ENS,PR_ENS,HT,XLAND,gsw &
,GDC,GDC2 &
,ensdim,maxiens,maxens,maxens2,maxens3 &
,ids,ide, jds,jde, kds,kde &
,ims,ime, jms,jme, kms,kme &
,its,ite, jts,jte, kts,kte &
,periodic_x,periodic_y &
,RQVCUTEN,RQCCUTEN,RQICUTEN &
,RQVFTEN,RQVBLTEN &
,RTHFTEN,RTHCUTEN,RTHRATEN,RTHBLTEN &
,F_QV ,F_QC ,F_QR ,F_QI ,F_QS &
,CFU1,CFD1,DFU1,EFU1,DFD1,EFD1,f_flux )
!-------------------------------------------------------------
IMPLICIT NONE
!-------------------------------------------------------------
INTEGER, INTENT(IN ) :: &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte
LOGICAL periodic_x,periodic_y
integer, intent (in ) :: &
ensdim,maxiens,maxens,maxens2,maxens3
INTEGER, INTENT(IN ) :: ITIMESTEP
LOGICAL, INTENT(IN ) :: warm_rain
REAL, INTENT(IN ) :: XLV, R_v
REAL, INTENT(IN ) :: CP,G
REAL, DIMENSION( ims:ime , kms:kme , jms:jme ) , &
INTENT(IN ) :: &
U, &
V, &
W, &
pi, &
t, &
q, &
p, &
dz8w, &
p8w, &
rho
REAL, DIMENSION( ims:ime , kms:kme , jms:jme ) , &
OPTIONAL , &
INTENT(INOUT ) :: &
GDC,GDC2
REAL, DIMENSION( ims:ime , jms:jme ),INTENT(IN) :: GSW,HT,XLAND
!
REAL, INTENT(IN ) :: DT, DX
!
REAL, DIMENSION( ims:ime , jms:jme ), &
INTENT(INOUT) :: RAINCV, PRATEC, MASS_FLUX, &
APR_GR,APR_W,APR_MC,APR_ST,APR_AS, &
APR_CAPMA,APR_CAPME,APR_CAPMI,htop,hbot
!+lxz
! REAL, DIMENSION( ims:ime , jms:jme ) :: & !, INTENT(INOUT) :: &
! HTOP, &! highest model layer penetrated by cumulus since last reset in radiation_driver
! HBOT ! lowest model layer penetrated by cumulus since last reset in radiation_driver
! ! HBOT>HTOP follow physics leveling convention
LOGICAL, DIMENSION( ims:ime , jms:jme ), &
INTENT(INOUT) :: CU_ACT_FLAG
!
! Optionals
!
INTEGER, DIMENSION( ims:ime, jms:jme ), &
OPTIONAL, &
INTENT( OUT) :: ktop_deep
REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), &
OPTIONAL, &
INTENT(INOUT) :: RTHFTEN, &
RQVFTEN
REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), &
OPTIONAL, &
INTENT(IN ) :: &
RTHRATEN, &
RTHBLTEN, &
RQVBLTEN
REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), &
OPTIONAL, &
INTENT(INOUT) :: &
RTHCUTEN, &
RQVCUTEN, &
RQCCUTEN, &
RQICUTEN
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, OPTIONAL :: &
F_QV &
,F_QC &
,F_QR &
,F_QI &
,F_QS
LOGICAL, intent(in), OPTIONAL :: f_flux
! LOCAL VARS
real, dimension ( ims:ime , jms:jme , 1:ensdim) :: &
massfln,xf_ens,pr_ens
real, dimension (its:ite,kts:kte+1) :: &
OUTT,OUTQ,OUTQC,phh,cupclw, &
outCFU1,outCFD1,outDFU1,outEFU1,outDFD1,outEFD1
logical :: l_flux
real, dimension (its:ite) :: &
pret, ter11, aa0, fp
!+lxz
integer, dimension (its:ite) :: &
kbcon, ktop
!.lxz
integer, dimension (its:ite,jts:jte) :: &
iact_old_gr
integer :: ichoice,iens,ibeg,iend,jbeg,jend
!
! basic environmental input includes moisture convergence (mconv)
! omega (omeg), windspeed (us,vs), and a flag (aaeq) to turn off
! convection for this call only and at that particular gridpoint
!
real, dimension (its:ite,kts:kte+1) :: &
T2d,TN,q2d,qo,PO,P2d,US,VS,omeg
real, dimension (its:ite) :: &
Z1,PSUR,AAEQ,direction,mconv,cuten,umean,vmean,pmean
INTEGER :: i,j,k,ICLDCK,ipr,jpr
REAL :: tcrit,dp,dq
INTEGER :: itf,jtf,ktf
REAL :: rkbcon,rktop !-lxz
l_flux=.FALSE.
if (present(f_flux)) l_flux=f_flux
if (l_flux) then
l_flux = l_flux .and. present(cfu1) .and. present(cfd1) &
.and. present(dfu1) .and. present(efu1) &
.and. present(dfd1) .and. present(efd1)
endif
ichoice=0
iens=1
ipr=0
jpr=0
IF ( periodic_x ) THEN
ibeg=max(its,ids)
iend=min(ite,ide-1)
ELSE
ibeg=max(its,ids+4)
iend=min(ite,ide-5)
END IF
IF ( periodic_y ) THEN
jbeg=max(jts,jds)
jend=min(jte,jde-1)
ELSE
jbeg=max(jts,jds+4)
jend=min(jte,jde-5)
END IF
tcrit=258.
itf=MIN(ite,ide-1)
ktf=MIN(kte,kde-1)
jtf=MIN(jte,jde-1)
!
DO 100 J = jts,jtf
DO I= its,itf
cuten(i)=0.
iact_old_gr(i,j)=0
mass_flux(i,j)=0.
pratec(i,j) = 0.
raincv(i,j)=0.
CU_ACT_FLAG(i,j) = .true.
ktop_deep(i,j) = 0
ENDDO
DO k=1,ensdim
DO I= its,itf
massfln(i,j,k)=0.
ENDDO
ENDDO
#if ( EM_CORE == 1 )
DO k= kts,ktf
DO I= its,itf
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
#endif
! put hydrostatic pressure on half levels
DO K=kts,ktf
DO I=ITS,ITF
phh(i,k) = p(i,k,j)
ENDDO
ENDDO
DO I=ITS,ITF
PSUR(I)=p8w(I,1,J)*.01
TER11(I)=HT(i,j)
mconv(i)=0.
aaeq(i)=0.
direction(i)=0.
pret(i)=0.
umean(i)=0.
vmean(i)=0.
pmean(i)=0.
ENDDO
DO K=kts,ktf
DO I=ITS,ITF
omeg(i,k)=0.
! cupclw(i,k)=0.
po(i,k)=phh(i,k)*.01
P2d(I,K)=PO(i,k)
US(I,K) =u(i,k,j)
VS(I,K) =v(i,k,j)
T2d(I,K)=t(i,k,j)
q2d(I,K)=q(i,k,j)
omeg(I,K)= -g*rho(i,k,j)*w(i,k,j)
TN(I,K)=t2d(i,k)+RTHFTEN(i,k,j)*dt
IF(TN(I,K).LT.200.)TN(I,K)=T2d(I,K)
QO(I,K)=q2d(i,k)+RQVFTEN(i,k,j)*dt
IF(Q2d(I,K).LT.1.E-08)Q2d(I,K)=1.E-08
IF(QO(I,K).LT.1.E-08)QO(I,K)=1.E-08
OUTT(I,K)=0.
OUTQ(I,K)=0.
OUTQC(I,K)=0.
! RTHFTEN(i,k,j)=0.
! RQVFTEN(i,k,j)=0.
ENDDO
ENDDO
do k= kts+1,ktf-1
DO I = its,itf
if((p2d(i,1)-p2d(i,k)).gt.150.and.p2d(i,k).gt.300)then
dp=-.5*(p2d(i,k+1)-p2d(i,k-1))
umean(i)=umean(i)+us(i,k)*dp
vmean(i)=vmean(i)+vs(i,k)*dp
pmean(i)=pmean(i)+dp
endif
enddo
enddo
DO I = its,itf
if(pmean(i).gt.0)then
umean(i)=umean(i)/pmean(i)
vmean(i)=vmean(i)/pmean(i)
direction(i)=(atan2(umean(i),vmean(i))+3.1415926)*57.29578
if(direction(i).gt.360.)direction(i)=direction(i)-360.
endif
ENDDO
DO K=kts,ktf-1
DO I = its,itf
dq=(q2d(i,k+1)-q2d(i,k))
mconv(i)=mconv(i)+omeg(i,k)*dq/g
ENDDO
ENDDO
DO I = its,itf
if(mconv(i).lt.0.)mconv(i)=0.
ENDDO
!
!---- CALL CUMULUS PARAMETERIZATION
!
CALL CUP_enss(outqc,j,AAEQ,T2d,Q2d,TER11,TN,QO,PO,PRET, &
P2d,OUTT,OUTQ,DT,PSUR,US,VS,tcrit,iens, &
mconv,massfln,iact_old_gr,omeg,direction,MASS_FLUX, &
maxiens,maxens,maxens2,maxens3,ensdim, &
APR_GR,APR_W,APR_MC,APR_ST,APR_AS, &
APR_CAPMA,APR_CAPME,APR_CAPMI,kbcon,ktop, &
xf_ens,pr_ens,XLAND,gsw,cupclw, &
xlv,r_v,cp,g,ichoice,ipr,jpr, &
outCFU1,outCFD1,outDFU1,outEFU1,outDFD1,outEFD1,l_flux,&
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte )
CALL neg_check(dt,q2d,outq,outt,outqc,pret,its,ite,kts,kte,itf,ktf)
if(j.ge.jbeg.and.j.le.jend)then
DO I=its,itf
! cuten(i)=0.
ktop_deep(i,j) = ktop(i)
if(i.ge.ibeg.and.i.le.iend)then
if(pret(i).gt.0.)then
pratec(i,j)=pret(i)
raincv(i,j)=pret(i)*dt
cuten(i)=1.
rkbcon = kte+kts - kbcon(i)
rktop = kte+kts - ktop(i)
if (ktop(i) > HTOP(i,j)) HTOP(i,j) = ktop(i)+.001
if (kbcon(i) < HBOT(i,j)) HBOT(i,j) = kbcon(i)+.001
endif
else
pret(i)=0.
endif
ENDDO
DO K=kts,ktf
DO I=its,itf
RTHCUTEN(I,K,J)=outt(i,k)*cuten(i)/pi(i,k,j)
RQVCUTEN(I,K,J)=outq(i,k)*cuten(i)
ENDDO
ENDDO
IF(PRESENT(RQCCUTEN)) THEN
IF ( F_QC ) THEN
DO K=kts,ktf
DO I=its,itf
RQCCUTEN(I,K,J)=outqc(I,K)*cuten(i)
IF ( PRESENT( GDC ) ) GDC(I,K,J)=CUPCLW(I,K)*cuten(i)
IF ( PRESENT( GDC2 ) ) GDC2(I,K,J)=0.
ENDDO
ENDDO
ENDIF
ENDIF
!...... QSTEN STORES GRAUPEL TENDENCY IF IT EXISTS, OTHERISE SNOW (V2)
IF(PRESENT(RQICUTEN).AND.PRESENT(RQCCUTEN))THEN
IF (F_QI) THEN
DO K=kts,ktf
DO I=its,itf
if(t2d(i,k).lt.258.)then
RQICUTEN(I,K,J)=outqc(I,K)*cuten(i)
RQCCUTEN(I,K,J)=0.
IF ( PRESENT( GDC2 ) ) GDC2(I,K,J)=CUPCLW(I,K)*cuten(i)
else
RQICUTEN(I,K,J)=0.
RQCCUTEN(I,K,J)=outqc(I,K)*cuten(i)
IF ( PRESENT( GDC ) ) GDC(I,K,J)=CUPCLW(I,K)*cuten(i)
endif
ENDDO
ENDDO
ENDIF
ENDIF
if (l_flux) then
DO K=kts,ktf
DO I=its,itf
cfu1(i,k,j)=outcfu1(i,k)*cuten(i)
cfd1(i,k,j)=outcfd1(i,k)*cuten(i)
dfu1(i,k,j)=outdfu1(i,k)*cuten(i)
efu1(i,k,j)=outefu1(i,k)*cuten(i)
dfd1(i,k,j)=outdfd1(i,k)*cuten(i)
efd1(i,k,j)=outefd1(i,k)*cuten(i)
enddo
enddo
endif
endif !jbeg,jend
100 continue
END SUBROUTINE GRELLDRV
SUBROUTINE CUP_enss(OUTQC,J,AAEQ,T,Q,Z1, &
TN,QO,PO,PRE,P,OUTT,OUTQ,DTIME,PSUR,US,VS, &
TCRIT,iens,mconv,massfln,iact, &
omeg,direction,massflx,maxiens, &
maxens,maxens2,maxens3,ensdim, &
APR_GR,APR_W,APR_MC,APR_ST,APR_AS, &
APR_CAPMA,APR_CAPME,APR_CAPMI,kbcon,ktop, & !-lxz
xf_ens,pr_ens,xland,gsw,cupclw, &
xl,rv,cp,g,ichoice,ipr,jpr, &
outCFU1,outCFD1,outDFU1,outEFU1,outDFD1,outEFD1,l_flux, &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte )
IMPLICIT NONE
integer &
,intent (in ) :: &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte,ipr,jpr
integer, intent (in ) :: &
j,ensdim,maxiens,maxens,maxens2,maxens3,ichoice,iens
!
!
!
real, dimension (ims:ime,jms:jme,1:ensdim) &
,intent (inout) :: &
massfln,xf_ens,pr_ens
real, dimension (ims:ime,jms:jme) &
,intent (inout ) :: &
APR_GR,APR_W,APR_MC,APR_ST,APR_AS,APR_CAPMA, &
APR_CAPME,APR_CAPMI,massflx
real, dimension (ims:ime,jms:jme) &
,intent (in ) :: &
xland,gsw
integer, dimension (its:ite,jts:jte) &
,intent (in ) :: &
iact
! outtem = output temp tendency (per s)
! outq = output q tendency (per s)
! outqc = output qc tendency (per s)
! pre = output precip
real, dimension (its:ite,kts:kte) &
,intent (out ) :: &
OUTT,OUTQ,OUTQC,CUPCLW, &
outCFU1,outCFD1,outDFU1,outEFU1,outDFD1,outEFD1
logical, intent(in) :: l_flux
real, dimension (its:ite) &
,intent (out ) :: &
pre
!+lxz
integer, dimension (its:ite) &
,intent (out ) :: &
kbcon,ktop
!.lxz
!
! basic environmental input includes moisture convergence (mconv)
! omega (omeg), windspeed (us,vs), and a flag (aaeq) to turn off
! convection for this call only and at that particular gridpoint
!
real, dimension (its:ite,kts:kte) &
,intent (in ) :: &
T,TN,PO,P,US,VS,omeg
real, dimension (its:ite,kts:kte) &
,intent (inout) :: &
Q,QO
real, dimension (its:ite) &
,intent (in ) :: &
Z1,PSUR,AAEQ,direction,mconv
real &
,intent (in ) :: &
dtime,tcrit,xl,cp,rv,g
!
! local ensemble dependent variables in this routine
!
real, dimension (its:ite,1:maxens) :: &
xaa0_ens
real, dimension (1:maxens) :: &
mbdt_ens
real, dimension (1:maxens2) :: &
edt_ens
real, dimension (its:ite,1:maxens2) :: &
edtc
real, dimension (its:ite,kts:kte,1:maxens2) :: &
dellat_ens,dellaqc_ens,dellaq_ens,pwo_ens
real, dimension (its:ite,kts:kte,1:maxens2) :: &
CFU1_ens,CFD1_ens,DFU1_ens,EFU1_ens,DFD1_ens,EFD1_ens
!
!
!
!***************** the following are your basic environmental
! variables. They carry a "_cup" if they are
! on model cloud levels (staggered). They carry
! an "o"-ending (z becomes zo), if they are the forced
! variables. They are preceded by x (z becomes xz)
! to indicate modification by some typ of cloud
!
! z = heights of model levels
! q = environmental mixing ratio
! qes = environmental saturation mixing ratio
! t = environmental temp
! p = environmental pressure
! he = environmental moist static energy
! hes = environmental saturation moist static energy
! z_cup = heights of model cloud levels
! q_cup = environmental q on model cloud levels
! qes_cup = saturation q on model cloud levels
! t_cup = temperature (Kelvin) on model cloud levels
! p_cup = environmental pressure
! he_cup = moist static energy on model cloud levels
! hes_cup = saturation moist static energy on model cloud levels
! gamma_cup = gamma on model cloud levels
!
!
! hcd = moist static energy in downdraft
! zd normalized downdraft mass flux
! dby = buoancy term
! entr = entrainment rate
! zd = downdraft normalized mass flux
! entr= entrainment rate
! hcd = h in model cloud
! bu = buoancy term
! zd = normalized downdraft mass flux
! gamma_cup = gamma on model cloud levels
! mentr_rate = entrainment rate
! qcd = cloud q (including liquid water) after entrainment
! qrch = saturation q in cloud
! pwd = evaporate at that level
! pwev = total normalized integrated evaoprate (I2)
! entr= entrainment rate
! z1 = terrain elevation
! entr = downdraft entrainment rate
! jmin = downdraft originating level
! kdet = level above ground where downdraft start detraining
! psur = surface pressure
! z1 = terrain elevation
! pr_ens = precipitation ensemble
! xf_ens = mass flux ensembles
! massfln = downdraft mass flux ensembles used in next timestep
! omeg = omega from large scale model
! mconv = moisture convergence from large scale model
! zd = downdraft normalized mass flux
! zu = updraft normalized mass flux
! dir = "storm motion"
! mbdt = arbitrary numerical parameter
! dtime = dt over which forcing is applied
! iact_gr_old = flag to tell where convection was active
! kbcon = LFC of parcel from k22
! k22 = updraft originating level
! icoic = flag if only want one closure (usually set to zero!)
! dby = buoancy term
! ktop = cloud top (output)
! xmb = total base mass flux
! hc = cloud moist static energy
! hkb = moist static energy at originating level
! mentr_rate = entrainment rate
real, dimension (its:ite,kts:kte) :: &
he,hes,qes,z, &
heo,heso,qeso,zo, &
xhe,xhes,xqes,xz,xt,xq, &
qes_cup,q_cup,he_cup,hes_cup,z_cup,p_cup,gamma_cup,t_cup, &
qeso_cup,qo_cup,heo_cup,heso_cup,zo_cup,po_cup,gammao_cup, &
tn_cup, &
xqes_cup,xq_cup,xhe_cup,xhes_cup,xz_cup,xp_cup,xgamma_cup, &
xt_cup, &
dby,qc,qrcd,pwd,pw,hcd,qcd,dbyd,hc,qrc,zu,zd,clw_all, &
dbyo,qco,qrcdo,pwdo,pwo,hcdo,qcdo,dbydo,hco,qrco,zuo,zdo, &
xdby,xqc,xqrcd,xpwd,xpw,xhcd,xqcd,xhc,xqrc,xzu,xzd, &
! cd = detrainment function for updraft
! cdd = detrainment function for downdraft
! dellat = change of temperature per unit mass flux of cloud ensemble
! dellaq = change of q per unit mass flux of cloud ensemble
! dellaqc = change of qc per unit mass flux of cloud ensemble
cd,cdd,scr1,DELLAH,DELLAQ,DELLAT,DELLAQC, &
CFU1,CFD1,DFU1,EFU1,DFD1,EFD1
! aa0 cloud work function for downdraft
! edt = epsilon
! aa0 = cloud work function without forcing effects
! aa1 = cloud work function with forcing effects
! xaa0 = cloud work function with cloud effects (ensemble dependent)
! edt = epsilon
real, dimension (its:ite) :: &
edt,edto,edtx,AA1,AA0,XAA0,HKB,HKBO,aad,XHKB,QKB,QKBO, &
XMB,XPWAV,XPWEV,PWAV,PWEV,PWAVO,PWEVO,BU,BUO,cap_max,xland1, &
cap_max_increment,closure_n
integer, dimension (its:ite) :: &
kzdown,KDET,K22,KB,JMIN,kstabi,kstabm,K22x, & !-lxz
KBCONx,KBx,KTOPx,ierr,ierr2,ierr3,KBMAX
integer :: &
nall,iedt,nens,nens3,ki,I,K,KK,iresult
real :: &
day,dz,mbdt,entr_rate,radius,entrd_rate,mentr_rate,mentrd_rate, &
zcutdown,edtmax,edtmin,depth_min,zkbmax,z_detr,zktop, &
massfld,dh,cap_maxs
integer :: itf,jtf,ktf
integer :: jmini
logical :: keep_going
itf=MIN(ite,ide-1)
ktf=MIN(kte,kde-1)
jtf=MIN(jte,jde-1)
!sms$distribute end
day=86400.
do i=its,itf
closure_n(i)=16.
xland1(i)=1.
if(xland(i,j).gt.1.5)xland1(i)=0.
cap_max_increment(i)=25.
enddo
!
!--- specify entrainmentrate and detrainmentrate
!
if(iens.le.4)then
radius=14000.-float(iens)*2000.
else
radius=12000.
endif
!
!--- gross entrainment rate (these may be changed later on in the
!--- program, depending what your detrainment is!!)
!
entr_rate=.2/radius
!
!--- entrainment of mass
!
mentrd_rate=0.
mentr_rate=entr_rate
!
!--- initial detrainmentrates
!
do k=kts,ktf
do i=its,itf
cupclw(i,k)=0.
cd(i,k)=0.1*entr_rate
cdd(i,k)=0.
enddo
enddo
!
!--- max/min allowed value for epsilon (ratio downdraft base mass flux/updraft
! base mass flux
!
edtmax=.8
edtmin=.2
!
!--- minimum depth (m), clouds must have
!
depth_min=500.
!
!--- maximum depth (mb) of capping
!--- inversion (larger cap = no convection)
!
cap_maxs=75.
!sms$to_local(grid_dh: <1, mix :size>, <2, mjx :size>) begin
DO 7 i=its,itf
kbmax(i)=1
aa0(i)=0.
aa1(i)=0.
aad(i)=0.
edt(i)=0.
kstabm(i)=ktf-1
IERR(i)=0
IERR2(i)=0
IERR3(i)=0
if(aaeq(i).lt.-1.)then
ierr(i)=20
endif
7 CONTINUE
!
!--- first check for upstream convection
!
do i=its,itf
cap_max(i)=cap_maxs
! if(tkmax(i,j).lt.2.)cap_max(i)=25.
if(gsw(i,j).lt.1.)cap_max(i)=25.
iresult=0
! massfld=0.
! call cup_direction2(i,j,direction,iact, &
! cu_mfx,iresult,0,massfld, &
! ids,ide, jds,jde, kds,kde, &
! ims,ime, jms,jme, kms,kme, &
! its,ite, jts,jte, kts,kte)
! cap_max(i)=cap_maxs
if(iresult.eq.1)then
cap_max(i)=cap_maxs+20.
endif
! endif
enddo
!
!--- max height(m) above ground where updraft air can originate
!
zkbmax=4000.
!
!--- height(m) above which no downdrafts are allowed to originate
!
zcutdown=3000.
!
!--- depth(m) over which downdraft detrains all its mass
!
z_detr=1250.
!
do nens=1,maxens
mbdt_ens(nens)=(float(nens)-3.)*dtime*1.e-3+dtime*5.E-03
enddo
do nens=1,maxens2
edt_ens(nens)=.95-float(nens)*.01
enddo
! if(j.eq.jpr)then
! print *,'radius ensemble ',iens,radius
! print *,mbdt_ens
! print *,edt_ens
! endif
!
!--- environmental conditions, FIRST HEIGHTS
!
do i=its,itf
if(ierr(i).ne.20)then
do k=1,maxens*maxens2*maxens3
xf_ens(i,j,(iens-1)*maxens*maxens2*maxens3+k)=0.
pr_ens(i,j,(iens-1)*maxens*maxens2*maxens3+k)=0.
enddo
endif
enddo
!
!--- calculate moist static energy, heights, qes
!
call cup_env(z,qes,he,hes,t,q,p,z1, &
psur,ierr,tcrit,0,xl,cp, &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte)
call cup_env(zo,qeso,heo,heso,tn,qo,po,z1, &
psur,ierr,tcrit,0,xl,cp, &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte)
!
!--- environmental values on cloud levels
!
call cup_env_clev(t,qes,q,he,hes,z,p,qes_cup,q_cup,he_cup, &
hes_cup,z_cup,p_cup,gamma_cup,t_cup,psur, &
ierr,z1,xl,rv,cp, &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte)
call cup_env_clev(tn,qeso,qo,heo,heso,zo,po,qeso_cup,qo_cup, &
heo_cup,heso_cup,zo_cup,po_cup,gammao_cup,tn_cup,psur, &
ierr,z1,xl,rv,cp, &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte)
do i=its,itf
if(ierr(i).eq.0)then
!
do k=kts,ktf-2
if(zo_cup(i,k).gt.zkbmax+z1(i))then
kbmax(i)=k
go to 25
endif
enddo
25 continue
!
!
!--- level where detrainment for downdraft starts
!
do k=kts,ktf
if(zo_cup(i,k).gt.z_detr+z1(i))then
kdet(i)=k
go to 26
endif
enddo
26 continue
!
endif
enddo
!
!
!
!------- DETERMINE LEVEL WITH HIGHEST MOIST STATIC ENERGY CONTENT - K22
!
CALL cup_MAXIMI(HEO_CUP,3,KBMAX,K22,ierr, &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte)
DO 36 i=its,itf
IF(ierr(I).eq.0.)THEN
IF(K22(I).GE.KBMAX(i))ierr(i)=2
endif
36 CONTINUE
!
!--- DETERMINE THE LEVEL OF CONVECTIVE CLOUD BASE - KBCON
!
call cup_kbcon(cap_max_increment,1,k22,kbcon,heo_cup,heso_cup, &
ierr,kbmax,po_cup,cap_max, &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte)
! call cup_kbcon_cin(1,k22,kbcon,heo_cup,heso_cup,z,tn_cup, &
! qeso_cup,ierr,kbmax,po_cup,cap_max,xl,cp,&
! ids,ide, jds,jde, kds,kde, &
! ims,ime, jms,jme, kms,kme, &
! its,ite, jts,jte, kts,kte)
!
!--- increase detrainment in stable layers
!
CALL cup_minimi(HEso_cup,Kbcon,kstabm,kstabi,ierr, &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte)
do i=its,itf
IF(ierr(I).eq.0.)THEN
if(kstabm(i)-1.gt.kstabi(i))then
do k=kstabi(i),kstabm(i)-1
cd(i,k)=cd(i,k-1)+1.5*entr_rate
if(cd(i,k).gt.10.0*entr_rate)cd(i,k)=10.0*entr_rate
enddo
ENDIF
ENDIF
ENDDO
!
!--- calculate incloud moist static energy
!
call cup_up_he(k22,hkb,z_cup,cd,mentr_rate,he_cup,hc, &
kbcon,ierr,dby,he,hes_cup, &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte)
call cup_up_he(k22,hkbo,zo_cup,cd,mentr_rate,heo_cup,hco, &
kbcon,ierr,dbyo,heo,heso_cup, &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte)
!--- DETERMINE CLOUD TOP - KTOP
!
call cup_ktop(1,dbyo,kbcon,ktop,ierr, &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte)
DO 37 i=its,itf
kzdown(i)=0
if(ierr(i).eq.0)then
zktop=(zo_cup(i,ktop(i))-z1(i))*.6
zktop=min(zktop+z1(i),zcutdown+z1(i))
do k=kts,kte
if(zo_cup(i,k).gt.zktop)then
kzdown(i)=k
go to 37
endif
enddo
endif
37 CONTINUE
!
!--- DOWNDRAFT ORIGINATING LEVEL - JMIN
!
call cup_minimi(HEso_cup,K22,kzdown,JMIN,ierr, &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte)
DO 100 i=its,ite
IF(ierr(I).eq.0.)THEN
!
!--- check whether it would have buoyancy, if there where
!--- no entrainment/detrainment
!
!jm begin 20061212: the following code replaces code that
! was too complex and causing problem for optimization.
! Done in consultation with G. Grell.
jmini = jmin(i)
keep_going = .TRUE.
DO WHILE ( keep_going )
keep_going = .FALSE.
if ( jmini - 1 .lt. kdet(i) ) kdet(i) = jmini-1
if ( jmini .ge. ktop(i)-1 ) jmini = ktop(i) - 2
ki = jmini
hcdo(i,ki)=heso_cup(i,ki)
DZ=Zo_cup(i,Ki+1)-Zo_cup(i,Ki)
dh=0.
DO k=ki-1,1,-1
hcdo(i,k)=heso_cup(i,jmini)
DZ=Zo_cup(i,K+1)-Zo_cup(i,K)
dh=dh+dz*(HCDo(i,K)-heso_cup(i,k))
IF(dh.gt.0.)THEN
jmini=jmini-1
IF ( jmini .gt. 3 ) THEN
keep_going = .TRUE.
ELSE
ierr(i) = 9
EXIT
ENDIF
ENDIF
ENDDO
ENDDO
jmin(i) = jmini
IF ( jmini .le. 3 ) THEN
ierr(i)=4
ENDIF
!jm end 20061212
ENDIF
100 CONTINUE
!
! - Must have at least depth_min m between cloud convective base
! and cloud top.
!
do i=its,itf
IF(ierr(I).eq.0.)THEN
IF(-zo_cup(I,KBCON(I))+zo_cup(I,KTOP(I)).LT.depth_min)then
ierr(i)=6
endif
endif
enddo
!
!c--- normalized updraft mass flux profile
!
call cup_up_nms(zu,z_cup,mentr_rate,cd,kbcon,ktop,ierr,k22, &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte)
call cup_up_nms(zuo,zo_cup,mentr_rate,cd,kbcon,ktop,ierr,k22, &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte)
!
!c--- normalized downdraft mass flux profile,also work on bottom detrainment
!--- in this routine
!
call cup_dd_nms(zd,z_cup,cdd,mentrd_rate,jmin,ierr, &
0,kdet,z1, &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte)
call cup_dd_nms(zdo,zo_cup,cdd,mentrd_rate,jmin,ierr, &
1,kdet,z1, &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte)
!
!--- downdraft moist static energy
!
call cup_dd_he(hes_cup,zd,hcd,z_cup,cdd,mentrd_rate, &
jmin,ierr,he,dbyd,he_cup, &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte)
call cup_dd_he(heso_cup,zdo,hcdo,zo_cup,cdd,mentrd_rate, &
jmin,ierr,heo,dbydo,he_cup,&
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte)
!
!--- calculate moisture properties of downdraft
!
call cup_dd_moisture(zd,hcd,hes_cup,qcd,qes_cup, &
pwd,q_cup,z_cup,cdd,mentrd_rate,jmin,ierr,gamma_cup, &
pwev,bu,qrcd,q,he,t_cup,2,xl, &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte)
call cup_dd_moisture(zdo,hcdo,heso_cup,qcdo,qeso_cup, &
pwdo,qo_cup,zo_cup,cdd,mentrd_rate,jmin,ierr,gammao_cup, &
pwevo,bu,qrcdo,qo,heo,tn_cup,1,xl, &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte)
!
!--- calculate moisture properties of updraft
!
call cup_up_moisture(ierr,z_cup,qc,qrc,pw,pwav, &
kbcon,ktop,cd,dby,mentr_rate,clw_all, &
q,GAMMA_cup,zu,qes_cup,k22,q_cup,xl, &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte)
do k=kts,ktf
do i=its,itf
cupclw(i,k)=qrc(i,k)
enddo
enddo
call cup_up_moisture(ierr,zo_cup,qco,qrco,pwo,pwavo, &
kbcon,ktop,cd,dbyo,mentr_rate,clw_all, &
qo,GAMMAo_cup,zuo,qeso_cup,k22,qo_cup,xl,&
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte)
!
!--- calculate workfunctions for updrafts
!
call cup_up_aa0(aa0,z,zu,dby,GAMMA_CUP,t_cup, &
kbcon,ktop,ierr, &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte)
call cup_up_aa0(aa1,zo,zuo,dbyo,GAMMAo_CUP,tn_cup, &
kbcon,ktop,ierr, &
ids,ide, jds,jde, kds,kde, &
ims,ime, jms,jme, kms,kme, &
its,ite, jts,jte, kts,kte)
do i=its,itf
if(ierr(i).eq.0)then