70 integer(c_int),
value,
intent(in) :: ims, ime, jms, jme, kms, kme
71 integer(c_int),
value,
intent(in) :: its, ite, jts, jte, kts, kte
72 integer(c_int),
value,
intent(in) :: microphysics_debug
73 integer(c_int),
value,
intent(in) :: diag_i_dbg, diag_j_dbg
74 real(c_double),
intent(inout),
dimension(ims:ime, jms:jme, kms:kme) :: t, qv, qc, qi, qr, qs, qg
75 real(c_double),
intent(inout),
dimension(ims:ime, jms:jme, kms:kme) :: nn, nc, nr
76 real(c_double),
intent(in),
dimension(ims:ime, jms:jme, kms:kme) :: den, p, delz
77 real(c_double),
value,
intent(in) :: delt, g, cpd, cpv, rd, rv, t0c, ep1, ep2, qmin, xls
78 real(c_double),
value,
intent(in) :: xlv0, xlf0, den0, denr, cliq, cice, psat, ccn0
79 real(c_double),
intent(in),
dimension(ims:ime, jms:jme) :: xland
80 real(c_double),
intent(inout),
dimension(ims:ime, jms:jme) :: rain, rainncv, sr
81 real(c_double),
intent(inout),
dimension(ims:ime, jms:jme) :: snow, snowncv, graupel, graupelncv
83 integer :: i, j, k, kk, kdim, debug_local, i_dbg_local, j_dbg_target
84 integer :: i_max, k_max, max_loc(2)
85 logical :: i_dbg_in_tile
87 character(len=256) :: errmsg
89 real(c_double),
allocatable :: t_col(:,:), q_col(:,:), qc_col(:,:), qi_col(:,:), qr_col(:,:), qs_col(:,:), qg_col(:,:)
90 real(c_double),
allocatable :: nn_col(:,:), nc_col(:,:), nr_col(:,:)
91 real(c_double),
allocatable :: den_col(:,:), p_col(:,:), delz_col(:,:)
92 real(c_double),
allocatable :: xland_col(:)
93 real(c_double),
allocatable :: rain_col(:), rainncv_col(:), sr_col(:)
94 real(c_double),
allocatable :: snow_col(:), snowncv_col(:), graupel_col(:), graupelncv_col(:)
96 if (its < ims .or. ite > ime .or. jts < jms .or. jte > jme .or. kts < kms .or. kte > kme)
then
97 write(*,
'(A)')
'mp_wdm6_run_c bounds error: run-window outside storage bounds'
98 write(*,
'(A,6(1X,I0))')
' storage ims ime jms jme kms kme =', ims, ime, jms, jme, kms, kme
99 write(*,
'(A,6(1X,I0))')
' active its ite jts jte kts kte =', its, ite, jts, jte, kts, kte
102 if (its > ite .or. jts > jte .or. kts > kte)
then
103 write(*,
'(A)')
'mp_wdm6_run_c bounds error: invalid active index ordering'
104 write(*,
'(A,6(1X,I0))')
' active its ite jts jte kts kte =', its, ite, jts, jte, kts, kte
108 i_dbg_local = diag_i_dbg
109 i_dbg_in_tile = (i_dbg_local >= its .and. i_dbg_local <= ite)
110 if (.not. i_dbg_in_tile) i_dbg_local = its
111 j_dbg_target = diag_j_dbg
112 if (j_dbg_target < jts .or. j_dbg_target > jte) j_dbg_target = jts - 1
116 allocate(t_col(its:ite,1:kdim), q_col(its:ite,1:kdim), qc_col(its:ite,1:kdim), qi_col(its:ite,1:kdim))
117 allocate(qr_col(its:ite,1:kdim), qs_col(its:ite,1:kdim), qg_col(its:ite,1:kdim))
118 allocate(nn_col(its:ite,1:kdim), nc_col(its:ite,1:kdim), nr_col(its:ite,1:kdim))
119 allocate(den_col(its:ite,1:kdim), p_col(its:ite,1:kdim), delz_col(its:ite,1:kdim))
120 allocate(xland_col(its:ite))
121 allocate(rain_col(its:ite), rainncv_col(its:ite), sr_col(its:ite))
122 allocate(snow_col(its:ite), snowncv_col(its:ite), graupel_col(its:ite), graupelncv_col(its:ite))
128 t_col(i,kk) = t(i,j,k)
129 q_col(i,kk) = qv(i,j,k)
130 qc_col(i,kk) = qc(i,j,k)
131 qi_col(i,kk) = qi(i,j,k)
132 qr_col(i,kk) = qr(i,j,k)
133 qs_col(i,kk) = qs(i,j,k)
134 qg_col(i,kk) = qg(i,j,k)
135 nn_col(i,kk) = nn(i,j,k)
136 nc_col(i,kk) = nc(i,j,k)
137 nr_col(i,kk) = nr(i,j,k)
138 den_col(i,kk) = den(i,j,k)
139 p_col(i,kk) = p(i,j,k)
140 delz_col(i,kk) = delz(i,j,k)
145 xland_col(i) = xland(i,j)
146 rain_col(i) = rain(i,j)
147 rainncv_col(i) = rainncv(i,j)
149 snow_col(i) = snow(i,j)
150 snowncv_col(i) = snowncv(i,j)
151 graupel_col(i) = graupel(i,j)
152 graupelncv_col(i)= graupelncv(i,j)
155 debug_local = int(microphysics_debug, kind(0))
156 if (microphysics_debug >= 1_c_int .and. (j /= j_dbg_target .or. .not. i_dbg_in_tile)) debug_local = 0
158 call mp_wdm6_run(t_col, q_col, qc_col, qi_col, qr_col, qs_col, qg_col, &
159 nn_col, nc_col, nr_col, &
160 den_col, p_col, delz_col, &
161 delt, g, cpd, cpv, rd, rv, t0c, ep1, ep2, qmin, xls, xlv0, xlf0, den0, denr, &
162 cliq, cice, psat, ccn0, xland_col, &
163 rain_col, rainncv_col, sr_col, snow_col, snowncv_col, &
164 graupel_col, graupelncv_col, its=its, ite=ite, kts=1, kte=kdim, &
165 microphysics_debug=debug_local, diag_i_dbg=i_dbg_local, diag_j_dbg=j, diag_k_raw_base=kts, &
166 errmsg=errmsg, errflg=errflg)
168 if (errflg /= 0)
then
169 write(*,
'(A,1X,I0,2A)')
'mp_wdm6_run_c error at j=', j,
': ', trim(errmsg)
170 write(*,
'(A,6(1X,I0))')
' storage ims ime jms jme kms kme =', ims, ime, jms, jme, kms, kme
171 write(*,
'(A,6(1X,I0))')
' active its ite jts jte kts kte =', its, ite, jts, jte, kts, kte
178 t(i,j,k) = t_col(i,kk)
179 qv(i,j,k) = q_col(i,kk)
180 qc(i,j,k) = qc_col(i,kk)
181 qi(i,j,k) = qi_col(i,kk)
182 qr(i,j,k) = qr_col(i,kk)
183 qs(i,j,k) = qs_col(i,kk)
184 qg(i,j,k) = qg_col(i,kk)
185 nn(i,j,k) = nn_col(i,kk)
186 nc(i,j,k) = nc_col(i,kk)
187 nr(i,j,k) = nr_col(i,kk)
192 rain(i,j) = rain_col(i)
193 rainncv(i,j) = rainncv_col(i)
195 snow(i,j) = snow_col(i)
196 snowncv(i,j) = snowncv_col(i)
197 graupel(i,j) = graupel_col(i)
198 graupelncv(i,j) = graupelncv_col(i)
202 deallocate(t_col, q_col, qc_col, qi_col, qr_col, qs_col, qg_col)
203 deallocate(nn_col, nc_col, nr_col)
204 deallocate(den_col, p_col, delz_col, xland_col)
205 deallocate(rain_col, rainncv_col, sr_col, snow_col, snowncv_col, graupel_col, graupelncv_col)