forked from NCAR/MMM-physics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bl_mynn.F90
1244 lines (1089 loc) · 41.4 KB
/
bl_mynn.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
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 bl_mynn
use ccpp_kind_types,only: kind_phys
use bl_mynn_common,only: &
cp , cpv , cliq , cice , ep_1 , ep_2 , ep_3 , grav , karman , p1000mb , &
r_d , r_v , svp1 , svp2 , svp3 , svpt0 , xlf , xls , xlv , p608 , &
t0c , tref , tkmin , tv0 , gtr , xlvcp , xlscp , rvovrd , rcp , cphh_st , &
cphm_st , cphh_unst , cphm_unst , b1 , b2 , zero
use bl_mynn_subroutines
implicit none
private
public:: bl_mynn_init, &
bl_mynn_finalize, &
bl_mynn_run
contains
!=================================================================================================================
subroutine bl_mynn_init(con_cp,con_cpv,con_cice,con_cliq,con_ep1,con_ep2,con_grav,con_karman,con_p0, &
con_rd,con_rv,con_svp1,con_svp2,con_svp3,con_svpt0,con_xlf,con_xls,con_xlv, &
errmsg,errflg)
!=================================================================================================================
!-- input arguments:
real(kind=kind_phys),intent(in):: &
con_cp, &
con_cpv, &
con_cice, &
con_cliq
real(kind=kind_phys),intent(in):: &
con_ep1, &
con_ep2
real(kind=kind_phys),intent(in):: &
con_grav
real(kind=kind_phys),intent(in):: &
con_karman
real(kind=kind_phys),intent(in):: &
con_p0
real(kind=kind_phys),intent(in):: &
con_rd, &
con_rv
real(kind=kind_phys),intent(in):: &
con_svp1, &
con_svp2, &
con_svp3, &
con_svpt0
real(kind=kind_phys),intent(in):: &
con_xlf, &
con_xls, &
con_xlv
character(len=*),intent(out):: errmsg
integer,intent(out):: errflg
!-----------------------------------------------------------------------------------------------------------------
!--- initialization of physics constants needed in the MYNN PBL scheme and already available from MPAS:
cp = con_cp
cpv = con_cpv
cliq = con_cliq
cice = con_cice
ep_1 = con_ep1
ep_2 = con_ep2
grav = con_grav
karman = con_karman
p1000mb = con_p0
r_d = con_rd
r_v = con_rv
rvovrd = r_v/r_d
svp1 = con_svp1
svp2 = con_svp2
svp3 = con_svp3
svpt0 = con_svpt0
xlf = con_xlf
xls = con_xls
xlv = con_xlv
!--- initialization of derived physics constants needed in the MYNN PBL scheme:
ep_3 = 1.-ep_2
gtr = grav/tref
p608 = ep_1
rcp = r_d/cp
t0c = svpt0
tv0 = p608*tref
xlscp = (xlv+xlf)/cp
xlvcp = xlv/cp
!ev = xlv
!rk = cp/r_d
!svp11 = svp1*1.e3
!tv1 = (1.+p608)*tref
!vk = karman
errmsg = " "
errflg = 0
end subroutine bl_mynn_init
!=================================================================================================================
subroutine bl_mynn_finalize(errmsg,errflg)
!=================================================================================================================
character(len=*),intent(out):: errmsg
integer,intent(out):: errflg
!-----------------------------------------------------------------------------------------------------------------
!note: this subroutine currently does nothing.
errmsg = ' '
errflg = 0
end subroutine bl_mynn_finalize
!=================================================================================================================
subroutine bl_mynn_run &
(initflag , restart , cycling , &
delt , dz , dx , &
znt , u , v , &
w , th , sqv , &
sqc , sqi , sqs , &
qnc , qni , qnwfa , &
qnifa , qnbca , qozone , &
p , exner , rho , &
tt , xland , ts , &
qsfc , ps , ust , &
ch , hfx , qfx , &
rmol , wspd , uoce , &
voce , qke , qke_adv , &
tsq , qsq , cov , &
rublten , rvblten , rthblten , &
rqvblten , rqcblten , rqiblten , &
rqsblten , rqncblten , rqniblten , &
rqnwfablten , rqnifablten , rqnbcablten , &
rqozblten , exch_h , exch_m , &
pblh , kpbl , el_pbl , &
dqke , qwt , qshear , &
qbuoy , qdiss , sh , &
sm , qc_bl , qi_bl , &
cldfra_bl , icloud_bl , bl_mynn_tkeadvect , &
bl_mynn_tkebudget , bl_mynn_cloudpdf , bl_mynn_mixlength , &
bl_mynn_closure , bl_mynn_stfunc , bl_mynn_topdown , &
bl_mynn_edmf , bl_mynn_edmf_dd , bl_mynn_edmf_mom , &
bl_mynn_edmf_tke , bl_mynn_mixscalars , bl_mynn_output , &
bl_mynn_cloudmix , bl_mynn_mixqt , bl_mynn_scaleaware , &
bl_mynn_dheatopt , edmf_a , edmf_w , &
edmf_qt , edmf_thl , edmf_ent , &
edmf_qc , sub_thl , sub_sqv , &
det_thl , det_sqv , edmf_a_dd , &
edmf_w_dd , edmf_qt_dd , edmf_thl_dd , &
edmf_ent_dd , edmf_qc_dd , maxwidth , &
maxmf , ztop_plume , ktop_plume , &
spp_pbl , pattern_spp_pbl , rthraten , &
flag_qc , flag_qi , flag_qs , &
flag_qnc , flag_qni , flag_qnwfa , &
flag_qnifa , flag_qnbca , flag_qoz , &
#if(WRF_CHEM == 1)
mix_chem , nchem , kdvel , &
ndvel , chem , emis_ant_no , &
frp , vdep , &
#endif
its, ite , kts , kte , kme , errmsg , errflg &
)
!=================================================================================================================
!input arguments:
logical,intent(in):: &
flag_qc,flag_qi,flag_qs,flag_qoz,flag_qnc,flag_qni,flag_qnifa,flag_qnwfa,flag_qnbca
logical,intent(in):: bl_mynn_edmf,bl_mynn_edmf_dd,bl_mynn_edmf_mom,bl_mynn_edmf_tke
logical,intent(in):: bl_mynn_mixscalars,bl_mynn_cloudmix,bl_mynn_mixqt
logical,intent(in):: bl_mynn_tkeadvect,bl_mynn_tkebudget
logical,intent(in):: bl_mynn_output,bl_mynn_dheatopt,bl_mynn_scaleaware,bl_mynn_topdown
logical,intent(in):: &
restart,cycling
integer,intent(in):: its,ite,kts,kte,kme
integer,intent(in):: &
initflag,icloud_bl,spp_pbl
integer,intent(in):: &
bl_mynn_cloudpdf,bl_mynn_mixlength,bl_mynn_stfunc
real(kind=kind_phys),intent(in):: &
bl_mynn_closure
real(kind=kind_phys),intent(in):: &
delt
real(kind=kind_phys),intent(in),dimension(its:):: &
dx, &!
xland, &!
ps, &!
ts, &!
qsfc, &!
ust, &!
ch, &!
hfx, &!
qfx, &!
rmol, &!
wspd, &!
uoce, &!
voce, &!
znt !
real(kind=kind_phys),intent(in),dimension(its:,:):: &
dz, &!
u, &!
v, &!
th, &!
tt, &!
p, &!
exner, &!
rho, &!
rthraten !
real(kind=kind_phys),intent(in),dimension(its:,:):: &
sqv, &!
sqc, &!
sqi, &!
sqs, &!
qnc, &!
qni, &!
qnifa, &!
qnwfa, &!
qnbca, &!
qozone !
real(kind=kind_phys),intent(in),dimension(its:,:):: &
pattern_spp_pbl
real(kind=kind_phys),intent(in),dimension(its:,:):: &
w !
!inout arguments:
integer,intent(inout),dimension(its:):: &
kpbl, &!
ktop_plume !
real(kind=kind_phys),intent(inout),dimension(its:):: &
pblh
real(kind=kind_phys),intent(inout),dimension(its:,:):: &
cldfra_bl, &!
qc_bl, &!
qi_bl !
real(kind=kind_phys),intent(inout),dimension(its:,:):: &
el_pbl, &!
qke, &!
qke_adv, &!
cov, &!
qsq, &!
tsq, &!
sh, &!
sm !
real(kind=kind_phys),intent(inout),dimension(its:,:):: &
rublten, &!
rvblten, &!
rthblten, &!
rqvblten, &!
rqcblten, &!
rqiblten, &!
rqsblten, &!
rqncblten, &!
rqniblten, &!
rqnifablten, &!
rqnwfablten, &!
rqnbcablten, &!
rqozblten !
real(kind=kind_phys),intent(inout),dimension(its:,:):: &
edmf_a, &!
edmf_w, &!
edmf_qt, &!
edmf_thl, &!
edmf_ent, &!
edmf_qc, &!
sub_thl, &!
sub_sqv, &!
det_thl, &!
det_sqv !
real(kind=kind_phys),intent(inout),dimension(its:,:),optional:: &
edmf_a_dd, &!
edmf_w_dd, &!
edmf_qt_dd, &!
edmf_thl_dd, &!
edmf_ent_dd, &!
edmf_qc_dd
!output arguments:
character(len=*),intent(out):: &
errmsg ! output error message (-).
integer,intent(out):: &
errflg ! output error flag (-).
real(kind=kind_phys),intent(out),dimension(:):: &
maxwidth, &!
maxmf, &!
ztop_plume
real(kind=kind_phys),intent(out),dimension(its:,:):: &
exch_h, &!
exch_m !
real(kind=kind_phys),intent(out),dimension(its:,:),optional:: &
dqke, &!
qwt, &!
qshear, &!
qbuoy, &!
qdiss !
!local variable and arrays:
logical:: initialize_qke
integer:: i,k
real(kind=kind_phys):: qc_bl2,qi_bl2
real(kind=kind_phys):: cpm,exnerg,flq,flqc,flqv,flt,fltv,phh,pmz,psig_bl,psig_shcu,sqcg,phi_m, &
th_sfc,zet,ts_decay
real(kind=kind_phys),dimension(kts:kte):: cldfra_bl1_old,qc_bl1_old,qi_bl1_old
real(kind=kind_phys),dimension(kts:kte):: qv1,qc1,qi1,qs1
real(kind=kind_phys),dimension(kts:kte):: det_sqc,det_u,det_v,sub_u,sub_v
real(kind=kind_phys),dimension(kts:kte):: pdc,pdk,pdq,pdt,sgm,sqw,thetav,thl,vq,vt,kzero
real(kind=kind_phys),dimension(kts:kte):: dfh,dfm,dfq,qcd,tcd,diss_heat
real(kind=kind_phys),dimension(kts:kte):: rstoch_col
real(kind=kind_phys),dimension(kts:kte+1):: zw
real(kind=kind_phys),dimension(kts:kte+1):: &
s_aw1,s_awthl1,s_awqt1,s_awqv1,s_awqc1,s_awu1,s_awv1,s_awqke1,s_awqnc1,s_awqni1, &
s_awqnwfa1,s_awqnifa1,s_awqnbca1
real(kind=kind_phys),dimension(kts:kte+1):: &
sd_aw1,sd_awthl1,sd_awqt1,sd_awqv1,sd_awqc1,sd_awu1,sd_awv1,sd_awqke1
!JOE-top-down diffusion
logical :: cloudflg
integer :: kk,kminrad
real(kind=kind_phys),parameter:: pfac =2.0, zfmin = 0.01, phifac=8.0
real(kind=kind_phys):: maxkhtopdown
real(kind=kind_phys):: bfxpbl,dthvx,tmp1,temps,templ,zl1,wstar3_2
real(kind=kind_phys):: ent_eff,radsum,radflux,we,rcldb,rvls,minrad,zminrad
real(kind=kind_phys),dimension(kts:kte):: khtopdown,zfac,wscalek2,zfacent,tkeprodtd
!JOE-end top down
!local 1D input arguments:
real(kind=kind_phys):: dx1,xland1,ps1,ts1,qsfc1,ust1,ch1,hfx1,qfx1,rmol1,wspd1, &
uoce1,voce1,znt1
real(kind=kind_phys),dimension(kts:kte):: &
dz1,u1,v1,th1,tk1,p1,ex1,rho1,qnc1,qni1,qnifa1,qnwfa1,qnbca1,qozone1,rthraten1,sqv1,sqc1,sqi1,sqs1
real(kind=kind_phys),dimension(kts:kme):: w1
!local 1D inout arguments:
integer:: kpbl1,ktop_plume1
real(kind=kind_phys):: pblh1
real(kind=kind_phys),dimension(kts:kte):: cldfra_bl1,qc_bl1,qi_bl1
real(kind=kind_phys),dimension(kts:kte):: el_pbl1,qke1,qke_adv1,cov1,qsq1,tsq1,sh1,sm1
real(kind=kind_phys),dimension(kts:kte):: du1,dv1,dth1,dqv1,dqc1,dqi1,dqs1,dqnc1,dqni1,dqnifa1,dqnwfa1, &
dqnbca1,dqozone1
real(kind=kind_phys),dimension(kts:kte):: edmf_a1,edmf_w1,edmf_qt1,edmf_thl1,edmf_ent1,edmf_qc1,sub_thl1, &
sub_sqv1,det_thl1,det_sqv1
real(kind=kind_phys),dimension(kts:kte):: edmf_a_dd1,edmf_w_dd1,edmf_qt_dd1,edmf_thl_dd1,edmf_ent_dd1, &
edmf_qc_dd1
!local 1D output arguments:
real(kind=kind_phys):: maxwidth1,maxmf1,ztop_plume1
real(kind=kind_phys),dimension(kts:kte):: exch_h1,exch_m1
real(kind=kind_phys),dimension(kts:kte):: dqke1,qwt1,qshear1,qbuoy1,qdiss1
!substepping TKE:
integer:: nsub
real(kind=kind_phys):: delt2
!VARIABLES NEEDED FOR MIXING OF CHEMICAL SPECIES:
#if(WRF_CHEM == 1)
!--- inputs:
logical,intent(in):: mix_chem
integer,intent(in):: nchem,kdvel,ndvel
real(kind=kind_phys),intent(in),dimension(its:ite),optional:: frp,emis_ant_no
real(kind=kind_phys),intent(in),dimension(its:ite,ndvel):: vdep
!--- inouts:
real(kind=kind_phys),intent(inout),dimension(its:ite,kts:kte,nchem):: chem
#else
logical,parameter:: mix_chem = .false.
integer,parameter:: nchem = 1
integer,parameter:: kdvel = 1
integer,parameter:: ndvel = 1
#endif
!--- local variables and arrays:
logical,parameter:: rrfs_sd = .false.
logical,parameter:: smoke_dbg = .false.
logical,parameter:: enh_mix = .false.
integer:: ic
real(kind=kind_phys):: emis_ant_no1,frp1
real(kind=kind_phys),dimension(ndvel):: vd1
real(kind=kind_phys),dimension(kts:kte,nchem):: chem1
real(kind=kind_phys),dimension(kts:kte+1,nchem):: s_awchem1
!END VARIABLES NEEDED FOR MIXING OF CHEMICAL SPECIES.
!-----------------------------------------------------------------------------------------------------------------
errmsg = " "
errflg = 0
do i = its,ite
if(present(dqke)) then
do k = kts,kte
dqke(i,k) = qke(i,k)
enddo
endif
!--- initialization of 2D inout tendencies:
do k = kts,kte
rublten(i,k) = 0._kind_phys
rvblten(i,k) = 0._kind_phys
rthblten(i,k) = 0._kind_phys
rqvblten(i,k) = 0._kind_phys
rqcblten(i,k) = 0._kind_phys
rqiblten(i,k) = 0._kind_phys
rqsblten(i,k) = 0._kind_phys
rqncblten(i,k) = 0._kind_phys
rqniblten(i,k) = 0._kind_phys
rqnifablten(i,k) = 0._kind_phys
rqnwfablten(i,k) = 0._kind_phys
rqnbcablten(i,k) = 0._kind_phys
rqozblten(i,k) = 0._kind_phys
enddo
!--- initialization of 2D output variables:
ktop_plume(i) = 0
maxwidth(i) = 0._kind_phys
maxmf(i) = 0._kind_phys
ztop_plume(i) = 0._kind_phys
!--- initialization of 1D input variables using 2D input variables:
dx1 = dx(i)
xland1 = xland(i)
ps1 = ps(i)
ts1 = ts(i)
qsfc1 = qsfc(i)
ust1 = ust(i)
ch1 = ch(i)
hfx1 = hfx(i)
qfx1 = qfx(i)
rmol1 = rmol(i)
wspd1 = wspd(i)
uoce1 = uoce(i)
voce1 = voce(i)
znt1 = znt(i)
do k = kts,kte
dz1(k) = dz(i,k)
u1(k) = u(i,k)
v1(k) = v(i,k)
w1(k) = w(i,k)
th1(k) = th(i,k)
tk1(k) = tt(i,k)
p1(k) = p(i,k)
ex1(k) = exner(i,k)
rho1(k) = rho(i,k)
sh1(k) = sh(i,k)
sm1(k) = sm(i,k)
rthraten1(k) = rthraten(i,k)
sqv1(k) = sqv(i,k)
sqc1(k) = sqc(i,k)
sqi1(k) = sqi(i,k)
sqs1(k) = sqs(i,k)
qnc1(k) = qnc(i,k)
qni1(k) = qni(i,k)
qnifa1(k) = qnifa(i,k)
qnwfa1(k) = qnwfa(i,k)
qnbca1(k) = qnbca(i,k)
qozone1(k) = qozone(i,k)
kzero(k) = 0._kind_phys
enddo
do k = kte,kte+1
w1(k) = w(i,k)
enddo
!--- initialization of the PBL stochastic forcing:
if(spp_pbl .eq. 1) then
do k = kts,kte
rstoch_col(k) = pattern_spp_pbl(i,k)
enddo
else
do k = kts,kte
rstoch_col(k) = 0._kind_phys
enddo
endif
!--- initialization of 1D inout variables using 2D inout variables:
kpbl1 = kpbl(i)
pblh1 = pblh(i)
do k = kts,kte
cldfra_bl1(k) = cldfra_bl(i,k)
qc_bl1(k) = qc_bl(i,k)
qi_bl1(k) = qi_bl(i,k)
enddo
do k = kts,kte
el_pbl1(k) = el_pbl(i,k)
qke1(k) = qke(i,k)
qke_adv1(k) = qke_adv(i,k)
cov1(k) = cov(i,k)
qsq1(k) = qsq(i,k)
tsq1(k) = tsq(i,k)
sh1(k) = sh(i,k)
sm1(k) = sm(i,k)
enddo
!--- initialization of 1D local variables:
ktop_plume1 = 0
maxwidth1 = 0._kind_phys
maxmf1 = 0._kind_phys
ztop_plume1 = 0._kind_phys
maxkhtopdown = 0._kind_phys
do k = kts,kte
du1(k) = 0._kind_phys
dv1(k) = 0._kind_phys
dth1(k) = 0._kind_phys
dqv1(k) = 0._kind_phys
dqc1(k) = 0._kind_phys
dqi1(k) = 0._kind_phys
dqs1(k) = 0._kind_phys
dqnc1(k) = 0._kind_phys
dqni1(k) = 0._kind_phys
dqnifa1(k) = 0._kind_phys
dqnwfa1(k) = 0._kind_phys
dqnbca1(k) = 0._kind_phys
dqozone1(k) = 0._kind_phys
enddo
do k = kts,kte
edmf_a1(k) = 0._kind_phys
edmf_w1(k) = 0._kind_phys
edmf_qc1(k) = 0._kind_phys
edmf_ent1(k) = 0._kind_phys
edmf_qt1(k) = 0._kind_phys
edmf_thl1(k) = 0._kind_phys
sub_thl1(k) = 0._kind_phys
sub_sqv1(k) = 0._kind_phys
det_thl1(k) = 0._kind_phys
det_sqv1(k) = 0._kind_phys
edmf_a_dd1(k) = 0._kind_phys
edmf_w_dd1(k) = 0._kind_phys
edmf_qc_dd1(k) = 0._kind_phys
edmf_ent_dd1(k) = 0._kind_phys
edmf_qt_dd1(k) = 0._kind_phys
edmf_thl_dd1(k) = 0._kind_phys
enddo
do k = kts,kte
dqke1(k) = 0._kind_phys
qwt1(k) = 0._kind_phys
qshear1(k) = 0._kind_phys
qbuoy1(k) = 0._kind_phys
qdiss1(k) = 0._kind_phys
exch_h1(k) = 0._kind_phys
exch_m1(k) = 0._kind_phys
enddo
do k = kts,kte
sub_u(k) = 0._kind_phys
sub_v(k) = 0._kind_phys
det_sqc(k) = 0._kind_phys
det_u(k) = 0._kind_phys
det_v(k) = 0._kind_phys
enddo
do k = kts,kte+1
s_aw1(k) = 0._kind_phys
s_awthl1(k) = 0._kind_phys
s_awqt1(k) = 0._kind_phys
s_awqv1(k) = 0._kind_phys
s_awqc1(k) = 0._kind_phys
s_awu1(k) = 0._kind_phys
s_awv1(k) = 0._kind_phys
s_awqke1(k) = 0._kind_phys
s_awqnc1(k) = 0._kind_phys
s_awqni1(k) = 0._kind_phys
s_awqnwfa1(k) = 0._kind_phys
s_awqnifa1(k) = 0._kind_phys
s_awqnbca1(k) = 0._kind_phys
enddo
do k = kts,kte+1
sd_aw1(k) = 0._kind_phys
sd_awthl1(k) = 0._kind_phys
sd_awqt1(k) = 0._kind_phys
sd_awqv1(k) = 0._kind_phys
sd_awqc1(k) = 0._kind_phys
sd_awu1(k) = 0._kind_phys
sd_awv1(k) = 0._kind_phys
sd_awqke1(k) = 0._kind_phys
enddo
do k = kts,kte
cldfra_bl1_old(k) = 0._kind_phys
qc_bl1_old(k) = 0._kind_phys
qi_bl1_old(k) = 0._kind_phys
enddo
do k = kts,kte
qv1(k) = sqv1(k)/(1.-sqv1(k))
qc1(k) = sqc1(k)/(1.-sqv1(k))
qi1(k) = sqi1(k)/(1.-sqv1(k))
qs1(k) = sqs1(k)/(1.-sqv1(k))
enddo
k = kts
zw(k) = 0._kind_phys
do k = kts+1,kte+1
zw(k) = zw(k-1) + dz1(k-1)
enddo
!INITIALIZATION OF LOCAL CHEMICAL SPECIES:
#if(WRF_CHEM == 1)
do ic = 1,nchem
vd1(ic) = vdep(i,ic)
do k = kts,kte
chem1(k,ic) = chem(i,k,ic)
enddo
enddo
if(present(emis_ant_no) .and. present(frp)) then
emis_ant_no1 = emis_ant_no(i)
frp1 = frp(i)
else
emis_ant_no1 = 0._kind_phys
frp1 = 0._kind_phys
endif
!END INITIALIZATION OF LOCAL CHEMICAL SPECIES.
#else
do ic = 1,nchem
vd1(ic) = 0._kind_phys
do k = kts,kte
chem1(k,ic) = 0._kind_phys
enddo
enddo
emis_ant_no1 = 0._kind_phys
frp1 = 0._kind_phys
#endif
do ic = 1,nchem
do k = kts,kte+1
s_awchem1(k,ic) = 0._kind_phys
enddo
enddo
!END INITIALIZATION OF LOCAL CHEMICAL SPECIES.
do k = kts,kte
!keep snow out for now - increase ceiling bias
sqw(k) = sqv1(k)+sqc1(k)+sqi1(k) !+sqs1(k)
thl(k) = th1(k) - xlvcp/ex1(k)*sqc1(k) - xlscp/ex1(k)*(sqi1(k))!+sqs1(k))
thetav(k) = th1(k)*(1.+0.608*sqv1(k))
!Use form from Tripoli and Cotton (1981) with their
!suggested min temperature to improve accuracy.
!thl(k)=th(k)*(1.- xlvcp/MAX(tk1(k),TKmin)*sqc1(k) - xlscp/MAX(tk1(k),TKmin)*sqi1(k))
!thetav(k) = th1(k)*(1.+p608)*sqv1(k)
enddo
!-----------------------------------------------------------------------------------------------------------------
!initflag > 0:
!-----------------------------------------------------------------------------------------------------------------
if(initflag > 0 .and. .not.restart) then
!test to see if we want to initialize qke1:
if((restart .or. cycling)) then
if(qke1(kts) < 0.0002) then
initialize_qke = .true.
else
initialize_qke = .false.
endif
else ! not cycling or restarting:
initialize_qke = .true.
endif
if(.not.restart .or. .not.cycling) then
do k = kts,kte
sh1(k) = 0._kind_phys
sm1(k) = 0._kind_phys
el_pbl1(k) = 0._kind_phys
tsq1(k) = 0._kind_phys
qsq1(k) = 0._kind_phys
cov1(k) = 0._kind_phys
cldfra_bl1(k) = 0._kind_phys
qc_bl1(k) = 0._kind_phys
qi_bl1(k) = 0._kind_phys
qke1(k) = 0._kind_phys
enddo
endif
do k = kts,kte
cldfra_bl1_old(k) = 0._kind_phys
qc_bl1_old(k) = 0._kind_phys
qi_bl1_old(k) = 0._kind_phys
enddo
if(initialize_qke) then
do k = kts,kte
qke1(k)=5.*ust1*max((ust1*700.-zw(k))/(max(ust1,0.01)*700.),0.01)
enddo
endif
!--- computes the PBL height:
call get_pblh(kts,kte,pblh1,thetav,qke1,zw,dz1,xland1,kpbl1)
!--- computes the similarity functions:
if(bl_mynn_scaleaware) then
call scale_aware(dx1,pblh1,psig_bl,psig_shcu)
else
psig_bl = 1._kind_phys
psig_shcu = 1._kind_phys
endif
!--- calls mym_initialize:
call mym_initialize( &
kts,kte,xland1, &
dz1,dx1,zw, &
u1,v1,thl,sqv1, &
pblh1,th1,thetav,sh1,sm1, &
ust1, rmol1, &
el_pbl1,qke1,tsq1,qsq1,cov1, &
psig_bl,cldfra_bl1, &
bl_mynn_mixlength, &
edmf_w1,edmf_a1, &
initialize_qke, &
spp_pbl,rstoch_col)
endif
!-----------------------------------------------------------------------------------------------------------------
!end initflag > 0:
!-----------------------------------------------------------------------------------------------------------------
if(bl_mynn_tkeadvect) then
do k = kts,kte
qke1(k) = qke_adv1(k)
enddo
endif
!Joe-TKE budget:
if(bl_mynn_tkebudget) then
do k = kts,kte
dqke1(k) = qke1(k)
enddo
endif
if(icloud_bl > 0) then
do k = kts,kte
cldfra_bl1_old(k) = cldfra_bl1(k)
qc_bl1_old(k) = qc_bl1(k)
qi_bl1_old(k) = qi_bl1(k)
enddo
endif
!--- computes the PBL height:
call get_pblh(kts,kte,pblh1,thetav,qke1,zw,dz1,xland1,kpbl1)
!--- computes the similarity functions:
if(bl_mynn_scaleaware) then
call scale_aware(dx1,pblh1,psig_bl,psig_shcu)
else
psig_bl = 1._kind_phys
psig_shcu = 1._kind_phys
endif
sqcg = 0.0 !ill-defined variable; qcg has been removed
cpm = cp*(1.+0.84*qv1(kts))
exnerg = (ps1/p1000mb)**rcp
!-----------------------------------------------------
!ORIGINAL CODE
!flt = hfx(i)/( rho(i,kts)*cpm ) &
! +xlvcp*ch(i)*(sqc(kts)/exner(i,kts) -sqcg/exnerg)
!flq = qfx(i)/ rho(i,kts) &
! -ch(i)*(sqc(kts) -sqcg )
!-----------------------------------------------------
flqv = qfx1/rho1(kts)
flqc = 0.0 !currently no sea-spray fluxes, fog settling hangled elsewhere
th_sfc = ts1/ex1(kts)
!--- turbulent flux for the TKE voundary conditions:
flq = flqv + flqc ! Latent
flt = hfx1/(rho1(kts)*cpm ) - xlvcp*flqc/ex1(kts) ! Temperature flux
fltv = flt + flqv*p608*th_sfc ! Virtual temperature flux
!--- update 1/L using updated sfc heat flux and friction velocity:
rmol1 = -karman*gtr*fltv/max(ust1**3,1.0e-6)
zet = 0.5*dz1(kts)*rmol1
zet = max(zet, -20.)
zet = min(zet, 20.)
!if(i.eq.idbg)print*,"updated z/L=",zet
if(bl_mynn_stfunc == 0) then
!original Kansas-type stability functions:
if(zet >= 0.0) then
pmz = 1.0 + (cphm_st-1.0) * zet
phh = 1.0 + cphh_st * zet
else
pmz = 1.0/ (1.0-cphm_unst*zet)**0.25 - zet
phh = 1.0/sqrt(1.0-cphh_unst*zet)
endif
phi_m = pmz + zet
else
!updated stability functions (Puhales, 2020):
phi_m = phim(zet)
pmz = phi_m - zet
phh = phih(zet)
endif
!call mym_condensation() to calculate the nonconvective component of the subgrid-scale cloud fraction
!and mixing ratio as well as the functions used to calculate the buoyancy flux. Different cloud PDFs
!can be selected by use of the namelist parameter bl_mynn_cloudpdf:
do k = kts,kte
vt(k) = 0._kind_phys
vq(k) = 0._kind_phys
sgm(k) = 0._kind_phys
enddo
call mym_condensation(kts,kte, &
dx1,dz1,zw,xland1, &
thl,sqw,sqv1,sqc1,sqi1,sqs1, &
p1,ex1,tsq1,qsq1,cov1, &
sh1,el_pbl1,bl_mynn_cloudpdf, &
qc_bl1,qi_bl1,cldfra_bl1, &
pblh1,hfx1, &
vt,vq,th1,sgm,rmol1, &
spp_pbl,rstoch_col)
!add TKE source driven by cloud top cooling. calculate the buoyancy production of tke from cloud-top
!cooling when bl_mynn_topdown = .true.
if(bl_mynn_topdown)then
call topdown_cloudrad(kts,kte,dz1,zw,fltv, &
xland1,kpbl1,pblh1, &
sqc1,sqi1,sqw,thl,th1,ex1,p1,rho1,thetav, &
cldfra_bl1,rthraten1, &
maxkhtopdown,khtopdown,tkeprodtd)
else
maxkhtopdown = 0._kind_phys
do k = kts,kte
khtopdown(k) = 0._kind_phys
tkeprodtd(k) = 0._kind_phys
enddo
endif
!--- calls subroutine dmp_mf():
if(bl_mynn_edmf) then
call dmp_mf( i, &
kts,kte,delt,zw,dz1,p1,rho1, &
bl_mynn_edmf_mom, &
bl_mynn_edmf_tke, &
bl_mynn_mixscalars, &
u1,v1,w1,th1,thl,thetav,tk1, &
sqw,sqv1,sqc1,qke1, &
qnc1,qni1,qnwfa1,qnifa1,qnbca1, &
ex1,vt,vq,sgm, &
ust1,flt,fltv,flq,flqv, &
pblh1,kpbl1,dx1, &
xland1,th_sfc, &
!now outputs - tendencies
!dth1mf,dqv1mf,dqc1mf,du1mf,dv1mf, &
!outputs - updraft properties
edmf_a1,edmf_w1,edmf_qt1, &
edmf_thl1,edmf_ent1,edmf_qc1, &
!for the solver
s_aw1,s_awthl1,s_awqt1, &
s_awqv1,s_awqc1, &
s_awu1,s_awv1,s_awqke1, &
s_awqnc1,s_awqni1, &
s_awqnwfa1,s_awqnifa1,s_awqnbca1, &
sub_thl1,sub_sqv1, &
sub_u,sub_v, &
det_thl1,det_sqv1,det_sqc, &
det_u,det_v, &
!chem/smoke mixing
nchem,chem1,s_awchem1, &
mix_chem, &
qc_bl1,cldfra_bl1, &
qc_bl1_old,cldfra_bl1_old, &
flag_qc,flag_qi, &
flag_qnc,flag_qni, &
flag_qnwfa,flag_qnifa,flag_qnbca, &
psig_shcu, &
maxwidth1,ktop_plume1, &
maxmf1,ztop_plume1, &
spp_pbl,rstoch_col)
if(bl_mynn_edmf_dd) then
call ddmf_jpl(kts,kte,delt,zw,dz1,p1, &
u1,v1,th1,thl,thetav,tk1, &
sqw,sqv1,sqc1,rho1,ex1, &
ust1,flt,flq, &
pblh1,kpbl1, &
edmf_a_dd1,edmf_w_dd1,edmf_qt_dd1, &
edmf_thl_dd1,edmf_ent_dd1, &
edmf_qc_dd1, &
sd_aw1,sd_awthl1,sd_awqt1, &
sd_awqv1,sd_awqc1,sd_awu1,sd_awv1, &
sd_awqke1, &
qc_bl1,cldfra_bl1, &
rthraten)
endif
endif
!--- capability to substep the eddy-diffusivity portion:
!do nsub = 1,2
delt2 = delt !*0.5 !only works if topdown=0
call mym_turbulence &
(kts,kte,xland1,bl_mynn_closure, &
dz1,dx1,zw, &
u1,v1,thl,thetav,sqc1,sqw, &
qke1,tsq1,qsq1,cov1, &
vt,vq, &
rmol1,flt,fltv,flq, &
pblh1,th1, &
sh1,sm1,el_pbl1, &
dfm,dfh,dfq, &
tcd,qcd,pdk, &
pdt,pdq,pdc, &
qwt1,qshear1,qbuoy1,qdiss1, &
bl_mynn_tkebudget, &
psig_bl,psig_shcu, &
cldfra_bl1,bl_mynn_mixlength, &
edmf_w1,edmf_a1, &
tkeprodtd, &
spp_pbl,rstoch_col)
!--- calls subroutine mym_predict() to solve TKE:
call mym_predict &
(kts,kte,bl_mynn_closure, &
delt2,dz1, &
ust1,flt,flq,pmz,phh, &
el_pbl1,dfq,rho1,pdk,pdt,pdq,pdc, &
qke1,tsq1,qsq1,cov1, &
s_aw1,s_awqke1,bl_mynn_edmf_tke, &
qwt1,qdiss1,bl_mynn_tkebudget) ! TKE budget (Puhales 2020)
if(bl_mynn_dheatopt) then
do k = kts,kte-1
!set max dissipative heating rate to 7.2 K per hour
diss_heat(k) = min(max(1.0*(qke1(k)**1.5)/(b1*max(0.5*(el_pbl1(k)+el_pbl1(k+1)),1.))/cp,0.0),0.002)
!limit heating above 100 mb:
diss_heat(k) = diss_heat(k) * exp(-10000./MAX(p1(k),1.))
enddo
diss_heat(kte) = 0.
else
do k = kts,kte
diss_heat(k) = 0.
enddo
endif
!--- call to subroutine mynn_tendencies:
call mynn_tendencies(kts,kte, &
delt,dz1,rho1, &
u1,v1,th1,tk1,qv1, &
qc1,qi1,kzero,qnc1,qni1, & !kzero replaces qs1 - not mixing snow
ps1,p1,ex1,thl, &
sqv1,sqc1,sqi1,kzero,sqw, & !kzero replaces sqs - not mxing snow
qnwfa1,qnifa1,qnbca1,qozone1, &
ust1,flt,flq,flqv,flqc, &
wspd1,uoce1,voce1, &
tsq1,qsq1,cov1, &
tcd,qcd, &
dfm,dfh,dfq, &