7module mp_tempo_condensation
10 use machine,
only : kind_phys, kind_dyn, kind_dbl_prec
12 use module_mp_tempo_params,
only : roverrv, rv, rdry, eps, r1, t0, cp, initialize_parameters
14 use module_mp_tempo_main,
only : cloud_check_and_update
15 use module_mp_tempo_utils,
only : calc_rslf, get_constant_cloud_number
19 public :: mp_tempo_condensation_init, mp_tempo_condensation_run, mp_tempo_condensation_final
28 subroutine mp_tempo_condensation_init(errmsg, errflg)
30 character(len=*),
intent( out) :: errmsg
31 integer,
intent( out) :: errflg
35 end subroutine mp_tempo_condensation_init
41 subroutine mp_tempo_condensation_run(mpicomm, mpirank, mpiroot, &
42 tgrs, prsl, spechum, qc, mdt, errmsg, errflg, &
43 is, ie, js, je, isc1, iec1, jsc1, jec1, &
44 isc2, iec2, jsc2, jec2, isd, ied, jsd, jed, km)
46 integer,
intent(in ) :: isc1, iec1, jsc1, jec1
47 integer,
intent(in ) :: isd, ied, jsd, jed, is, ie, js, je, km, isc2, iec2, jsc2, jec2
48 type(MPI_Comm),
intent(in ) :: mpicomm
49 integer,
intent(in ) :: mpirank
50 integer,
intent(in ) :: mpiroot
51 real(kind_dyn),
intent(in ) :: mdt
52 real(kind_dyn),
intent(inout) :: spechum(isd:ied, jsd:jed, 1:km)
53 real(kind_dyn),
intent(inout) :: qc(isd:ied, jsd:jed, 1:km)
54 real(kind_dyn),
intent(inout) :: tgrs(isd:ied, jsd:jed, 1:km)
55 real(kind_dyn),
intent(in ) :: prsl(is:ie, 1:km+1, js:je)
57 real(kind_phys) :: qv(is:ie, js:je, 1:km)
58 real(kind_phys) :: qc_mixing_ratio(is:ie, js:je, 1:km)
59 real(kind_phys) :: nc3d(is:ie, js:je, 1:km)
60 real(kind_phys) :: qvs(is:ie, js:je, 1:km)
61 real(kind_phys) :: rho(is:ie, js:je, 1:km)
62 real(kind_phys) :: temp(is:ie, js:je, 1:km)
63 real(kind_phys) :: satw(1:km)
64 real(kind_phys) :: ssatw(1:km)
65 real(kind_phys) :: lvap(1:km)
66 real(kind_phys) :: tcond(1:km)
67 real(kind_phys) :: diffu(1:km)
68 real(kind_phys) :: ocp(1:km)
69 real(kind_phys) :: lvt2(1:km)
70 real(kind_phys) :: rc(1:km)
71 real(kind_phys) :: nc(1:km)
72 real(kind_dbl_prec) :: ilamc(1:km)
73 real(kind_phys) :: mvd_c(1:km)
74 real(kind_phys) :: qcten(1:km)
75 real(kind_phys) :: ncten(1:km)
77 real(kind_phys) :: condensation(is:ie, js:je, 1:km)
78 real(kind_phys) :: orho, clap, fcd, dfcd, xrc, odt
81 character(len=*),
intent( out) :: errmsg
82 integer,
intent( out) :: errflg
84 logical,
save :: need_tempo_params = .true.
89 odt = 1._kind_phys/real(mdt,kind=kind_phys)
91 if (need_tempo_params)
then
92 call initialize_parameters()
93 need_tempo_params = .false.
96 if (mpirank == mpiroot)
write(*,*)
'tempo condensation on re-mapping timestep'
100 spechum(i,j,k) = max(1.e-10, spechum(i,j,k))
101 qv(i,j,k) = spechum(i,j,k)/(1.0_kind_phys-spechum(i,j,k))
102 qc_mixing_ratio(i,j,k) = real(qc(i,j,k),kind=kind_phys) / (1._kind_phys-real(spechum(i,j,k),kind=kind_phys))
103 temp(i,j,k) = tgrs(i,j,k) / ((0.608 * spechum(i,j,k)) + 1.)
104 rho(i,j,k) = roverrv * exp(prsl(i,k,j)) / (rdry*temp(i,j,k) * (qv(i,j,k)+roverrv))
105 qvs(i,j,k) = calc_rslf(real(exp(prsl(i,k,j)),kind=kind_phys), real(temp(i,j,k),kind=kind_phys))
119 call get_constant_cloud_number(nc=nc3d(i,j,:))
122 call cloud_check_and_update(dt=real(mdt,kind=kind_phys), odt=odt, rho=rho(i,j,:), l_qc=l_qc, &
123 qc1d=qc_mixing_ratio(i,j,:), nc1d=nc3d(i,j,:), rc=rc, nc=nc, qcten=qcten, ncten=ncten, ilamc=ilamc, mvd_c=mvd_c)
126 satw(k) = qv(i,j,k)/qvs(i,j,k)
127 ssatw(k) = satw(k) - 1.
128 if (abs(ssatw(k)) < eps) ssatw(k) = 0.
129 lvap(k) = 2.5e6 + (2106.0 - 4218.0)*(temp(i,j,k)-t0)
130 tcond(k) = (5.69 + 0.0168*(temp(i,j,k)-t0))*1.0e-5 * 418.936
131 diffu(k) = 2.11e-5*(temp(i,j,k)/t0)**1.94 * (101325./exp(prsl(i,k,j)))
132 ocp(k) = 1./(cp*(1.+0.887*qv(i,j,k)))
133 lvt2(k) = lvap(k)*lvap(k)*ocp(k)*(1./rv)*(1./temp(i,j,k))*(1./temp(i,j,k))
135 if (abs(ssatw(k)) >= eps)
then
137 clap = (qv(i,j,k)-qvs(i,j,k))/(1. + lvt2(k)*qvs(i,j,k))
139 fcd = qvs(i,j,k)*exp(lvt2(k)*clap) - qv(i,j,k) + clap
140 dfcd = qvs(i,j,k)*lvt2(k)*exp(lvt2(k)*clap) + 1.
141 clap = clap - fcd/dfcd
143 xrc = rc(k) + clap*rho(i,j,k)
146 condensation(i,j,k) = clap / mdt
148 if (l_qc(k) .and. ssatw(k) < -1.e-6 .and. clap < -eps)
then
149 condensation(i,j,k) = max(-rc(k)*0.99*orho/mdt, condensation(i,j,k))
152 condensation(i,j,k) = -rc(k)*orho/mdt
156 qv(i,j,k) = qv(i,j,k) - condensation(i,j,k)*mdt
157 qc_mixing_ratio(i,j,k) = qc_mixing_ratio(i,j,k) + condensation(i,j,k)*mdt
158 temp(i,j,k) = temp(i,j,k) + lvap(k)*ocp(k)*condensation(i,j,k)*mdt
161 call cloud_check_and_update(dt=real(mdt,kind=kind_phys), odt=odt, rho=rho(i,j,:), l_qc=l_qc, &
162 qc1d=qc_mixing_ratio(i,j,:), nc1d=nc3d(i,j,:), rc=rc, nc=nc, qcten=qcten, ncten=ncten, ilamc=ilamc, mvd_c=mvd_c)
169 spechum(i,j,k) = max(1.e-10, real(qv(i,j,k),kind=kind_dyn)/(1. + real(qv(i,j,k), kind=kind_dyn)))
170 qc(i,j,k) = real(qc_mixing_ratio(i,j,k), kind=kind_dyn)/(1. + real(qv(i,j,k), kind=kind_dyn))
171 tgrs(i,j,k) = temp(i,j,k)*((0.608*spechum(i,j,k)) + 1.)
176 end subroutine mp_tempo_condensation_run
181 subroutine mp_tempo_condensation_final(errmsg, errflg)
183 character(len=*),
intent( out) :: errmsg
184 integer,
intent( out) :: errflg
188 end subroutine mp_tempo_condensation_final
190end module mp_tempo_condensation