-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathProcess_Library.F90
3675 lines (3117 loc) · 126 KB
/
Process_Library.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
! $Id$
#include "MAPL_Generic.h"
!#define PDFDIAG 1
!=============================================================================
!BOP
module GEOSmoist_Process_Library
use ESMF
use MAPL
use GEOS_UtilsMod
use Aer_Actv_Single_Moment
use aer_cloud
implicit none
private
character(len=ESMF_MAXSTR) :: IAm="GEOSmoist_Process_Library"
integer :: STATUS
interface MELTFRZ
module procedure MELTFRZ_3D
module procedure MELTFRZ_2D
module procedure MELTFRZ_1D
module procedure MELTFRZ_SC
end interface MELTFRZ
interface ICE_FRACTION
module procedure ICE_FRACTION_3D
module procedure ICE_FRACTION_2D
module procedure ICE_FRACTION_1D
module procedure ICE_FRACTION_SC
end interface ICE_FRACTION
! ICE_FRACTION constants
! In anvil/convective clouds
real, parameter :: aT_ICE_ALL = 252.16
real, parameter :: aT_ICE_MAX = 268.16
real, parameter :: aICEFRPWR = 2.0
! Over snow/ice SRF_TYPE = 2
real, parameter :: iT_ICE_ALL = 236.16
real, parameter :: iT_ICE_MAX = 261.16
real, parameter :: iICEFRPWR = 6.0
! Over Land SRF_TYPE = 1
real, parameter :: lT_ICE_ALL = 239.16
real, parameter :: lT_ICE_MAX = 261.16
real, parameter :: lICEFRPWR = 2.0
! Over Oceans SRF_TYPE = 0
real, parameter :: oT_ICE_ALL = 238.16
real, parameter :: oT_ICE_MAX = 263.16
real, parameter :: oICEFRPWR = 4.0
! Jason
! In anvil/convective clouds
real, parameter :: JaT_ICE_ALL = 245.16
real, parameter :: JaT_ICE_MAX = 261.16
real, parameter :: JaICEFRPWR = 2.0
! Over snow/ice
real, parameter :: JiT_ICE_ALL = MAPL_TICE-40.0
real, parameter :: JiT_ICE_MAX = MAPL_TICE
real, parameter :: JiICEFRPWR = 4.0
! parameters
real, parameter :: EPSILON = MAPL_H2OMW/MAPL_AIRMW
real, parameter :: K_COND = 2.4e-2 ! J m**-1 s**-1 K**-1
real, parameter :: DIFFU = 2.2e-5 ! m**2 s**-1
real, parameter :: taufrz = 450.0
real, parameter :: dQCmax = 1.e-4
! LDRADIUS4
! Jason
real, parameter :: abeta = 0.07
real, parameter :: r13bbeta = 1./3. - 0.14
real, parameter :: bx = 100.* (3./(4.*MAPL_PI))**(1./3.)
! Liquid based on DOI 10.1088/1748-9326/3/4/045021
real, parameter :: RHO_W = 1000.0 ! Density of liquid water in kg/m^3
real, parameter :: Ldiss = 0.07 ! tunable dispersion effect
real, parameter :: Lk = 0.75 ! tunable shape effect (0.5:1)
real, parameter :: Lbe = 1./3. - 0.14
real, parameter :: Lbx = Ldiss*1.e3*(3./(4.*MAPL_PI*Lk*RHO_W*1.e-3))**(1./3.)
! LDRADIUS eqs are in cgs units
! Ice
real, parameter :: RHO_I = 916.8 ! Density of ice crystal in kg/m^3
! combined constantc
real, parameter :: cpbgrav = MAPL_CP/MAPL_GRAV
real, parameter :: gravbcp = MAPL_GRAV/MAPL_CP
real, parameter :: alhlbcp = MAPL_ALHL/MAPL_CP
real, parameter :: alhfbcp = MAPL_ALHF/MAPL_CP
real, parameter :: alhsbcp = MAPL_ALHS/MAPL_CP
! control for order of plumes
logical :: SH_MD_DP = .FALSE.
! option for cloud liq/ice radii
integer :: LIQ_RADII_PARAM = 1
integer :: ICE_RADII_PARAM = 1
! defined to determine CNV_FRACTION
real :: CNV_FRACTION_MIN
real :: CNV_FRACTION_MAX
real :: CNV_FRACTION_EXP
! Storage of aerosol properties for activation
type(AerProps), allocatable, dimension (:,:,:) :: AeroProps
! Tracer Bundle things for convection
type CNV_Tracer_Type
real, pointer :: Q(:,:,:) => null()
real :: fscav = 0.0
real :: Vect_Hcts(4)
real :: KcScal(3)
real :: convfaci2g
real :: retfactor
real :: liq_and_gas
real :: online_cldliq
real :: online_vud
real :: ftemp_threshold
logical :: use_gcc_washout
logical :: use_gocart
logical :: is_wetdep
character(len=ESMF_MAXSTR) :: QNAME ! Tracer Name
character(len=ESMF_MAXSTR) :: CNAME ! Component Name
end type CNV_Tracer_Type
type(CNV_Tracer_Type), allocatable :: CNV_Tracers(:)
public :: AeroProps
public :: CNV_Tracer_Type, CNV_Tracers, CNV_Tracers_Init
public :: ICE_FRACTION, EVAP3, SUBL3, LDRADIUS4, BUOYANCY, BUOYANCY2
public :: REDISTRIBUTE_CLOUDS, RADCOUPLE, FIX_UP_CLOUDS
public :: hystpdf, fix_up_clouds_2M
public :: FILLQ2ZERO, FILLQ2ZERO1
public :: MELTFRZ
public :: DIAGNOSE_PRECIP_TYPE
public :: VertInterp, cs_interpolator
public :: find_l, FIND_EIS, FIND_KLCL
public :: find_cldtop, find_cldbase, gw_prof
public :: make_IceNumber, make_DropletNumber, make_RainNumber
public :: dissipative_ke_heating
public :: pdffrac, pdfcondensate, partition_dblgss
public :: CNV_FRACTION_MIN, CNV_FRACTION_MAX, CNV_FRACTION_EXP
public :: SH_MD_DP, LIQ_RADII_PARAM, ICE_RADII_PARAM
public :: update_cld, meltfrz_inst2M
public :: FIX_NEGATIVE_PRECIP
public :: pdf_alpha
public :: sigma
contains
subroutine CNV_Tracers_Init(TR, RC)
type (ESMF_FieldBundle), intent(inout) :: TR
integer, optional, intent(inout) :: RC
! Local
type (ESMF_Field) :: FIELD
integer :: TotalTracers, FriendlyTracers
logical :: isPresent, isFriendly
integer :: ind, N, F
real :: rtmp
character(len=ESMF_MAXSTR), pointer, dimension(:) :: QNAMES
character(len=ESMF_MAXSTR) :: QNAME, STR_CNV_TRACER
call ESMF_FieldBundleGet(TR, FieldCount=TotalTracers, RC=STATUS); VERIFY_(STATUS)
allocate(QNAMES(TotalTracers), stat=STATUS); VERIFY_(STATUS)
call ESMF_FieldBundleGet(TR, fieldNameList=QNAMES, RC=STATUS); VERIFY_(STATUS)
FriendlyTracers = 0
do N=1,TotalTracers
QNAME = trim(QNAMES(N))
call ESMF_FieldBundleGet(TR, fieldName=trim(QNAME), Field=FIELD, RC=STATUS); VERIFY_(STATUS)
call ESMF_AttributeGet (FIELD, "FriendlyToMOIST",isPresent=isPresent, RC=STATUS); VERIFY_(STATUS)
if(isPresent) then
call ESMF_AttributeGet(FIELD, "FriendlyToMOIST", isFriendly, RC=STATUS); VERIFY_(STATUS)
if (isFriendly) FriendlyTracers = FriendlyTracers + 1
end if
enddo
! see if we need to allocate
if (allocated(CNV_Tracers)) then
ASSERT_( size(CNV_Tracers) == FriendlyTracers )
else
call WRITE_PARALLEL ("List of species friendly to MoistGridComp:")
! fill CNV_Tracers
allocate( CNV_Tracers(FriendlyTracers), stat=STATUS); VERIFY_(STATUS)
F = 0
do N=1,TotalTracers
QNAME = trim(QNAMES(N))
call ESMF_FieldBundleGet(TR, fieldName=trim(QNAME), Field=FIELD, RC=STATUS); VERIFY_(STATUS)
call ESMF_AttributeGet (FIELD, "FriendlyToMOIST",isPresent=isPresent, RC=STATUS); VERIFY_(STATUS)
if(isPresent) then
call ESMF_AttributeGet(FIELD, "FriendlyToMOIST", isFriendly, RC=STATUS); VERIFY_(STATUS)
if (isFriendly) then
! Iterate the friendly index
!-------------------------------
F = F + 1
! Get items scavenging fraction
!-------------------------------
CNV_Tracers(F)%fscav = 0.0
call ESMF_AttributeGet(FIELD, "ScavengingFractionPerKm", isPresent=isPresent, RC=STATUS); VERIFY_(STATUS)
if(isPresent) then
call ESMF_AttributeGet(FIELD, "ScavengingFractionPerKm", CNV_Tracers(F)%fscav, RC=STATUS); VERIFY_(STATUS)
end if
! Get component and tracer names
!-------------------------------------------------------------------------------------
ind= index(QNAME, '::')
if (ind > 0) then
CNV_Tracers(F)%CNAME = trim(QNAME(1:ind-1)) ! Component name (e.g., GOCART, CARMA)
CNV_Tracers(F)%QNAME = trim(QNAME(ind+2:))
end if
! Get items for the wet removal parameterization for gases based on the Henry's Law
!-------------------------------------------------------------------------------------
CNV_Tracers(F)%Vect_Hcts(:)=-99.
call ESMF_AttributeGet(FIELD, "SetofHenryLawCts", isPresent=isPresent, RC=STATUS); VERIFY_(STATUS)
if (isPresent) then
call ESMF_AttributeGet(FIELD, "SetofHenryLawCts", CNV_Tracers(F)%Vect_Hcts, RC=STATUS); VERIFY_(STATUS)
end if
! Additional items, needed for GEOS-Chem washout parameterization
!-------------------------------------------------------------------------------------
! Defaults
CNV_Tracers(F)%is_wetdep = .FALSE.
CNV_Tracers(F)%use_gcc_washout = .FALSE.
CNV_Tracers(F)%KcScal(:) = 1.0
CNV_Tracers(F)%retfactor = 1.0
CNV_Tracers(F)%liq_and_gas = 0.0
CNV_Tracers(F)%convfaci2g = 0.0
CNV_Tracers(F)%online_cldliq = 0.0
CNV_Tracers(F)%online_vud = 1.0
CNV_Tracers(F)%use_gocart = .FALSE.
CNV_Tracers(F)%ftemp_threshold = -999.0
! Check if GEOS-Chem washout should be used. Assume this is the case if Kc scale factors are
! present
call ESMF_AttributeGet(FIELD, "SetofKcScalFactors", isPresent=isPresent, RC=STATUS); VERIFY_(STATUS)
CNV_Tracers(F)%use_gcc_washout = isPresent
! If using GEOS-Chem parameterization, retrieve all necessary parameter
if ( CNV_Tracers(F)%use_gcc_washout ) then
! KC scale factors
call ESMF_AttributeGet(FIELD, "SetofKcScalFactors", isPresent=isPresent, RC=STATUS); VERIFY_(STATUS)
if (isPresent) then
call ESMF_AttributeGet(FIELD, "SetofKcScalFactors", CNV_Tracers(F)%KcScal, RC=STATUS); VERIFY_(STATUS)
end if
! is this a wetdep species?
call ESMF_AttributeGet(FIELD, "IsWetDep", isPresent=isPresent, RC=STATUS); VERIFY_(STATUS)
if (isPresent) then
call ESMF_AttributeGet(FIELD, "IsWetDep", rtmp, RC=STATUS); VERIFY_(STATUS)
CNV_Tracers(F)%is_wetdep = ( rtmp == 1.0 )
end if
! Gas-phase washout parameter for GEOS-Chem
call ESMF_AttributeGet (FIELD, "RetentionFactor",isPresent=isPresent, RC=STATUS); VERIFY_(STATUS)
if (isPresent) then
call ESMF_AttributeGet (FIELD, "RetentionFactor", CNV_Tracers(F)%retfactor, RC=STATUS); VERIFY_(STATUS)
endif
call ESMF_AttributeGet (FIELD, "LiqAndGas",isPresent=isPresent, RC=STATUS); VERIFY_(STATUS)
if (isPresent) then
call ESMF_AttributeGet (FIELD, "LiqAndGas", CNV_Tracers(F)%liq_and_gas, RC=STATUS); VERIFY_(STATUS)
endif
call ESMF_AttributeGet (FIELD, "ConvFacI2G",isPresent=isPresent, RC=STATUS); VERIFY_(STATUS)
if (isPresent) then
call ESMF_AttributeGet (FIELD, "ConvFacI2G", CNV_Tracers(F)%convfaci2g, RC=STATUS); VERIFY_(STATUS)
endif
call ESMF_AttributeGet (FIELD, "OnlineCLDLIQ",isPresent=isPresent, RC=STATUS); VERIFY_(STATUS)
if (isPresent) then
call ESMF_AttributeGet (FIELD, "OnlineCLDLIQ", CNV_Tracers(F)%online_cldliq, RC=STATUS); VERIFY_(STATUS)
endif
call ESMF_AttributeGet (FIELD,"OnlineVUD",isPresent=isPresent, RC=STATUS); VERIFY_(STATUS)
if (isPresent) then
call ESMF_AttributeGet (FIELD,"OnlineVUD", CNV_Tracers(F)%online_vud, RC=STATUS); VERIFY_(STATUS)
endif
call ESMF_AttributeGet (FIELD,"UseGOCART",isPresent=isPresent, RC=STATUS); VERIFY_(STATUS)
if (isPresent) then
call ESMF_AttributeGet (FIELD,"UseGOCART", rtmp, RC=STATUS); VERIFY_(STATUS)
CNV_Tracers(F)%use_gocart = ( rtmp == 1.0 )
endif
call ESMF_AttributeGet (FIELD,"GOCARTfTempThreshold",isPresent=isPresent, RC=STATUS); VERIFY_(STATUS)
if (isPresent) then
call ESMF_AttributeGet (FIELD,"GOCARTfTempThreshold", CNV_Tracers(F)%ftemp_threshold, RC=STATUS); VERIFY_(STATUS)
endif
end if ! use_gcc_washout
! Get pointer to friendly tracers
!-----------------------------------------
call ESMFL_BundleGetPointerToData(TR, trim(QNAME), CNV_Tracers(F)%Q, RC=STATUS); VERIFY_(STATUS)
! Report tracer status
!-----------------------------------------
if (CNV_Tracers(F)%fscav > 1.e-6) then
WRITE(STR_CNV_TRACER,101) TRIM(QNAME), CNV_Tracers(F)%fscav
call WRITE_PARALLEL (trim(STR_CNV_TRACER))
elseif (CNV_Tracers(F)%Vect_Hcts(1)>1.e-6) then
WRITE(STR_CNV_TRACER,102) TRIM(QNAME), CNV_Tracers(F)%Vect_Hcts
call WRITE_PARALLEL (trim(STR_CNV_TRACER))
else
WRITE(STR_CNV_TRACER,103) TRIM(QNAME)
call WRITE_PARALLEL (trim(STR_CNV_TRACER))
endif
101 FORMAT(a,' ScavengingFractionPerKm:',1(1x,f3.1))
102 FORMAT(a,' SetofHenryLawCts:',4(1x,es9.2))
103 FORMAT(a,' is transported by Moist')
! Additional information for GEOS-Chem washout species
!-----------------------------------------------------
if (CNV_Tracers(F)%use_gcc_washout .and. CNV_Tracers(F)%is_wetdep) then
STR_CNV_TRACER = TRIM(QNAME)//": will use GEOS-Chem washout formulation"
call WRITE_PARALLEL (trim(STR_CNV_TRACER))
WRITE(STR_CNV_TRACER,104) TRIM(QNAME), CNV_Tracers(F)%KcScal
call WRITE_PARALLEL (trim(STR_CNV_TRACER))
WRITE(STR_CNV_TRACER,105) TRIM(QNAME), CNV_Tracers(F)%retfactor
call WRITE_PARALLEL (trim(STR_CNV_TRACER))
WRITE(STR_CNV_TRACER,106) TRIM(QNAME), CNV_Tracers(F)%liq_and_gas
call WRITE_PARALLEL (trim(STR_CNV_TRACER))
WRITE(STR_CNV_TRACER,107) TRIM(QNAME), CNV_Tracers(F)%convfaci2g
call WRITE_PARALLEL (trim(STR_CNV_TRACER))
WRITE(STR_CNV_TRACER,108) TRIM(QNAME), CNV_Tracers(F)%online_cldliq
call WRITE_PARALLEL (trim(STR_CNV_TRACER))
WRITE(STR_CNV_TRACER,109) TRIM(QNAME), CNV_Tracers(F)%online_vud
call WRITE_PARALLEL (trim(STR_CNV_TRACER))
if (CNV_Tracers(F)%use_gocart)then
STR_CNV_TRACER = TRIM(QNAME)//": will treat like GOCART aerosol"
call WRITE_PARALLEL (trim(STR_CNV_TRACER))
WRITE(STR_CNV_TRACER,110) TRIM(QNAME), CNV_Tracers(F)%ftemp_threshold
call WRITE_PARALLEL (trim(STR_CNV_TRACER))
endif
endif
104 FORMAT(a,' KcScaleFactors:',3(1x,es9.2))
105 FORMAT(a,' RetentionFactor:',1(1x,es9.2))
106 FORMAT(a,' Liq_and_gas:',1(1x,es9.2))
107 FORMAT(a,' ConvFacI2G:',1(1x,es9.2))
108 FORMAT(a,' online_cldliq:',1(1x,es9.2))
109 FORMAT(a,' online_vud:',1(1x,es9.2))
110 FORMAT(a,' ftemp_threshold:',1(1x,es9.2))
end if
end if
enddo
end if
deallocate(QNAMES)
end subroutine CNV_Tracers_Init
real function sigma (dx)
real, intent(in) :: dx
sigma = 1.0-0.9839*exp(-0.09835*(dx/1000.)) ! Arakawa 2011 sigma
end function sigma
function ICE_FRACTION_3D (TEMP,CNV_FRACTION,SRF_TYPE) RESULT(ICEFRCT)
real, intent(in) :: TEMP(:,:,:),CNV_FRACTION(:,:),SRF_TYPE(:,:)
real :: ICEFRCT(size(TEMP,1),size(TEMP,2),size(TEMP,3))
integer :: i,j,l
do l=1,size(TEMP,3)
do j=1,size(TEMP,2)
do i=1,size(TEMP,1)
ICEFRCT(i,j,l) = ICE_FRACTION_SC(TEMP(i,j,l),CNV_FRACTION(i,j),SRF_TYPE(i,j))
enddo
enddo
enddo
end function ICE_FRACTION_3D
function ICE_FRACTION_2D (TEMP,CNV_FRACTION,SRF_TYPE) RESULT(ICEFRCT)
real, intent(in) :: TEMP(:,:),CNV_FRACTION(:,:),SRF_TYPE(:,:)
real :: ICEFRCT(size(TEMP,1),size(TEMP,2))
integer :: i,j
do j=1,size(TEMP,2)
do i=1,size(TEMP,1)
ICEFRCT(i,j) = ICE_FRACTION_SC(TEMP(i,j),CNV_FRACTION(i,j),SRF_TYPE(i,j))
enddo
enddo
end function ICE_FRACTION_2D
function ICE_FRACTION_1D (TEMP,CNV_FRACTION,SRF_TYPE) RESULT(ICEFRCT)
real, intent(in) :: TEMP(:),CNV_FRACTION(:),SRF_TYPE(:)
real :: ICEFRCT(size(TEMP))
integer :: i
do i=1,size(TEMP)
ICEFRCT(i) = ICE_FRACTION_SC(TEMP(i),CNV_FRACTION(i),SRF_TYPE(i))
enddo
end function ICE_FRACTION_1D
function ICE_FRACTION_SC (TEMP,CNV_FRACTION,SRF_TYPE) RESULT(ICEFRCT)
real, intent(in) :: TEMP,CNV_FRACTION,SRF_TYPE
real :: ICEFRCT
real :: tc, ptc
real :: ICEFRCT_C, ICEFRCT_M
#ifdef MODIS_ICE_POLY
! Use MODIS polynomial from Hu et al, DOI: (10.1029/2009JD012384)
tc = MAX(-46.0,MIN(TEMP-MAPL_TICE,46.0)) ! convert to celcius and limit range from -46:46 C
ptc = 7.6725 + 1.0118*tc + 0.1422*tc**2 + 0.0106*tc**3 + 0.000339*tc**4 + 0.00000395*tc**5
ICEFRCT = 1.0 - (1.0/(1.0 + exp(-1*ptc)))
#else
! Anvil clouds
! Anvil-Convective sigmoidal function like figure 6(right)
! Sigmoidal functions Hu et al 2010, doi:10.1029/2009JD012384
if (ICE_RADII_PARAM == 1) then
! Jason formula
ICEFRCT_C = 0.00
if ( TEMP <= JaT_ICE_ALL ) then
ICEFRCT_C = 1.000
else if ( (TEMP > JaT_ICE_ALL) .AND. (TEMP <= JaT_ICE_MAX) ) then
ICEFRCT_C = SIN( 0.5*MAPL_PI*( 1.00 - ( TEMP - JaT_ICE_ALL ) / ( JaT_ICE_MAX - JaT_ICE_ALL ) ) )
end if
else
ICEFRCT_C = 0.00
if ( TEMP <= aT_ICE_ALL ) then
ICEFRCT_C = 1.000
else if ( (TEMP > aT_ICE_ALL) .AND. (TEMP <= aT_ICE_MAX) ) then
ICEFRCT_C = SIN( 0.5*MAPL_PI*( 1.00 - ( TEMP - aT_ICE_ALL ) / ( aT_ICE_MAX - aT_ICE_ALL ) ) )
end if
end if
ICEFRCT_C = MIN(ICEFRCT_C,1.00)
ICEFRCT_C = MAX(ICEFRCT_C,0.00)
ICEFRCT_C = ICEFRCT_C**aICEFRPWR
! Sigmoidal functions like figure 6b/6c of Hu et al 2010, doi:10.1029/2009JD012384
if (SRF_TYPE == 2.0) then
! Over snow/ice
if (ICE_RADII_PARAM == 1) then
! Jason formula
ICEFRCT_M = 0.00
if ( TEMP <= JiT_ICE_ALL ) then
ICEFRCT_M = 1.000
else if ( (TEMP > JiT_ICE_ALL) .AND. (TEMP <= JiT_ICE_MAX) ) then
ICEFRCT_M = 1.00 - ( TEMP - JiT_ICE_ALL ) / ( JiT_ICE_MAX - JiT_ICE_ALL )
end if
else
ICEFRCT_M = 0.00
if ( TEMP <= iT_ICE_ALL ) then
ICEFRCT_M = 1.000
else if ( (TEMP > iT_ICE_ALL) .AND. (TEMP <= iT_ICE_MAX) ) then
ICEFRCT_M = SIN( 0.5*MAPL_PI*( 1.00 - ( TEMP - iT_ICE_ALL ) / ( iT_ICE_MAX - iT_ICE_ALL ) ) )
end if
end if
ICEFRCT_M = MIN(ICEFRCT_M,1.00)
ICEFRCT_M = MAX(ICEFRCT_M,0.00)
ICEFRCT_M = ICEFRCT_M**iICEFRPWR
else if (SRF_TYPE > 1.0) then
! Over Land
ICEFRCT_M = 0.00
if ( TEMP <= lT_ICE_ALL ) then
ICEFRCT_M = 1.000
else if ( (TEMP > lT_ICE_ALL) .AND. (TEMP <= lT_ICE_MAX) ) then
ICEFRCT_M = SIN( 0.5*MAPL_PI*( 1.00 - ( TEMP - lT_ICE_ALL ) / ( lT_ICE_MAX - lT_ICE_ALL ) ) )
end if
ICEFRCT_M = MIN(ICEFRCT_M,1.00)
ICEFRCT_M = MAX(ICEFRCT_M,0.00)
ICEFRCT_M = ICEFRCT_M**lICEFRPWR
else
! Over Oceans
ICEFRCT_M = 0.00
if ( TEMP <= oT_ICE_ALL ) then
ICEFRCT_M = 1.000
else if ( (TEMP > oT_ICE_ALL) .AND. (TEMP <= oT_ICE_MAX) ) then
ICEFRCT_M = SIN( 0.5*MAPL_PI*( 1.00 - ( TEMP - oT_ICE_ALL ) / ( oT_ICE_MAX - oT_ICE_ALL ) ) )
end if
ICEFRCT_M = MIN(ICEFRCT_M,1.00)
ICEFRCT_M = MAX(ICEFRCT_M,0.00)
ICEFRCT_M = ICEFRCT_M**oICEFRPWR
endif
! Combine the Convective and MODIS functions
ICEFRCT = ICEFRCT_M*(1.0-CNV_FRACTION) + ICEFRCT_C*(CNV_FRACTION)
#endif
end function ICE_FRACTION_SC
subroutine EVAP3(&
DT , &
A_EFF , &
RHCR , &
PL , &
TE , &
QV , &
QL , &
QI , &
F , &
NL , &
NI , &
QS )
real, intent(in ) :: DT
real, intent(in ) :: A_EFF
real, intent(in ) :: RHCR
real, intent(in ) :: PL
real, intent(inout) :: TE
real, intent(inout) :: QV
real, intent(inout) :: QL,QI
real, intent(inout) :: F
real, intent(in ) :: NL,NI
real, intent(in ) :: QS
real :: ES,RADIUS,K1,K2,QCm,EVAP,RHx,QC
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! EVAPORATION OF CLOUD WATER. !!
!! !!
!! DelGenio et al (1996, J. Clim., 9, 270-303) !!
!! formulation (Eq.s 15-17) !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! QS = QSAT( &
! TE , &
! PL )
ES = 100.* PL * QS / ( (EPSILON) + (1.0-(EPSILON))*QS ) ! (100's <-^ convert from mbar to Pa)
RHx = MIN( QV/QS , 1.00 )
K1 = (MAPL_ALHL**2) * RHO_W / ( K_COND*MAPL_RVAP*(TE**2))
K2 = MAPL_RVAP * TE * RHO_W / ( DIFFU * (1000./PL) * ES )
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! Here DIFFU is given for 1000 mb !!
!! so 1000./PR accounts for inc- !!
!! reased diffusivity at lower !!
!! pressure. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if ( ( F > 0.) .and. ( QL > 0. ) ) then
QCm=QL/F
else
QCm=0.
end if
RADIUS = LDRADIUS4(PL,TE,QCm,NL,NI,1)
if ( (RHx < RHCR ) .and. (RADIUS > 0.0) ) then
EVAP = A_EFF*QL*DT*(RHCR - RHx) / ((K1+K2)*RADIUS**2)
EVAP = MIN( EVAP , QL )
else
EVAP = 0.0
end if
QC=QL+QI
if (QC > 0.) then
F = F * ( QC - EVAP ) / QC
end if
QV = QV + EVAP
QL = QL - EVAP
TE = TE - alhlbcp*EVAP
end subroutine EVAP3
subroutine SUBL3( &
DT , &
A_EFF , &
RHCR , &
PL , &
TE , &
QV , &
QL , &
QI , &
F , &
NL , &
NI , &
QS )
real, intent(in ) :: DT
real, intent(in ) :: A_EFF
real, intent(in ) :: RHCR
real, intent(in ) :: PL
real, intent(inout) :: TE
real, intent(inout) :: QV
real, intent(inout) :: QL,QI
real, intent(inout) :: F
real, intent(in ) :: NL,NI
real, intent(in ) :: QS
real :: ES,RADIUS,K1,K2,TEFF,QCm,SUBL,RHx,QC
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! SUBLORATION OF CLOUD WATER. !!
!! !!
!! DelGenio et al (1996, J. Clim., 9, 270-303) !!
!! formulation (Eq.s 15-17) !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! QS = QSAT( &
! TE , &
! PL )
ES = 100.* PL * QS / ( (EPSILON) + (1.0-(EPSILON))*QS ) ! (100s <-^ convert from mbar to Pa)
RHx = MIN( QV/QS , 1.00 )
K1 = (MAPL_ALHL**2) * RHO_I / ( K_COND*MAPL_RVAP*(TE**2))
K2 = MAPL_RVAP * TE * RHO_I / ( DIFFU * (1000./PL) * ES )
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! Here DIFFU is given for 1000 mb !!
!! so 1000./PR accounts for inc- !!
!! reased diffusivity at lower !!
!! pressure. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if ( ( F > 0.) .and. ( QI > 0. ) ) then
QCm=QI/F
else
QCm=0.
end if
RADIUS = LDRADIUS4(PL,TE,QCm,NL,NI,2)
if ( (RHx < RHCR) .and.(RADIUS > 0.0) ) then
SUBL = A_EFF*QI*DT*(RHCR - RHx) / ((K1+K2)*RADIUS**2)
SUBL = MIN( SUBL , QI )
else
SUBL = 0.0
end if
QC=QL+QI
if (QC > 0.) then
F = F * ( QC - SUBL ) / QC
end if
QV = QV + SUBL
QI = QI - SUBL
TE = TE - alhsbcp*SUBL
end subroutine SUBL3
function LDRADIUS4(PL,TE,QC,NNL,NNI,ITYPE) RESULT(RADIUS)
REAL , INTENT(IN) :: TE,PL,QC
REAL , INTENT(IN) :: NNL,NNI ! #/m^3
INTEGER, INTENT(IN) :: ITYPE
REAL :: RADIUS
INTEGER, PARAMETER :: LIQUID=1, ICE=2
REAL :: NNX,RHO,BB,WC
REAL :: TC,ZFSR,AA
!- air density (kg/m^3)
RHO = (100.*PL) / (MAPL_RGAS*TE )
IF(ITYPE == LIQUID) THEN
!- liquid cloud effective radius -----
!- liquid water content
WC = 1.e3*RHO*QC ! air density [g/m3] * liquid cloud mixing ratio [kg/kg]
!- cloud drop number concentration
!- from the aerosol model + ....
NNX = max(NNL*1.e-6, 10.0)
!- radius in meters
if (LIQ_RADII_PARAM == 1) then
!- Jason Version
RADIUS= MIN(60.e-6,MAX(2.5e-6, 1.e-6*bx*(WC/NNX)**r13bbeta*abeta*6.92))
else
!- [liu&daum, 2000 and 2005. liu et al 2008]
RADIUS = MIN(60.e-6,MAX(2.5e-6, 1.e-6*Lbx*(WC/NNX)**Lbe))
endif
ELSEIF(ITYPE == ICE) THEN
!- ice cloud effective radius -----
!- ice water content
WC = 1.e3*RHO*QC ! air density [g/m3] * ice cloud mixing ratio [kg/kg]
!- radius in meters
if (ICE_RADII_PARAM == 1) then
!------ice cloud effective radius ----- [klaus wyser, 1998]
if(TE>MAPL_TICE .or. QC <=0.) then
BB = -2.
else
BB = -2. + log10(WC/50.)*(1.e-3*(MAPL_TICE-TE)**1.5)
endif
BB = MIN((MAX(BB,-6.)),-2.)
RADIUS = 377.4 + 203.3 * BB+ 37.91 * BB **2 + 2.3696 * BB **3
RADIUS = MIN(150.e-6,MAX(5.e-6, 1.e-6*RADIUS))
else
!------ice cloud effective radius ----- [Sun, 2001]
TC = TE - MAPL_TICE
ZFSR = 1.2351 + 0.0105 * TC
AA = 45.8966 * (WC**0.2214)
BB = 0.79570 * (WC**0.2535)
RADIUS = ZFSR * (AA + BB * (TE - 83.15))
RADIUS = MIN(150.e-6,MAX(5.e-6, 1.e-6*RADIUS*0.64952))
endif
ELSE
STOP "WRONG HYDROMETEOR type: CLOUD = 1 OR ICE = 2"
ENDIF
end function LDRADIUS4
subroutine BUOYANCY2( IM, JM, LM, T, Q, QS, DQS, DZ, ZLO, PLO, PS, SBCAPE, MLCAPE, MUCAPE, &
SBCIN, MLCIN, MUCIN, BYNCY, LFC, LNB )
! Computes surface-based (SB), mixed-layer (ML) and most unstable (MU) versions
! of CAPE and CIN.
integer, intent(in) :: IM, JM, LM
real, dimension(:,:,:), intent(in) :: T, Q, QS, DQS, DZ, ZLO, PLO
real, dimension(:,:,:), intent(out) :: BYNCY
real, pointer, dimension(:,:) :: MLCAPE, MUCAPE, MLCIN, MUCIN
real, dimension(:,:) :: SBCAPE, SBCIN, LFC, LNB
real, dimension(:,:), intent(in) :: PS
real, dimension(IM,JM,LM) :: Tve
real, dimension(IM,JM) :: MSEp, Qp, tmp1, tmp2
integer, dimension(IM,JM) :: Lev0
integer :: I, J, L
Tve = T*(1.+MAPL_VIREPS*Q)
BYNCY = MAPL_UNDEF
MSEp = 0.
Qp = 0.
! Mixed-layer calculation. Parcel properties averaged over lowest 90 hPa
if ( associated(MLCAPE) .and. associated(MLCIN) ) then
BYNCY = MAPL_UNDEF
tmp1 = 0.
Lev0 = LM
do L = LM,1,-1
where (PS-PLO(:,:,L).lt.90.)
MSEp = MSEp + (T(:,:,L) + gravbcp*ZLO(:,:,L) + alhlbcp*Q(:,:,L))*DZ(:,:,L)
Qp = Qp + Q(:,:,L)*DZ(:,:,L)
tmp1 = tmp1 + DZ(:,:,L)
Lev0 = L
end where
if (all(PS-PLO(:,:,L).gt.90.)) exit
end do
where (tmp1.gt.0.) ! average
MSEp = MSEp / tmp1
Qp = Qp / tmp1
end where
do I = 1,IM
do J = 1,JM
call RETURN_CAPE_CIN( ZLO(I,J,1:Lev0(I,J)), PLO(I,J,1:Lev0(I,J)), DZ(I,J,1:Lev0(I,J)), &
MSEp(I,J), Qp(I,J), Tve(I,J,1:Lev0(I,J)), QS(I,J,1:Lev0(I,J)), DQS(I,J,1:Lev0(I,J)), &
MLCAPE(I,J), MLCIN(I,J), BYNCY(I,J,1:Lev0(I,J)), LFC(I,J), LNB(I,J) )
end do
end do
where (MLCAPE.le.0.)
MLCAPE = MAPL_UNDEF
MLCIN = MAPL_UNDEF
end where
end if
! Most unstable calculation. Parcel in lowest 255 hPa with largest CAPE
if ( associated(MUCAPE) .and. associated(MUCIN) ) then
MUCAPE = 0.
MUCIN = 0.
BYNCY = MAPL_UNDEF
LFC = MAPL_UNDEF
LNB = MAPL_UNDEF
do I = 1,IM
do J = 1,JM
do L = LM,1,-1
if (PS(I,J)-PLO(I,J,L).gt.255.) exit
MSEp(I,J) = T(I,J,L) + gravbcp*ZLO(I,J,L) + alhlbcp*Q(I,J,L)
Qp(I,J) = Q(I,J,L)
call RETURN_CAPE_CIN( ZLO(I,J,1:L), PLO(I,J,1:L), DZ(I,J,1:L), &
MSEp(I,J), Qp(I,J), Tve(I,J,1:L), QS(I,J,1:L), DQS(I,J,1:L), &
tmp1(I,J), tmp2(I,J), BYNCY(I,J,1:L), LFC(I,J), LNB(I,J) )
if (tmp1(I,J) .gt. MUCAPE(I,J)) then
MUCAPE(I,J) = tmp1(I,J)
MUCIN(I,J) = tmp2(I,J)
end if
end do
end do
end do
where (MUCAPE.le.0.)
MUCAPE = MAPL_UNDEF
MUCIN = MAPL_UNDEF
end where
end if
! Surface-based calculation
MSEp = T(:,:,LM) + gravbcp*ZLO(:,:,LM) + alhlbcp*Q(:,:,LM) ! parcel moist static energy
Qp = Q(:,:,LM) ! parcel specific humidity
do I = 1,IM
do J = 1,JM
call RETURN_CAPE_CIN( ZLO(I,J,:), PLO(I,J,:), DZ(I,J,:), &
MSEp(I,J), Qp(I,J), Tve(I,J,:), QS(I,J,:), DQS(I,J,:), &
SBCAPE(I,J), SBCIN(I,J), BYNCY(I,J,:), LFC(I,J), LNB(I,J) )
end do
end do
where (SBCAPE.le.0.)
SBCAPE = MAPL_UNDEF
SBCIN = MAPL_UNDEF
end where
end subroutine BUOYANCY2
subroutine RETURN_CAPE_CIN( ZLO, PLO, DZ, MSEp, Qp, Tve, Qsate, DQS, CAPE, CIN, BYNCY, LFC, LNB )
real, intent(in) :: MSEp, Qp
real, dimension(:), intent(in) :: ZLO, PLO, DZ, Tve, Qsate, DQS
real, intent(out) :: CAPE, CIN, LFC, LNB
real, dimension(:), intent(out) :: BYNCY
integer :: I, L, LM, KLNB, KLFC
real :: Qpnew, Tp, Tvp, Tlcl, Buoy, dq
logical :: aboveLNB, aboveLFC, aboveLCL
LM = size(ZLO,1)
aboveLNB = .false.
aboveLFC = .false.
Qpnew = Qp
CAPE = 0.
CIN = 0.
BYNCY = 0.
LFC = MAPL_UNDEF
LNB = MAPL_UNDEF
Tp = MSEp - gravbcp*ZLO(LM) - alhlbcp*Qp ! initial parcel temp at source level LM
Tlcl = find_tlcl( Tp, 100.*Qp/QSATE(LM) )
aboveLCL = (Tp.lt.Tlcl)
do L = LM-1,1,-1 ! start at level above source air
! determine parcel Qp, Tp
if ( .not. aboveLCL ) then
Tp = Tp - gravbcp*(ZLO(L)-ZLO(L+1)) ! new parcel temperature w/o condensation
if (Tp.lt.Tlcl) then
Tp = Tp + gravbcp*(ZLO(L)-ZLO(L+1)) ! if cross LCL, revert Tp and go to aboveLCL below
aboveLCL = .true.
end if
end if
if ( aboveLCL .and. Qpnew*alhlbcp.gt.0.01 ) then
Tp = Tp - gravbcp*( ZLO(L)-ZLO(L+1) ) / ( 1.+alhlbcp*DQS(L) ) ! initial guess including condensation
DO I = 1,10 ! iterate until Qp=qsat(Tp)
dq = Qpnew - GEOS_QSAT( Tp, PLO(L) )
if (abs(dq*alhlbcp)<0.01) then
exit
end if
Tp = Tp + dq*alhlbcp/(1.+alhlbcp*DQS(L))
Qpnew = Qpnew - dq/(1.+alhlbcp*DQS(L))
END DO
end if
Tp = MSEp - gravbcp*ZLO(L) - alhlbcp*Qpnew
! Qc = qp - qpnew. ! condensate (not used for pseudoadiabatic ascent)
Tvp = Tp*(1.+MAPL_VIREPS*Qpnew) ! parcel virtual temp
! Tvp = Tp*(1.+0.61*Qpnew - Qc) ! condensate loading
BYNCY(L) = MAPL_GRAV*(Tvp-Tve(L))/Tve(L) ! parcel buoyancy
end do
! if surface parcel immediately buoyant, scan upward to find first elevated
! B>0 level above a B<0 level, label it LFC. If no such level, set LFC at surface.
KLFC = LM
KLNB = LM
aboveLFC = .false.
if (BYNCY(LM-1).gt.0.) then
do L = LM-2,1,-1 ! scan up to find elevated LFC
if (BYNCY(L).gt.0. .and. BYNCY(L+1).le.0.) then
KLFC = L
aboveLFC = .true.
end if
if (aboveLFC .and. BYNCY(L).lt.0. ) then
KLNB = L
exit
end if
end do
else ! if surface parcel not immediately buoyant, LFC is first B>0 level
do L = LM-1,1,-1
if (BYNCY(L).gt.0. .and. .not.aboveLFC) then
KLFC = L
aboveLFC = .true.
end if
if (aboveLFC .and. BYNCY(L).lt.0.) then
KLNB = L
exit
end if
end do
end if
LFC = ZLO(KLFC)
LNB = ZLO(KLNB)
CIN = SUM( min(0.,BYNCY(KLFC:)*DZ(KLFC:)) ) ! define CIN as negative
! CAPE = SUM( max(0.,BYNCY(KLNB:KLFC)*DZ(KLNB:KLFC)) )
CAPE = SUM( max(0.,BYNCY(:)*DZ(:)) )
end subroutine RETURN_CAPE_CIN
subroutine BUOYANCY( T, Q, QS, DQS, DZ, ZLO, BUOY, CAPE, INHB)
! !DESCRIPTION: Computes the buoyancy $ g \frac{T_c-T_e}{T_e} $ at each level
! for a parcel raised from the surface. $T_c$ is the virtual temperature of
! the parcel and $T_e$ is the virtual temperature of the environment.
real, dimension(:,:,:), intent(in) :: T, Q, QS, DQS, DZ, ZLO
real, dimension(:,:,:), intent(out) :: BUOY
real, dimension(:,:), intent(out) :: CAPE, INHB
integer :: L, LM
LM = size(T,3)
BUOY(:,:,LM) = T(:,:,LM) + gravbcp*ZLO(:,:,LM) + alhlbcp*Q(:,:,LM)
do L=LM-1,1,-1
BUOY(:,:,L) = BUOY(:,:,LM) - (T(:,:,L) + gravbcp*ZLO(:,:,L) + alhlbcp*QS(:,:,L))
BUOY(:,:,L) = MAPL_GRAV*BUOY(:,:,L) / ( (1.+ alhlbcp*DQS(:,:,L))*T(:,:,L) )
enddo
BUOY(:,:,LM) = 0.0
CAPE = 0.
INHB = 0.
do L=1,LM-1
where(BUOY(:,:,L)>0.)
CAPE = CAPE + BUOY(:,:,L)*DZ(:,:,L)
end where
where(BUOY(:,:,L)<0.)
INHB = INHB - BUOY(:,:,L)*DZ(:,:,L)
end where
end do
where(CAPE <= 0.0)
CAPE=MAPL_UNDEF
INHB=MAPL_UNDEF
end where
end subroutine BUOYANCY
subroutine RADCOUPLE( &
TE, &
PL, &
CF, &
AF, &
QV, &
QClLS, &
QCiLS, &
QClAN, &
QCiAN, &
QRN_ALL, &
QSN_ALL, &
QGR_ALL, &
NL, &
NI, &
RAD_QV, &
RAD_QL, &
RAD_QI, &
RAD_QR, &
RAD_QS, &
RAD_QG, &
RAD_CF, &
RAD_RL, &
RAD_RI, &
FAC_RL, MIN_RL, MAX_RL, &
FAC_RI, MIN_RI, MAX_RI)
real, intent(in ) :: TE
real, intent(in ) :: PL
real, intent(in ) :: AF,CF, QV, QClAN, QCiAN, QClLS, QCiLS
real, intent(in ) :: QRN_ALL, QSN_ALL, QGR_ALL
real, intent(in ) :: NL,NI
real, intent(out) :: RAD_QV,RAD_QL,RAD_QI,RAD_QR,RAD_QS,RAD_QG,RAD_CF,RAD_RL,RAD_RI
real, intent(in ) :: FAC_RL, MIN_RL, MAX_RL, FAC_RI, MIN_RI, MAX_RI
! Limits on Radii needed to ensure
! correct behavior of cloud optical
! properties currently calculated in
! sorad and irrad (1e-6 m = micron)
! water vapor
RAD_QV = QV
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Total cloud fraction
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
RAD_CF = MAX(MIN(CF+AF,1.0),0.0)
if ( RAD_CF >= 1.e-5 ) then
! Total In-cloud liquid
if ( (QClLS + QClAN) >= 1.e-8 ) then
RAD_QL = ( QClLS + QClAN ) / RAD_CF
else
RAD_QL = 0.0
end if
! Total In-cloud ice
if ( (QCiLS + QCiAN) >= 1.e-8 ) then
RAD_QI = ( QCiLS + QCiAN ) / RAD_CF
else
RAD_QI = 0.0
end if
! Total In-cloud precipitation
if (QRN_ALL >= 1.e-8 ) then
RAD_QR = ( QRN_ALL ) / RAD_CF
else
RAD_QR = 0.0
end if
if (QSN_ALL >= 1.e-8 ) then
RAD_QS = ( QSN_ALL ) / RAD_CF
else
RAD_QS = 0.0
end if
if (QGR_ALL >= 1.e-8 ) then
RAD_QG = ( QGR_ALL ) / RAD_CF
else
RAD_QG = 0.0
end if
else
RAD_CF = 0.0
RAD_QL = 0.0
RAD_QI = 0.0
RAD_QR = 0.0
RAD_QS = 0.0