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_cam_cldwat.F
1816 lines (1666 loc) · 67.3 KB
/
module_cam_cldwat.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
#undef DEBUG
#define WRF_PORT
#define MODAL_AERO
! Updated to CESM1.0.3 (CAM5.1.01) by [email protected]
module cldwat
!-----------------------------------------------------------------------
!
! Purpose: Prognostic cloud water data and methods.
!
! Public interfaces:
!
! inimc -- Initialize constants
! pcond -- Calculate prognostic condensate
!
! cldwat_fice -- calculate fraction of condensate in ice phase (radiation partitioning)
!
! Author: P. Rasch, with Modifications by Minghua Zhang
! January 2010, modified by J. Kay to add precip fluxes for COSP simulator
! Ported to WRF by [email protected], Nov. 2009
! updated to CESM1_0_1, Nov. 2010
!
!-----------------------------------------------------------------------
use shr_kind_mod, only: r8 => shr_kind_r8
#ifndef WRF_PORT
use spmd_utils, only: masterproc
use ppgrid, only: pcols, pver, pverp
#endif
use wv_saturation, only: estblf, hlatv, tmin, hlatf, rgasv, pcf, &
cp, epsqs, ttrice
#ifndef WRF_PORT
use abortutils, only: endrun
use cam_logfile, only: iulog
#else
use module_cam_support, only: masterproc, &
pcols, pver, pverp, &
endrun, &
iulog
#endif
implicit none
!-----------------------------------------------------------------------
! PUBLIC: Make default data and interfaces private
!-----------------------------------------------------------------------
private
save
#ifndef WRF_PORT
public inimc, pcond ! Public interfaces
#endif
public cldwat_fice ! Public interfaces
public cldwat_readnl
integer, public:: ktop ! Level above 10 hPa
#ifndef WRF_PORT
real(r8),public :: icritc ! threshold for autoconversion of cold ice
real(r8),public :: icritw ! threshold for autoconversion of warm ice
!!$ real(r8),public,parameter:: conke = 1.e-6 ! tunable constant for evaporation of precip
!!$ real(r8),public,parameter:: conke = 2.e-6 ! tunable constant for evaporation of precip
real(r8),public :: conke ! tunable constant for evaporation of precip
real(r8),public :: r3lcrit ! critical radius where liq conversion begins
#else
! Currently, the WRF_PORT bipasses the namelist initialization of these
! tunable parameters. We are hard-coding them to the default values for
! the fv 0.23x0.31 grid. One might choose to implement an option to set
! these via the WRF Registry in the future.
real(r8),public :: icritw = 2.0e-4
real(r8),public :: icritc = 45.0e-6
real(r8),public :: conke = 5.0e-6
#endif
!-----------------------------------------------------------------------
! PRIVATE: Everything else is private to this module
!-----------------------------------------------------------------------
real(r8), private:: tmax_fice! max temperature for cloud ice formation
real(r8), private:: tmin_fice! min temperature for cloud ice formation
real(r8), private:: tmax_fsnow ! max temperature for transition to convective snow
real(r8), private:: tmin_fsnow ! min temperature for transition to convective snow
real(r8), private:: rhonot ! air density at surface
real(r8), private:: t0 ! Freezing temperature
real(r8), private:: cldmin ! assumed minimum cloud amount
real(r8), private:: small ! small number compared to unity
real(r8), private:: c ! constant for graupel like snow cm**(1-d)/s
real(r8), private:: d ! constant for graupel like snow
real(r8), private:: esi ! collection efficient for ice by snow
real(r8), private:: esw ! collection efficient for water by snow
real(r8), private:: nos ! particles snow / cm**4
real(r8), private:: pi ! Mathematical constant
real(r8), private:: gravit ! Gravitational acceleration at surface
real(r8), private:: rh2o
real(r8), private:: prhonos
real(r8), private:: thrpd ! numerical three added to d
real(r8), private:: gam3pd ! gamma function on (3+d)
real(r8), private:: gam4pd ! gamma function on (4+d)
real(r8), private:: rhoi ! ice density
real(r8), private:: rhos ! snow density
real(r8), private:: rhow ! water density
real(r8), private:: mcon01 ! constants used in cloud microphysics
real(r8), private:: mcon02 ! constants used in cloud microphysics
real(r8), private:: mcon03 ! constants used in cloud microphysics
real(r8), private:: mcon04 ! constants used in cloud microphysics
real(r8), private:: mcon05 ! constants used in cloud microphysics
real(r8), private:: mcon06 ! constants used in cloud microphysics
real(r8), private:: mcon07 ! constants used in cloud microphysics
real(r8), private:: mcon08 ! constants used in cloud microphysics
integer, private :: k1mb ! index of the eta level near 1 mb
! Parameters used in findmcnew
real(r8) :: capnsi ! sea ice cloud particles / cm3
real(r8) :: capnc ! cold and oceanic cloud particles / cm3
real(r8) :: capnw ! warm continental cloud particles / cm3
real(r8) :: kconst ! const for terminal velocity (stokes regime)
real(r8) :: effc ! collection efficiency
real(r8) :: alpha ! ratio of 3rd moment radius to 2nd
real(r8) :: capc ! constant for autoconversion
real(r8) :: convfw ! constant used for fall velocity calculation
real(r8) :: cracw ! constant used for rain accreting water
real(r8) :: critpr ! critical precip rate collection efficiency changes
real(r8) :: ciautb ! coefficient of autoconversion of ice (1/s)
#ifdef DEBUG
integer, private,parameter :: nlook = 1 ! Number of points to examine
integer, private :: ilook(nlook) ! Longitude index to examine
integer, private :: latlook(nlook) ! Latitude index to examine
integer, private :: lchnklook(nlook) ! Chunk index to examine
integer, private :: icollook(nlook) ! Column index to examine
#endif
! Private data
real(r8), parameter :: unset_r8 = huge(1.0_r8)
contains
!===============================================================================
subroutine cldwat_readnl(nlfile)
#ifndef WRF_PORT
use namelist_utils, only: find_group_name
use units, only: getunit, freeunit
use mpishorthand
#endif
character(len=*), intent(in) :: nlfile ! filepath for file containing namelist input
#ifndef WRF_PORT
! Namelist variables
real(r8) :: cldwat_icritw = unset_r8 ! icritw = threshold for autoconversion of warm ice
real(r8) :: cldwat_icritc = unset_r8 ! icritc = threshold for autoconversion of cold ice
real(r8) :: cldwat_conke = unset_r8 ! conke = tunable constant for evaporation of precip
real(r8) :: cldwat_r3lcrit = unset_r8 ! r3lcrit = critical radius where liq conversion begins
! Local variables
integer :: unitn, ierr
character(len=*), parameter :: subname = 'cldwat_readnl'
namelist /cldwat_nl/ cldwat_icritw, cldwat_icritc, cldwat_conke, cldwat_r3lcrit
!-----------------------------------------------------------------------------
if (masterproc) then
unitn = getunit()
open( unitn, file=trim(nlfile), status='old' )
call find_group_name(unitn, 'cldwat_nl', status=ierr)
if (ierr == 0) then
read(unitn, cldwat_nl, iostat=ierr)
if (ierr /= 0) then
call endrun(subname // ':: ERROR reading namelist')
end if
end if
close(unitn)
call freeunit(unitn)
! set local variables
icritw = cldwat_icritw
icritc = cldwat_icritc
conke = cldwat_conke
r3lcrit = cldwat_r3lcrit
end if
#ifdef SPMD
! Broadcast namelist variables
call mpibcast(icritw, 1, mpir8, 0, mpicom)
call mpibcast(icritc, 1, mpir8, 0, mpicom)
call mpibcast(conke, 1, mpir8, 0, mpicom)
call mpibcast(r3lcrit, 1, mpir8, 0, mpicom)
#endif
#endif
end subroutine cldwat_readnl
!================================================================================================
subroutine cldwat_fice(ncol, t, fice, fsnow)
!
! Compute the fraction of the total cloud water which is in ice phase.
! The fraction depends on temperature only.
! This is the form that was used for radiation, the code came from cldefr originally
!
! Author: B. A. Boville Sept 10, 2002
! modified: PJR 3/13/03 (added fsnow to ascribe snow production for convection )
!-----------------------------------------------------------------------
use physconst, only: tmelt
implicit none
! Arguments
integer, intent(in) :: ncol ! number of active columns
real(r8), intent(in) :: t(pcols,pver) ! temperature
real(r8), intent(out) :: fice(pcols,pver) ! Fractional ice content within cloud
real(r8), intent(out) :: fsnow(pcols,pver) ! Fractional snow content for convection
! Local variables
integer :: i,k ! loop indexes
!-----------------------------------------------------------------------
!BSINGH - This is a temporary fix for uninitialized tmax_* and tmin_* variables
!This can be fixed by calling the inimc subroutine in physics init calls
tmax_fice = tmelt - 10._r8
tmin_fice = tmax_fice - 30._r8
tmax_fsnow = tmelt
tmin_fsnow = tmelt - 5._r8
! Define fractional amount of cloud that is ice
do k=1,pver
do i=1,ncol
! If warmer than tmax then water phase
if (t(i,k) > tmax_fice) then
fice(i,k) = 0.0_r8
! If colder than tmin then ice phase
else if (t(i,k) < tmin_fice) then
fice(i,k) = 1.0_r8
! Otherwise mixed phase, with ice fraction decreasing linearly from tmin to tmax
else
fice(i,k) =(tmax_fice - t(i,k)) / (tmax_fice - tmin_fice)
end if
! snow fraction partitioning
! If warmer than tmax then water phase
if (t(i,k) > tmax_fsnow) then
fsnow(i,k) = 0.0_r8
! If colder than tmin then ice phase
else if (t(i,k) < tmin_fsnow) then
fsnow(i,k) = 1.0_r8
! Otherwise mixed phase, with ice fraction decreasing linearly from tmin to tmax
else
fsnow(i,k) =(tmax_fsnow - t(i,k)) / (tmax_fsnow - tmin_fsnow)
end if
end do
end do
return
end subroutine cldwat_fice
#ifndef WRF_PORT
subroutine inimc( tmeltx, rhonotx, gravitx, rh2ox)
!-----------------------------------------------------------------------
!
! Purpose:
! initialize constants for the prognostic condensate
!
! Author: P. Rasch, April 1997
!
!-----------------------------------------------------------------------
use pmgrid, only: plev, plevp
use dycore, only: dycore_is, get_resolution
use hycoef, only: hypm
use phys_control, only: phys_getopts
integer k
real(r8), intent(in) :: tmeltx
real(r8), intent(in) :: rhonotx
real(r8), intent(in) :: gravitx
real(r8), intent(in) :: rh2ox
#ifdef UNICOSMP
real(r8) signgam ! variable required by cray gamma function
external gamma
#endif
character(len=16) :: microp_scheme
! Get microphysics option
call phys_getopts( microp_scheme_out = microp_scheme )
! Set following for all physics packages
tmax_fice = tmeltx - 10._r8
!! tmax_fice = tmeltx
!! tmin_fice = tmax_fice - 20.
tmin_fice = tmax_fice - 30._r8
tmax_fsnow = tmeltx
tmin_fsnow = tmeltx - 5._r8
! Set remaining for RK microphysics
if( microp_scheme .eq. 'RK' ) then
rhonot = rhonotx ! air density at surface (gm/cm3)
gravit = gravitx
rh2o = rh2ox
rhos = .1_r8 ! assumed snow density (gm/cm3)
rhow = 1._r8 ! water density
rhoi = 1._r8 ! ice density
esi = 1.0_r8 ! collection efficient for ice by snow
esw = 0.1_r8 ! collection efficient for water by snow
t0 = tmeltx ! approximate freezing temp
cldmin = 0.02_r8 ! assumed minimum cloud amount
small = 1.e-22_r8 ! a small number compared to unity
c = 152.93_r8 ! constant for graupel like snow cm**(1-d)/s
d = 0.25_r8 ! constant for graupel like snow
nos = 3.e-2_r8 ! particles snow / cm**4
pi = 4._r8*atan(1.0_r8)
prhonos = pi*rhos*nos
thrpd = 3._r8 + d
if (d==0.25_r8) then
gam3pd = 2.549256966718531_r8 ! only right for d = 0.25
gam4pd = 8.285085141835282_r8
else
#ifdef UNICOSMP
call gamma(3._r8+d, signgam, gam3pd)
gam3pd = sign(exp(gam3pd),signgam)
call gamma(4._r8+d, signgam, gam4pd)
gam4pd = sign(exp(gam4pd),signgam)
write(iulog,*) ' d, gamma(3+d), gamma(4+d) =', gam3pd, gam4pd
#ifdef WRF_PORT
call wrf_message(iulog)
#endif
#else
write(iulog,*) ' can only use d ne 0.25 on a cray '
#ifdef WRF_PORT
call wrf_message(iulog)
#endif
stop
#endif
endif
mcon01 = pi*nos*c*gam3pd/4._r8
mcon02 = 1._r8/(c*gam4pd*sqrt(rhonot)/(6*prhonos**(d/4._r8)))
mcon03 = -(0.5_r8+d/4._r8)
mcon04 = 4._r8/(4._r8+d)
mcon05 = (3+d)/(4+d)
mcon06 = (3+d)/4._r8
mcon07 = mcon01*sqrt(rhonot)*mcon02**mcon05/prhonos**mcon06
mcon08 = -0.5_r8/(4._r8+d)
! find the level about 1mb, we wont do the microphysics above this level
k1mb = 1
do k=1,pver-1
if (hypm(k) < 1.e2_r8 .and. hypm(k+1) >= 1.e2_r8) then
if (1.e2_r8-hypm(k) < hypm(k+1)-1.e2_r8) then
k1mb = k
else
k1mb = k + 1
end if
goto 20
end if
end do
if (masterproc) then
write(iulog,*)'inimc: model levels bracketing 1 mb not found'
#ifdef WRF_PORT
call wrf_message(iulog)
#endif
end if
! call endrun
k1mb = 1
20 if( masterproc ) write(iulog,*)'inimc: model level nearest 1 mb is',k1mb,'which is',hypm(k1mb),'pascals'
#ifdef WRF_PORT
call wrf_message(iulog)
#endif
if( masterproc ) write(iulog,*) 'cloud water initialization by inimc complete '
#ifdef WRF_PORT
call wrf_message(iulog)
#endif
! Initialize parameters used by findmcnew
capnw = 400._r8 ! warm continental cloud particles / cm3
capnc = 150._r8 ! cold and oceanic cloud particles / cm3
! capnsi = 40._r8 ! sea ice cloud particles density / cm3
capnsi = 75._r8 ! sea ice cloud particles density / cm3
kconst = 1.18e6_r8 ! const for terminal velocity
! effc = 1._r8 ! autoconv collection efficiency following boucher 96
! effc = .55*0.05_r8 ! autoconv collection efficiency following baker 93
effc = 0.55_r8 ! autoconv collection efficiency following tripoli and cotton
! effc = 0._r8 ! turn off warm-cloud autoconv
alpha = 1.1_r8**4
capc = pi**(-.333_r8)*kconst*effc *(0.75_r8)**(1.333_r8)*alpha ! constant for autoconversion
! critical precip rate at which we assume the collector drops can change the
! drop size enough to enhance the auto-conversion process (mm/day)
critpr = 0.5_r8
convfw = 1.94_r8*2.13_r8*sqrt(rhow*1000._r8*9.81_r8*2.7e-4_r8)
! liquid microphysics
! cracw = 6_r8 ! beheng
cracw = .884_r8*sqrt(9.81_r8/(rhow*1000._r8*2.7e-4_r8)) ! tripoli and cotton
! ice microphysics
ciautb = 5.e-4_r8
if ( masterproc ) then
write(iulog,*)'tuning parameters cldwat: icritw',icritw,'icritc',icritc,'conke',conke,'r3lcrit',r3lcrit
#ifdef WRF_PORT
call wrf_message(iulog)
#endif
write(iulog,*)'tuning parameters cldwat: capnw',capnw,'capnc',capnc,'capnsi',capnsi,'kconst',kconst
#ifdef WRF_PORT
call wrf_message(iulog)
#endif
write(iulog,*)'tuning parameters cldwat: effc',effc,'alpha',alpha,'capc',capc
#ifdef WRF_PORT
call wrf_message(iulog)
#endif
write(iulog,*)'tuning parameters cldwat: critpr',critpr,'convfw',convfw,'cracw',cracw,'ciautb',ciautb
#ifdef WRF_PORT
call wrf_message(iulog)
#endif
endif
endif
return
end subroutine inimc
subroutine pcond (lchnk ,ncol , &
tn ,ttend ,qn ,qtend ,omega , &
cwat ,p ,pdel ,cldn ,fice , fsnow, &
cme ,prodprec,prodsnow,evapprec,evapsnow,evapheat, prfzheat, &
meltheat,precip ,snowab ,deltat ,fwaut , &
fsaut ,fracw ,fsacw ,fsaci ,lctend , &
rhdfda ,rhu00 ,seaicef, zi ,ice2pr, liq2pr, &
liq2snow, snowh, rkflxprc, rkflxsnw, pracwo, psacwo, psacio)
!-----------------------------------------------------------------------
!
! Purpose:
! The public interface to the cloud water parameterization
! returns tendencies to water vapor, temperature and cloud water variables
!
! For basic method
! See: Rasch, P. J, and J. E. Kristjansson, A Comparison of the CCM3
! model climate using diagnosed and
! predicted condensate parameterizations, 1998, J. Clim., 11,
! pp1587---1614.
!
! For important modifications to improve the method of determining
! condensation/evaporation see Zhang et al (2001, in preparation)
!
! Authors: M. Zhang, W. Lin, P. Rasch and J.E. Kristjansson
! B. A. Boville (latent heat of fusion)
!-----------------------------------------------------------------------
use wv_saturation, only: vqsatd
use cam_control_mod, only: nlvdry
!
!---------------------------------------------------------------------
!
! Input Arguments
!
integer, intent(in) :: lchnk ! chunk identifier
integer, intent(in) :: ncol ! number of atmospheric columns
real(r8), intent(in) :: fice(pcols,pver) ! fraction of cwat that is ice
real(r8), intent(in) :: fsnow(pcols,pver) ! fraction of rain that freezes to snow
real(r8), intent(in) :: cldn(pcols,pver) ! new value of cloud fraction (fraction)
real(r8), intent(in) :: cwat(pcols,pver) ! cloud water (kg/kg)
real(r8), intent(in) :: omega(pcols,pver) ! vert pressure vel (Pa/s)
real(r8), intent(in) :: p(pcols,pver) ! pressure (K)
real(r8), intent(in) :: pdel(pcols,pver) ! pressure thickness (Pa)
real(r8), intent(in) :: qn(pcols,pver) ! new water vapor (kg/kg)
real(r8), intent(in) :: qtend(pcols,pver) ! mixing ratio tend (kg/kg/s)
real(r8), intent(in) :: tn(pcols,pver) ! new temperature (K)
real(r8), intent(in) :: ttend(pcols,pver) ! temp tendencies (K/s)
real(r8), intent(in) :: deltat ! time step to advance solution over
real(r8), intent(in) :: lctend(pcols,pver) ! cloud liquid water tendencies ====wlin
real(r8), intent(in) :: rhdfda(pcols,pver) ! dG(a)/da, rh=G(a), when rh>u00 ====wlin
real(r8), intent(in) :: rhu00 (pcols,pver) ! Rhlim for cloud ====wlin
real(r8), intent(in) :: seaicef(pcols) ! sea ice fraction (fraction)
real(r8), intent(in) :: zi(pcols,pverp) ! layer interfaces (m)
real(r8), intent(in) :: snowh(pcols) ! Snow depth over land, water equivalent (m)
!
! Output Arguments
!
real(r8), intent(out) :: cme (pcols,pver) ! rate of cond-evap of condensate (1/s)
real(r8), intent(out) :: prodprec(pcols,pver) ! rate of conversion of condensate to precip (1/s)
real(r8), intent(out) :: evapprec(pcols,pver) ! rate of evaporation of falling precip (1/s)
real(r8), intent(out) :: evapsnow(pcols,pver) ! rate of evaporation of falling snow (1/s)
real(r8), intent(out) :: evapheat(pcols,pver) ! heating rate due to evaporation of precip (W/kg)
real(r8), intent(out) :: prfzheat(pcols,pver) ! heating rate due to freezing of precip (W/kg)
real(r8), intent(out) :: meltheat(pcols,pver) ! heating rate due to snow melt (W/kg)
real(r8), intent(out) :: precip(pcols) ! rate of precipitation (kg / (m**2 * s))
real(r8), intent(out) :: snowab(pcols) ! rate of snow (kg / (m**2 * s))
real(r8), intent(out) :: ice2pr(pcols,pver) ! rate of conversion of ice to precip
real(r8), intent(out) :: liq2pr(pcols,pver) ! rate of conversion of liquid to precip
real(r8), intent(out) :: liq2snow(pcols,pver) ! rate of conversion of liquid to snow
real(r8), intent(out) :: rkflxprc(pcols,pverp) ! grid-box mean RK flux_large_scale_cloud_rain+snow at interfaces (kg m^-2 s^-1)
real(r8), intent(out) :: rkflxsnw(pcols,pverp) ! grid-box mean RK flux_large_scale_cloud_snow at interfaces (kg m^-2 s^-1)
! intent(out)s here for pcond to pass to stratiform.F90 to be addflded/outflded
real(r8), intent(out) :: pracwo(pcols,pver) ! accretion of cloud water by rain (1/s)
real(r8), intent(out) :: psacwo(pcols,pver) ! accretion of cloud water by snow (1/s)
real(r8), intent(out) :: psacio(pcols,pver) ! accretion of cloud ice by snow (1/s)
real(r8) nice2pr ! rate of conversion of ice to snow
real(r8) nliq2pr ! rate of conversion of liquid to precip
real(r8) nliq2snow ! rate of conversion of liquid to snow
real(r8) prodsnow(pcols,pver) ! rate of production of snow
!
! Local workspace
!
real(r8) :: precab(pcols) ! rate of precipitation (kg / (m**2 * s))
integer i ! work variable
integer iter ! #iterations for precipitation calculation
integer k ! work variable
integer l ! work variable
real(r8) cldm(pcols) ! mean cloud fraction over the time step
real(r8) cldmax(pcols) ! max cloud fraction above
real(r8) coef(pcols) ! conversion time scale for condensate to rain
real(r8) cwm(pcols) ! cwat mixing ratio at midpoint of time step
real(r8) cwn(pcols) ! cwat mixing ratio at end
real(r8) denom ! work variable
real(r8) dqsdt ! change in sat spec. hum. wrt temperature
real(r8) es(pcols) ! sat. vapor pressure
real(r8) fracw(pcols,pver) ! relative importance of collection of liquid by rain
real(r8) fsaci(pcols,pver) ! relative importance of collection of ice by snow
real(r8) fsacw(pcols,pver) ! relative importance of collection of liquid by snow
real(r8) fsaut(pcols,pver) ! relative importance of ice auto conversion
real(r8) fwaut(pcols,pver) ! relative importance of warm cloud autoconversion
real(r8) gamma(pcols) ! d qs / dT
real(r8) icwc(pcols) ! in-cloud water content (kg/kg)
real(r8) mincld ! a small cloud fraction to avoid / zero
real(r8) omeps ! 1 minus epsilon
real(r8),parameter ::omsm=0.99999_r8 ! a number just less than unity (for rounding)
real(r8) prprov(pcols) ! provisional value of precip at btm of layer
real(r8) prtmp ! work variable
real(r8) q(pcols,pver) ! mixing ratio before time step ignoring condensate
real(r8) qs(pcols) ! spec. hum. of water vapor
real(r8) qsn, esn ! work variable
real(r8) qsp(pcols,pver) ! sat pt mixing ratio
real(r8) qtl(pcols) ! tendency which would saturate the grid box in deltat
real(r8) qtmp, ttmp ! work variable
real(r8) relhum1(pcols) ! relative humidity
real(r8) relhum(pcols) ! relative humidity
!!$ real(r8) tc ! crit temp of transition to ice
real(r8) t(pcols,pver) ! temp before time step ignoring condensate
real(r8) tsp(pcols,pver) ! sat pt temperature
real(r8) pol ! work variable
real(r8) cdt ! work variable
real(r8) wtthick ! work variable
! Extra local work space for cloud scheme modification
real(r8) cpohl !Cp/Hlatv
real(r8) hlocp !Hlatv/Cp
real(r8) dto2 !0.5*deltat (delta=2.0*dt)
real(r8) calpha(pcols) !alpha of new C - E scheme formulation
real(r8) cbeta (pcols) !beta of new C - E scheme formulation
real(r8) cbetah(pcols) !beta_hat at saturation portion
real(r8) cgamma(pcols) !gamma of new C - E scheme formulation
real(r8) cgamah(pcols) !gamma_hat at saturation portion
real(r8) rcgama(pcols) !gamma/gamma_hat
real(r8) csigma(pcols) !sigma of new C - E scheme formulation
real(r8) cmec1 (pcols) !c1 of new C - E scheme formulation
real(r8) cmec2 (pcols) !c2 of new C - E scheme formulation
real(r8) cmec3 (pcols) !c3 of new C - E scheme formulation
real(r8) cmec4 (pcols) !c4 of new C - E scheme formulation
real(r8) cmeres(pcols) !residual cond of over-sat after cme and evapprec
real(r8) ctmp !a scalar representation of cmeres
real(r8) clrh2o ! Ratio of latvap to water vapor gas const
real(r8) ice(pcols,pver) ! ice mixing ratio
real(r8) liq(pcols,pver) ! liquid mixing ratio
real(r8) rcwn(pcols,2,pver), rliq(pcols,2,pver), rice(pcols,2,pver)
real(r8) cwnsave(pcols,2,pver), cmesave(pcols,2,pver)
real(r8) prodprecsave(pcols,2,pver)
logical error_found
!
!------------------------------------------------------------
!
clrh2o = hlatv/rh2o ! Ratio of latvap to water vapor gas const
omeps = 1.0_r8 - epsqs
#ifdef PERGRO
mincld = 1.e-4_r8
iter = 1 ! number of times to iterate the precipitation calculation
#else
mincld = 1.e-4_r8
iter = 2
#endif
! omsm = 0.99999
cpohl = cp/hlatv
hlocp = hlatv/cp
dto2=0.5_r8*deltat
!
! Constant for computing rate of evaporation of precipitation:
!
!!$ conke = 1.e-5
!!$ conke = 1.e-6
!
! initialize a few single level fields
!
do i = 1,ncol
precip(i) = 0.0_r8
precab(i) = 0.0_r8
snowab(i) = 0.0_r8
cldmax(i) = 0.0_r8
end do
!
! initialize multi-level fields
!
do k = 1,pver
do i = 1,ncol
q(i,k) = qn(i,k)
t(i,k) = tn(i,k)
! q(i,k)=qn(i,k)-qtend(i,k)*deltat
! t(i,k)=tn(i,k)-ttend(i,k)*deltat
end do
end do
cme (:ncol,:) = 0._r8
evapprec(:ncol,:) = 0._r8
prodprec(:ncol,:) = 0._r8
evapsnow(:ncol,:) = 0._r8
prodsnow(:ncol,:) = 0._r8
evapheat(:ncol,:) = 0._r8
meltheat(:ncol,:) = 0._r8
prfzheat(:ncol,:) = 0._r8
ice2pr(:ncol,:) = 0._r8
liq2pr(:ncol,:) = 0._r8
liq2snow(:ncol,:) = 0._r8
fwaut(:ncol,:) = 0._r8
fsaut(:ncol,:) = 0._r8
fracw(:ncol,:) = 0._r8
fsacw(:ncol,:) = 0._r8
fsaci(:ncol,:) = 0._r8
rkflxprc(:ncol,:) = 0._r8
rkflxsnw(:ncol,:) = 0._r8
pracwo(:ncol,:) = 0._r8
psacwo(:ncol,:) = 0._r8
psacio(:ncol,:) = 0._r8
!
! find the wet bulb temp and saturation value
! for the provisional t and q without condensation
!
call findsp (lchnk, ncol, qn, tn, p, tsp, qsp)
do 800 k = k1mb,pver
call vqsatd (t(1,k), p(1,k), es, qs, gamma, ncol)
do i = 1,ncol
relhum(i) = q(i,k)/qs(i)
!
cldm(i) = max(cldn(i,k),mincld)
!
! the max cloud fraction above this level
!
cldmax(i) = max(cldmax(i), cldm(i))
! define the coefficients for C - E calculation
calpha(i) = 1.0_r8/qs(i)
cbeta (i) = q(i,k)/qs(i)**2*gamma(i)*cpohl
cbetah(i) = 1.0_r8/qs(i)*gamma(i)*cpohl
cgamma(i) = calpha(i)+hlatv*cbeta(i)/cp
cgamah(i) = calpha(i)+hlatv*cbetah(i)/cp
rcgama(i) = cgamma(i)/cgamah(i)
if(cldm(i) > mincld) then
icwc(i) = max(0._r8,cwat(i,k)/cldm(i))
else
icwc(i) = 0.0_r8
endif
!PJR the above logic give zero icwc with nonzero cwat, dont like it!
!PJR generates problems with csigma
!PJR set the icwc to a very small number, so we can start from zero cloud cover and make some clouds
! icwc(i) = max(1.e-8_r8,cwat(i,k)/cldm(i))
!
! initial guess of evaporation, will be updated within iteration
!
evapprec(i,k) = conke*(1._r8 - cldm(i))*sqrt(precab(i)) &
*(1._r8 - min(relhum(i),1._r8))
!
! zero cmeres before iteration for each level
!
cmeres(i)=0.0_r8
end do
do i = 1,ncol
!
! fractions of ice at this level
!
!!$ tc = t(i,k) - t0
!!$ fice(i,k) = max(0._r8,min(-tc*0.05,1.0_r8))
!
! calculate the cooling due to a phase change of the rainwater
! from above
!
if (t(i,k) >= t0) then
meltheat(i,k) = -hlatf * snowab(i) * gravit/pdel(i,k)
snowab(i) = 0._r8
else
meltheat(i,k) = 0._r8
endif
end do
!
! calculate cme and formation of precip.
!
! The cloud microphysics is highly nonlinear and coupled with cme
! Both rain processes and cme are calculated iteratively.
!
do 100 l = 1,iter
do i = 1,ncol
!
! calculation of cme has 4 scenarios
! ==================================
!
if(relhum(i) > rhu00(i,k)) then
! 1. whole grid saturation
! ========================
if(relhum(i) >= 0.999_r8 .or. cldm(i) >= 0.999_r8 ) then
cme(i,k)=(calpha(i)*qtend(i,k)-cbetah(i)*ttend(i,k))/cgamah(i)
! 2. fractional saturation
! ========================
else
if (rhdfda(i,k) .eq. 0. .and. icwc(i).eq.0.) then
write (iulog,*) ' cldwat.F90: empty rh cloud ', i, k, lchnk
#ifdef WRF_PORT
call wrf_message(iulog)
#endif
write (iulog,*) ' relhum, iter ', relhum(i), l, rhu00(i,k), cldm(i), cldn(i,k)
#ifdef WRF_PORT
call wrf_message(iulog)
#endif
call endrun ()
endif
csigma(i) = 1.0_r8/(rhdfda(i,k)+cgamma(i)*icwc(i))
cmec1(i) = (1.0_r8-cldm(i))*csigma(i)*rhdfda(i,k)
cmec2(i) = cldm(i)*calpha(i)/cgamah(i)+(1.0_r8-rcgama(i)*cldm(i))* &
csigma(i)*calpha(i)*icwc(i)
cmec3(i) = cldm(i)*cbetah(i)/cgamah(i) + &
(cbeta(i)-rcgama(i)*cldm(i)*cbetah(i))*csigma(i)*icwc(i)
cmec4(i) = csigma(i)*cgamma(i)*icwc(i)
! Q=C-E=-C1*Al + C2*Aq - C3* At + C4*Er
cme(i,k) = -cmec1(i)*lctend(i,k) + cmec2(i)*qtend(i,k) &
-cmec3(i)*ttend(i,k) + cmec4(i)*evapprec(i,k)
endif
! 3. when rh < rhu00, evaporate existing cloud water
! ==================================================
else if(cwat(i,k) > 0.0_r8)then
! liquid water should be evaporated but not to exceed
! saturation point. if qn > qsp, not to evaporate cwat
cme(i,k)=-min(max(0._r8,qsp(i,k)-qn(i,k)),cwat(i,k))/deltat
! 4. no condensation nor evaporation
! ==================================
else
cme(i,k)=0.0_r8
endif
end do !end loop for cme update
! Because of the finite time step,
! place a bound here not to exceed wet bulb point
! and not to evaporate more than available water
!
do i = 1, ncol
qtmp = qn(i,k) - cme(i,k)*deltat
! possibilities to have qtmp > qsp
!
! 1. if qn > qs(tn), it condenses;
! if after applying cme, qtmp > qsp, more condensation is applied.
!
! 2. if qn < qs, evaporation should not exceed qsp,
if(qtmp > qsp(i,k)) then
cme(i,k) = cme(i,k) + (qtmp-qsp(i,k))/deltat
endif
!
! if net evaporation, it should not exceed available cwat
!
if(cme(i,k) < -cwat(i,k)/deltat) &
cme(i,k) = -cwat(i,k)/deltat
!
! addition of residual condensation from previous step of iteration
!
cme(i,k) = cme(i,k) + cmeres(i)
end do
! limit cme for roundoff errors
do i = 1, ncol
cme(i,k) = cme(i,k)*omsm
end do
do i = 1,ncol
!
! as a safe limit, condensation should not reduce grid mean rh below rhu00
!
if(cme(i,k) > 0.0_r8 .and. relhum(i) > rhu00(i,k) ) &
cme(i,k) = min(cme(i,k), (qn(i,k)-qs(i)*rhu00(i,k))/deltat)
!
! initial guess for cwm (mean cloud water over time step) if 1st iteration
!
if(l < 2) then
cwm(i) = max(cwat(i,k)+cme(i,k)*dto2, 0._r8)
endif
enddo
! provisional precipitation falling through model layer
do i = 1,ncol
!!$ prprov(i) = precab(i) + prodprec(i,k)*pdel(i,k)/gravit
! rain produced in this layer not too effective in collection process
wtthick = max(0._r8,min(0.5_r8,((zi(i,k)-zi(i,k+1))/1000._r8)**2))
prprov(i) = precab(i) + wtthick*prodprec(i,k)*pdel(i,k)/gravit
end do
! calculate conversion of condensate to precipitation by cloud microphysics
call findmcnew (lchnk ,ncol , &
k ,prprov ,snowab, t ,p , &
cwm ,cldm ,cldmax ,fice(1,k),coef , &
fwaut(1,k),fsaut(1,k),fracw(1,k),fsacw(1,k),fsaci(1,k), &
seaicef, snowh, pracwo(1,k), psacwo(1,k), psacio(1,k))
!
! calculate the precip rate
!
error_found = .false.
do i = 1,ncol
if (cldm(i) > 0) then
!
! first predict the cloud water
!
cdt = coef(i)*deltat
if (cdt > 0.01_r8) then
pol = cme(i,k)/coef(i) ! production over loss
cwn(i) = max(0._r8,(cwat(i,k)-pol)*exp(-cdt)+ pol)
else
cwn(i) = max(0._r8,(cwat(i,k) + cme(i,k)*deltat)/(1+cdt))
endif
!
! now back out the tendency of net rain production
!
prodprec(i,k) = max(0._r8,cme(i,k)-(cwn(i)-cwat(i,k))/deltat)
else
prodprec(i,k) = 0.0_r8
cwn(i) = 0._r8
endif
! provisional calculation of conversion terms
ice2pr(i,k) = prodprec(i,k)*(fsaut(i,k)+fsaci(i,k))
liq2pr(i,k) = prodprec(i,k)*(fwaut(i,k)+fsacw(i,k)+fracw(i,k))
!old liq2snow(i,k) = prodprec(i,k)*fsacw(i,k)
! revision suggested by Jim McCaa
! it controls the amount of snow hitting the sfc
! by forcing a lot of conversion of cloud liquid to snow phase
! it might be better done later by an explicit representation of
! rain accreting ice (and freezing), or by an explicit freezing of raindrops
liq2snow(i,k) = max(prodprec(i,k)*fsacw(i,k), fsnow(i,k)*liq2pr(i,k))
! bounds
nice2pr = min(ice2pr(i,k),(cwat(i,k)+cme(i,k)*deltat)*fice(i,k)/deltat)
nliq2pr = min(liq2pr(i,k),(cwat(i,k)+cme(i,k)*deltat)*(1._r8-fice(i,k))/deltat)
! write(iulog,*) ' prodprec ', i, k, prodprec(i,k)
! write(iulog,*) ' nliq2pr, nice2pr ', nliq2pr, nice2pr
if (liq2pr(i,k).ne.0._r8) then
nliq2snow = liq2snow(i,k)*nliq2pr/liq2pr(i,k) ! correction
else
nliq2snow = liq2snow(i,k)
endif
! avoid roundoff problems generating negatives
nliq2snow = nliq2snow*omsm
nliq2pr = nliq2pr*omsm
nice2pr = nice2pr*omsm
! final estimates of conversion to precip and snow
prodprec(i,k) = (nliq2pr + nice2pr)
prodsnow(i,k) = (nice2pr + nliq2snow)
rcwn(i,l,k) = cwat(i,k) + (cme(i,k)- prodprec(i,k))*deltat
rliq(i,l,k) = (cwat(i,k) + cme(i,k)*deltat)*(1._r8-fice(i,k)) - nliq2pr * deltat
rice(i,l,k) = (cwat(i,k) + cme(i,k)*deltat)* fice(i,k) - nice2pr *deltat
! Save for sanity check later...
! Putting sanity checks inside loops 100 and 800 screws up the
! IBM compiler for reasons as yet unknown. TBH
cwnsave(i,l,k) = cwn(i)
cmesave(i,l,k) = cme(i,k)
prodprecsave(i,l,k) = prodprec(i,k)
! End of save for sanity check later...
! final version of condensate to precip terms
liq2pr(i,k) = nliq2pr
liq2snow(i,k) = nliq2snow
ice2pr(i,k) = nice2pr
cwn(i) = rcwn(i,l,k)
!
! update any remaining provisional values
!
cwm(i) = (cwn(i) + cwat(i,k))*0.5_r8
!
! update in cloud water
!
if(cldm(i) > mincld) then
icwc(i) = cwm(i)/cldm(i)
else
icwc(i) = 0.0_r8
endif
!PJR the above logic give zero icwc with nonzero cwat, dont like it!
!PJR generates problems with csigma
!PJR set the icwc to a very small number, so we can start from zero cloud cover and make some clouds
! icwc(i) = max(1.e-8_r8,cwm(i)/cldm(i))
end do ! end of do i = 1,ncol
!
! calculate provisional value of cloud water for
! evaporation of precipitate (evapprec) calculation
!
do i = 1,ncol
qtmp = qn(i,k) - cme(i,k)*deltat
ttmp = tn(i,k) + deltat/cp * ( meltheat(i,k) &
+ (hlatv + hlatf*fice(i,k)) * cme(i,k) )
esn = estblf(ttmp)
qsn = min(epsqs*esn/(p(i,k) - omeps*esn),1._r8)
qtl(i) = max((qsn - qtmp)/deltat,0._r8)
relhum1(i) = qtmp/qsn
end do
!
do i = 1,ncol
#ifdef PERGRO
evapprec(i,k) = conke*(1._r8 - max(cldm(i),mincld))* &
sqrt(precab(i))*(1._r8 - min(relhum1(i),1._r8))
#else
evapprec(i,k) = conke*(1._r8 - cldm(i))*sqrt(precab(i)) &
*(1._r8 - min(relhum1(i),1._r8))
#endif
!
! limit the evaporation to the amount which is entering the box
! or saturates the box
!
prtmp = precab(i)*gravit/pdel(i,k)
evapprec(i,k) = min(evapprec(i,k), prtmp, qtl(i))*omsm
#ifdef PERGRO
! zeroing needed for pert growth
evapprec(i,k) = 0._r8
#endif
!
! Partition evaporation of precipitate between rain and snow using
! the fraction of snow falling into the box. Determine the heating
! due to evaporation. Note that evaporation is positive (loss of precip,
! gain of vapor) and that heating is negative.
if (evapprec(i,k) > 0._r8) then
evapsnow(i,k) = evapprec(i,k) * snowab(i) / precab(i)
evapheat(i,k) = -hlatv * evapprec(i,k) - hlatf * evapsnow(i,k)
else
evapsnow(i,k) = 0._r8
evapheat(i,k) = 0._r8
end if
! Account for the latent heat of fusion for liquid drops collected by falling snow
prfzheat(i,k) = hlatf * liq2snow(i,k)
end do
! now remove the residual of any over-saturation. Normally,
! the oversaturated water vapor should have been removed by
! cme formulation plus constraints by wet bulb tsp/qsp
! as computed above. However, because of non-linearity,
! addition of (cme-evapprec) to update t and q may still cause
! a very small amount of over saturation. It is called a
! residual of over-saturation because theoretically, cme
! should have taken care of all of large scale condensation.
!
do i = 1,ncol
qtmp = qn(i,k)-(cme(i,k)-evapprec(i,k))*deltat
ttmp = tn(i,k) + deltat/cp * ( meltheat(i,k) + evapheat(i,k) + prfzheat(i,k) &
+ (hlatv + hlatf*fice(i,k)) * cme(i,k) )
esn = estblf(ttmp)
qsn = min(epsqs*esn/(p(i,k) - omeps*esn),1._r8)
!
!Upper stratosphere and mesosphere, qsn calculated
!above may be negative. Here just to skip it instead
!of resetting it to 1 as in aqsat
!