9 real(kind=dbl_kind),
PARAMETER :: MIN_CF = 1.0e-6
10 real(kind=dbl_kind),
PARAMETER :: MIN_LC = 1.0
14 subroutine bugs_ctot(nlen, len_loc, nlm, pl2,tl, acld, l_c, c_tot)
17 integer (kind=int_kind),
intent(in) :: &
21 real (kind=dbl_kind),
intent(in),
dimension(nlen) :: &
23 real(kind=dbl_kind),
intent(in),
dimension(nlen,nlm) :: &
26 real(kind=dbl_kind),
intent(in),
dimension(nlen,nlm+1) :: &
28 real(kind=dbl_kind),
intent(out),
dimension(nlen) :: &
32 integer(kind=int_kind) :: &
33 i_lay_a, i_lay_b, i_domain, ncloud, kcld, j
34 integer(kind=int_kind),
dimension(:),
allocatable :: &
36 real(kind=dbl_kind) :: &
40 real(kind=dbl_kind),
dimension(nlm) :: &
42 real(kind=dbl_kind),
dimension(:),
allocatable :: &
50 ncloud = count(acld(i_domain,:) > min_cf)
54 else if (ncloud == 1)
then
56 c_tot(i_domain) = maxval(acld(i_domain,:))
58 if (maxval(acld(i_domain,:)) >= 1.)
then
65 do i_lay_a = nlm, 1, -1
66 dz = 29.286*log(pl2(i_domain,i_lay_a+1)/pl2(i_domain,i_lay_a))*tl(i_domain,i_lay_a)
67 z(i_lay_a) = z0 + dz/2.
72 allocate(i_cld(ncloud),cloud(ncloud),olap(ncloud-1), cld_below(ncloud))
75 if (acld(i_domain,i_lay_a) > min_cf)
then
82 cloud(1) = acld(i_domain,i_cld(1))
84 cloud(kcld) = acld(i_domain,i_cld(kcld))
86 if (l_c(i_domain) < min_lc)
then
88 olap(kcld-1) = cloud(kcld-1)*cloud(kcld)
90 dz=z(i_cld(kcld-1)) - z(i_cld(kcld))
91 alpha =
exp(-dz/l_c(i_domain))
92 olap(kcld-1) = alpha*min(cloud(kcld-1),cloud(kcld)) + &
93 (1. - alpha)*cloud(kcld-1)*cloud(kcld)
98 cld_below(1) = cloud(1)
99 cld_below(2) = cloud(2) - olap(1)
104 cld_below(kcld) = cloud(kcld) - olap(kcld-1)
106 cld_below(kcld) = cld_below(kcld)*(1. - (cloud(j)-olap(j))/&
111 c_tot(i_domain) = sum(cld_below)
112 deallocate(i_cld, cloud,olap, cld_below)
121 c_maximal, cf_max, cf_random)
125 integer (kind=int_kind),
intent(in) :: &
128 real (kind=dbl_kind),
intent(in),
dimension(len) :: &
130 real (kind=dbl_kind),
intent(in),
dimension(len,nlm) :: &
132 real (kind=dbl_kind),
intent(out),
dimension(len) :: &
134 real (kind=dbl_kind),
intent(out),
dimension(len,nlm) :: &
140 integer(kind=int_kind) :: i, j, nc
142 real(kind=dbl_kind) :: min_frac, max_frac
143 real(kind=dbl_kind) :: prod, c_tot_max, cf_stacked, &
144 c_tot_calcd,tol,delta
145 real(kind=dbl_kind),
dimension(nlm) :: cf_tmp
146 integer(kind=int_kind) :: frac_set
149 real(kind=dbl_kind) :: cf_stacked_thresh, &
151 integer(kind=int_kind) :: cf_stacked_min_set
162 if (acld(i,j) > min_cf)
then
165 if (acld(i,j) < min_frac)
then
168 if (acld(i,j) > max_frac)
then
173 if (frac_set == 0)
then
186 prod = prod*(1. - acld(i,j))
188 c_tot_max = 1. - prod
194 if (c_tot_max - c_tot(i) > tol)
then
196 c_tot_calcd = c_tot_max
197 delta = max_frac/1000.
198 do while (c_tot_calcd > c_tot(i) .and. cf_stacked <= max_frac)
202 if (acld(i,j) > cf_stacked)
then
203 prod = prod*(1. - acld(i,j))/(1. - cf_stacked)
206 c_tot_calcd = cf_stacked + (1 - cf_stacked)*(1. - prod)
207 cf_stacked = cf_stacked + delta
209 if (cf_stacked > max_frac)
then
213 cf_stacked = max_frac
218 cf_stacked = cf_stacked - delta/2.
226 cf_stacked = min_frac
252 c_maximal(i) = cf_stacked
254 if (acld(i,j) >= cf_stacked)
then
255 cf_max(i,j) = cf_stacked
256 cf_random(i,j) = acld(i,j) - cf_stacked
258 cf_max(i,j) = acld(i,j)
264 if (c_maximal(i) > 0. .and. c_maximal(i) < 1.)
then
265 cf_max(i,:) = cf_max(i,:)/c_maximal(i)
266 cf_random(i,:) = cf_random(i,:)/(1. - c_maximal(i))