45 real,
parameter::
r3 = 1./3.
51 SUBROUTINE update_dz_c_tlm(is, ie, js, je, km, ng, dt, dp0, zs, area, &
52 & ut, ut_tl, vt, vt_tl, gz, gz_tl, ws, ws_tl, npx, npy, sw_corner, &
53 & se_corner, ne_corner, nw_corner, bd, grid_type)
57 INTEGER,
INTENT(IN) :: is, ie, js, je, ng, km, npx, npy,
grid_type 58 LOGICAL,
INTENT(IN) :: sw_corner, se_corner, ne_corner, nw_corner
59 REAL,
INTENT(IN) :: dt
60 REAL,
INTENT(IN) :: dp0(km)
61 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng, km),
INTENT(IN) :: ut, vt
62 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng, km),
INTENT(IN) :: ut_tl, &
64 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng),
INTENT(IN) :: area
65 REAL,
INTENT(INOUT) :: gz(is-ng:ie+ng, js-ng:je+ng, km+1)
66 REAL,
INTENT(INOUT) :: gz_tl(is-ng:ie+ng, js-ng:je+ng, km+1)
67 REAL,
INTENT(IN) :: zs(is-ng:ie+ng, js-ng:je+ng)
68 REAL,
INTENT(OUT) :: ws(is-ng:ie+ng, js-ng:je+ng)
69 REAL,
INTENT(OUT) :: ws_tl(is-ng:ie+ng, js-ng:je+ng)
71 REAL :: gz2(is-ng:ie+ng, js-ng:je+ng)
72 REAL :: gz2_tl(is-ng:ie+ng, js-ng:je+ng)
73 REAL,
DIMENSION(is-1:ie+2, js-1:je+1) :: xfx, fx
74 REAL,
DIMENSION(is-1:ie+2, js-1:je+1) :: xfx_tl, fx_tl
75 REAL,
DIMENSION(is-1:ie+1, js-1:je+2) :: yfx, fy
76 REAL,
DIMENSION(is-1:ie+1, js-1:je+2) :: yfx_tl, fy_tl
77 REAL,
PARAMETER :: r14=1./14.
79 INTEGER :: is1, ie1, js1, je1
81 REAL :: rdt, top_ratio, bot_ratio, int_ratio
85 top_ratio = dp0(1)/(dp0(1)+dp0(2))
86 bot_ratio = dp0(km)/(dp0(km-1)+dp0(km))
107 xfx_tl(i, j) = ut_tl(i, j, 1) + top_ratio*(ut_tl(i, j, 1)-&
109 xfx(i, j) = ut(i, j, 1) + (ut(i, j, 1)-ut(i, j, 2))*&
115 yfx_tl(i, j) = vt_tl(i, j, 1) + top_ratio*(vt_tl(i, j, 1)-&
117 yfx(i, j) = vt(i, j, 1) + (vt(i, j, 1)-vt(i, j, 2))*&
121 ELSE IF (k .EQ. km + 1)
THEN 125 xfx_tl(i, j) = ut_tl(i, j, km) + bot_ratio*(ut_tl(i, j, km)-&
127 xfx(i, j) = ut(i, j, km) + (ut(i, j, km)-ut(i, j, km-1))*&
135 yfx_tl(i, j) = vt_tl(i, j, km) + bot_ratio*(vt_tl(i, j, km)-&
137 yfx(i, j) = vt(i, j, km) + (vt(i, j, km)-vt(i, j, km-1))*&
144 int_ratio = 1./(dp0(k-1)+dp0(k))
147 xfx_tl(i, j) = int_ratio*(dp0(k)*ut_tl(i, j, k-1)+dp0(k-1)*&
149 xfx(i, j) = (dp0(k)*ut(i, j, k-1)+dp0(k-1)*ut(i, j, k))*&
155 yfx_tl(i, j) = int_ratio*(dp0(k)*vt_tl(i, j, k-1)+dp0(k-1)*&
157 yfx(i, j) = (dp0(k)*vt(i, j, k-1)+dp0(k-1)*vt(i, j, k))*&
164 gz2_tl(i, j) = gz_tl(i, j, k)
165 gz2(i, j) = gz(i, j, k)
169 & npx, npy, sw_corner, &
170 & se_corner, ne_corner, &
174 IF (xfx(i, j) .GT. 0.)
THEN 175 fx_tl(i, j) = gz2_tl(i-1, j)
176 fx(i, j) = gz2(i-1, j)
178 fx_tl(i, j) = gz2_tl(i, j)
181 fx_tl(i, j) = xfx_tl(i, j)*fx(i, j) + xfx(i, j)*fx_tl(i, j)
182 fx(i, j) = xfx(i, j)*fx(i, j)
186 & npx, npy, sw_corner, &
187 & se_corner, ne_corner, &
191 IF (yfx(i, j) .GT. 0.)
THEN 192 fy_tl(i, j) = gz2_tl(i, j-1)
193 fy(i, j) = gz2(i, j-1)
195 fy_tl(i, j) = gz2_tl(i, j)
198 fy_tl(i, j) = yfx_tl(i, j)*fy(i, j) + yfx(i, j)*fy_tl(i, j)
199 fy(i, j) = yfx(i, j)*fy(i, j)
204 gz_tl(i, j, k) = ((area(i, j)*gz2_tl(i, j)+fx_tl(i, j)-fx_tl(i&
205 & +1, j)+fy_tl(i, j)-fy_tl(i, j+1))*(area(i, j)+(xfx(i, j)-xfx&
206 & (i+1, j))+(yfx(i, j)-yfx(i, j+1)))-(gz2(i, j)*area(i, j)+(fx&
207 & (i, j)-fx(i+1, j))+(fy(i, j)-fy(i, j+1)))*(xfx_tl(i, j)-&
208 & xfx_tl(i+1, j)+yfx_tl(i, j)-yfx_tl(i, j+1)))/(area(i, j)+(&
209 & xfx(i, j)-xfx(i+1, j))+(yfx(i, j)-yfx(i, j+1)))**2
210 gz(i, j, k) = (gz2(i, j)*area(i, j)+(fx(i, j)-fx(i+1, j))+(fy(&
211 & i, j)-fy(i, j+1)))/(area(i, j)+(xfx(i, j)-xfx(i+1, j))+(yfx(&
212 & i, j)-yfx(i, j+1)))
220 ws_tl(i, j) = -(rdt*gz_tl(i, j, km+1))
221 ws(i, j) = (zs(i, j)-gz(i, j, km+1))*rdt
225 IF (gz(i, j, k) .LT. gz(i, j, k+1) +
dz_min)
THEN 226 gz_tl(i, j, k) = gz_tl(i, j, k+1)
227 gz(i, j, k) = gz(i, j, k+1) +
dz_min 229 gz(i, j, k) = gz(i, j, k)
235 SUBROUTINE update_dz_c(is, ie, js, je, km, ng, dt, dp0, zs, area, ut, &
236 & vt, gz, ws, npx, npy, sw_corner, se_corner, ne_corner, nw_corner, bd&
241 INTEGER,
INTENT(IN) :: is, ie, js, je, ng, km, npx, npy,
grid_type 242 LOGICAL,
INTENT(IN) :: sw_corner, se_corner, ne_corner, nw_corner
243 REAL,
INTENT(IN) :: dt
244 REAL,
INTENT(IN) :: dp0(km)
245 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng, km),
INTENT(IN) :: ut, vt
246 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng),
INTENT(IN) :: area
247 REAL,
INTENT(INOUT) :: gz(is-ng:ie+ng, js-ng:je+ng, km+1)
248 REAL,
INTENT(IN) :: zs(is-ng:ie+ng, js-ng:je+ng)
249 REAL,
INTENT(OUT) :: ws(is-ng:ie+ng, js-ng:je+ng)
251 REAL :: gz2(is-ng:ie+ng, js-ng:je+ng)
252 REAL,
DIMENSION(is-1:ie+2, js-1:je+1) :: xfx, fx
253 REAL,
DIMENSION(is-1:ie+1, js-1:je+2) :: yfx, fy
254 REAL,
PARAMETER :: r14=1./14.
256 INTEGER :: is1, ie1, js1, je1
258 REAL :: rdt, top_ratio, bot_ratio, int_ratio
262 top_ratio = dp0(1)/(dp0(1)+dp0(2))
263 bot_ratio = dp0(km)/(dp0(km-1)+dp0(km))
279 xfx(i, j) = ut(i, j, 1) + (ut(i, j, 1)-ut(i, j, 2))*&
285 yfx(i, j) = vt(i, j, 1) + (vt(i, j, 1)-vt(i, j, 2))*&
289 ELSE IF (k .EQ. km + 1)
THEN 293 xfx(i, j) = ut(i, j, km) + (ut(i, j, km)-ut(i, j, km-1))*&
301 yfx(i, j) = vt(i, j, km) + (vt(i, j, km)-vt(i, j, km-1))*&
308 int_ratio = 1./(dp0(k-1)+dp0(k))
311 xfx(i, j) = (dp0(k)*ut(i, j, k-1)+dp0(k-1)*ut(i, j, k))*&
317 yfx(i, j) = (dp0(k)*vt(i, j, k-1)+dp0(k-1)*vt(i, j, k))*&
324 gz2(i, j) = gz(i, j, k)
327 IF (
grid_type .LT. 3)
CALL fill_4corners(gz2, 1, bd, npx, npy, &
328 & sw_corner, se_corner, ne_corner&
332 IF (xfx(i, j) .GT. 0.)
THEN 333 fx(i, j) = gz2(i-1, j)
337 fx(i, j) = xfx(i, j)*fx(i, j)
340 IF (
grid_type .LT. 3)
CALL fill_4corners(gz2, 2, bd, npx, npy, &
341 & sw_corner, se_corner, ne_corner&
345 IF (yfx(i, j) .GT. 0.)
THEN 346 fy(i, j) = gz2(i, j-1)
350 fy(i, j) = yfx(i, j)*fy(i, j)
355 gz(i, j, k) = (gz2(i, j)*area(i, j)+(fx(i, j)-fx(i+1, j))+(fy(&
356 & i, j)-fy(i, j+1)))/(area(i, j)+(xfx(i, j)-xfx(i+1, j))+(yfx(&
357 & i, j)-yfx(i, j+1)))
365 ws(i, j) = (zs(i, j)-gz(i, j, km+1))*rdt
369 IF (gz(i, j, k) .LT. gz(i, j, k+1) +
dz_min)
THEN 370 gz(i, j, k) = gz(i, j, k+1) +
dz_min 372 gz(i, j, k) = gz(i, j, k)
382 & npx, npy, area, rarea, dp0, zs, zh, zh_tl, crx, crx_tl, cry, cry_tl&
383 & , xfx, xfx_tl, yfx, yfx_tl, delz, ws, ws_tl, rdt, gridstruct, bd, &
387 INTEGER,
INTENT(IN) :: is, ie, js, je, ng, km, npx, npy
388 INTEGER,
INTENT(IN) :: hord, hord_pert
389 REAL,
INTENT(IN) :: rdt
390 REAL,
INTENT(IN) :: dp0(km)
391 REAL,
INTENT(IN) :: area(is-ng:ie+ng, js-ng:je+ng)
392 REAL,
INTENT(IN) :: rarea(is-ng:ie+ng, js-ng:je+ng)
393 REAL,
INTENT(INOUT) :: damp(km+1)
394 INTEGER,
INTENT(INOUT) :: ndif(km+1)
395 REAL,
INTENT(IN) :: zs(is-ng:ie+ng, js-ng:je+ng)
396 REAL,
INTENT(INOUT) :: zh(is-ng:ie+ng, js-ng:je+ng, km+1)
397 REAL,
INTENT(INOUT) :: zh_tl(is-ng:ie+ng, js-ng:je+ng, km+1)
398 REAL,
INTENT(OUT) :: delz(is-ng:ie+ng, js-ng:je+ng, km)
399 REAL,
DIMENSION(is:ie+1, js-ng:je+ng, km),
INTENT(INOUT) :: crx, xfx
400 REAL,
DIMENSION(is:ie+1, js-ng:je+ng, km),
INTENT(INOUT) :: crx_tl, &
402 REAL,
DIMENSION(is-ng:ie+ng, js:je+1, km),
INTENT(INOUT) :: cry, yfx
403 REAL,
DIMENSION(is-ng:ie+ng, js:je+1, km),
INTENT(INOUT) :: cry_tl, &
405 REAL,
INTENT(OUT) :: ws(is:ie, js:je)
406 REAL,
INTENT(OUT) :: ws_tl(is:ie, js:je)
410 REAL,
DIMENSION(is:ie+1, js-ng:je+ng, km+1) :: crx_adv, xfx_adv
411 REAL,
DIMENSION(is:ie+1, js-ng:je+ng, km+1) :: crx_adv_tl, &
413 REAL,
DIMENSION(is-ng:ie+ng, js:je+1, km+1) :: cry_adv, yfx_adv
414 REAL,
DIMENSION(is-ng:ie+ng, js:je+1, km+1) :: cry_adv_tl, &
416 REAL,
DIMENSION(is:ie+1, js:je) :: fx
417 REAL,
DIMENSION(is:ie+1, js:je) :: fx_tl
418 REAL,
DIMENSION(is:ie, js:je+1) :: fy
419 REAL,
DIMENSION(is:ie, js:je+1) :: fy_tl
420 REAL,
DIMENSION(is-ng:ie+ng+1, js-ng:je+ng) :: fx2
421 REAL,
DIMENSION(is-ng:ie+ng+1, js-ng:je+ng) :: fx2_tl
422 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng+1) :: fy2
423 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng+1) :: fy2_tl
424 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng) :: wk2, z2
425 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng) :: wk2_tl, z2_tl
426 REAL :: ra_x(is:ie, js-ng:je+ng)
427 REAL :: ra_x_tl(is:ie, js-ng:je+ng)
428 REAL :: ra_y(is-ng:ie+ng, js:je)
429 REAL :: ra_y_tl(is-ng:ie+ng, js:je)
431 INTEGER :: i, j, k, isd, ied, jsd, jed
432 LOGICAL :: uniform_grid
434 uniform_grid = .false.
435 damp(km+1) = damp(km)
436 ndif(km+1) = ndif(km)
449 & crx_adv_tl, xfx_adv, xfx_adv_tl, is, ie + 1, jsd, &
450 & jed, j, km, dp0, uniform_grid, 0)
477 ra_x_tl(i, j) = xfx_adv_tl(i, j, k) - xfx_adv_tl(i+1, j, k)
478 ra_x(i, j) = area(i, j) + (xfx_adv(i, j, k)-xfx_adv(i+1, j, k)&
484 ra_y_tl(i, j) = yfx_adv_tl(i, j, k) - yfx_adv_tl(i, j+1, k)
485 ra_y(i, j) = area(i, j) + (yfx_adv(i, j, k)-yfx_adv(i, j+1, k)&
489 IF (damp(k) .GT. 1.e-5)
THEN 492 z2_tl(i, j) = zh_tl(i, j, k)
493 z2(i, j) = zh(i, j, k)
496 IF (hord .EQ. hord_pert)
THEN 497 CALL fv_tp_2d_tlm(z2, z2_tl, crx_adv(is:ie+1, jsd:jed, k), &
498 & crx_adv_tl(is:ie+1, jsd:jed, k), cry_adv(isd:&
499 & ied, js:je+1, k), cry_adv_tl(isd:ied, js:je+1, &
500 & k), npx, npy, hord, fx, fx_tl, fy, fy_tl, &
501 & xfx_adv(is:ie+1, jsd:jed, k), xfx_adv_tl(is:ie+&
502 & 1, jsd:jed, k), yfx_adv(isd:ied, js:je+1, k), &
503 & yfx_adv_tl(isd:ied, js:je+1, k), gridstruct, bd&
504 & , ra_x, ra_x_tl, ra_y, ra_y_tl)
506 CALL fv_tp_2d_tlm(z2, z2_tl, crx_adv(is:ie+1, jsd:jed, k), &
507 & crx_adv_tl(is:ie+1, jsd:jed, k), cry_adv(isd:ied, &
508 & js:je+1, k), cry_adv_tl(isd:ied, js:je+1, k), npx&
509 & , npy, hord_pert, fx, fx_tl, fy, fy_tl, xfx_adv(is&
510 & :ie+1, jsd:jed, k), xfx_adv_tl(is:ie+1, jsd:jed, k&
511 & ), yfx_adv(isd:ied, js:je+1, k), yfx_adv_tl(isd:&
512 & ied, js:je+1, k), gridstruct, bd, ra_x, ra_x_tl, &
514 call fv_tp_2d(z2, crx_adv(is:ie+1,jsd:jed,k), cry_adv(isd:ied,js:je+1,k), npx, npy, hord, &
515 fx, fy, xfx_adv(is:ie+1,jsd:jed,k), yfx_adv(isd:ied,js:je+1,k), gridstruct, bd, ra_x, ra_y)
518 & , wk2_tl, fx2, fx2_tl, fy2, fy2_tl, gridstruct, &
522 zh_tl(i, j, k) = ((area(i, j)*z2_tl(i, j)+fx_tl(i, j)-fx_tl(&
523 & i+1, j)+fy_tl(i, j)-fy_tl(i, j+1))*(ra_x(i, j)+ra_y(i, j)-&
524 & area(i, j))-(z2(i, j)*area(i, j)+(fx(i, j)-fx(i+1, j))+(fy&
525 & (i, j)-fy(i, j+1)))*(ra_x_tl(i, j)+ra_y_tl(i, j)))/(ra_x(i&
526 & , j)+ra_y(i, j)-area(i, j))**2 + rarea(i, j)*(fx2_tl(i, j)&
527 & -fx2_tl(i+1, j)+fy2_tl(i, j)-fy2_tl(i, j+1))
528 zh(i, j, k) = (z2(i, j)*area(i, j)+(fx(i, j)-fx(i+1, j))+(fy&
529 & (i, j)-fy(i, j+1)))/(ra_x(i, j)+ra_y(i, j)-area(i, j)) + (&
530 & fx2(i, j)-fx2(i+1, j)+(fy2(i, j)-fy2(i, j+1)))*rarea(i, j)
534 IF (hord .EQ. hord_pert)
THEN 535 CALL fv_tp_2d_tlm(zh(isd:ied, jsd:jed, k), zh_tl(isd:ied, &
536 & jsd:jed, k), crx_adv(is:ie+1, jsd:jed, k), &
537 & crx_adv_tl(is:ie+1, jsd:jed, k), cry_adv(isd:&
538 & ied, js:je+1, k), cry_adv_tl(isd:ied, js:je+1, &
539 & k), npx, npy, hord, fx, fx_tl, fy, fy_tl, &
540 & xfx_adv(is:ie+1, jsd:jed, k), xfx_adv_tl(is:ie+&
541 & 1, jsd:jed, k), yfx_adv(isd:ied, js:je+1, k), &
542 & yfx_adv_tl(isd:ied, js:je+1, k), gridstruct, bd&
543 & , ra_x, ra_x_tl, ra_y, ra_y_tl)
545 CALL fv_tp_2d_tlm(zh(isd:ied, jsd:jed, k), zh_tl(isd:ied, jsd:&
546 & jed, k), crx_adv(is:ie+1, jsd:jed, k), crx_adv_tl(&
547 & is:ie+1, jsd:jed, k), cry_adv(isd:ied, js:je+1, k)&
548 & , cry_adv_tl(isd:ied, js:je+1, k), npx, npy, &
549 & hord_pert, fx, fx_tl, fy, fy_tl, xfx_adv(is:ie+1, &
550 & jsd:jed, k), xfx_adv_tl(is:ie+1, jsd:jed, k), &
551 & yfx_adv(isd:ied, js:je+1, k), yfx_adv_tl(isd:ied, &
552 & js:je+1, k), gridstruct, bd, ra_x, ra_x_tl, ra_y, &
554 call fv_tp_2d(zh(isd:ied,jsd:jed,k), crx_adv(is:ie+1,jsd:jed,k), cry_adv(isd:ied,js:je+1,k), npx, npy, hord, &
555 fx, fy, xfx_adv(is:ie+1,jsd:jed,k), yfx_adv(isd:ied,js:je+1,k), gridstruct, bd, ra_x, ra_y)
559 zh_tl(i, j, k) = ((area(i, j)*zh_tl(i, j, k)+fx_tl(i, j)-&
560 & fx_tl(i+1, j)+fy_tl(i, j)-fy_tl(i, j+1))*(ra_x(i, j)+ra_y(&
561 & i, j)-area(i, j))-(zh(i, j, k)*area(i, j)+(fx(i, j)-fx(i+1&
562 & , j))+(fy(i, j)-fy(i, j+1)))*(ra_x_tl(i, j)+ra_y_tl(i, j))&
563 & )/(ra_x(i, j)+ra_y(i, j)-area(i, j))**2
564 zh(i, j, k) = (zh(i, j, k)*area(i, j)+(fx(i, j)-fx(i+1, j))+&
565 & (fy(i, j)-fy(i, j+1)))/(ra_x(i, j)+ra_y(i, j)-area(i, j))
575 ws_tl(i, j) = -(rdt*zh_tl(i, j, km+1))
576 ws(i, j) = (zs(i, j)-zh(i, j, km+1))*rdt
580 IF (zh(i, j, k) .LT. zh(i, j, k+1) +
dz_min)
THEN 581 zh_tl(i, j, k) = zh_tl(i, j, k+1)
582 zh(i, j, k) = zh(i, j, k+1) +
dz_min 584 zh(i, j, k) = zh(i, j, k)
590 SUBROUTINE update_dz_d(ndif, damp, hord, is, ie, js, je, km, ng, npx, &
591 & npy, area, rarea, dp0, zs, zh, crx, cry, xfx, yfx, delz, ws, rdt, &
592 & gridstruct, bd, hord_pert)
595 INTEGER,
INTENT(IN) :: is, ie, js, je, ng, km, npx, npy
596 INTEGER,
INTENT(IN) :: hord, hord_pert
597 REAL,
INTENT(IN) :: rdt
598 REAL,
INTENT(IN) :: dp0(km)
599 REAL,
INTENT(IN) :: area(is-ng:ie+ng, js-ng:je+ng)
600 REAL,
INTENT(IN) :: rarea(is-ng:ie+ng, js-ng:je+ng)
601 REAL,
INTENT(INOUT) :: damp(km+1)
602 INTEGER,
INTENT(INOUT) :: ndif(km+1)
603 REAL,
INTENT(IN) :: zs(is-ng:ie+ng, js-ng:je+ng)
604 REAL,
INTENT(INOUT) :: zh(is-ng:ie+ng, js-ng:je+ng, km+1)
605 REAL,
INTENT(OUT) :: delz(is-ng:ie+ng, js-ng:je+ng, km)
606 REAL,
DIMENSION(is:ie+1, js-ng:je+ng, km),
INTENT(INOUT) :: crx, xfx
607 REAL,
DIMENSION(is-ng:ie+ng, js:je+1, km),
INTENT(INOUT) :: cry, yfx
608 REAL,
INTENT(OUT) :: ws(is:ie, js:je)
612 REAL,
DIMENSION(is:ie+1, js-ng:je+ng, km+1) :: crx_adv, xfx_adv
613 REAL,
DIMENSION(is-ng:ie+ng, js:je+1, km+1) :: cry_adv, yfx_adv
614 REAL,
DIMENSION(is:ie+1, js:je) :: fx
615 REAL,
DIMENSION(is:ie, js:je+1) :: fy
616 REAL,
DIMENSION(is-ng:ie+ng+1, js-ng:je+ng) :: fx2
617 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng+1) :: fy2
618 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng) :: wk2, z2
619 REAL :: ra_x(is:ie, js-ng:je+ng)
620 REAL :: ra_y(is-ng:ie+ng, js:je)
622 INTEGER :: i, j, k, isd, ied, jsd, jed
623 LOGICAL :: uniform_grid
625 uniform_grid = .false.
626 damp(km+1) = damp(km)
627 ndif(km+1) = ndif(km)
635 CALL edge_profile(crx, xfx, crx_adv, xfx_adv, is, ie + 1, jsd, jed&
636 & , j, km, dp0, uniform_grid, 0)
637 IF (j .LE. je + 1 .AND. j .GE. js)
CALL edge_profile(cry, yfx, &
638 & cry_adv, yfx_adv, &
639 & isd, ied, js, je + &
650 ra_x(i, j) = area(i, j) + (xfx_adv(i, j, k)-xfx_adv(i+1, j, k)&
656 ra_y(i, j) = area(i, j) + (yfx_adv(i, j, k)-yfx_adv(i, j+1, k)&
660 IF (damp(k) .GT. 1.e-5)
THEN 663 z2(i, j) = zh(i, j, k)
666 IF (hord .EQ. hord_pert)
THEN 667 CALL fv_tp_2d(z2, crx_adv(is:ie+1, jsd:jed, k), cry_adv(isd&
668 & :ied, js:je+1, k), npx, npy, hord, fx, fy, xfx_adv(&
669 & is:ie+1, jsd:jed, k), yfx_adv(isd:ied, js:je+1, k)&
670 & , gridstruct, bd, ra_x, ra_y)
672 call fv_tp_2d(z2, crx_adv(is:ie+1,jsd:jed,k), cry_adv(isd:ied,js:je+1,k), npx, npy, hord, &
673 fx, fy, xfx_adv(is:ie+1,jsd:jed,k), yfx_adv(isd:ied,js:je+1,k), gridstruct, bd, ra_x, ra_y)
675 CALL del6_vt_flux(ndif(k), npx, npy, damp(k), z2, wk2, fx2, fy2&
679 zh(i, j, k) = (z2(i, j)*area(i, j)+(fx(i, j)-fx(i+1, j))+(fy&
680 & (i, j)-fy(i, j+1)))/(ra_x(i, j)+ra_y(i, j)-area(i, j)) + (&
681 & fx2(i, j)-fx2(i+1, j)+(fy2(i, j)-fy2(i, j+1)))*rarea(i, j)
685 IF (hord .EQ. hord_pert)
THEN 686 CALL fv_tp_2d(zh(isd:ied, jsd:jed, k), crx_adv(is:ie+1, jsd&
687 & :jed, k), cry_adv(isd:ied, js:je+1, k), npx, npy, &
688 & hord, fx, fy, xfx_adv(is:ie+1, jsd:jed, k), yfx_adv&
689 & (isd:ied, js:je+1, k), gridstruct, bd, ra_x, ra_y)
691 call fv_tp_2d(zh(isd:ied,jsd:jed,k), crx_adv(is:ie+1,jsd:jed,k), cry_adv(isd:ied,js:je+1,k), npx, npy, hord, &
692 fx, fy, xfx_adv(is:ie+1,jsd:jed,k), yfx_adv(isd:ied,js:je+1,k), gridstruct, bd, ra_x, ra_y)
696 zh(i, j, k) = (zh(i, j, k)*area(i, j)+(fx(i, j)-fx(i+1, j))+&
697 & (fy(i, j)-fy(i, j+1)))/(ra_x(i, j)+ra_y(i, j)-area(i, j))
707 ws(i, j) = (zs(i, j)-zh(i, j, km+1))*rdt
711 IF (zh(i, j, k) .LT. zh(i, j, k+1) +
dz_min)
THEN 712 zh(i, j, k) = zh(i, j, k+1) +
dz_min 714 zh(i, j, k) = zh(i, j, k)
724 & cappa, cp, ptop, hs, w3, w3_tl, pt, pt_tl, q_con, delp, delp_tl, gz&
725 & , gz_tl, pef, pef_tl, ws, ws_tl, p_fac, a_imp, scale_m)
727 INTEGER,
INTENT(IN) :: is, ie, js, je, ng, km
728 INTEGER,
INTENT(IN) :: ms
729 REAL,
INTENT(IN) :: dt, akap, cp, ptop, p_fac, a_imp, scale_m
730 REAL,
INTENT(IN) :: ws(is-ng:ie+ng, js-ng:je+ng)
731 REAL,
INTENT(IN) :: ws_tl(is-ng:ie+ng, js-ng:je+ng)
732 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng, km),
INTENT(IN) :: pt, &
734 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng, km),
INTENT(IN) :: pt_tl, &
736 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng, km),
INTENT(IN) :: q_con, &
738 REAL,
INTENT(IN) :: hs(is-ng:ie+ng, js-ng:je+ng)
739 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng, km),
INTENT(IN) :: w3
740 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng, km),
INTENT(IN) :: w3_tl
742 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng, km+1),
INTENT(INOUT) :: gz
743 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng, km+1),
INTENT(INOUT) :: &
745 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng, km+1),
INTENT(OUT) :: pef
746 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng, km+1),
INTENT(OUT) :: &
749 REAL,
DIMENSION(is-1:ie+1, km) :: dm, dz2, w2, pm2, gm2, cp2
750 REAL,
DIMENSION(is-1:ie+1, km) :: dm_tl, dz2_tl, w2_tl, pm2_tl
751 REAL,
DIMENSION(is-1:ie+1, km+1) :: pem, pe2, peg
752 REAL,
DIMENSION(is-1:ie+1, km+1) :: pem_tl, pe2_tl
775 dm_tl(i, k) = delp_tl(i, j, k)
776 dm(i, k) = delp(i, j, k)
781 pef_tl(i, j, 1) = 0.0
788 pem_tl(i, k) = pem_tl(i, k-1) + dm_tl(i, k-1)
789 pem(i, k) = pem(i, k-1) + dm(i, k-1)
794 dz2_tl(i, k) = gz_tl(i, j, k+1) - gz_tl(i, j, k)
795 dz2(i, k) = gz(i, j, k+1) - gz(i, j, k)
796 arg1_tl = (pem_tl(i, k+1)*pem(i, k)-pem(i, k+1)*pem_tl(i, k))/&
798 arg1 = pem(i, k+1)/pem(i, k)
799 pm2_tl(i, k) = (dm_tl(i, k)*log(arg1)-dm(i, k)*arg1_tl/arg1)/&
801 pm2(i, k) = dm(i, k)/log(arg1)
802 dm_tl(i, k) = rgrav*dm_tl(i, k)
803 dm(i, k) = dm(i, k)*rgrav
804 w2_tl(i, k) = w3_tl(i, j, k)
805 w2(i, k) = w3(i, j, k)
808 IF (a_imp .LT. -0.01)
THEN 810 & , pe2_tl, dm, dm_tl, pem, pem_tl, w2, w2_tl, &
811 & dz2, dz2_tl, pt(is1:ie1, j, 1:km), pt_tl(is1:&
812 & ie1, j, 1:km), ws(is1:ie1, j), ws_tl(is1:ie1, j&
814 ELSE IF (a_imp .LE. 0.5)
THEN 816 & pe2_tl, dm, dm_tl, pm2, pm2_tl, w2, w2_tl, dz2, dz2_tl&
817 & , pt(is1:ie1, j, 1:km), pt_tl(is1:ie1, j, 1:km), ws(&
818 & is1:ie1, j), ws_tl(is1:ie1, j), .true.)
821 & akap, pe2, pe2_tl, dm, dm_tl, pm2, pm2_tl, pem, &
822 & pem_tl, w2, w2_tl, dz2, dz2_tl, pt(is1:ie1, j, 1:&
823 & km), pt_tl(is1:ie1, j, 1:km), ws(is1:ie1, j), &
824 & ws_tl(is1:ie1, j), p_fac)
829 pef_tl(i, j, k) = pe2_tl(i, k) + pem_tl(i, k)
830 pef(i, j, k) = pe2(i, k) + pem(i, k)
835 gz_tl(i, j, km+1) = 0.0
836 gz(i, j, km+1) = hs(i, j)
840 gz_tl(i, j, k) = gz_tl(i, j, k+1) -
grav*dz2_tl(i, k)
841 gz(i, j, k) = gz(i, j, k+1) - dz2(i, k)*
grav 846 SUBROUTINE riem_solver_c(ms, dt, is, ie, js, je, km, ng, akap, cappa, &
847 & cp, ptop, hs, w3, pt, q_con, delp, gz, pef, ws, p_fac, a_imp, &
850 INTEGER,
INTENT(IN) :: is, ie, js, je, ng, km
851 INTEGER,
INTENT(IN) :: ms
852 REAL,
INTENT(IN) :: dt, akap, cp, ptop, p_fac, a_imp, scale_m
853 REAL,
INTENT(IN) :: ws(is-ng:ie+ng, js-ng:je+ng)
854 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng, km),
INTENT(IN) :: pt, &
856 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng, km),
INTENT(IN) :: q_con, &
858 REAL,
INTENT(IN) :: hs(is-ng:ie+ng, js-ng:je+ng)
859 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng, km),
INTENT(IN) :: w3
861 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng, km+1),
INTENT(INOUT) :: gz
862 REAL,
DIMENSION(is-ng:ie+ng, js-ng:je+ng, km+1),
INTENT(OUT) :: pef
864 REAL,
DIMENSION(is-1:ie+1, km) :: dm, dz2, w2, pm2, gm2, cp2
865 REAL,
DIMENSION(is-1:ie+1, km+1) :: pem, pe2, peg
881 dm(i, k) = delp(i, j, k)
891 pem(i, k) = pem(i, k-1) + dm(i, k-1)
896 dz2(i, k) = gz(i, j, k+1) - gz(i, j, k)
897 arg1 = pem(i, k+1)/pem(i, k)
898 pm2(i, k) = dm(i, k)/log(arg1)
899 dm(i, k) = dm(i, k)*rgrav
900 w2(i, k) = w3(i, j, k)
903 IF (a_imp .LT. -0.01)
THEN 905 & , pem, w2, dz2, pt(is1:ie1, j, 1:km), ws(is1:ie1, j&
907 ELSE IF (a_imp .LE. 0.5)
THEN 908 CALL rim_2d(ms, dt, is1, ie1, km,
rdgas, gama, gm2, pe2, dm, pm2&
909 & , w2, dz2, pt(is1:ie1, j, 1:km), ws(is1:ie1, j), .true.)
912 & pe2, dm, pm2, pem, w2, dz2, pt(is1:ie1, j, 1:km), ws(&
913 & is1:ie1, j), p_fac)
918 pef(i, j, k) = pe2(i, k) + pem(i, k)
923 gz(i, j, km+1) = hs(i, j)
927 gz(i, j, k) = gz(i, j, k+1) - dz2(i, k)*
grav 934 SUBROUTINE riem_solver3test(ms, dt, is, ie, js, je, km, ng, isd, ied, &
935 & jsd, jed, akap, cappa, cp, ptop, zs, q_con, w, delz, pt, delp, zh, &
936 & pe, ppe, pk3, pk, peln, ws, scale_m, p_fac, a_imp, use_logp, &
945 INTEGER,
INTENT(IN) :: ms, is, ie, js, je, km, ng
946 INTEGER,
INTENT(IN) :: isd, ied, jsd, jed
948 REAL,
INTENT(IN) :: dt
949 REAL,
INTENT(IN) :: akap, cp, ptop, p_fac, a_imp, scale_m
950 REAL,
INTENT(IN) :: zs(isd:ied, jsd:jed)
951 LOGICAL,
INTENT(IN) :: last_call, use_logp, fp_out
952 REAL,
INTENT(IN) :: ws(is:ie, js:je)
953 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(IN) :: q_con, cappa
954 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(IN) :: delp, pt
955 REAL,
DIMENSION(isd:ied, jsd:jed, km+1),
INTENT(INOUT) :: zh
956 REAL,
DIMENSION(isd:ied, jsd:jed, km),
INTENT(INOUT) :: w
957 REAL,
INTENT(INOUT) :: pe(is-1:ie+1, km+1, js-1:je+1)
959 REAL,
INTENT(OUT) :: peln(is:ie, km+1, js:je)
960 REAL,
DIMENSION(isd:ied, jsd:jed, km+1),
INTENT(OUT) :: ppe
961 REAL,
INTENT(OUT) :: delz(is-ng:ie+ng, js-ng:je+ng, km)
962 REAL,
INTENT(OUT) :: pk(is:ie, js:je, km+1)
963 REAL,
INTENT(OUT) :: pk3(isd:ied, jsd:jed, km+1)
965 REAL,
DIMENSION(is:ie, km) :: dm, dz2, pm2, w2, gm2, cp2
966 REAL,
DIMENSION(is:ie, km+1) :: pem, pe2, peln2, peg, pelng
967 REAL :: gama, rgrav, ptk, peln1
976 ptk = exp(akap*peln1)
984 dm(i, k) = delp(i, j, k)
994 pem(i, k) = pem(i, k-1) + dm(i, k-1)
995 peln2(i, k) = log(pem(i, k))
996 pk3(i, j, k) = exp(akap*peln2(i, k))
1001 pm2(i, k) = dm(i, k)/(peln2(i, k+1)-peln2(i, k))
1002 dm(i, k) = dm(i, k)*rgrav
1003 dz2(i, k) = zh(i, j, k+1) - zh(i, j, k)
1004 w2(i, k) = w(i, j, k)
1007 IF (a_imp .LT. -0.999)
THEN 1009 & pem, w2, dz2, pt(is:ie, j, 1:km), ws(is:ie, j), &
1011 ELSE IF (a_imp .LT. -0.5)
THEN 1012 IF (a_imp .GE. 0.)
THEN 1018 & , w2, dz2, pt(is:ie, j, 1:km), ws(is:ie, j), abs0, &
1020 ELSE IF (a_imp .LE. 0.5)
THEN 1021 CALL rim_2d(ms, dt, is, ie, km,
rdgas, gama, gm2, pe2, dm, pm2, &
1022 & w2, dz2, pt(is:ie, j, 1:km), ws(is:ie, j), .false.)
1023 ELSE IF (a_imp .GT. 0.999)
THEN 1025 & pe2, dm, pm2, pem, w2, dz2, pt(is:ie, j, 1:km), ws(is&
1029 & , dm, pm2, pem, w2, dz2, pt(is:ie, j, 1:km), ws(is:ie&
1030 & , j), a_imp, p_fac, scale_m)
1034 w(i, j, k) = w2(i, k)
1035 delz(i, j, k) = dz2(i, k)
1041 peln(i, k, j) = peln2(i, k)
1042 pk(i, j, k) = pk3(i, j, k)
1043 pe(i, k, j) = pem(i, k)
1050 ppe(i, j, k) = pe2(i, k) + pem(i, k)
1056 ppe(i, j, k) = pe2(i, k)
1063 pk3(i, j, k) = peln2(i, k)
1068 zh(i, j, km+1) = zs(i, j)
1072 zh(i, j, k) = zh(i, j, k+1) - dz2(i, k)
1077 SUBROUTINE imp_diff_w(j, is, ie, js, je, ng, km, cd, delz, ws, w, w3)
1079 INTEGER,
INTENT(IN) :: j, is, ie, js, je, km, ng
1080 REAL,
INTENT(IN) :: cd
1082 REAL,
INTENT(IN) :: delz(is-ng:ie+ng, km)
1084 REAL,
INTENT(IN) :: w(is:ie, km)
1085 REAL,
INTENT(IN) :: ws(is:ie)
1086 REAL,
INTENT(OUT) :: w3(is-ng:ie+ng, js-ng:je+ng, km)
1088 REAL,
DIMENSION(is:ie, km) :: c, gam, dz, wt
1094 dz(i, k) = 0.5*(delz(i, k-1)+delz(i, k))
1099 c(i, k) = -(cd/(dz(i, k+1)*delz(i, k)))
1105 bet(i) = 1. - c(i, 1)
1106 wt(i, 1) = w(i, 1)/bet(i)
1111 gam(i, k) = c(i, k-1)/bet(i)
1112 a = cd/(dz(i, k)*delz(i, k))
1113 bet(i) = 1. + a - c(i, k) + a*gam(i, k)
1114 wt(i, k) = (w(i, k)+a*wt(i, k-1))/bet(i)
1119 gam(i, km) = c(i, km-1)/bet(i)
1120 a = cd/(dz(i, km)*delz(i, km))
1121 wt(i, km) = (w(i, km)+2.*ws(i)*cd/delz(i, km)**2+a*wt(i, km-1))/(&
1122 & 1.+a+(cd+cd)/delz(i, km)**2+a*gam(i, km))
1126 wt(i, k) = wt(i, k) - gam(i, k+1)*wt(i, k+1)
1131 w3(i, j, k) = wt(i, k)
1138 SUBROUTINE rim_2d_tlm(ms, bdt, is, ie, km, rgas, gama, gm2, pe2, &
1139 & pe2_tl, dm2, dm2_tl, pm2, pm2_tl, w2, w2_tl, dz2, dz2_tl, pt2, &
1140 & pt2_tl, ws, ws_tl, c_core)
1142 INTEGER,
INTENT(IN) :: ms, is, ie, km
1143 REAL,
INTENT(IN) :: bdt, gama, rgas
1144 REAL,
DIMENSION(is:ie, km),
INTENT(IN) :: dm2, pm2, gm2
1145 REAL,
DIMENSION(is:ie, km),
INTENT(IN) :: dm2_tl, pm2_tl
1146 LOGICAL,
INTENT(IN) :: c_core
1147 REAL,
INTENT(IN) :: pt2(is:ie, km)
1148 REAL,
INTENT(IN) :: pt2_tl(is:ie, km)
1149 REAL,
INTENT(IN) :: ws(is:ie)
1150 REAL,
INTENT(IN) :: ws_tl(is:ie)
1152 REAL,
INTENT(INOUT) :: dz2(is:ie, km)
1153 REAL,
INTENT(INOUT) :: dz2_tl(is:ie, km)
1154 REAL,
INTENT(INOUT) :: w2(is:ie, km)
1155 REAL,
INTENT(INOUT) :: w2_tl(is:ie, km)
1156 REAL,
INTENT(OUT) :: pe2(is:ie, km+1)
1157 REAL,
INTENT(OUT) :: pe2_tl(is:ie, km+1)
1160 REAL :: ws2_tl(is:ie)
1161 REAL,
DIMENSION(km+1) :: m_bot, m_top, r_bot, r_top, pe1, pbar, wbar
1162 REAL,
DIMENSION(km+1) :: m_bot_tl, m_top_tl, r_bot_tl, r_top_tl, &
1163 & pe1_tl, pbar_tl, wbar_tl
1164 REAL,
DIMENSION(km) :: r_hi, r_lo, dz, wm, dm, dts
1165 REAL,
DIMENSION(km) :: r_hi_tl, r_lo_tl, dz_tl, wm_tl, dm_tl, dts_tl
1166 REAL,
DIMENSION(km) :: pf1, wc, cm, pp, pt1
1167 REAL,
DIMENSION(km) :: pf1_tl, wc_tl, cm_tl, pp_tl, pt1_tl
1168 REAL :: dt, rdt, grg, z_frac, ptmp1, rden, pf, time_left
1169 REAL :: z_frac_tl, ptmp1_tl, rden_tl, pf_tl, time_left_tl
1172 INTEGER :: i, k, n, ke, kt1, ktop
1190 ws2_tl(i) = 2.*ws_tl(i)
1213 dz_tl(k) = dz2_tl(i, k)
1215 dm_tl(k) = dm2_tl(i, k)
1217 wm_tl(k) = w2_tl(i, k)*dm(k) + w2(i, k)*dm_tl(k)
1218 wm(k) = w2(i, k)*dm(k)
1219 pt1_tl(k) = pt2_tl(i, k)
1223 wbar_tl(km+1) = ws_tl(i)
1226 IF (ms .GT. 1 .AND. ms .LT. 8)
THEN 1229 rden_tl = -((rgas*dm_tl(k)*dz(k)-rgas*dm(k)*dz_tl(k))/dz(k)**2&
1231 rden = -(rgas*dm(k)/dz(k))
1232 arg1_tl = gama*(rden_tl*pt1(k)+rden*pt1_tl(k))/(rden*pt1(k))
1233 arg1 = gama*log(rden*pt1(k))
1234 pf1_tl(k) = arg1_tl*exp(arg1)
1236 arg1_tl = (grg*pf1_tl(k)*rden-grg*pf1(k)*rden_tl)/rden**2
1237 arg1 = grg*pf1(k)/rden
1238 IF (arg1 .EQ. 0.0)
THEN 1241 result1_tl = arg1_tl/(2.0*sqrt(arg1))
1243 result1 = sqrt(arg1)
1244 dts_tl(k) = -((dz_tl(k)*result1-dz(k)*result1_tl)/result1**2)
1245 dts(k) = -(dz(k)/result1)
1246 IF (bdt .GT. dts(k))
GOTO 100
1251 222
IF (ks0 .EQ. 1)
THEN 1255 cm_tl(k) = (dm_tl(k)*dts(k)-dm(k)*dts_tl(k))/dts(k)**2
1256 cm(k) = dm(k)/dts(k)
1257 wc_tl(k) = (wm_tl(k)*dts(k)-wm(k)*dts_tl(k))/dts(k)**2
1258 wc(k) = wm(k)/dts(k)
1259 pp_tl(k) = pf1_tl(k) - pm2_tl(i, k)
1260 pp(k) = pf1(k) - pm2(i, k)
1262 wbar_tl(1) = ((wc_tl(1)+pp_tl(1))*cm(1)-(wc(1)+pp(1))*cm_tl(1)&
1264 wbar(1) = (wc(1)+pp(1))/cm(1)
1267 wbar_tl(k) = ((wc_tl(k-1)+wc_tl(k)+pp_tl(k)-pp_tl(k-1))*(cm(&
1268 & k-1)+cm(k))-(wc(k-1)+wc(k)+pp(k)-pp(k-1))*(cm_tl(k-1)+&
1269 & cm_tl(k)))/(cm(k-1)+cm(k))**2
1270 wbar(k) = (wc(k-1)+wc(k)+pp(k)-pp(k-1))/(cm(k-1)+cm(k))
1271 pbar_tl(k) = bdt*(cm_tl(k-1)*wbar(k)+cm(k-1)*wbar_tl(k)-&
1272 & wc_tl(k-1)+pp_tl(k-1))
1273 pbar(k) = bdt*(cm(k-1)*wbar(k)-wc(k-1)+pp(k-1))
1274 pe1_tl(k) = pbar_tl(k)
1277 IF (ks0 .EQ. km)
THEN 1278 pbar_tl(km+1) = bdt*(cm_tl(km)*wbar(km+1)+cm(km)*wbar_tl(km+&
1279 & 1)-wc_tl(km)+pp_tl(km))
1280 pbar(km+1) = bdt*(cm(km)*wbar(km+1)-wc(km)+pp(km))
1283 dz2_tl(i, k) = dz_tl(k) + bdt*(wbar_tl(k+1)-wbar_tl(k))
1284 dz2(i, k) = dz(k) + bdt*(wbar(k+1)-wbar(k))
1288 dz2_tl(i, k) = dz_tl(k) + bdt*(wbar_tl(k+1)-wbar_tl(k))
1289 dz2(i, k) = dz(k) + bdt*(wbar(k+1)-wbar(k))
1290 w2_tl(i, k) = ((wm_tl(k)+pbar_tl(k+1)-pbar_tl(k))*dm(k)-&
1291 & (wm(k)+pbar(k+1)-pbar(k))*dm_tl(k))/dm(k)**2
1292 w2(i, k) = (wm(k)+pbar(k+1)-pbar(k))/dm(k)
1298 pe2_tl(i, k) = rdt*pbar_tl(k)
1299 pe2(i, k) = pbar(k)*rdt
1306 dz2_tl(i, k) = dz_tl(k) + bdt*(wbar_tl(k+1)-wbar_tl(k))
1307 dz2(i, k) = dz(k) + bdt*(wbar(k+1)-wbar(k))
1311 dz2_tl(i, k) = dz_tl(k) + bdt*(wbar_tl(k+1)-wbar_tl(k))
1312 dz2(i, k) = dz(k) + bdt*(wbar(k+1)-wbar(k))
1313 w2_tl(i, k) = ((wm_tl(k)+pbar_tl(k+1)-pbar_tl(k))*dm(k)-&
1314 & (wm(k)+pbar(k+1)-pbar(k))*dm_tl(k))/dm(k)**2
1315 w2(i, k) = (wm(k)+pbar(k+1)-pbar(k))/dm(k)
1318 pbar_tl(ks0) = pbar_tl(ks0)/
REAL(ms)
1319 pbar(ks0) = pbar(ks0)/
REAL(ms)
1328 rden_tl = -((rgas*dm_tl(k)*dz(k)-rgas*dm(k)*dz_tl(k))/dz(k)**2&
1330 rden = -(rgas*dm(k)/dz(k))
1331 arg1_tl = gama*(rden_tl*pt1(k)+rden*pt1_tl(k))/(rden*pt1(k))
1332 arg1 = gama*log(rden*pt1(k))
1333 pf_tl = arg1_tl*exp(arg1)
1335 arg1_tl = (grg*pf_tl*rden-grg*pf*rden_tl)/rden**2
1337 IF (arg1 .EQ. 0.0)
THEN 1340 result1_tl = arg1_tl/(2.0*sqrt(arg1))
1342 result1 = sqrt(arg1)
1343 dts_tl(k) = -((dz_tl(k)*result1-dz(k)*result1_tl)/result1**2)
1344 dts(k) = -(dz(k)/result1)
1345 ptmp1_tl = dts_tl(k)*(pf-pm2(i, k)) + dts(k)*(pf_tl-pm2_tl(i, &
1347 ptmp1 = dts(k)*(pf-pm2(i, k))
1348 r_lo_tl(k) = wm_tl(k) + ptmp1_tl
1349 r_lo(k) = wm(k) + ptmp1
1350 r_hi_tl(k) = wm_tl(k) - ptmp1_tl
1351 r_hi(k) = wm(k) - ptmp1
1355 IF (dt .GT. dts(k))
GOTO 110
1360 333
IF (ktop .GE. ks1)
THEN 1362 z_frac_tl = -(dt*dts_tl(k)/dts(k)**2)
1364 r_bot_tl(k) = z_frac_tl*r_lo(k) + z_frac*r_lo_tl(k)
1365 r_bot(k) = z_frac*r_lo(k)
1366 r_top_tl(k+1) = z_frac_tl*r_hi(k) + z_frac*r_hi_tl(k)
1367 r_top(k+1) = z_frac*r_hi(k)
1368 m_bot_tl(k) = z_frac_tl*dm(k) + z_frac*dm_tl(k)
1369 m_bot(k) = z_frac*dm(k)
1370 m_top_tl(k+1) = m_bot_tl(k)
1371 m_top(k+1) = m_bot(k)
1373 IF (ktop .EQ. km)
GOTO 666
1381 IF (1 .LT. ktop)
THEN 1386 DO 444 ke=km+1,ktop+2,-1
1390 IF (time_left .GT. dts(k))
THEN 1391 time_left_tl = time_left_tl - dts_tl(k)
1392 time_left = time_left - dts(k)
1393 m_top_tl(ke) = m_top_tl(ke) + dm_tl(k)
1394 m_top(ke) = m_top(ke) + dm(k)
1395 r_top_tl(ke) = r_top_tl(ke) + r_hi_tl(k)
1396 r_top(ke) = r_top(ke) + r_hi(k)
1402 120 z_frac_tl = (time_left_tl*dts(k)-time_left*dts_tl(k))/dts(k)**&
1404 z_frac = time_left/dts(k)
1405 m_top_tl(ke) = m_top_tl(ke) + z_frac_tl*dm(k) + z_frac*dm_tl(k&
1407 m_top(ke) = m_top(ke) + z_frac*dm(k)
1408 r_top_tl(ke) = r_top_tl(ke) + z_frac_tl*r_hi(k) + z_frac*&
1410 r_top(ke) = r_top(ke) + z_frac*r_hi(k)
1419 DO 4000 ke=ktop+1,km
1423 IF (time_left .GT. dts(k))
THEN 1424 time_left_tl = time_left_tl - dts_tl(k)
1425 time_left = time_left - dts(k)
1426 m_bot_tl(ke) = m_bot_tl(ke) + dm_tl(k)
1427 m_bot(ke) = m_bot(ke) + dm(k)
1428 r_bot_tl(ke) = r_bot_tl(ke) + r_lo_tl(k)
1429 r_bot(ke) = r_bot(ke) + r_lo(k)
1435 m_surf_tl = m_bot_tl(ke)
1438 IF (time_left .GT. dts(k))
THEN 1439 time_left_tl = time_left_tl - dts_tl(k)
1440 time_left = time_left - dts(k)
1441 m_bot_tl(ke) = m_bot_tl(ke) + dm_tl(k)
1442 m_bot(ke) = m_bot(ke) + dm(k)
1443 r_bot_tl(ke) = r_bot_tl(ke) - r_hi_tl(k)
1444 r_bot(ke) = r_bot(ke) - r_hi(k)
1450 130 z_frac_tl = (time_left_tl*dts(k)-time_left*dts_tl(k))/dts(k)**&
1452 z_frac = time_left/dts(k)
1453 m_bot_tl(ke) = m_bot_tl(ke) + z_frac_tl*dm(k) + z_frac*dm_tl(k&
1455 m_bot(ke) = m_bot(ke) + z_frac*dm(k)
1456 r_bot_tl(ke) = r_bot_tl(ke) - z_frac_tl*r_hi(k) - z_frac*&
1457 & r_hi_tl(k) + (m_bot_tl(ke)-m_surf_tl)*ws2(i) + (m_bot(ke)-&
1459 r_bot(ke) = r_bot(ke) - z_frac*r_hi(k) + (m_bot(ke)-m_surf)*&
1462 140 z_frac_tl = (time_left_tl*dts(k)-time_left*dts_tl(k))/dts(k)**&
1464 z_frac = time_left/dts(k)
1465 m_bot_tl(ke) = m_bot_tl(ke) + z_frac_tl*dm(k) + z_frac*dm_tl(k&
1467 m_bot(ke) = m_bot(ke) + z_frac*dm(k)
1468 r_bot_tl(ke) = r_bot_tl(ke) + z_frac_tl*r_lo(k) + z_frac*&
1470 r_bot(ke) = r_bot(ke) + z_frac*r_lo(k)
1473 666
IF (ks1 .EQ. 1)
THEN 1474 wbar_tl(1) = (r_bot_tl(1)*m_bot(1)-r_bot(1)*m_bot_tl(1))/m_bot&
1476 wbar(1) = r_bot(1)/m_bot(1)
1479 wbar_tl(k) = ((r_bot_tl(k)+r_top_tl(k))*(m_top(k)+m_bot(k))-(&
1480 & r_bot(k)+r_top(k))*(m_top_tl(k)+m_bot_tl(k)))/(m_top(k)+&
1482 wbar(k) = (r_bot(k)+r_top(k))/(m_top(k)+m_bot(k))
1486 pbar_tl(k) = m_top_tl(k)*wbar(k) + m_top(k)*wbar_tl(k) - &
1488 pbar(k) = m_top(k)*wbar(k) - r_top(k)
1489 pe1_tl(k) = pe1_tl(k) + pbar_tl(k)
1490 pe1(k) = pe1(k) + pbar(k)
1495 dz2_tl(i, k) = dz_tl(k) + dt*(wbar_tl(k+1)-wbar_tl(k))
1496 dz2(i, k) = dz(k) + dt*(wbar(k+1)-wbar(k))
1500 dz2_tl(i, k) = dz_tl(k) + dt*(wbar_tl(k+1)-wbar_tl(k))
1501 dz2(i, k) = dz(k) + dt*(wbar(k+1)-wbar(k))
1502 w2_tl(i, k) = ((wm_tl(k)+pbar_tl(k+1)-pbar_tl(k))*dm(k)-(&
1503 & wm(k)+pbar(k+1)-pbar(k))*dm_tl(k))/dm(k)**2
1504 w2(i, k) = (wm(k)+pbar(k+1)-pbar(k))/dm(k)
1509 dz_tl(k) = dz_tl(k) + dt*(wbar_tl(k+1)-wbar_tl(k))
1510 dz(k) = dz(k) + dt*(wbar(k+1)-wbar(k))
1511 wm_tl(k) = wm_tl(k) + pbar_tl(k+1) - pbar_tl(k)
1512 wm(k) = wm(k) + pbar(k+1) - pbar(k)
1519 pe2_tl(i, k) = rdt*pe1_tl(k)
1520 pe2(i, k) = pe1(k)*rdt
1524 SUBROUTINE rim_2d(ms, bdt, is, ie, km, rgas, gama, gm2, pe2, dm2, pm2&
1525 & , w2, dz2, pt2, ws, c_core)
1527 INTEGER,
INTENT(IN) :: ms, is, ie, km
1528 REAL,
INTENT(IN) :: bdt, gama, rgas
1529 REAL,
DIMENSION(is:ie, km),
INTENT(IN) :: dm2, pm2, gm2
1530 LOGICAL,
INTENT(IN) :: c_core
1531 REAL,
INTENT(IN) :: pt2(is:ie, km)
1532 REAL,
INTENT(IN) :: ws(is:ie)
1534 REAL,
INTENT(INOUT) :: dz2(is:ie, km)
1535 REAL,
INTENT(INOUT) :: w2(is:ie, km)
1536 REAL,
INTENT(OUT) :: pe2(is:ie, km+1)
1539 REAL,
DIMENSION(km+1) :: m_bot, m_top, r_bot, r_top, pe1, pbar, wbar
1540 REAL,
DIMENSION(km) :: r_hi, r_lo, dz, wm, dm, dts
1541 REAL,
DIMENSION(km) :: pf1, wc, cm, pp, pt1
1542 REAL :: dt, rdt, grg, z_frac, ptmp1, rden, pf, time_left
1544 INTEGER :: i, k, n, ke, kt1, ktop
1566 wm(k) = w2(i, k)*dm(k)
1572 IF (ms .GT. 1 .AND. ms .LT. 8)
THEN 1575 rden = -(rgas*dm(k)/dz(k))
1576 arg1 = gama*log(rden*pt1(k))
1578 arg1 = grg*pf1(k)/rden
1579 result1 = sqrt(arg1)
1580 dts(k) = -(dz(k)/result1)
1581 IF (bdt .GT. dts(k))
THEN 1587 222
IF (ks0 .NE. 1)
THEN 1589 cm(k) = dm(k)/dts(k)
1590 wc(k) = wm(k)/dts(k)
1591 pp(k) = pf1(k) - pm2(i, k)
1593 wbar(1) = (wc(1)+pp(1))/cm(1)
1595 wbar(k) = (wc(k-1)+wc(k)+pp(k)-pp(k-1))/(cm(k-1)+cm(k))
1596 pbar(k) = bdt*(cm(k-1)*wbar(k)-wc(k-1)+pp(k-1))
1599 IF (ks0 .EQ. km)
THEN 1600 pbar(km+1) = bdt*(cm(km)*wbar(km+1)-wc(km)+pp(km))
1603 dz2(i, k) = dz(k) + bdt*(wbar(k+1)-wbar(k))
1607 dz2(i, k) = dz(k) + bdt*(wbar(k+1)-wbar(k))
1608 w2(i, k) = (wm(k)+pbar(k+1)-pbar(k))/dm(k)
1613 pe2(i, k) = pbar(k)*rdt
1620 dz2(i, k) = dz(k) + bdt*(wbar(k+1)-wbar(k))
1624 dz2(i, k) = dz(k) + bdt*(wbar(k+1)-wbar(k))
1625 w2(i, k) = (wm(k)+pbar(k+1)-pbar(k))/dm(k)
1628 pbar(ks0) = pbar(ks0)/
REAL(ms)
1635 rden = -(rgas*dm(k)/dz(k))
1636 arg1 = gama*log(rden*pt1(k))
1639 result1 = sqrt(arg1)
1640 dts(k) = -(dz(k)/result1)
1641 ptmp1 = dts(k)*(pf-pm2(i, k))
1642 r_lo(k) = wm(k) + ptmp1
1643 r_hi(k) = wm(k) - ptmp1
1647 IF (dt .GT. dts(k))
THEN 1653 333
IF (ktop .GE. ks1)
THEN 1656 r_bot(k) = z_frac*r_lo(k)
1657 r_top(k+1) = z_frac*r_hi(k)
1658 m_bot(k) = z_frac*dm(k)
1659 m_top(k+1) = m_bot(k)
1661 IF (ktop .EQ. km)
GOTO 666
1667 IF (1 .LT. ktop)
THEN 1672 DO ke=km+1,ktop+2,-1
1675 IF (time_left .GT. dts(k))
THEN 1676 time_left = time_left - dts(k)
1677 m_top(ke) = m_top(ke) + dm(k)
1678 r_top(ke) = r_top(ke) + r_hi(k)
1680 z_frac = time_left/dts(k)
1681 m_top(ke) = m_top(ke) + z_frac*dm(k)
1682 r_top(ke) = r_top(ke) + z_frac*r_hi(k)
1696 IF (time_left .GT. dts(k))
THEN 1697 time_left = time_left - dts(k)
1698 m_bot(ke) = m_bot(ke) + dm(k)
1699 r_bot(ke) = r_bot(ke) + r_lo(k)
1701 z_frac = time_left/dts(k)
1702 m_bot(ke) = m_bot(ke) + z_frac*dm(k)
1703 r_bot(ke) = r_bot(ke) + z_frac*r_lo(k)
1710 IF (time_left .GT. dts(k))
THEN 1711 time_left = time_left - dts(k)
1712 m_bot(ke) = m_bot(ke) + dm(k)
1713 r_bot(ke) = r_bot(ke) - r_hi(k)
1715 z_frac = time_left/dts(k)
1716 m_bot(ke) = m_bot(ke) + z_frac*dm(k)
1717 r_bot(ke) = r_bot(ke) - z_frac*r_hi(k) + (m_bot(ke)-m_surf&
1725 666
IF (ks1 .EQ. 1) wbar(1) = r_bot(1)/m_bot(1)
1727 wbar(k) = (r_bot(k)+r_top(k))/(m_top(k)+m_bot(k))
1731 pbar(k) = m_top(k)*wbar(k) - r_top(k)
1732 pe1(k) = pe1(k) + pbar(k)
1737 dz2(i, k) = dz(k) + dt*(wbar(k+1)-wbar(k))
1741 dz2(i, k) = dz(k) + dt*(wbar(k+1)-wbar(k))
1742 w2(i, k) = (wm(k)+pbar(k+1)-pbar(k))/dm(k)
1747 dz(k) = dz(k) + dt*(wbar(k+1)-wbar(k))
1748 wm(k) = wm(k) + pbar(k+1) - pbar(k)
1754 pe2(i, k) = pe1(k)*rdt
1763 & pe2_tl, dm, dm_tl, pem, pem_tl, w2, w2_tl, dz2, dz2_tl, pt2, pt2_tl&
1764 & , ws, ws_tl, alpha, p_fac, scale_m)
1766 INTEGER,
INTENT(IN) :: is, ie, km
1767 REAL,
INTENT(IN) :: dt, rgas, gama, kappa, alpha, p_fac, scale_m
1768 REAL,
DIMENSION(is:ie, km),
INTENT(IN) :: dm, pt2
1769 REAL,
DIMENSION(is:ie, km),
INTENT(IN) :: dm_tl, pt2_tl
1770 REAL,
INTENT(IN) :: ws(is:ie)
1771 REAL,
INTENT(IN) :: ws_tl(is:ie)
1772 REAL,
DIMENSION(is:ie, km+1),
INTENT(IN) :: pem
1773 REAL,
DIMENSION(is:ie, km+1),
INTENT(IN) :: pem_tl
1774 REAL,
INTENT(OUT) :: pe2(is:ie, km+1)
1775 REAL,
INTENT(OUT) :: pe2_tl(is:ie, km+1)
1776 REAL,
DIMENSION(is:ie, km),
INTENT(INOUT) :: dz2, w2
1777 REAL,
DIMENSION(is:ie, km),
INTENT(INOUT) :: dz2_tl, w2_tl
1779 REAL,
DIMENSION(is:ie, km) :: aa, bb, dd, w1, wk, g_rat, gam
1780 REAL,
DIMENSION(is:ie, km) :: aa_tl, bb_tl, dd_tl, w1_tl, wk_tl, &
1782 REAL,
DIMENSION(is:ie, km+1) :: pp
1783 REAL,
DIMENSION(is:ie, km+1) :: pp_tl
1784 REAL,
DIMENSION(is:ie) :: p1, wk1, bet
1785 REAL,
DIMENSION(is:ie) :: p1_tl, wk1_tl, bet_tl
1786 REAL :: beta, t2, t1g, rdt, ra, capa1, r2g, r6g
1798 t1g = gama*2.*(alpha*dt)**2
1807 w1_tl(i, k) = w2_tl(i, k)
1810 arg1_tl = -(rgas*((dm_tl(i, k)*dz2(i, k)-dm(i, k)*dz2_tl(i, k))*&
1811 & pt2(i, k)/dz2(i, k)**2+dm(i, k)*pt2_tl(i, k)/dz2(i, k)))
1812 arg1 = -(dm(i, k)/dz2(i, k)*rgas*pt2(i, k))
1813 arg2_tl = gama*arg1_tl/arg1
1814 arg2 = gama*log(arg1)
1815 aa_tl(i, k) = arg2_tl*exp(arg2)
1816 aa(i, k) = exp(arg2)
1825 g_rat_tl(i, k) = (dm_tl(i, k)*dm(i, k+1)-dm(i, k)*dm_tl(i, k+1))&
1827 g_rat(i, k) = dm(i, k)/dm(i, k+1)
1828 bb_tl(i, k) = 2.*g_rat_tl(i, k)
1829 bb(i, k) = 2.*(1.+g_rat(i, k))
1830 dd_tl(i, k) = 3.*(aa_tl(i, k)+g_rat_tl(i, k)*aa(i, k+1)+g_rat(i&
1831 & , k)*aa_tl(i, k+1))
1832 dd(i, k) = 3.*(aa(i, k)+g_rat(i, k)*aa(i, k+1))
1839 bet_tl(i) = bb_tl(i, 1)
1841 pe2_tl(i, 1) = pem_tl(i, 1)
1842 pe2(i, 1) = pem(i, 1)
1843 pe2_tl(i, 2) = ((dd_tl(i, 1)-pem_tl(i, 1))*bet(i)-(dd(i, 1)-pem(i&
1844 & , 1))*bet_tl(i))/bet(i)**2
1845 pe2(i, 2) = (dd(i, 1)-pem(i, 1))/bet(i)
1849 dd_tl(i, km) = 3.*aa_tl(i, km) + r2g*dm_tl(i, km)
1850 dd(i, km) = 3.*aa(i, km) + r2g*dm(i, km)
1855 gam_tl(i, k) = (g_rat_tl(i, k-1)*bet(i)-g_rat(i, k-1)*bet_tl(i))&
1857 gam(i, k) = g_rat(i, k-1)/bet(i)
1858 bet_tl(i) = bb_tl(i, k) - gam_tl(i, k)
1859 bet(i) = bb(i, k) - gam(i, k)
1860 pe2_tl(i, k+1) = ((dd_tl(i, k)-pe2_tl(i, k))*bet(i)-(dd(i, k)-&
1861 & pe2(i, k))*bet_tl(i))/bet(i)**2
1862 pe2(i, k+1) = (dd(i, k)-pe2(i, k))/bet(i)
1867 pe2_tl(i, k) = pe2_tl(i, k) - gam_tl(i, k)*pe2(i, k+1) - gam(i, &
1869 pe2(i, k) = pe2(i, k) - gam(i, k)*pe2(i, k+1)
1877 pp_tl(i, k) = pe2_tl(i, k) - pem_tl(i, k)
1878 pp(i, k) = pe2(i, k) - pem(i, k)
1884 aa_tl(i, k) = t1g*pe2_tl(i, k)/(dz2(i, k-1)+dz2(i, k)) - t1g*(&
1885 & dz2_tl(i, k-1)+dz2_tl(i, k))*pe2(i, k)/(dz2(i, k-1)+dz2(i, k))&
1887 aa(i, k) = t1g/(dz2(i, k-1)+dz2(i, k))*pe2(i, k)
1888 wk_tl(i, k) = t2*(aa_tl(i, k)*(w1(i, k-1)-w1(i, k))+aa(i, k)*(&
1889 & w1_tl(i, k-1)-w1_tl(i, k)))
1890 wk(i, k) = t2*aa(i, k)*(w1(i, k-1)-w1(i, k))
1891 aa_tl(i, k) = aa_tl(i, k) - scale_m*dm_tl(i, 1)
1892 aa(i, k) = aa(i, k) - scale_m*dm(i, 1)
1896 bet_tl(i) = dm_tl(i, 1) - aa_tl(i, 2)
1897 bet(i) = dm(i, 1) - aa(i, 2)
1898 w2_tl(i, 1) = ((dm_tl(i, 1)*w1(i, 1)+dm(i, 1)*w1_tl(i, 1)+dt*pp_tl&
1899 & (i, 2)+wk_tl(i, 2))*bet(i)-(dm(i, 1)*w1(i, 1)+dt*pp(i, 2)+wk(i, &
1900 & 2))*bet_tl(i))/bet(i)**2
1901 w2(i, 1) = (dm(i, 1)*w1(i, 1)+dt*pp(i, 2)+wk(i, 2))/bet(i)
1905 gam_tl(i, k) = (aa_tl(i, k)*bet(i)-aa(i, k)*bet_tl(i))/bet(i)**2
1906 gam(i, k) = aa(i, k)/bet(i)
1907 bet_tl(i) = dm_tl(i, k) - aa_tl(i, k) - aa_tl(i, k+1) - aa_tl(i&
1908 & , k)*gam(i, k) - aa(i, k)*gam_tl(i, k)
1909 bet(i) = dm(i, k) - (aa(i, k)+aa(i, k+1)+aa(i, k)*gam(i, k))
1910 w2_tl(i, k) = ((dm_tl(i, k)*w1(i, k)+dm(i, k)*w1_tl(i, k)+dt*(&
1911 & pp_tl(i, k+1)-pp_tl(i, k))+wk_tl(i, k+1)-wk_tl(i, k)-aa_tl(i, &
1912 & k)*w2(i, k-1)-aa(i, k)*w2_tl(i, k-1))*bet(i)-(dm(i, k)*w1(i, k&
1913 & )+dt*(pp(i, k+1)-pp(i, k))+wk(i, k+1)-wk(i, k)-aa(i, k)*w2(i, &
1914 & k-1))*bet_tl(i))/bet(i)**2
1915 w2(i, k) = (dm(i, k)*w1(i, k)+dt*(pp(i, k+1)-pp(i, k))+wk(i, k+1&
1916 & )-wk(i, k)-aa(i, k)*w2(i, k-1))/bet(i)
1921 wk1_tl(i) = t1g*pe2_tl(i, km+1)/dz2(i, km) - t1g*dz2_tl(i, km)*pe2&
1922 & (i, km+1)/dz2(i, km)**2
1923 wk1(i) = t1g/dz2(i, km)*pe2(i, km+1)
1924 gam_tl(i, km) = (aa_tl(i, km)*bet(i)-aa(i, km)*bet_tl(i))/bet(i)**&
1926 gam(i, km) = aa(i, km)/bet(i)
1927 bet_tl(i) = dm_tl(i, km) - aa_tl(i, km) - wk1_tl(i) - aa_tl(i, km)&
1928 & *gam(i, km) - aa(i, km)*gam_tl(i, km)
1929 bet(i) = dm(i, km) - (aa(i, km)+wk1(i)+aa(i, km)*gam(i, km))
1930 w2_tl(i, km) = ((dm_tl(i, km)*w1(i, km)+dm(i, km)*w1_tl(i, km)+dt*&
1931 & (pp_tl(i, km+1)-pp_tl(i, km))-wk_tl(i, km)+wk1_tl(i)*(t2*w1(i, &
1932 & km)-ra*ws(i))+wk1(i)*(t2*w1_tl(i, km)-ra*ws_tl(i))-aa_tl(i, km)*&
1933 & w2(i, km-1)-aa(i, km)*w2_tl(i, km-1))*bet(i)-(dm(i, km)*w1(i, km&
1934 & )+dt*(pp(i, km+1)-pp(i, km))-wk(i, km)+wk1(i)*(t2*w1(i, km)-ra*&
1935 & ws(i))-aa(i, km)*w2(i, km-1))*bet_tl(i))/bet(i)**2
1936 w2(i, km) = (dm(i, km)*w1(i, km)+dt*(pp(i, km+1)-pp(i, km))-wk(i, &
1937 & km)+wk1(i)*(t2*w1(i, km)-ra*ws(i))-aa(i, km)*w2(i, km-1))/bet(i)
1941 w2_tl(i, k) = w2_tl(i, k) - gam_tl(i, k+1)*w2(i, k+1) - gam(i, k&
1943 w2(i, k) = w2(i, k) - gam(i, k+1)*w2(i, k+1)
1953 pe2_tl(i, k+1) = pe2_tl(i, k) + ra*(rdt*(dm_tl(i, k)*(w2(i, k)-&
1954 & w1(i, k))+dm(i, k)*(w2_tl(i, k)-w1_tl(i, k)))-beta*(pp_tl(i, k&
1956 pe2(i, k+1) = pe2(i, k) + (dm(i, k)*(w2(i, k)-w1(i, k))*rdt-beta&
1957 & *(pp(i, k+1)-pp(i, k)))*ra
1962 pe2_tl(i, 1) = pem_tl(i, 1)
1963 pe2(i, 1) = pem(i, 1)
1967 IF (p_fac*pem(i, k) .LT. pe2(i, k) + pem(i, k))
THEN 1968 pe2_tl(i, k) = pe2_tl(i, k) + pem_tl(i, k)
1969 pe2(i, k) = pe2(i, k) + pem(i, k)
1971 pe2_tl(i, k) = p_fac*pem_tl(i, k)
1972 pe2(i, k) = p_fac*pem(i, k)
1979 p1_tl(i) =
r3*(pe2_tl(i, km)+2.*pe2_tl(i, km+1)) - r6g*dm_tl(i, km&
1981 p1(i) = (pe2(i, km)+2.*pe2(i, km+1))*
r3 - r6g*dm(i, km)
1982 arg1_tl = capa1*p1_tl(i)/p1(i)
1983 arg1 = capa1*log(p1(i))
1984 dz2_tl(i, km) = -(rgas*((dm_tl(i, km)*pt2(i, km)+dm(i, km)*pt2_tl(&
1985 & i, km))*exp(arg1)+dm(i, km)*pt2(i, km)*arg1_tl*exp(arg1)))
1986 dz2(i, km) = -(dm(i, km)*rgas*pt2(i, km)*exp(arg1))
1990 p1_tl(i) =
r3*(pe2_tl(i, k)+bb_tl(i, k)*pe2(i, k+1)+bb(i, k)*&
1991 & pe2_tl(i, k+1)+g_rat_tl(i, k)*pe2(i, k+2)+g_rat(i, k)*pe2_tl(i&
1992 & , k+2)) - g_rat_tl(i, k)*p1(i) - g_rat(i, k)*p1_tl(i)
1993 p1(i) = (pe2(i, k)+bb(i, k)*pe2(i, k+1)+g_rat(i, k)*pe2(i, k+2))&
1994 & *
r3 - g_rat(i, k)*p1(i)
1995 arg1_tl = capa1*p1_tl(i)/p1(i)
1996 arg1 = capa1*log(p1(i))
1997 dz2_tl(i, k) = -(rgas*((dm_tl(i, k)*pt2(i, k)+dm(i, k)*pt2_tl(i&
1998 & , k))*exp(arg1)+dm(i, k)*pt2(i, k)*arg1_tl*exp(arg1)))
1999 dz2(i, k) = -(dm(i, k)*rgas*pt2(i, k)*exp(arg1))
2004 pe2_tl(i, k) = pe2_tl(i, k) - pem_tl(i, k)
2005 pe2(i, k) = pe2(i, k) - pem(i, k)
2006 pe2_tl(i, k) = pe2_tl(i, k) + beta*(pp_tl(i, k)-pe2_tl(i, k))
2007 pe2(i, k) = pe2(i, k) + beta*(pp(i, k)-pe2(i, k))
2011 SUBROUTINE sim3_solver(dt, is, ie, km, rgas, gama, kappa, pe2, dm, pem&
2012 & , w2, dz2, pt2, ws, alpha, p_fac, scale_m)
2014 INTEGER,
INTENT(IN) :: is, ie, km
2015 REAL,
INTENT(IN) :: dt, rgas, gama, kappa, alpha, p_fac, scale_m
2016 REAL,
DIMENSION(is:ie, km),
INTENT(IN) :: dm, pt2
2017 REAL,
INTENT(IN) :: ws(is:ie)
2018 REAL,
DIMENSION(is:ie, km+1),
INTENT(IN) :: pem
2019 REAL,
INTENT(OUT) :: pe2(is:ie, km+1)
2020 REAL,
DIMENSION(is:ie, km),
INTENT(INOUT) :: dz2, w2
2022 REAL,
DIMENSION(is:ie, km) :: aa, bb, dd, w1, wk, g_rat, gam
2023 REAL,
DIMENSION(is:ie, km+1) :: pp
2024 REAL,
DIMENSION(is:ie) :: p1, wk1, bet
2025 REAL :: beta, t2, t1g, rdt, ra, capa1, r2g, r6g
2035 t1g = gama*2.*(alpha*dt)**2
2044 arg1 = -(dm(i, k)/dz2(i, k)*rgas*pt2(i, k))
2045 arg2 = gama*log(arg1)
2046 aa(i, k) = exp(arg2)
2052 g_rat(i, k) = dm(i, k)/dm(i, k+1)
2053 bb(i, k) = 2.*(1.+g_rat(i, k))
2054 dd(i, k) = 3.*(aa(i, k)+g_rat(i, k)*aa(i, k+1))
2061 pe2(i, 1) = pem(i, 1)
2062 pe2(i, 2) = (dd(i, 1)-pem(i, 1))/bet(i)
2065 dd(i, km) = 3.*aa(i, km) + r2g*dm(i, km)
2069 gam(i, k) = g_rat(i, k-1)/bet(i)
2070 bet(i) = bb(i, k) - gam(i, k)
2071 pe2(i, k+1) = (dd(i, k)-pe2(i, k))/bet(i)
2076 pe2(i, k) = pe2(i, k) - gam(i, k)*pe2(i, k+1)
2083 pp(i, k) = pe2(i, k) - pem(i, k)
2088 aa(i, k) = t1g/(dz2(i, k-1)+dz2(i, k))*pe2(i, k)
2089 wk(i, k) = t2*aa(i, k)*(w1(i, k-1)-w1(i, k))
2090 aa(i, k) = aa(i, k) - scale_m*dm(i, 1)
2094 bet(i) = dm(i, 1) - aa(i, 2)
2095 w2(i, 1) = (dm(i, 1)*w1(i, 1)+dt*pp(i, 2)+wk(i, 2))/bet(i)
2099 gam(i, k) = aa(i, k)/bet(i)
2100 bet(i) = dm(i, k) - (aa(i, k)+aa(i, k+1)+aa(i, k)*gam(i, k))
2101 w2(i, k) = (dm(i, k)*w1(i, k)+dt*(pp(i, k+1)-pp(i, k))+wk(i, k+1&
2102 & )-wk(i, k)-aa(i, k)*w2(i, k-1))/bet(i)
2106 wk1(i) = t1g/dz2(i, km)*pe2(i, km+1)
2107 gam(i, km) = aa(i, km)/bet(i)
2108 bet(i) = dm(i, km) - (aa(i, km)+wk1(i)+aa(i, km)*gam(i, km))
2109 w2(i, km) = (dm(i, km)*w1(i, km)+dt*(pp(i, km+1)-pp(i, km))-wk(i, &
2110 & km)+wk1(i)*(t2*w1(i, km)-ra*ws(i))-aa(i, km)*w2(i, km-1))/bet(i)
2114 w2(i, k) = w2(i, k) - gam(i, k+1)*w2(i, k+1)
2123 pe2(i, k+1) = pe2(i, k) + (dm(i, k)*(w2(i, k)-w1(i, k))*rdt-beta&
2124 & *(pp(i, k+1)-pp(i, k)))*ra
2129 pe2(i, 1) = pem(i, 1)
2133 IF (p_fac*pem(i, k) .LT. pe2(i, k) + pem(i, k))
THEN 2134 pe2(i, k) = pe2(i, k) + pem(i, k)
2136 pe2(i, k) = p_fac*pem(i, k)
2142 p1(i) = (pe2(i, km)+2.*pe2(i, km+1))*
r3 - r6g*dm(i, km)
2143 arg1 = capa1*log(p1(i))
2144 dz2(i, km) = -(dm(i, km)*rgas*pt2(i, km)*exp(arg1))
2148 p1(i) = (pe2(i, k)+bb(i, k)*pe2(i, k+1)+g_rat(i, k)*pe2(i, k+2))&
2149 & *
r3 - g_rat(i, k)*p1(i)
2150 arg1 = capa1*log(p1(i))
2151 dz2(i, k) = -(dm(i, k)*rgas*pt2(i, k)*exp(arg1))
2156 pe2(i, k) = pe2(i, k) - pem(i, k)
2157 pe2(i, k) = pe2(i, k) + beta*(pp(i, k)-pe2(i, k))
2165 & pe2_tl, dm, dm_tl, pem, pem_tl, w2, w2_tl, dz2, dz2_tl, pt2, pt2_tl&
2166 & , ws, ws_tl, p_fac, scale_m)
2169 INTEGER,
INTENT(IN) :: is, ie, km
2170 REAL,
INTENT(IN) :: dt, rgas, gama, kappa, p_fac, scale_m
2171 REAL,
DIMENSION(is:ie, km),
INTENT(IN) :: dm, pt2
2172 REAL,
DIMENSION(is:ie, km),
INTENT(IN) :: dm_tl, pt2_tl
2173 REAL,
INTENT(IN) :: ws(is:ie)
2174 REAL,
INTENT(IN) :: ws_tl(is:ie)
2175 REAL,
INTENT(IN) :: pem(is:ie, km+1)
2176 REAL,
INTENT(IN) :: pem_tl(is:ie, km+1)
2177 REAL,
INTENT(OUT) :: pe2(is:ie, km+1)
2178 REAL,
INTENT(OUT) :: pe2_tl(is:ie, km+1)
2179 REAL,
DIMENSION(is:ie, km),
INTENT(INOUT) :: dz2, w2
2180 REAL,
DIMENSION(is:ie, km),
INTENT(INOUT) :: dz2_tl, w2_tl
2182 REAL,
DIMENSION(is:ie, km) :: aa, bb, dd, w1, g_rat, gam
2183 REAL,
DIMENSION(is:ie, km) :: aa_tl, bb_tl, dd_tl, w1_tl, g_rat_tl, &
2185 REAL,
DIMENSION(is:ie, km+1) :: pp
2186 REAL,
DIMENSION(is:ie, km+1) :: pp_tl
2187 REAL,
DIMENSION(is:ie) :: p1, wk1, bet
2188 REAL,
DIMENSION(is:ie) :: p1_tl, wk1_tl, bet_tl
2189 REAL :: t1g, rdt, capa1, r2g, r6g
2207 w1_tl(i, k) = w2_tl(i, k)
2210 arg1_tl = -(rgas*((dm_tl(i, k)*dz2(i, k)-dm(i, k)*dz2_tl(i, k))*&
2211 & pt2(i, k)/dz2(i, k)**2+dm(i, k)*pt2_tl(i, k)/dz2(i, k)))
2212 arg1 = -(dm(i, k)/dz2(i, k)*rgas*pt2(i, k))
2213 arg2_tl = gama*arg1_tl/arg1
2214 arg2 = gama*log(arg1)
2215 aa_tl(i, k) = arg2_tl*exp(arg2)
2216 aa(i, k) = exp(arg2)
2225 g_rat_tl(i, k) = (dm_tl(i, k)*dm(i, k+1)-dm(i, k)*dm_tl(i, k+1))&
2227 g_rat(i, k) = dm(i, k)/dm(i, k+1)
2228 bb_tl(i, k) = 2.*g_rat_tl(i, k)
2229 bb(i, k) = 2.*(1.+g_rat(i, k))
2230 dd_tl(i, k) = 3.*(aa_tl(i, k)+g_rat_tl(i, k)*aa(i, k+1)+g_rat(i&
2231 & , k)*aa_tl(i, k+1))
2232 dd(i, k) = 3.*(aa(i, k)+g_rat(i, k)*aa(i, k+1))
2239 bet_tl(i) = bb_tl(i, 1)
2241 pe2_tl(i, 1) = pem_tl(i, 1)
2242 pe2(i, 1) = pem(i, 1)
2243 pe2_tl(i, 2) = ((dd_tl(i, 1)-pem_tl(i, 1))*bet(i)-(dd(i, 1)-pem(i&
2244 & , 1))*bet_tl(i))/bet(i)**2
2245 pe2(i, 2) = (dd(i, 1)-pem(i, 1))/bet(i)
2249 dd_tl(i, km) = 3.*aa_tl(i, km) + r2g*dm_tl(i, km)
2250 dd(i, km) = 3.*aa(i, km) + r2g*dm(i, km)
2255 gam_tl(i, k) = (g_rat_tl(i, k-1)*bet(i)-g_rat(i, k-1)*bet_tl(i))&
2257 gam(i, k) = g_rat(i, k-1)/bet(i)
2258 bet_tl(i) = bb_tl(i, k) - gam_tl(i, k)
2259 bet(i) = bb(i, k) - gam(i, k)
2260 pe2_tl(i, k+1) = ((dd_tl(i, k)-pe2_tl(i, k))*bet(i)-(dd(i, k)-&
2261 & pe2(i, k))*bet_tl(i))/bet(i)**2
2262 pe2(i, k+1) = (dd(i, k)-pe2(i, k))/bet(i)
2267 pe2_tl(i, k) = pe2_tl(i, k) - gam_tl(i, k)*pe2(i, k+1) - gam(i, &
2269 pe2(i, k) = pe2(i, k) - gam(i, k)*pe2(i, k+1)
2277 pp_tl(i, k) = pe2_tl(i, k) - pem_tl(i, k)
2278 pp(i, k) = pe2(i, k) - pem(i, k)
2283 aa_tl(i, k) = t1g*pe2_tl(i, k)/(dz2(i, k-1)+dz2(i, k)) - t1g*(&
2284 & dz2_tl(i, k-1)+dz2_tl(i, k))*pe2(i, k)/(dz2(i, k-1)+dz2(i, k))&
2285 & **2 - scale_m*dm_tl(i, 1)
2286 aa(i, k) = t1g/(dz2(i, k-1)+dz2(i, k))*pe2(i, k) - scale_m*dm(i&
2291 bet_tl(i) = dm_tl(i, 1) - aa_tl(i, 2)
2292 bet(i) = dm(i, 1) - aa(i, 2)
2293 w2_tl(i, 1) = ((dm_tl(i, 1)*w1(i, 1)+dm(i, 1)*w1_tl(i, 1)+dt*pp_tl&
2294 & (i, 2))*bet(i)-(dm(i, 1)*w1(i, 1)+dt*pp(i, 2))*bet_tl(i))/bet(i)&
2296 w2(i, 1) = (dm(i, 1)*w1(i, 1)+dt*pp(i, 2))/bet(i)
2300 gam_tl(i, k) = (aa_tl(i, k)*bet(i)-aa(i, k)*bet_tl(i))/bet(i)**2
2301 gam(i, k) = aa(i, k)/bet(i)
2302 bet_tl(i) = dm_tl(i, k) - aa_tl(i, k) - aa_tl(i, k+1) - aa_tl(i&
2303 & , k)*gam(i, k) - aa(i, k)*gam_tl(i, k)
2304 bet(i) = dm(i, k) - (aa(i, k)+aa(i, k+1)+aa(i, k)*gam(i, k))
2305 w2_tl(i, k) = ((dm_tl(i, k)*w1(i, k)+dm(i, k)*w1_tl(i, k)+dt*(&
2306 & pp_tl(i, k+1)-pp_tl(i, k))-aa_tl(i, k)*w2(i, k-1)-aa(i, k)*&
2307 & w2_tl(i, k-1))*bet(i)-(dm(i, k)*w1(i, k)+dt*(pp(i, k+1)-pp(i, &
2308 & k))-aa(i, k)*w2(i, k-1))*bet_tl(i))/bet(i)**2
2309 w2(i, k) = (dm(i, k)*w1(i, k)+dt*(pp(i, k+1)-pp(i, k))-aa(i, k)*&
2310 & w2(i, k-1))/bet(i)
2315 wk1_tl(i) = t1g*pe2_tl(i, km+1)/dz2(i, km) - t1g*dz2_tl(i, km)*pe2&
2316 & (i, km+1)/dz2(i, km)**2
2317 wk1(i) = t1g/dz2(i, km)*pe2(i, km+1)
2318 gam_tl(i, km) = (aa_tl(i, km)*bet(i)-aa(i, km)*bet_tl(i))/bet(i)**&
2320 gam(i, km) = aa(i, km)/bet(i)
2321 bet_tl(i) = dm_tl(i, km) - aa_tl(i, km) - wk1_tl(i) - aa_tl(i, km)&
2322 & *gam(i, km) - aa(i, km)*gam_tl(i, km)
2323 bet(i) = dm(i, km) - (aa(i, km)+wk1(i)+aa(i, km)*gam(i, km))
2324 w2_tl(i, km) = ((dm_tl(i, km)*w1(i, km)+dm(i, km)*w1_tl(i, km)+dt*&
2325 & (pp_tl(i, km+1)-pp_tl(i, km))-wk1_tl(i)*ws(i)-wk1(i)*ws_tl(i)-&
2326 & aa_tl(i, km)*w2(i, km-1)-aa(i, km)*w2_tl(i, km-1))*bet(i)-(dm(i&
2327 & , km)*w1(i, km)+dt*(pp(i, km+1)-pp(i, km))-wk1(i)*ws(i)-aa(i, km&
2328 & )*w2(i, km-1))*bet_tl(i))/bet(i)**2
2329 w2(i, km) = (dm(i, km)*w1(i, km)+dt*(pp(i, km+1)-pp(i, km))-wk1(i)&
2330 & *ws(i)-aa(i, km)*w2(i, km-1))/bet(i)
2334 w2_tl(i, k) = w2_tl(i, k) - gam_tl(i, k+1)*w2(i, k+1) - gam(i, k&
2336 w2(i, k) = w2(i, k) - gam(i, k+1)*w2(i, k+1)
2346 pe2_tl(i, k+1) = pe2_tl(i, k) + rdt*(dm_tl(i, k)*(w2(i, k)-w1(i&
2347 & , k))+dm(i, k)*(w2_tl(i, k)-w1_tl(i, k)))
2348 pe2(i, k+1) = pe2(i, k) + dm(i, k)*(w2(i, k)-w1(i, k))*rdt
2353 pe2_tl(i, 1) = pem_tl(i, 1)
2354 pe2(i, 1) = pem(i, 1)
2358 IF (p_fac*pem(i, k) .LT. pe2(i, k) + pem(i, k))
THEN 2359 pe2_tl(i, k) = pe2_tl(i, k) + pem_tl(i, k)
2360 pe2(i, k) = pe2(i, k) + pem(i, k)
2362 pe2_tl(i, k) = p_fac*pem_tl(i, k)
2363 pe2(i, k) = p_fac*pem(i, k)
2370 p1_tl(i) =
r3*(pe2_tl(i, km)+2.*pe2_tl(i, km+1)) - r6g*dm_tl(i, km&
2372 p1(i) = (pe2(i, km)+2.*pe2(i, km+1))*
r3 - r6g*dm(i, km)
2373 arg1_tl = capa1*p1_tl(i)/p1(i)
2374 arg1 = capa1*log(p1(i))
2375 dz2_tl(i, km) = -(rgas*((dm_tl(i, km)*pt2(i, km)+dm(i, km)*pt2_tl(&
2376 & i, km))*exp(arg1)+dm(i, km)*pt2(i, km)*arg1_tl*exp(arg1)))
2377 dz2(i, km) = -(dm(i, km)*rgas*pt2(i, km)*exp(arg1))
2381 p1_tl(i) =
r3*(pe2_tl(i, k)+bb_tl(i, k)*pe2(i, k+1)+bb(i, k)*&
2382 & pe2_tl(i, k+1)+g_rat_tl(i, k)*pe2(i, k+2)+g_rat(i, k)*pe2_tl(i&
2383 & , k+2)) - g_rat_tl(i, k)*p1(i) - g_rat(i, k)*p1_tl(i)
2384 p1(i) = (pe2(i, k)+bb(i, k)*pe2(i, k+1)+g_rat(i, k)*pe2(i, k+2))&
2385 & *
r3 - g_rat(i, k)*p1(i)
2386 arg1_tl = capa1*p1_tl(i)/p1(i)
2387 arg1 = capa1*log(p1(i))
2388 dz2_tl(i, k) = -(rgas*((dm_tl(i, k)*pt2(i, k)+dm(i, k)*pt2_tl(i&
2389 & , k))*exp(arg1)+dm(i, k)*pt2(i, k)*arg1_tl*exp(arg1)))
2390 dz2(i, k) = -(dm(i, k)*rgas*pt2(i, k)*exp(arg1))
2395 pe2_tl(i, k) = pe2_tl(i, k) - pem_tl(i, k)
2396 pe2(i, k) = pe2(i, k) - pem(i, k)
2400 SUBROUTINE sim3p0_solver(dt, is, ie, km, rgas, gama, kappa, pe2, dm, &
2401 & pem, w2, dz2, pt2, ws, p_fac, scale_m)
2404 INTEGER,
INTENT(IN) :: is, ie, km
2405 REAL,
INTENT(IN) :: dt, rgas, gama, kappa, p_fac, scale_m
2406 REAL,
DIMENSION(is:ie, km),
INTENT(IN) :: dm, pt2
2407 REAL,
INTENT(IN) :: ws(is:ie)
2408 REAL,
INTENT(IN) :: pem(is:ie, km+1)
2409 REAL,
INTENT(OUT) :: pe2(is:ie, km+1)
2410 REAL,
DIMENSION(is:ie, km),
INTENT(INOUT) :: dz2, w2
2412 REAL,
DIMENSION(is:ie, km) :: aa, bb, dd, w1, g_rat, gam
2413 REAL,
DIMENSION(is:ie, km+1) :: pp
2414 REAL,
DIMENSION(is:ie) :: p1, wk1, bet
2415 REAL :: t1g, rdt, capa1, r2g, r6g
2431 arg1 = -(dm(i, k)/dz2(i, k)*rgas*pt2(i, k))
2432 arg2 = gama*log(arg1)
2433 aa(i, k) = exp(arg2)
2439 g_rat(i, k) = dm(i, k)/dm(i, k+1)
2440 bb(i, k) = 2.*(1.+g_rat(i, k))
2441 dd(i, k) = 3.*(aa(i, k)+g_rat(i, k)*aa(i, k+1))
2448 pe2(i, 1) = pem(i, 1)
2449 pe2(i, 2) = (dd(i, 1)-pem(i, 1))/bet(i)
2452 dd(i, km) = 3.*aa(i, km) + r2g*dm(i, km)
2456 gam(i, k) = g_rat(i, k-1)/bet(i)
2457 bet(i) = bb(i, k) - gam(i, k)
2458 pe2(i, k+1) = (dd(i, k)-pe2(i, k))/bet(i)
2463 pe2(i, k) = pe2(i, k) - gam(i, k)*pe2(i, k+1)
2470 pp(i, k) = pe2(i, k) - pem(i, k)
2475 aa(i, k) = t1g/(dz2(i, k-1)+dz2(i, k))*pe2(i, k) - scale_m*dm(i&
2480 bet(i) = dm(i, 1) - aa(i, 2)
2481 w2(i, 1) = (dm(i, 1)*w1(i, 1)+dt*pp(i, 2))/bet(i)
2485 gam(i, k) = aa(i, k)/bet(i)
2486 bet(i) = dm(i, k) - (aa(i, k)+aa(i, k+1)+aa(i, k)*gam(i, k))
2487 w2(i, k) = (dm(i, k)*w1(i, k)+dt*(pp(i, k+1)-pp(i, k))-aa(i, k)*&
2488 & w2(i, k-1))/bet(i)
2492 wk1(i) = t1g/dz2(i, km)*pe2(i, km+1)
2493 gam(i, km) = aa(i, km)/bet(i)
2494 bet(i) = dm(i, km) - (aa(i, km)+wk1(i)+aa(i, km)*gam(i, km))
2495 w2(i, km) = (dm(i, km)*w1(i, km)+dt*(pp(i, km+1)-pp(i, km))-wk1(i)&
2496 & *ws(i)-aa(i, km)*w2(i, km-1))/bet(i)
2500 w2(i, k) = w2(i, k) - gam(i, k+1)*w2(i, k+1)
2509 pe2(i, k+1) = pe2(i, k) + dm(i, k)*(w2(i, k)-w1(i, k))*rdt
2514 pe2(i, 1) = pem(i, 1)
2518 IF (p_fac*pem(i, k) .LT. pe2(i, k) + pem(i, k))
THEN 2519 pe2(i, k) = pe2(i, k) + pem(i, k)
2521 pe2(i, k) = p_fac*pem(i, k)
2527 p1(i) = (pe2(i, km)+2.*pe2(i, km+1))*
r3 - r6g*dm(i, km)
2528 arg1 = capa1*log(p1(i))
2529 dz2(i, km) = -(dm(i, km)*rgas*pt2(i, km)*exp(arg1))
2533 p1(i) = (pe2(i, k)+bb(i, k)*pe2(i, k+1)+g_rat(i, k)*pe2(i, k+2))&
2534 & *
r3 - g_rat(i, k)*p1(i)
2535 arg1 = capa1*log(p1(i))
2536 dz2(i, k) = -(dm(i, k)*rgas*pt2(i, k)*exp(arg1))
2541 pe2(i, k) = pe2(i, k) - pem(i, k)
2548 SUBROUTINE sim1_solver_tlm(dt, is, ie, km, rgas, gama, gm2, cp2, kappa&
2549 & , pe, pe_tl, dm2, dm2_tl, pm2, pm2_tl, pem, pem_tl, w2, w2_tl, dz2, &
2550 & dz2_tl, pt2, pt2_tl, ws, ws_tl, p_fac)
2552 INTEGER,
INTENT(IN) :: is, ie, km
2553 REAL,
INTENT(IN) :: dt, rgas, gama, kappa, p_fac
2554 REAL,
DIMENSION(is:ie, km),
INTENT(IN) :: dm2, pt2, pm2, gm2, cp2
2555 REAL,
DIMENSION(is:ie, km),
INTENT(IN) :: dm2_tl, pt2_tl, pm2_tl
2556 REAL,
INTENT(IN) :: ws(is:ie)
2557 REAL,
INTENT(IN) :: ws_tl(is:ie)
2558 REAL,
DIMENSION(is:ie, km+1),
INTENT(IN) :: pem
2559 REAL,
DIMENSION(is:ie, km+1),
INTENT(IN) :: pem_tl
2560 REAL,
INTENT(OUT) :: pe(is:ie, km+1)
2561 REAL,
INTENT(OUT) :: pe_tl(is:ie, km+1)
2562 REAL,
DIMENSION(is:ie, km),
INTENT(INOUT) :: dz2, w2
2563 REAL,
DIMENSION(is:ie, km),
INTENT(INOUT) :: dz2_tl, w2_tl
2565 REAL,
DIMENSION(is:ie, km) :: aa, bb, dd, w1, g_rat, gam
2566 REAL,
DIMENSION(is:ie, km) :: aa_tl, bb_tl, dd_tl, w1_tl, g_rat_tl, &
2568 REAL,
DIMENSION(is:ie, km+1) :: pp
2569 REAL,
DIMENSION(is:ie, km+1) :: pp_tl
2570 REAL,
DIMENSION(is:ie) :: p1, bet
2571 REAL,
DIMENSION(is:ie) :: p1_tl, bet_tl
2572 REAL :: t1g, rdt, capa1
2591 w1_tl(i, k) = w2_tl(i, k)
2593 arg1_tl = -(rgas*((dm2_tl(i, k)*dz2(i, k)-dm2(i, k)*dz2_tl(i, k)&
2594 & )*pt2(i, k)/dz2(i, k)**2+dm2(i, k)*pt2_tl(i, k)/dz2(i, k)))
2595 arg1 = -(dm2(i, k)/dz2(i, k)*rgas*pt2(i, k))
2596 arg2_tl = gama*arg1_tl/arg1
2597 arg2 = gama*log(arg1)
2598 pe_tl(i, k) = arg2_tl*exp(arg2) - pm2_tl(i, k)
2599 pe(i, k) = exp(arg2) - pm2(i, k)
2607 g_rat_tl(i, k) = (dm2_tl(i, k)*dm2(i, k+1)-dm2(i, k)*dm2_tl(i, k&
2608 & +1))/dm2(i, k+1)**2
2609 g_rat(i, k) = dm2(i, k)/dm2(i, k+1)
2610 bb_tl(i, k) = 2.*g_rat_tl(i, k)
2611 bb(i, k) = 2.*(1.+g_rat(i, k))
2612 dd_tl(i, k) = 3.*(pe_tl(i, k)+g_rat_tl(i, k)*pe(i, k+1)+g_rat(i&
2613 & , k)*pe_tl(i, k+1))
2614 dd(i, k) = 3.*(pe(i, k)+g_rat(i, k)*pe(i, k+1))
2620 bet_tl(i) = bb_tl(i, 1)
2624 pp_tl(i, 2) = (dd_tl(i, 1)*bet(i)-dd(i, 1)*bet_tl(i))/bet(i)**2
2625 pp(i, 2) = dd(i, 1)/bet(i)
2628 dd_tl(i, km) = 3.*pe_tl(i, km)
2629 dd(i, km) = 3.*pe(i, km)
2634 gam_tl(i, k) = (g_rat_tl(i, k-1)*bet(i)-g_rat(i, k-1)*bet_tl(i))&
2636 gam(i, k) = g_rat(i, k-1)/bet(i)
2637 bet_tl(i) = bb_tl(i, k) - gam_tl(i, k)
2638 bet(i) = bb(i, k) - gam(i, k)
2639 pp_tl(i, k+1) = ((dd_tl(i, k)-pp_tl(i, k))*bet(i)-(dd(i, k)-pp(i&
2640 & , k))*bet_tl(i))/bet(i)**2
2641 pp(i, k+1) = (dd(i, k)-pp(i, k))/bet(i)
2646 pp_tl(i, k) = pp_tl(i, k) - gam_tl(i, k)*pp(i, k+1) - gam(i, k)*&
2648 pp(i, k) = pp(i, k) - gam(i, k)*pp(i, k+1)
2655 aa_tl(i, k) = t1g*(pem_tl(i, k)+pp_tl(i, k))/(dz2(i, k-1)+dz2(i&
2656 & , k)) - t1g*(dz2_tl(i, k-1)+dz2_tl(i, k))*(pem(i, k)+pp(i, k))&
2657 & /(dz2(i, k-1)+dz2(i, k))**2
2658 aa(i, k) = t1g/(dz2(i, k-1)+dz2(i, k))*(pem(i, k)+pp(i, k))
2662 bet_tl(i) = dm2_tl(i, 1) - aa_tl(i, 2)
2663 bet(i) = dm2(i, 1) - aa(i, 2)
2664 w2_tl(i, 1) = ((dm2_tl(i, 1)*w1(i, 1)+dm2(i, 1)*w1_tl(i, 1)+dt*&
2665 & pp_tl(i, 2))*bet(i)-(dm2(i, 1)*w1(i, 1)+dt*pp(i, 2))*bet_tl(i))/&
2667 w2(i, 1) = (dm2(i, 1)*w1(i, 1)+dt*pp(i, 2))/bet(i)
2671 gam_tl(i, k) = (aa_tl(i, k)*bet(i)-aa(i, k)*bet_tl(i))/bet(i)**2
2672 gam(i, k) = aa(i, k)/bet(i)
2673 bet_tl(i) = dm2_tl(i, k) - aa_tl(i, k) - aa_tl(i, k+1) - aa_tl(i&
2674 & , k)*gam(i, k) - aa(i, k)*gam_tl(i, k)
2675 bet(i) = dm2(i, k) - (aa(i, k)+aa(i, k+1)+aa(i, k)*gam(i, k))
2676 w2_tl(i, k) = ((dm2_tl(i, k)*w1(i, k)+dm2(i, k)*w1_tl(i, k)+dt*(&
2677 & pp_tl(i, k+1)-pp_tl(i, k))-aa_tl(i, k)*w2(i, k-1)-aa(i, k)*&
2678 & w2_tl(i, k-1))*bet(i)-(dm2(i, k)*w1(i, k)+dt*(pp(i, k+1)-pp(i&
2679 & , k))-aa(i, k)*w2(i, k-1))*bet_tl(i))/bet(i)**2
2680 w2(i, k) = (dm2(i, k)*w1(i, k)+dt*(pp(i, k+1)-pp(i, k))-aa(i, k)&
2681 & *w2(i, k-1))/bet(i)
2686 p1_tl(i) = t1g*(pem_tl(i, km+1)+pp_tl(i, km+1))/dz2(i, km) - t1g*&
2687 & dz2_tl(i, km)*(pem(i, km+1)+pp(i, km+1))/dz2(i, km)**2
2688 p1(i) = t1g/dz2(i, km)*(pem(i, km+1)+pp(i, km+1))
2689 gam_tl(i, km) = (aa_tl(i, km)*bet(i)-aa(i, km)*bet_tl(i))/bet(i)**&
2691 gam(i, km) = aa(i, km)/bet(i)
2692 bet_tl(i) = dm2_tl(i, km) - aa_tl(i, km) - p1_tl(i) - aa_tl(i, km)&
2693 & *gam(i, km) - aa(i, km)*gam_tl(i, km)
2694 bet(i) = dm2(i, km) - (aa(i, km)+p1(i)+aa(i, km)*gam(i, km))
2695 w2_tl(i, km) = ((dm2_tl(i, km)*w1(i, km)+dm2(i, km)*w1_tl(i, km)+&
2696 & dt*(pp_tl(i, km+1)-pp_tl(i, km))-p1_tl(i)*ws(i)-p1(i)*ws_tl(i)-&
2697 & aa_tl(i, km)*w2(i, km-1)-aa(i, km)*w2_tl(i, km-1))*bet(i)-(dm2(i&
2698 & , km)*w1(i, km)+dt*(pp(i, km+1)-pp(i, km))-p1(i)*ws(i)-aa(i, km)&
2699 & *w2(i, km-1))*bet_tl(i))/bet(i)**2
2700 w2(i, km) = (dm2(i, km)*w1(i, km)+dt*(pp(i, km+1)-pp(i, km))-p1(i)&
2701 & *ws(i)-aa(i, km)*w2(i, km-1))/bet(i)
2705 w2_tl(i, k) = w2_tl(i, k) - gam_tl(i, k+1)*w2(i, k+1) - gam(i, k&
2707 w2(i, k) = w2(i, k) - gam(i, k+1)*w2(i, k+1)
2716 pe_tl(i, k+1) = pe_tl(i, k) + rdt*(dm2_tl(i, k)*(w2(i, k)-w1(i, &
2717 & k))+dm2(i, k)*(w2_tl(i, k)-w1_tl(i, k)))
2718 pe(i, k+1) = pe(i, k) + dm2(i, k)*(w2(i, k)-w1(i, k))*rdt
2722 p1_tl(i) =
r3*(pe_tl(i, km)+2.*pe_tl(i, km+1))
2723 p1(i) = (pe(i, km)+2.*pe(i, km+1))*
r3 2724 IF (p_fac*pm2(i, km) .LT. p1(i) + pm2(i, km))
THEN 2725 max1_tl = p1_tl(i) + pm2_tl(i, km)
2726 max1 = p1(i) + pm2(i, km)
2728 max1_tl = p_fac*pm2_tl(i, km)
2729 max1 = p_fac*pm2(i, km)
2731 arg1_tl = capa1*max1_tl/max1
2732 arg1 = capa1*log(max1)
2733 dz2_tl(i, km) = -(rgas*((dm2_tl(i, km)*pt2(i, km)+dm2(i, km)*&
2734 & pt2_tl(i, km))*exp(arg1)+dm2(i, km)*pt2(i, km)*arg1_tl*exp(arg1)&
2736 dz2(i, km) = -(dm2(i, km)*rgas*pt2(i, km)*exp(arg1))
2740 p1_tl(i) =
r3*(pe_tl(i, k)+bb_tl(i, k)*pe(i, k+1)+bb(i, k)*pe_tl&
2741 & (i, k+1)+g_rat_tl(i, k)*pe(i, k+2)+g_rat(i, k)*pe_tl(i, k+2)) &
2742 & - g_rat_tl(i, k)*p1(i) - g_rat(i, k)*p1_tl(i)
2743 p1(i) = (pe(i, k)+bb(i, k)*pe(i, k+1)+g_rat(i, k)*pe(i, k+2))*
r3&
2744 & - g_rat(i, k)*p1(i)
2745 IF (p_fac*pm2(i, k) .LT. p1(i) + pm2(i, k))
THEN 2746 max2_tl = p1_tl(i) + pm2_tl(i, k)
2747 max2 = p1(i) + pm2(i, k)
2749 max2_tl = p_fac*pm2_tl(i, k)
2750 max2 = p_fac*pm2(i, k)
2752 arg1_tl = capa1*max2_tl/max2
2753 arg1 = capa1*log(max2)
2754 dz2_tl(i, k) = -(rgas*((dm2_tl(i, k)*pt2(i, k)+dm2(i, k)*pt2_tl(&
2755 & i, k))*exp(arg1)+dm2(i, k)*pt2(i, k)*arg1_tl*exp(arg1)))
2756 dz2(i, k) = -(dm2(i, k)*rgas*pt2(i, k)*exp(arg1))
2760 SUBROUTINE sim1_solver(dt, is, ie, km, rgas, gama, gm2, cp2, kappa, pe&
2761 & , dm2, pm2, pem, w2, dz2, pt2, ws, p_fac)
2763 INTEGER,
INTENT(IN) :: is, ie, km
2764 REAL,
INTENT(IN) :: dt, rgas, gama, kappa, p_fac
2765 REAL,
DIMENSION(is:ie, km),
INTENT(IN) :: dm2, pt2, pm2, gm2, cp2
2766 REAL,
INTENT(IN) :: ws(is:ie)
2767 REAL,
DIMENSION(is:ie, km+1),
INTENT(IN) :: pem
2768 REAL,
INTENT(OUT) :: pe(is:ie, km+1)
2769 REAL,
DIMENSION(is:ie, km),
INTENT(INOUT) :: dz2, w2
2771 REAL,
DIMENSION(is:ie, km) :: aa, bb, dd, w1, g_rat, gam
2772 REAL,
DIMENSION(is:ie, km+1) :: pp
2773 REAL,
DIMENSION(is:ie) :: p1, bet
2774 REAL :: t1g, rdt, capa1
2789 arg1 = -(dm2(i, k)/dz2(i, k)*rgas*pt2(i, k))
2790 arg2 = gama*log(arg1)
2791 pe(i, k) = exp(arg2) - pm2(i, k)
2796 g_rat(i, k) = dm2(i, k)/dm2(i, k+1)
2797 bb(i, k) = 2.*(1.+g_rat(i, k))
2798 dd(i, k) = 3.*(pe(i, k)+g_rat(i, k)*pe(i, k+1))
2804 pp(i, 2) = dd(i, 1)/bet(i)
2806 dd(i, km) = 3.*pe(i, km)
2810 gam(i, k) = g_rat(i, k-1)/bet(i)
2811 bet(i) = bb(i, k) - gam(i, k)
2812 pp(i, k+1) = (dd(i, k)-pp(i, k))/bet(i)
2817 pp(i, k) = pp(i, k) - gam(i, k)*pp(i, k+1)
2823 aa(i, k) = t1g/(dz2(i, k-1)+dz2(i, k))*(pem(i, k)+pp(i, k))
2827 bet(i) = dm2(i, 1) - aa(i, 2)
2828 w2(i, 1) = (dm2(i, 1)*w1(i, 1)+dt*pp(i, 2))/bet(i)
2832 gam(i, k) = aa(i, k)/bet(i)
2833 bet(i) = dm2(i, k) - (aa(i, k)+aa(i, k+1)+aa(i, k)*gam(i, k))
2834 w2(i, k) = (dm2(i, k)*w1(i, k)+dt*(pp(i, k+1)-pp(i, k))-aa(i, k)&
2835 & *w2(i, k-1))/bet(i)
2839 p1(i) = t1g/dz2(i, km)*(pem(i, km+1)+pp(i, km+1))
2840 gam(i, km) = aa(i, km)/bet(i)
2841 bet(i) = dm2(i, km) - (aa(i, km)+p1(i)+aa(i, km)*gam(i, km))
2842 w2(i, km) = (dm2(i, km)*w1(i, km)+dt*(pp(i, km+1)-pp(i, km))-p1(i)&
2843 & *ws(i)-aa(i, km)*w2(i, km-1))/bet(i)
2847 w2(i, k) = w2(i, k) - gam(i, k+1)*w2(i, k+1)
2855 pe(i, k+1) = pe(i, k) + dm2(i, k)*(w2(i, k)-w1(i, k))*rdt
2859 p1(i) = (pe(i, km)+2.*pe(i, km+1))*
r3 2860 IF (p_fac*pm2(i, km) .LT. p1(i) + pm2(i, km))
THEN 2861 max1 = p1(i) + pm2(i, km)
2863 max1 = p_fac*pm2(i, km)
2865 arg1 = capa1*log(max1)
2866 dz2(i, km) = -(dm2(i, km)*rgas*pt2(i, km)*exp(arg1))
2870 p1(i) = (pe(i, k)+bb(i, k)*pe(i, k+1)+g_rat(i, k)*pe(i, k+2))*
r3&
2871 & - g_rat(i, k)*p1(i)
2872 IF (p_fac*pm2(i, k) .LT. p1(i) + pm2(i, k))
THEN 2873 max2 = p1(i) + pm2(i, k)
2875 max2 = p_fac*pm2(i, k)
2877 arg1 = capa1*log(max2)
2878 dz2(i, k) = -(dm2(i, k)*rgas*pt2(i, k)*exp(arg1))
2885 SUBROUTINE sim_solver_tlm(dt, is, ie, km, rgas, gama, gm2, cp2, kappa&
2886 & , pe2, pe2_tl, dm2, dm2_tl, pm2, pm2_tl, pem, pem_tl, w2, w2_tl, dz2&
2887 & , dz2_tl, pt2, pt2_tl, ws, ws_tl, alpha, p_fac, scale_m)
2889 INTEGER,
INTENT(IN) :: is, ie, km
2890 REAL,
INTENT(IN) :: dt, rgas, gama, kappa, p_fac, alpha, scale_m
2891 REAL,
DIMENSION(is:ie, km),
INTENT(IN) :: dm2, pt2, pm2, gm2, cp2
2892 REAL,
DIMENSION(is:ie, km),
INTENT(IN) :: dm2_tl, pt2_tl, pm2_tl
2893 REAL,
INTENT(IN) :: ws(is:ie)
2894 REAL,
INTENT(IN) :: ws_tl(is:ie)
2895 REAL,
DIMENSION(is:ie, km+1),
INTENT(IN) :: pem
2896 REAL,
DIMENSION(is:ie, km+1),
INTENT(IN) :: pem_tl
2897 REAL,
INTENT(OUT) :: pe2(is:ie, km+1)
2898 REAL,
INTENT(OUT) :: pe2_tl(is:ie, km+1)
2899 REAL,
DIMENSION(is:ie, km),
INTENT(INOUT) :: dz2, w2
2900 REAL,
DIMENSION(is:ie, km),
INTENT(INOUT) :: dz2_tl, w2_tl
2902 REAL,
DIMENSION(is:ie, km) :: aa, bb, dd, w1, wk, g_rat, gam
2903 REAL,
DIMENSION(is:ie, km) :: aa_tl, bb_tl, dd_tl, w1_tl, wk_tl, &
2905 REAL,
DIMENSION(is:ie, km+1) :: pp
2906 REAL,
DIMENSION(is:ie, km+1) :: pp_tl
2907 REAL,
DIMENSION(is:ie) :: p1, wk1, bet
2908 REAL,
DIMENSION(is:ie) :: p1_tl, wk1_tl, bet_tl
2909 REAL :: beta, t2, t1g, rdt, ra, capa1
2925 t1g = 2.*gama*(alpha*dt)**2
2931 w1_tl(i, k) = w2_tl(i, k)
2934 arg1_tl = -(rgas*((dm2_tl(i, k)*dz2(i, k)-dm2(i, k)*dz2_tl(i, k)&
2935 & )*pt2(i, k)/dz2(i, k)**2+dm2(i, k)*pt2_tl(i, k)/dz2(i, k)))
2936 arg1 = -(dm2(i, k)/dz2(i, k)*rgas*pt2(i, k))
2937 arg2_tl = gama*arg1_tl/arg1
2938 arg2 = gama*log(arg1)
2939 pe2_tl(i, k) = arg2_tl*exp(arg2) - pm2_tl(i, k)
2940 pe2(i, k) = exp(arg2) - pm2(i, k)
2948 g_rat_tl(i, k) = (dm2_tl(i, k)*dm2(i, k+1)-dm2(i, k)*dm2_tl(i, k&
2949 & +1))/dm2(i, k+1)**2
2950 g_rat(i, k) = dm2(i, k)/dm2(i, k+1)
2951 bb_tl(i, k) = 2.*g_rat_tl(i, k)
2952 bb(i, k) = 2.*(1.+g_rat(i, k))
2953 dd_tl(i, k) = 3.*(pe2_tl(i, k)+g_rat_tl(i, k)*pe2(i, k+1)+g_rat(&
2954 & i, k)*pe2_tl(i, k+1))
2955 dd(i, k) = 3.*(pe2(i, k)+g_rat(i, k)*pe2(i, k+1))
2961 bet_tl(i) = bb_tl(i, 1)
2965 pp_tl(i, 2) = (dd_tl(i, 1)*bet(i)-dd(i, 1)*bet_tl(i))/bet(i)**2
2966 pp(i, 2) = dd(i, 1)/bet(i)
2969 dd_tl(i, km) = 3.*pe2_tl(i, km)
2970 dd(i, km) = 3.*pe2(i, km)
2975 gam_tl(i, k) = (g_rat_tl(i, k-1)*bet(i)-g_rat(i, k-1)*bet_tl(i))&
2977 gam(i, k) = g_rat(i, k-1)/bet(i)
2978 bet_tl(i) = bb_tl(i, k) - gam_tl(i, k)
2979 bet(i) = bb(i, k) - gam(i, k)
2980 pp_tl(i, k+1) = ((dd_tl(i, k)-pp_tl(i, k))*bet(i)-(dd(i, k)-pp(i&
2981 & , k))*bet_tl(i))/bet(i)**2
2982 pp(i, k+1) = (dd(i, k)-pp(i, k))/bet(i)
2987 pp_tl(i, k) = pp_tl(i, k) - gam_tl(i, k)*pp(i, k+1) - gam(i, k)*&
2989 pp(i, k) = pp(i, k) - gam(i, k)*pp(i, k+1)
2995 pe2_tl(i, k) = pem_tl(i, k) + pp_tl(i, k)
2996 pe2(i, k) = pem(i, k) + pp(i, k)
3003 aa_tl(i, k) = t1g*pe2_tl(i, k)/(dz2(i, k-1)+dz2(i, k)) - t1g*(&
3004 & dz2_tl(i, k-1)+dz2_tl(i, k))*pe2(i, k)/(dz2(i, k-1)+dz2(i, k))&
3006 aa(i, k) = t1g/(dz2(i, k-1)+dz2(i, k))*pe2(i, k)
3007 wk_tl(i, k) = t2*(aa_tl(i, k)*(w1(i, k-1)-w1(i, k))+aa(i, k)*(&
3008 & w1_tl(i, k-1)-w1_tl(i, k)))
3009 wk(i, k) = t2*aa(i, k)*(w1(i, k-1)-w1(i, k))
3010 aa_tl(i, k) = aa_tl(i, k) - scale_m*dm2_tl(i, 1)
3011 aa(i, k) = aa(i, k) - scale_m*dm2(i, 1)
3016 bet_tl(i) = dm2_tl(i, 1) - aa_tl(i, 2)
3017 bet(i) = dm2(i, 1) - aa(i, 2)
3018 w2_tl(i, 1) = ((dm2_tl(i, 1)*w1(i, 1)+dm2(i, 1)*w1_tl(i, 1)+dt*&
3019 & pp_tl(i, 2)+wk_tl(i, 2))*bet(i)-(dm2(i, 1)*w1(i, 1)+dt*pp(i, 2)+&
3020 & wk(i, 2))*bet_tl(i))/bet(i)**2
3021 w2(i, 1) = (dm2(i, 1)*w1(i, 1)+dt*pp(i, 2)+wk(i, 2))/bet(i)
3026 gam_tl(i, k) = (aa_tl(i, k)*bet(i)-aa(i, k)*bet_tl(i))/bet(i)**2
3027 gam(i, k) = aa(i, k)/bet(i)
3028 bet_tl(i) = dm2_tl(i, k) - aa_tl(i, k) - aa_tl(i, k+1) - aa_tl(i&
3029 & , k)*gam(i, k) - aa(i, k)*gam_tl(i, k)
3030 bet(i) = dm2(i, k) - (aa(i, k)+aa(i, k+1)+aa(i, k)*gam(i, k))
3031 w2_tl(i, k) = ((dm2_tl(i, k)*w1(i, k)+dm2(i, k)*w1_tl(i, k)+dt*(&
3032 & pp_tl(i, k+1)-pp_tl(i, k))+wk_tl(i, k+1)-wk_tl(i, k)-aa_tl(i, &
3033 & k)*w2(i, k-1)-aa(i, k)*w2_tl(i, k-1))*bet(i)-(dm2(i, k)*w1(i, &
3034 & k)+dt*(pp(i, k+1)-pp(i, k))+wk(i, k+1)-wk(i, k)-aa(i, k)*w2(i&
3035 & , k-1))*bet_tl(i))/bet(i)**2
3036 w2(i, k) = (dm2(i, k)*w1(i, k)+dt*(pp(i, k+1)-pp(i, k))+wk(i, k+&
3037 & 1)-wk(i, k)-aa(i, k)*w2(i, k-1))/bet(i)
3043 wk1_tl(i) = t1g*pe2_tl(i, km+1)/dz2(i, km) - t1g*dz2_tl(i, km)*pe2&
3044 & (i, km+1)/dz2(i, km)**2
3045 wk1(i) = t1g/dz2(i, km)*pe2(i, km+1)
3046 gam_tl(i, km) = (aa_tl(i, km)*bet(i)-aa(i, km)*bet_tl(i))/bet(i)**&
3048 gam(i, km) = aa(i, km)/bet(i)
3049 bet_tl(i) = dm2_tl(i, km) - aa_tl(i, km) - wk1_tl(i) - aa_tl(i, km&
3050 & )*gam(i, km) - aa(i, km)*gam_tl(i, km)
3051 bet(i) = dm2(i, km) - (aa(i, km)+wk1(i)+aa(i, km)*gam(i, km))
3052 w2_tl(i, km) = ((dm2_tl(i, km)*w1(i, km)+dm2(i, km)*w1_tl(i, km)+&
3053 & dt*(pp_tl(i, km+1)-pp_tl(i, km))-wk_tl(i, km)+wk1_tl(i)*(t2*w1(i&
3054 & , km)-ra*ws(i))+wk1(i)*(t2*w1_tl(i, km)-ra*ws_tl(i))-aa_tl(i, km&
3055 & )*w2(i, km-1)-aa(i, km)*w2_tl(i, km-1))*bet(i)-(dm2(i, km)*w1(i&
3056 & , km)+dt*(pp(i, km+1)-pp(i, km))-wk(i, km)+wk1(i)*(t2*w1(i, km)-&
3057 & ra*ws(i))-aa(i, km)*w2(i, km-1))*bet_tl(i))/bet(i)**2
3058 w2(i, km) = (dm2(i, km)*w1(i, km)+dt*(pp(i, km+1)-pp(i, km))-wk(i&
3059 & , km)+wk1(i)*(t2*w1(i, km)-ra*ws(i))-aa(i, km)*w2(i, km-1))/bet(&
3064 w2_tl(i, k) = w2_tl(i, k) - gam_tl(i, k+1)*w2(i, k+1) - gam(i, k&
3066 w2(i, k) = w2(i, k) - gam(i, k+1)*w2(i, k+1)
3075 pe2_tl(i, k+1) = pe2_tl(i, k) + ra*(rdt*(dm2_tl(i, k)*(w2(i, k)-&
3076 & w1(i, k))+dm2(i, k)*(w2_tl(i, k)-w1_tl(i, k)))-beta*(pp_tl(i, &
3077 & k+1)-pp_tl(i, k)))
3078 pe2(i, k+1) = pe2(i, k) + (dm2(i, k)*(w2(i, k)-w1(i, k))*rdt-&
3079 & beta*(pp(i, k+1)-pp(i, k)))*ra
3084 p1_tl(i) =
r3*(pe2_tl(i, km)+2.*pe2_tl(i, km+1))
3085 p1(i) = (pe2(i, km)+2.*pe2(i, km+1))*
r3 3086 IF (p_fac*pm2(i, km) .LT. p1(i) + pm2(i, km))
THEN 3087 max1_tl = p1_tl(i) + pm2_tl(i, km)
3088 max1 = p1(i) + pm2(i, km)
3090 max1_tl = p_fac*pm2_tl(i, km)
3091 max1 = p_fac*pm2(i, km)
3093 arg1_tl = capa1*max1_tl/max1
3094 arg1 = capa1*log(max1)
3095 dz2_tl(i, km) = -(rgas*((dm2_tl(i, km)*pt2(i, km)+dm2(i, km)*&
3096 & pt2_tl(i, km))*exp(arg1)+dm2(i, km)*pt2(i, km)*arg1_tl*exp(arg1)&
3098 dz2(i, km) = -(dm2(i, km)*rgas*pt2(i, km)*exp(arg1))
3102 p1_tl(i) =
r3*(pe2_tl(i, k)+bb_tl(i, k)*pe2(i, k+1)+bb(i, k)*&
3103 & pe2_tl(i, k+1)+g_rat_tl(i, k)*pe2(i, k+2)+g_rat(i, k)*pe2_tl(i&
3104 & , k+2)) - g_rat_tl(i, k)*p1(i) - g_rat(i, k)*p1_tl(i)
3105 p1(i) = (pe2(i, k)+bb(i, k)*pe2(i, k+1)+g_rat(i, k)*pe2(i, k+2))&
3106 & *
r3 - g_rat(i, k)*p1(i)
3107 IF (p_fac*pm2(i, k) .LT. p1(i) + pm2(i, k))
THEN 3108 max2_tl = p1_tl(i) + pm2_tl(i, k)
3109 max2 = p1(i) + pm2(i, k)
3111 max2_tl = p_fac*pm2_tl(i, k)
3112 max2 = p_fac*pm2(i, k)
3115 arg1_tl = capa1*max2_tl/max2
3116 arg1 = capa1*log(max2)
3117 dz2_tl(i, k) = -(rgas*((dm2_tl(i, k)*pt2(i, k)+dm2(i, k)*pt2_tl(&
3118 & i, k))*exp(arg1)+dm2(i, k)*pt2(i, k)*arg1_tl*exp(arg1)))
3119 dz2(i, k) = -(dm2(i, k)*rgas*pt2(i, k)*exp(arg1))
3124 pe2_tl(i, k) = pe2_tl(i, k) + beta*(pp_tl(i, k)-pe2_tl(i, k))
3125 pe2(i, k) = pe2(i, k) + beta*(pp(i, k)-pe2(i, k))
3129 SUBROUTINE sim_solver(dt, is, ie, km, rgas, gama, gm2, cp2, kappa, pe2&
3130 & , dm2, pm2, pem, w2, dz2, pt2, ws, alpha, p_fac, scale_m)
3132 INTEGER,
INTENT(IN) :: is, ie, km
3133 REAL,
INTENT(IN) :: dt, rgas, gama, kappa, p_fac, alpha, scale_m
3134 REAL,
DIMENSION(is:ie, km),
INTENT(IN) :: dm2, pt2, pm2, gm2, cp2
3135 REAL,
INTENT(IN) :: ws(is:ie)
3136 REAL,
DIMENSION(is:ie, km+1),
INTENT(IN) :: pem
3137 REAL,
INTENT(OUT) :: pe2(is:ie, km+1)
3138 REAL,
DIMENSION(is:ie, km),
INTENT(INOUT) :: dz2, w2
3140 REAL,
DIMENSION(is:ie, km) :: aa, bb, dd, w1, wk, g_rat, gam
3141 REAL,
DIMENSION(is:ie, km+1) :: pp
3142 REAL,
DIMENSION(is:ie) :: p1, wk1, bet
3143 REAL :: beta, t2, t1g, rdt, ra, capa1
3155 t1g = 2.*gama*(alpha*dt)**2
3162 arg1 = -(dm2(i, k)/dz2(i, k)*rgas*pt2(i, k))
3163 arg2 = gama*log(arg1)
3164 pe2(i, k) = exp(arg2) - pm2(i, k)
3169 g_rat(i, k) = dm2(i, k)/dm2(i, k+1)
3170 bb(i, k) = 2.*(1.+g_rat(i, k))
3171 dd(i, k) = 3.*(pe2(i, k)+g_rat(i, k)*pe2(i, k+1))
3177 pp(i, 2) = dd(i, 1)/bet(i)
3179 dd(i, km) = 3.*pe2(i, km)
3183 gam(i, k) = g_rat(i, k-1)/bet(i)
3184 bet(i) = bb(i, k) - gam(i, k)
3185 pp(i, k+1) = (dd(i, k)-pp(i, k))/bet(i)
3190 pp(i, k) = pp(i, k) - gam(i, k)*pp(i, k+1)
3196 pe2(i, k) = pem(i, k) + pp(i, k)
3201 aa(i, k) = t1g/(dz2(i, k-1)+dz2(i, k))*pe2(i, k)
3202 wk(i, k) = t2*aa(i, k)*(w1(i, k-1)-w1(i, k))
3203 aa(i, k) = aa(i, k) - scale_m*dm2(i, 1)
3208 bet(i) = dm2(i, 1) - aa(i, 2)
3209 w2(i, 1) = (dm2(i, 1)*w1(i, 1)+dt*pp(i, 2)+wk(i, 2))/bet(i)
3214 gam(i, k) = aa(i, k)/bet(i)
3215 bet(i) = dm2(i, k) - (aa(i, k)+aa(i, k+1)+aa(i, k)*gam(i, k))
3216 w2(i, k) = (dm2(i, k)*w1(i, k)+dt*(pp(i, k+1)-pp(i, k))+wk(i, k+&
3217 & 1)-wk(i, k)-aa(i, k)*w2(i, k-1))/bet(i)
3222 wk1(i) = t1g/dz2(i, km)*pe2(i, km+1)
3223 gam(i, km) = aa(i, km)/bet(i)
3224 bet(i) = dm2(i, km) - (aa(i, km)+wk1(i)+aa(i, km)*gam(i, km))
3225 w2(i, km) = (dm2(i, km)*w1(i, km)+dt*(pp(i, km+1)-pp(i, km))-wk(i&
3226 & , km)+wk1(i)*(t2*w1(i, km)-ra*ws(i))-aa(i, km)*w2(i, km-1))/bet(&
3231 w2(i, k) = w2(i, k) - gam(i, k+1)*w2(i, k+1)
3239 pe2(i, k+1) = pe2(i, k) + (dm2(i, k)*(w2(i, k)-w1(i, k))*rdt-&
3240 & beta*(pp(i, k+1)-pp(i, k)))*ra
3244 p1(i) = (pe2(i, km)+2.*pe2(i, km+1))*
r3 3245 IF (p_fac*pm2(i, km) .LT. p1(i) + pm2(i, km))
THEN 3246 max1 = p1(i) + pm2(i, km)
3248 max1 = p_fac*pm2(i, km)
3250 arg1 = capa1*log(max1)
3251 dz2(i, km) = -(dm2(i, km)*rgas*pt2(i, km)*exp(arg1))
3255 p1(i) = (pe2(i, k)+bb(i, k)*pe2(i, k+1)+g_rat(i, k)*pe2(i, k+2))&
3256 & *
r3 - g_rat(i, k)*p1(i)
3257 IF (p_fac*pm2(i, k) .LT. p1(i) + pm2(i, k))
THEN 3258 max2 = p1(i) + pm2(i, k)
3260 max2 = p_fac*pm2(i, k)
3263 arg1 = capa1*log(max2)
3264 dz2(i, k) = -(dm2(i, k)*rgas*pt2(i, k)*exp(arg1))
3269 pe2(i, k) = pe2(i, k) + beta*(pp(i, k)-pe2(i, k))
3276 INTEGER,
INTENT(IN) :: i1, i2, km
3278 INTEGER,
INTENT(IN) :: id
3279 REAL,
DIMENSION(i1:i2, km),
INTENT(IN) :: q1
3280 REAL,
DIMENSION(i1:i2, km+1),
INTENT(OUT) :: qe
3282 REAL,
PARAMETER :: r2o3=2./3.
3283 REAL,
PARAMETER :: r4o3=4./3.
3292 qe(i, 1) = r4o3*q1(i, 1) + r2o3*q1(i, 2)
3301 gak(k) = 1./(4.-gak(k-1))
3303 qe(i, k) = (3.*(q1(i, k-1)+q1(i, k))-qe(i, k-1))*gak(k)
3306 bet = 1./(1.5-3.5*gak(km))
3308 qe(i, km+1) = (4.*q1(i, km)+q1(i, km-1)-3.5*qe(i, km))*bet
3312 qe(i, k) = qe(i, k) - gak(k)*qe(i, k+1)
3320 & q2e_tl, i1, i2, j1, j2, j, km, dp0, uniform_grid, limiter)
3323 INTEGER,
INTENT(IN) :: i1, i2, j1, j2
3324 INTEGER,
INTENT(IN) :: j, km
3325 INTEGER,
INTENT(IN) :: limiter
3326 LOGICAL,
INTENT(IN) :: uniform_grid
3327 REAL,
INTENT(IN) :: dp0(km)
3328 REAL,
DIMENSION(i1:i2, j1:j2, km),
INTENT(IN) :: q1, q2
3329 REAL,
DIMENSION(i1:i2, j1:j2, km),
INTENT(IN) :: q1_tl, q2_tl
3330 REAL,
DIMENSION(i1:i2, j1:j2, km+1),
INTENT(OUT) :: q1e, q2e
3331 REAL,
DIMENSION(i1:i2, j1:j2, km+1),
INTENT(OUT) :: q1e_tl, q2e_tl
3334 REAL,
DIMENSION(i1:i2, km+1) :: qe1, qe2, gam
3335 REAL,
DIMENSION(i1:i2, km+1) :: qe1_tl, qe2_tl
3337 REAL :: bet, r2o3, r4o3
3338 REAL :: g0, gk, xt1, xt2, a_bot
3340 IF (uniform_grid)
THEN 3349 qe1_tl(i, 1) = r4o3*q1_tl(i, j, 1) + r2o3*q1_tl(i, j, 2)
3350 qe1(i, 1) = r4o3*q1(i, j, 1) + r2o3*q1(i, j, 2)
3351 qe2_tl(i, 1) = r4o3*q2_tl(i, j, 1) + r2o3*q2_tl(i, j, 2)
3352 qe2(i, 1) = r4o3*q2(i, j, 1) + r2o3*q2(i, j, 2)
3356 gak(k) = 1./(4.-gak(k-1))
3358 qe1_tl(i, k) = gak(k)*(3.*(q1_tl(i, j, k-1)+q1_tl(i, j, k))-&
3360 qe1(i, k) = (3.*(q1(i, j, k-1)+q1(i, j, k))-qe1(i, k-1))*gak(k&
3362 qe2_tl(i, k) = gak(k)*(3.*(q2_tl(i, j, k-1)+q2_tl(i, j, k))-&
3364 qe2(i, k) = (3.*(q2(i, j, k-1)+q2(i, j, k))-qe2(i, k-1))*gak(k&
3368 bet = 1./(1.5-3.5*gak(km))
3370 qe1_tl(i, km+1) = bet*(4.*q1_tl(i, j, km)+q1_tl(i, j, km-1)-3.5*&
3372 qe1(i, km+1) = (4.*q1(i, j, km)+q1(i, j, km-1)-3.5*qe1(i, km))*&
3374 qe2_tl(i, km+1) = bet*(4.*q2_tl(i, j, km)+q2_tl(i, j, km-1)-3.5*&
3376 qe2(i, km+1) = (4.*q2(i, j, km)+q2(i, j, km-1)-3.5*qe2(i, km))*&
3381 qe1_tl(i, k) = qe1_tl(i, k) - gak(k)*qe1_tl(i, k+1)
3382 qe1(i, k) = qe1(i, k) - gak(k)*qe1(i, k+1)
3383 qe2_tl(i, k) = qe2_tl(i, k) - gak(k)*qe2_tl(i, k+1)
3384 qe2(i, k) = qe2(i, k) - gak(k)*qe2(i, k+1)
3395 qe1_tl(i, 1) = (xt1*q1_tl(i, j, 1)+q1_tl(i, j, 2))/bet
3396 qe1(i, 1) = (xt1*q1(i, j, 1)+q1(i, j, 2))/bet
3397 qe2_tl(i, 1) = (xt1*q2_tl(i, j, 1)+q2_tl(i, j, 2))/bet
3398 qe2(i, 1) = (xt1*q2(i, j, 1)+q2(i, j, 2))/bet
3399 gam(i, 1) = (1.+g0*(g0+1.5))/bet
3402 gk = dp0(k-1)/dp0(k)
3404 bet = 2. + 2.*gk - gam(i, k-1)
3405 qe1_tl(i, k) = (3.*(q1_tl(i, j, k-1)+gk*q1_tl(i, j, k))-qe1_tl&
3407 qe1(i, k) = (3.*(q1(i, j, k-1)+gk*q1(i, j, k))-qe1(i, k-1))/&
3409 qe2_tl(i, k) = (3.*(q2_tl(i, j, k-1)+gk*q2_tl(i, j, k))-qe2_tl&
3411 qe2(i, k) = (3.*(q2(i, j, k-1)+gk*q2(i, j, k))-qe2(i, k-1))/&
3416 a_bot = 1. + gk*(gk+1.5)
3419 xt2 = gk*(gk+0.5) - a_bot*gam(i, km)
3420 qe1_tl(i, km+1) = (xt1*q1_tl(i, j, km)+q1_tl(i, j, km-1)-a_bot*&
3421 & qe1_tl(i, km))/xt2
3422 qe1(i, km+1) = (xt1*q1(i, j, km)+q1(i, j, km-1)-a_bot*qe1(i, km)&
3424 qe2_tl(i, km+1) = (xt1*q2_tl(i, j, km)+q2_tl(i, j, km-1)-a_bot*&
3425 & qe2_tl(i, km))/xt2
3426 qe2(i, km+1) = (xt1*q2(i, j, km)+q2(i, j, km-1)-a_bot*qe2(i, km)&
3431 qe1_tl(i, k) = qe1_tl(i, k) - gam(i, k)*qe1_tl(i, k+1)
3432 qe1(i, k) = qe1(i, k) - gam(i, k)*qe1(i, k+1)
3433 qe2_tl(i, k) = qe2_tl(i, k) - gam(i, k)*qe2_tl(i, k+1)
3434 qe2(i, k) = qe2(i, k) - gam(i, k)*qe2(i, k+1)
3441 IF (limiter .NE. 0)
THEN 3445 IF (q1(i, j, 1)*qe1(i, 1) .LT. 0.)
THEN 3449 IF (q2(i, j, 1)*qe2(i, 1) .LT. 0.)
THEN 3454 IF (q1(i, j, km)*qe1(i, km+1) .LT. 0.)
THEN 3455 qe1_tl(i, km+1) = 0.0
3458 IF (q2(i, j, km)*qe2(i, km+1) .LT. 0.)
THEN 3459 qe2_tl(i, km+1) = 0.0
3466 q1e_tl(i, j, k) = qe1_tl(i, k)
3467 q1e(i, j, k) = qe1(i, k)
3468 q2e_tl(i, j, k) = qe2_tl(i, k)
3469 q2e(i, j, k) = qe2(i, k)
3473 SUBROUTINE edge_profile(q1, q2, q1e, q2e, i1, i2, j1, j2, j, km, dp0, &
3474 & uniform_grid, limiter)
3477 INTEGER,
INTENT(IN) :: i1, i2, j1, j2
3478 INTEGER,
INTENT(IN) :: j, km
3479 INTEGER,
INTENT(IN) :: limiter
3480 LOGICAL,
INTENT(IN) :: uniform_grid
3481 REAL,
INTENT(IN) :: dp0(km)
3482 REAL,
DIMENSION(i1:i2, j1:j2, km),
INTENT(IN) :: q1, q2
3483 REAL,
DIMENSION(i1:i2, j1:j2, km+1),
INTENT(OUT) :: q1e, q2e
3486 REAL,
DIMENSION(i1:i2, km+1) :: qe1, qe2, gam
3488 REAL :: bet, r2o3, r4o3
3489 REAL :: g0, gk, xt1, xt2, a_bot
3491 IF (uniform_grid)
THEN 3498 qe1(i, 1) = r4o3*q1(i, j, 1) + r2o3*q1(i, j, 2)
3499 qe2(i, 1) = r4o3*q2(i, j, 1) + r2o3*q2(i, j, 2)
3503 gak(k) = 1./(4.-gak(k-1))
3505 qe1(i, k) = (3.*(q1(i, j, k-1)+q1(i, j, k))-qe1(i, k-1))*gak(k&
3507 qe2(i, k) = (3.*(q2(i, j, k-1)+q2(i, j, k))-qe2(i, k-1))*gak(k&
3511 bet = 1./(1.5-3.5*gak(km))
3513 qe1(i, km+1) = (4.*q1(i, j, km)+q1(i, j, km-1)-3.5*qe1(i, km))*&
3515 qe2(i, km+1) = (4.*q2(i, j, km)+q2(i, j, km-1)-3.5*qe2(i, km))*&
3520 qe1(i, k) = qe1(i, k) - gak(k)*qe1(i, k+1)
3521 qe2(i, k) = qe2(i, k) - gak(k)*qe2(i, k+1)
3530 qe1(i, 1) = (xt1*q1(i, j, 1)+q1(i, j, 2))/bet
3531 qe2(i, 1) = (xt1*q2(i, j, 1)+q2(i, j, 2))/bet
3532 gam(i, 1) = (1.+g0*(g0+1.5))/bet
3535 gk = dp0(k-1)/dp0(k)
3537 bet = 2. + 2.*gk - gam(i, k-1)
3538 qe1(i, k) = (3.*(q1(i, j, k-1)+gk*q1(i, j, k))-qe1(i, k-1))/&
3540 qe2(i, k) = (3.*(q2(i, j, k-1)+gk*q2(i, j, k))-qe2(i, k-1))/&
3545 a_bot = 1. + gk*(gk+1.5)
3548 xt2 = gk*(gk+0.5) - a_bot*gam(i, km)
3549 qe1(i, km+1) = (xt1*q1(i, j, km)+q1(i, j, km-1)-a_bot*qe1(i, km)&
3551 qe2(i, km+1) = (xt1*q2(i, j, km)+q2(i, j, km-1)-a_bot*qe2(i, km)&
3556 qe1(i, k) = qe1(i, k) - gam(i, k)*qe1(i, k+1)
3557 qe2(i, k) = qe2(i, k) - gam(i, k)*qe2(i, k+1)
3564 IF (limiter .NE. 0)
THEN 3568 IF (q1(i, j, 1)*qe1(i, 1) .LT. 0.) qe1(i, 1) = 0.
3569 IF (q2(i, j, 1)*qe2(i, 1) .LT. 0.) qe2(i, 1) = 0.
3571 IF (q1(i, j, km)*qe1(i, km+1) .LT. 0.) qe1(i, km+1) = 0.
3572 IF (q2(i, j, km)*qe2(i, km+1) .LT. 0.) qe2(i, km+1) = 0.
3577 q1e(i, j, k) = qe1(i, k)
3578 q2e(i, j, k) = qe2(i, k)
3586 & , delz_tl, pt, pt_tl, phis, pkc, pkc_tl, gz, gz_tl, pk3, pk3_tl, npx&
3587 & , npy, npz, nested, pkc_pertn, computepk3, fullhalo, bd)
3591 INTEGER,
INTENT(IN) :: npx, npy, npz
3592 LOGICAL,
INTENT(IN) :: pkc_pertn, computepk3, fullhalo, nested
3593 REAL,
INTENT(IN) :: ptop, kappa, cp,
grav 3595 REAL,
INTENT(IN) :: phis(bd%isd:bd%ied, bd%jsd:bd%jed)
3596 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, npz),
INTENT(IN) :: pt&
3598 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, npz),
INTENT(IN) :: &
3599 & pt_tl, delp_tl, delz_tl
3600 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1),
INTENT(INOUT) &
3602 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1),
INTENT(INOUT) &
3603 & :: gz_tl, pkc_tl, pk3_tl
3607 REAL :: ptk, rgrav, rkap, peln1, rdg
3608 REAL,
DIMENSION(bd%isd:bd%ied, npz+1, bd%jsd:bd%jed) :: pe, peln
3609 REAL,
DIMENSION(bd%isd:bd%ied, npz+1, bd%jsd:bd%jed) :: pe_tl, &
3611 REAL,
DIMENSION(bd%isd:bd%ied, npz) :: gam, bb, dd, pkz
3612 REAL,
DIMENSION(bd%isd:bd%ied, npz) :: gam_tl, bb_tl, dd_tl, pkz_tl
3613 REAL,
DIMENSION(bd%isd:bd%ied, npz-1) :: g_rat
3614 REAL,
DIMENSION(bd%isd:bd%ied, npz-1) :: g_rat_tl
3615 REAL,
DIMENSION(bd%isd:bd%ied) :: bet
3616 REAL,
DIMENSION(bd%isd:bd%ied) :: bet_tl
3619 INTEGER :: ifirst, ilast, jfirst, jlast
3620 INTEGER :: is, ie, js, je
3621 INTEGER :: isd, ied, jsd, jed
3636 IF (.NOT.nested)
THEN 3646 gama = 1./(1.-kappa)
3650 rdg = -(
rdgas*rgrav)
3664 gz_tl(i, j, npz+1) = 0.0
3665 gz(i, j, npz+1) = phis(i, j)
3669 gz_tl(i, j, k) = gz_tl(i, j, k+1) -
grav*delz_tl(i, j, k)
3670 gz(i, j, k) = gz(i, j, k+1) - delz(i, j, k)*
grav 3675 pe_tl(i, 1, j) = 0.0
3677 peln_tl(i, 1, j) = 0.0
3678 peln(i, 1, j) = peln1
3682 pe_tl(i, k, j) = pe_tl(i, k-1, j) + delp_tl(i, j, k-1)
3683 pe(i, k, j) = pe(i, k-1, j) + delp(i, j, k-1)
3684 peln_tl(i, k, j) = pe_tl(i, k, j)/pe(i, k, j)
3685 peln(i, k, j) = log(pe(i, k, j))
3692 arg1_tl = -(
rdgas*((rgrav*delp_tl(i, j, k)*delz(i, j, k)-&
3693 & delp(i, j, k)*rgrav*delz_tl(i, j, k))*pt(i, j, k)/delz(i&
3694 & , j, k)**2+delp(i, j, k)*rgrav*pt_tl(i, j, k)/delz(i, j&
3696 arg1 = -(delp(i, j, k)*rgrav/delz(i, j, k)*
rdgas*pt(i, j, &
3698 arg2_tl = gama*arg1_tl/arg1
3699 arg2 = gama*log(arg1)
3700 pkz_tl(i, k) = arg2_tl*exp(arg2)
3701 pkz(i, k) = exp(arg2)
3703 pm_tl = (delp_tl(i, j, k)*(peln(i, k+1, j)-peln(i, k, j))-&
3704 & delp(i, j, k)*(peln_tl(i, k+1, j)-peln_tl(i, k, j)))/(&
3705 & peln(i, k+1, j)-peln(i, k, j))**2
3706 pm = delp(i, j, k)/(peln(i, k+1, j)-peln(i, k, j))
3708 pkz_tl(i, k) = pkz_tl(i, k) - pm_tl
3709 pkz(i, k) = pkz(i, k) - pm
3715 g_rat_tl(i, k) = (delp_tl(i, j, k)*delp(i, j, k+1)-delp(i&
3716 & , j, k)*delp_tl(i, j, k+1))/delp(i, j, k+1)**2
3717 g_rat(i, k) = delp(i, j, k)/delp(i, j, k+1)
3718 bb_tl(i, k) = 2.*g_rat_tl(i, k)
3719 bb(i, k) = 2.*(1.+g_rat(i, k))
3720 dd_tl(i, k) = 3.*(pkz_tl(i, k)+g_rat_tl(i, k)*pkz(i, k+1)+&
3721 & g_rat(i, k)*pkz_tl(i, k+1))
3722 dd(i, k) = 3.*(pkz(i, k)+g_rat(i, k)*pkz(i, k+1))
3726 bet_tl(i) = bb_tl(i, 1)
3728 pkc_tl(i, j, 1) = 0.0
3730 pkc_tl(i, j, 2) = (dd_tl(i, 1)*bet(i)-dd(i, 1)*bet_tl(i))/&
3732 pkc(i, j, 2) = dd(i, 1)/bet(i)
3735 dd_tl(i, npz) = 3.*pkz_tl(i, npz)
3736 dd(i, npz) = 3.*pkz(i, npz)
3740 gam_tl(i, k) = (g_rat_tl(i, k-1)*bet(i)-g_rat(i, k-1)*&
3741 & bet_tl(i))/bet(i)**2
3742 gam(i, k) = g_rat(i, k-1)/bet(i)
3743 bet_tl(i) = bb_tl(i, k) - gam_tl(i, k)
3744 bet(i) = bb(i, k) - gam(i, k)
3745 pkc_tl(i, j, k+1) = ((dd_tl(i, k)-pkc_tl(i, j, k))*bet(i)-&
3746 & (dd(i, k)-pkc(i, j, k))*bet_tl(i))/bet(i)**2
3747 pkc(i, j, k+1) = (dd(i, k)-pkc(i, j, k))/bet(i)
3752 pkc_tl(i, j, k) = pkc_tl(i, j, k) - gam_tl(i, k)*pkc(i, j&
3753 & , k+1) - gam(i, k)*pkc_tl(i, j, k+1)
3754 pkc(i, j, k) = pkc(i, j, k) - gam(i, k)*pkc(i, j, k+1)
3759 IF (.NOT.pkc_pertn)
THEN 3762 pkc_tl(i, j, k) = pkc_tl(i, j, k) + pe_tl(i, k, j)
3763 pkc(i, j, k) = pkc(i, j, k) + pe(i, k, j)
3768 IF (computepk3)
THEN 3770 pk3_tl(i, j, 1) = 0.0
3775 arg1_tl = kappa*pe_tl(i, k, j)/pe(i, k, j)
3776 arg1 = kappa*log(pe(i, k, j))
3777 pk3_tl(i, j, k) = arg1_tl*exp(arg1)
3778 pk3(i, j, k) = exp(arg1)
3793 IF (ie .EQ. npx - 1)
THEN 3797 gz_tl(i, j, npz+1) = 0.0
3798 gz(i, j, npz+1) = phis(i, j)
3802 gz_tl(i, j, k) = gz_tl(i, j, k+1) -
grav*delz_tl(i, j, k)
3803 gz(i, j, k) = gz(i, j, k+1) - delz(i, j, k)*
grav 3808 pe_tl(i, 1, j) = 0.0
3810 peln_tl(i, 1, j) = 0.0
3811 peln(i, 1, j) = peln1
3815 pe_tl(i, k, j) = pe_tl(i, k-1, j) + delp_tl(i, j, k-1)
3816 pe(i, k, j) = pe(i, k-1, j) + delp(i, j, k-1)
3817 peln_tl(i, k, j) = pe_tl(i, k, j)/pe(i, k, j)
3818 peln(i, k, j) = log(pe(i, k, j))
3825 arg1_tl = -(
rdgas*((rgrav*delp_tl(i, j, k)*delz(i, j, k)-&
3826 & delp(i, j, k)*rgrav*delz_tl(i, j, k))*pt(i, j, k)/delz(i&
3827 & , j, k)**2+delp(i, j, k)*rgrav*pt_tl(i, j, k)/delz(i, j&
3829 arg1 = -(delp(i, j, k)*rgrav/delz(i, j, k)*
rdgas*pt(i, j, &
3831 arg2_tl = gama*arg1_tl/arg1
3832 arg2 = gama*log(arg1)
3833 pkz_tl(i, k) = arg2_tl*exp(arg2)
3834 pkz(i, k) = exp(arg2)
3836 pm_tl = (delp_tl(i, j, k)*(peln(i, k+1, j)-peln(i, k, j))-&
3837 & delp(i, j, k)*(peln_tl(i, k+1, j)-peln_tl(i, k, j)))/(&
3838 & peln(i, k+1, j)-peln(i, k, j))**2
3839 pm = delp(i, j, k)/(peln(i, k+1, j)-peln(i, k, j))
3841 pkz_tl(i, k) = pkz_tl(i, k) - pm_tl
3842 pkz(i, k) = pkz(i, k) - pm
3848 g_rat_tl(i, k) = (delp_tl(i, j, k)*delp(i, j, k+1)-delp(i&
3849 & , j, k)*delp_tl(i, j, k+1))/delp(i, j, k+1)**2
3850 g_rat(i, k) = delp(i, j, k)/delp(i, j, k+1)
3851 bb_tl(i, k) = 2.*g_rat_tl(i, k)
3852 bb(i, k) = 2.*(1.+g_rat(i, k))
3853 dd_tl(i, k) = 3.*(pkz_tl(i, k)+g_rat_tl(i, k)*pkz(i, k+1)+&
3854 & g_rat(i, k)*pkz_tl(i, k+1))
3855 dd(i, k) = 3.*(pkz(i, k)+g_rat(i, k)*pkz(i, k+1))
3859 bet_tl(i) = bb_tl(i, 1)
3861 pkc_tl(i, j, 1) = 0.0
3863 pkc_tl(i, j, 2) = (dd_tl(i, 1)*bet(i)-dd(i, 1)*bet_tl(i))/&
3865 pkc(i, j, 2) = dd(i, 1)/bet(i)
3868 dd_tl(i, npz) = 3.*pkz_tl(i, npz)
3869 dd(i, npz) = 3.*pkz(i, npz)
3873 gam_tl(i, k) = (g_rat_tl(i, k-1)*bet(i)-g_rat(i, k-1)*&
3874 & bet_tl(i))/bet(i)**2
3875 gam(i, k) = g_rat(i, k-1)/bet(i)
3876 bet_tl(i) = bb_tl(i, k) - gam_tl(i, k)
3877 bet(i) = bb(i, k) - gam(i, k)
3878 pkc_tl(i, j, k+1) = ((dd_tl(i, k)-pkc_tl(i, j, k))*bet(i)-&
3879 & (dd(i, k)-pkc(i, j, k))*bet_tl(i))/bet(i)**2
3880 pkc(i, j, k+1) = (dd(i, k)-pkc(i, j, k))/bet(i)
3885 pkc_tl(i, j, k) = pkc_tl(i, j, k) - gam_tl(i, k)*pkc(i, j&
3886 & , k+1) - gam(i, k)*pkc_tl(i, j, k+1)
3887 pkc(i, j, k) = pkc(i, j, k) - gam(i, k)*pkc(i, j, k+1)
3892 IF (.NOT.pkc_pertn)
THEN 3895 pkc_tl(i, j, k) = pkc_tl(i, j, k) + pe_tl(i, k, j)
3896 pkc(i, j, k) = pkc(i, j, k) + pe(i, k, j)
3901 IF (computepk3)
THEN 3903 pk3_tl(i, j, 1) = 0.0
3908 arg1_tl = kappa*pe_tl(i, k, j)/pe(i, k, j)
3909 arg1 = kappa*log(pe(i, k, j))
3910 pk3_tl(i, j, k) = arg1_tl*exp(arg1)
3911 pk3(i, j, k) = exp(arg1)
3921 gz_tl(i, j, npz+1) = 0.0
3922 gz(i, j, npz+1) = phis(i, j)
3926 gz_tl(i, j, k) = gz_tl(i, j, k+1) -
grav*delz_tl(i, j, k)
3927 gz(i, j, k) = gz(i, j, k+1) - delz(i, j, k)*
grav 3932 pe_tl(i, 1, j) = 0.0
3934 peln_tl(i, 1, j) = 0.0
3935 peln(i, 1, j) = peln1
3939 pe_tl(i, k, j) = pe_tl(i, k-1, j) + delp_tl(i, j, k-1)
3940 pe(i, k, j) = pe(i, k-1, j) + delp(i, j, k-1)
3941 peln_tl(i, k, j) = pe_tl(i, k, j)/pe(i, k, j)
3942 peln(i, k, j) = log(pe(i, k, j))
3949 arg1_tl = -(
rdgas*((rgrav*delp_tl(i, j, k)*delz(i, j, k)-&
3950 & delp(i, j, k)*rgrav*delz_tl(i, j, k))*pt(i, j, k)/delz(i&
3951 & , j, k)**2+delp(i, j, k)*rgrav*pt_tl(i, j, k)/delz(i, j&
3953 arg1 = -(delp(i, j, k)*rgrav/delz(i, j, k)*
rdgas*pt(i, j, &
3955 arg2_tl = gama*arg1_tl/arg1
3956 arg2 = gama*log(arg1)
3957 pkz_tl(i, k) = arg2_tl*exp(arg2)
3958 pkz(i, k) = exp(arg2)
3960 pm = delp(i, j, k)/(peln(i, k+1, j)-peln(i, k, j))
3962 pm_tl = (delp_tl(i, j, k)*(peln(i, k+1, j)-peln(i, k, j))-&
3963 & delp(i, j, k)*(peln_tl(i, k+1, j)-peln_tl(i, k, j)))/(&
3964 & peln(i, k+1, j)-peln(i, k, j))**2
3965 pm = delp(i, j, k)/(peln(i, k+1, j)-peln(i, k, j))
3967 pkz_tl(i, k) = pkz_tl(i, k) - pm_tl
3968 pkz(i, k) = pkz(i, k) - pm
3974 g_rat_tl(i, k) = (delp_tl(i, j, k)*delp(i, j, k+1)-delp(i&
3975 & , j, k)*delp_tl(i, j, k+1))/delp(i, j, k+1)**2
3976 g_rat(i, k) = delp(i, j, k)/delp(i, j, k+1)
3977 bb_tl(i, k) = 2.*g_rat_tl(i, k)
3978 bb(i, k) = 2.*(1.+g_rat(i, k))
3979 dd_tl(i, k) = 3.*(pkz_tl(i, k)+g_rat_tl(i, k)*pkz(i, k+1)+&
3980 & g_rat(i, k)*pkz_tl(i, k+1))
3981 dd(i, k) = 3.*(pkz(i, k)+g_rat(i, k)*pkz(i, k+1))
3985 bet_tl(i) = bb_tl(i, 1)
3987 pkc_tl(i, j, 1) = 0.0
3989 pkc_tl(i, j, 2) = (dd_tl(i, 1)*bet(i)-dd(i, 1)*bet_tl(i))/&
3991 pkc(i, j, 2) = dd(i, 1)/bet(i)
3994 dd_tl(i, npz) = 3.*pkz_tl(i, npz)
3995 dd(i, npz) = 3.*pkz(i, npz)
3999 gam_tl(i, k) = (g_rat_tl(i, k-1)*bet(i)-g_rat(i, k-1)*&
4000 & bet_tl(i))/bet(i)**2
4001 gam(i, k) = g_rat(i, k-1)/bet(i)
4002 bet_tl(i) = bb_tl(i, k) - gam_tl(i, k)
4003 bet(i) = bb(i, k) - gam(i, k)
4004 pkc_tl(i, j, k+1) = ((dd_tl(i, k)-pkc_tl(i, j, k))*bet(i)-&
4005 & (dd(i, k)-pkc(i, j, k))*bet_tl(i))/bet(i)**2
4006 pkc(i, j, k+1) = (dd(i, k)-pkc(i, j, k))/bet(i)
4011 pkc_tl(i, j, k) = pkc_tl(i, j, k) - gam_tl(i, k)*pkc(i, j&
4012 & , k+1) - gam(i, k)*pkc_tl(i, j, k+1)
4013 pkc(i, j, k) = pkc(i, j, k) - gam(i, k)*pkc(i, j, k+1)
4018 IF (.NOT.pkc_pertn)
THEN 4021 pkc_tl(i, j, k) = pkc_tl(i, j, k) + pe_tl(i, k, j)
4022 pkc(i, j, k) = pkc(i, j, k) + pe(i, k, j)
4027 IF (computepk3)
THEN 4029 pk3_tl(i, j, 1) = 0.0
4034 arg1_tl = kappa*pe_tl(i, k, j)/pe(i, k, j)
4035 arg1 = kappa*log(pe(i, k, j))
4036 pk3_tl(i, j, k) = arg1_tl*exp(arg1)
4037 pk3(i, j, k) = exp(arg1)
4043 IF (je .EQ. npy - 1)
THEN 4047 gz_tl(i, j, npz+1) = 0.0
4048 gz(i, j, npz+1) = phis(i, j)
4052 gz_tl(i, j, k) = gz_tl(i, j, k+1) -
grav*delz_tl(i, j, k)
4053 gz(i, j, k) = gz(i, j, k+1) - delz(i, j, k)*
grav 4058 pe_tl(i, 1, j) = 0.0
4060 peln_tl(i, 1, j) = 0.0
4061 peln(i, 1, j) = peln1
4065 pe_tl(i, k, j) = pe_tl(i, k-1, j) + delp_tl(i, j, k-1)
4066 pe(i, k, j) = pe(i, k-1, j) + delp(i, j, k-1)
4067 peln_tl(i, k, j) = pe_tl(i, k, j)/pe(i, k, j)
4068 peln(i, k, j) = log(pe(i, k, j))
4075 arg1_tl = -(
rdgas*((rgrav*delp_tl(i, j, k)*delz(i, j, k)-&
4076 & delp(i, j, k)*rgrav*delz_tl(i, j, k))*pt(i, j, k)/delz(i&
4077 & , j, k)**2+delp(i, j, k)*rgrav*pt_tl(i, j, k)/delz(i, j&
4079 arg1 = -(delp(i, j, k)*rgrav/delz(i, j, k)*
rdgas*pt(i, j, &
4081 arg2_tl = gama*arg1_tl/arg1
4082 arg2 = gama*log(arg1)
4083 pkz_tl(i, k) = arg2_tl*exp(arg2)
4084 pkz(i, k) = exp(arg2)
4086 pm = delp(i, j, k)/(peln(i, k+1, j)-peln(i, k, j))
4088 pm_tl = (delp_tl(i, j, k)*(peln(i, k+1, j)-peln(i, k, j))-&
4089 & delp(i, j, k)*(peln_tl(i, k+1, j)-peln_tl(i, k, j)))/(&
4090 & peln(i, k+1, j)-peln(i, k, j))**2
4091 pm = delp(i, j, k)/(peln(i, k+1, j)-peln(i, k, j))
4093 pkz_tl(i, k) = pkz_tl(i, k) - pm_tl
4094 pkz(i, k) = pkz(i, k) - pm
4101 g_rat_tl(i, k) = (delp_tl(i, j, k)*delp(i, j, k+1)-delp(i&
4102 & , j, k)*delp_tl(i, j, k+1))/delp(i, j, k+1)**2
4103 g_rat(i, k) = delp(i, j, k)/delp(i, j, k+1)
4104 bb_tl(i, k) = 2.*g_rat_tl(i, k)
4105 bb(i, k) = 2.*(1.+g_rat(i, k))
4106 dd_tl(i, k) = 3.*(pkz_tl(i, k)+g_rat_tl(i, k)*pkz(i, k+1)+&
4107 & g_rat(i, k)*pkz_tl(i, k+1))
4108 dd(i, k) = 3.*(pkz(i, k)+g_rat(i, k)*pkz(i, k+1))
4112 bet_tl(i) = bb_tl(i, 1)
4114 pkc_tl(i, j, 1) = 0.0
4116 pkc_tl(i, j, 2) = (dd_tl(i, 1)*bet(i)-dd(i, 1)*bet_tl(i))/&
4118 pkc(i, j, 2) = dd(i, 1)/bet(i)
4121 dd_tl(i, npz) = 3.*pkz_tl(i, npz)
4122 dd(i, npz) = 3.*pkz(i, npz)
4126 gam_tl(i, k) = (g_rat_tl(i, k-1)*bet(i)-g_rat(i, k-1)*&
4127 & bet_tl(i))/bet(i)**2
4128 gam(i, k) = g_rat(i, k-1)/bet(i)
4129 bet_tl(i) = bb_tl(i, k) - gam_tl(i, k)
4130 bet(i) = bb(i, k) - gam(i, k)
4131 pkc_tl(i, j, k+1) = ((dd_tl(i, k)-pkc_tl(i, j, k))*bet(i)-&
4132 & (dd(i, k)-pkc(i, j, k))*bet_tl(i))/bet(i)**2
4133 pkc(i, j, k+1) = (dd(i, k)-pkc(i, j, k))/bet(i)
4138 pkc_tl(i, j, k) = pkc_tl(i, j, k) - gam_tl(i, k)*pkc(i, j&
4139 & , k+1) - gam(i, k)*pkc_tl(i, j, k+1)
4140 pkc(i, j, k) = pkc(i, j, k) - gam(i, k)*pkc(i, j, k+1)
4145 IF (.NOT.pkc_pertn)
THEN 4148 pkc_tl(i, j, k) = pkc_tl(i, j, k) + pe_tl(i, k, j)
4149 pkc(i, j, k) = pkc(i, j, k) + pe(i, k, j)
4154 IF (computepk3)
THEN 4156 pk3_tl(i, j, 1) = 0.0
4161 arg1_tl = kappa*pe_tl(i, k, j)/pe(i, k, j)
4162 arg1 = kappa*log(pe(i, k, j))
4163 pk3_tl(i, j, k) = arg1_tl*exp(arg1)
4164 pk3(i, j, k) = exp(arg1)
4172 SUBROUTINE nest_halo_nh(ptop, grav, kappa, cp, delp, delz, pt, phis, &
4173 & pkc, gz, pk3, npx, npy, npz, nested, pkc_pertn, computepk3, fullhalo&
4178 INTEGER,
INTENT(IN) :: npx, npy, npz
4179 LOGICAL,
INTENT(IN) :: pkc_pertn, computepk3, fullhalo, nested
4180 REAL,
INTENT(IN) :: ptop, kappa, cp,
grav 4182 REAL,
INTENT(IN) :: phis(bd%isd:bd%ied, bd%jsd:bd%jed)
4183 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, npz),
INTENT(IN) :: pt&
4185 REAL,
DIMENSION(bd%isd:bd%ied, bd%jsd:bd%jed, npz+1),
INTENT(INOUT) &
4190 REAL :: ptk, rgrav, rkap, peln1, rdg
4191 REAL,
DIMENSION(bd%isd:bd%ied, npz+1, bd%jsd:bd%jed) :: pe, peln
4192 REAL,
DIMENSION(bd%isd:bd%ied, npz) :: gam, bb, dd, pkz
4193 REAL,
DIMENSION(bd%isd:bd%ied, npz-1) :: g_rat
4194 REAL,
DIMENSION(bd%isd:bd%ied) :: bet
4196 INTEGER :: ifirst, ilast, jfirst, jlast
4197 INTEGER :: is, ie, js, je
4198 INTEGER :: isd, ied, jsd, jed
4211 IF (.NOT.nested)
THEN 4221 gama = 1./(1.-kappa)
4225 rdg = -(
rdgas*rgrav)
4231 gz(i, j, npz+1) = phis(i, j)
4235 gz(i, j, k) = gz(i, j, k+1) - delz(i, j, k)*
grav 4241 peln(i, 1, j) = peln1
4245 pe(i, k, j) = pe(i, k-1, j) + delp(i, j, k-1)
4246 peln(i, k, j) = log(pe(i, k, j))
4253 arg1 = -(delp(i, j, k)*rgrav/delz(i, j, k)*
rdgas*pt(i, j, &
4255 arg2 = gama*log(arg1)
4256 pkz(i, k) = exp(arg2)
4258 pm = delp(i, j, k)/(peln(i, k+1, j)-peln(i, k, j))
4260 pkz(i, k) = pkz(i, k) - pm
4266 g_rat(i, k) = delp(i, j, k)/delp(i, j, k+1)
4267 bb(i, k) = 2.*(1.+g_rat(i, k))
4268 dd(i, k) = 3.*(pkz(i, k)+g_rat(i, k)*pkz(i, k+1))
4274 pkc(i, j, 2) = dd(i, 1)/bet(i)
4276 dd(i, npz) = 3.*pkz(i, npz)
4280 gam(i, k) = g_rat(i, k-1)/bet(i)
4281 bet(i) = bb(i, k) - gam(i, k)
4282 pkc(i, j, k+1) = (dd(i, k)-pkc(i, j, k))/bet(i)
4287 pkc(i, j, k) = pkc(i, j, k) - gam(i, k)*pkc(i, j, k+1)
4292 IF (.NOT.pkc_pertn)
THEN 4295 pkc(i, j, k) = pkc(i, j, k) + pe(i, k, j)
4300 IF (computepk3)
THEN 4306 arg1 = kappa*log(pe(i, k, j))
4307 pk3(i, j, k) = exp(arg1)
4313 IF (ie .EQ. npx - 1)
THEN 4317 gz(i, j, npz+1) = phis(i, j)
4321 gz(i, j, k) = gz(i, j, k+1) - delz(i, j, k)*
grav 4327 peln(i, 1, j) = peln1
4331 pe(i, k, j) = pe(i, k-1, j) + delp(i, j, k-1)
4332 peln(i, k, j) = log(pe(i, k, j))
4339 arg1 = -(delp(i, j, k)*rgrav/delz(i, j, k)*
rdgas*pt(i, j, &
4341 arg2 = gama*log(arg1)
4342 pkz(i, k) = exp(arg2)
4344 pm = delp(i, j, k)/(peln(i, k+1, j)-peln(i, k, j))
4346 pkz(i, k) = pkz(i, k) - pm
4352 g_rat(i, k) = delp(i, j, k)/delp(i, j, k+1)
4353 bb(i, k) = 2.*(1.+g_rat(i, k))
4354 dd(i, k) = 3.*(pkz(i, k)+g_rat(i, k)*pkz(i, k+1))
4360 pkc(i, j, 2) = dd(i, 1)/bet(i)
4362 dd(i, npz) = 3.*pkz(i, npz)
4366 gam(i, k) = g_rat(i, k-1)/bet(i)
4367 bet(i) = bb(i, k) - gam(i, k)
4368 pkc(i, j, k+1) = (dd(i, k)-pkc(i, j, k))/bet(i)
4373 pkc(i, j, k) = pkc(i, j, k) - gam(i, k)*pkc(i, j, k+1)
4378 IF (.NOT.pkc_pertn)
THEN 4381 pkc(i, j, k) = pkc(i, j, k) + pe(i, k, j)
4386 IF (computepk3)
THEN 4392 arg1 = kappa*log(pe(i, k, j))
4393 pk3(i, j, k) = exp(arg1)
4403 gz(i, j, npz+1) = phis(i, j)
4407 gz(i, j, k) = gz(i, j, k+1) - delz(i, j, k)*
grav 4413 peln(i, 1, j) = peln1
4417 pe(i, k, j) = pe(i, k-1, j) + delp(i, j, k-1)
4418 peln(i, k, j) = log(pe(i, k, j))
4425 arg1 = -(delp(i, j, k)*rgrav/delz(i, j, k)*
rdgas*pt(i, j, &
4427 arg2 = gama*log(arg1)
4428 pkz(i, k) = exp(arg2)
4430 pm = delp(i, j, k)/(peln(i, k+1, j)-peln(i, k, j))
4432 pm = delp(i, j, k)/(peln(i, k+1, j)-peln(i, k, j))
4434 pkz(i, k) = pkz(i, k) - pm
4440 g_rat(i, k) = delp(i, j, k)/delp(i, j, k+1)
4441 bb(i, k) = 2.*(1.+g_rat(i, k))
4442 dd(i, k) = 3.*(pkz(i, k)+g_rat(i, k)*pkz(i, k+1))
4448 pkc(i, j, 2) = dd(i, 1)/bet(i)
4450 dd(i, npz) = 3.*pkz(i, npz)
4454 gam(i, k) = g_rat(i, k-1)/bet(i)
4455 bet(i) = bb(i, k) - gam(i, k)
4456 pkc(i, j, k+1) = (dd(i, k)-pkc(i, j, k))/bet(i)
4461 pkc(i, j, k) = pkc(i, j, k) - gam(i, k)*pkc(i, j, k+1)
4466 IF (.NOT.pkc_pertn)
THEN 4469 pkc(i, j, k) = pkc(i, j, k) + pe(i, k, j)
4474 IF (computepk3)
THEN 4480 arg1 = kappa*log(pe(i, k, j))
4481 pk3(i, j, k) = exp(arg1)
4487 IF (je .EQ. npy - 1)
THEN 4491 gz(i, j, npz+1) = phis(i, j)
4495 gz(i, j, k) = gz(i, j, k+1) - delz(i, j, k)*
grav 4501 peln(i, 1, j) = peln1
4505 pe(i, k, j) = pe(i, k-1, j) + delp(i, j, k-1)
4506 peln(i, k, j) = log(pe(i, k, j))
4513 arg1 = -(delp(i, j, k)*rgrav/delz(i, j, k)*
rdgas*pt(i, j, &
4515 arg2 = gama*log(arg1)
4516 pkz(i, k) = exp(arg2)
4518 pm = delp(i, j, k)/(peln(i, k+1, j)-peln(i, k, j))
4520 pm = delp(i, j, k)/(peln(i, k+1, j)-peln(i, k, j))
4522 pkz(i, k) = pkz(i, k) - pm
4529 g_rat(i, k) = delp(i, j, k)/delp(i, j, k+1)
4530 bb(i, k) = 2.*(1.+g_rat(i, k))
4531 dd(i, k) = 3.*(pkz(i, k)+g_rat(i, k)*pkz(i, k+1))
4537 pkc(i, j, 2) = dd(i, 1)/bet(i)
4539 dd(i, npz) = 3.*pkz(i, npz)
4543 gam(i, k) = g_rat(i, k-1)/bet(i)
4544 bet(i) = bb(i, k) - gam(i, k)
4545 pkc(i, j, k+1) = (dd(i, k)-pkc(i, j, k))/bet(i)
4550 pkc(i, j, k) = pkc(i, j, k) - gam(i, k)*pkc(i, j, k+1)
4555 IF (.NOT.pkc_pertn)
THEN 4558 pkc(i, j, k) = pkc(i, j, k) + pe(i, k, j)
4563 IF (computepk3)
THEN 4569 arg1 = kappa*log(pe(i, k, j))
4570 pk3(i, j, k) = exp(arg1)
subroutine edge_scalar(q1, qe, i1, i2, km, id)
subroutine, public nest_halo_nh_tlm(ptop, grav, kappa, cp, delp, delp_tl, delz, delz_tl, pt, pt_tl, phis, pkc, pkc_tl, gz, gz_tl, pk3, pk3_tl, npx, npy, npz, nested, pkc_pertn, computepk3, fullhalo, bd)
subroutine, public fv_tp_2d_tlm(q, q_tl, crx, crx_tl, cry, cry_tl, npx, npy, hord, fx, fx_tl, fy, fy_tl, xfx, xfx_tl, yfx, yfx_tl, gridstruct, bd, ra_x, ra_x_tl, ra_y, ra_y_tl, mfx, mfx_tl, mfy, mfy_tl, mass, mass_tl, nord, damp_c)
subroutine, public riem_solver_c(ms, dt, is, ie, js, je, km, ng, akap, cappa, cp, ptop, hs, w3, pt, q_con, delp, gz, pef, ws, p_fac, a_imp, scale_m)
subroutine, public sim1_solver_tlm(dt, is, ie, km, rgas, gama, gm2, cp2, kappa, pe, pe_tl, dm2, dm2_tl, pm2, pm2_tl, pem, pem_tl, w2, w2_tl, dz2, dz2_tl, pt2, pt2_tl, ws, ws_tl, p_fac)
subroutine, public fill_4corners_tlm(q, q_tl, dir, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
subroutine, public update_dz_d(ndif, damp, hord, is, ie, js, je, km, ng, npx, npy, area, rarea, dp0, zs, zh, crx, cry, xfx, yfx, delz, ws, rdt, gridstruct, bd, hord_pert)
subroutine, public fill_4corners(q, dir, bd, npx, npy, sw_corner, se_corner, ne_corner, nw_corner)
real, parameter, public rdgas
Gas constant for dry air [J/kg/deg].
subroutine, public sim3_solver(dt, is, ie, km, rgas, gama, kappa, pe2, dm, pem, w2, dz2, pt2, ws, alpha, p_fac, scale_m)
subroutine edge_profile(q1, q2, q1e, q2e, i1, i2, j1, j2, j, km, dp0, uniform_grid, limiter)
subroutine, public sim3p0_solver(dt, is, ie, km, rgas, gama, kappa, pe2, dm, pem, w2, dz2, pt2, ws, p_fac, scale_m)
subroutine, public update_dz_d_tlm(ndif, damp, hord, is, ie, js, je, km, ng, npx, npy, area, rarea, dp0, zs, zh, zh_tl, crx, crx_tl, cry, cry_tl, xfx, xfx_tl, yfx, yfx_tl, delz, ws, ws_tl, rdt, gridstruct, bd, hord_pert)
real, parameter, public cp_air
Specific heat capacity of dry air at constant pressure [J/kg/deg].
subroutine, public update_dz_c(is, ie, js, je, km, ng, dt, dp0, zs, area, ut, vt, gz, ws, npx, npy, sw_corner, se_corner, ne_corner, nw_corner, bd, grid_type)
subroutine, public sim_solver(dt, is, ie, km, rgas, gama, gm2, cp2, kappa, pe2, dm2, pm2, pem, w2, dz2, pt2, ws, alpha, p_fac, scale_m)
subroutine, public riem_solver_c_tlm(ms, dt, is, ie, js, je, km, ng, akap, cappa, cp, ptop, hs, w3, w3_tl, pt, pt_tl, q_con, delp, delp_tl, gz, gz_tl, pef, pef_tl, ws, ws_tl, p_fac, a_imp, scale_m)
subroutine, public sim3_solver_tlm(dt, is, ie, km, rgas, gama, kappa, pe2, pe2_tl, dm, dm_tl, pem, pem_tl, w2, w2_tl, dz2, dz2_tl, pt2, pt2_tl, ws, ws_tl, alpha, p_fac, scale_m)
real, parameter, public grav
Acceleration due to gravity [m/s^2].
subroutine, public rim_2d_tlm(ms, bdt, is, ie, km, rgas, gama, gm2, pe2, pe2_tl, dm2, dm2_tl, pm2, pm2_tl, w2, w2_tl, dz2, dz2_tl, pt2, pt2_tl, ws, ws_tl, c_core)
subroutine, public del6_vt_flux_tlm(nord, npx, npy, damp, q, q_tl, d2, d2_tl, fx2, fx2_tl, fy2, fy2_tl, gridstruct, bd)
subroutine, public fv_tp_2d(q, crx, cry, npx, npy, hord, fx, fy, xfx, yfx, gridstruct, bd, ra_x, ra_y, mfx, mfy, mass, nord, damp_c)
subroutine edge_profile_tlm(q1, q1_tl, q2, q2_tl, q1e, q1e_tl, q2e, q2e_tl, i1, i2, j1, j2, j, km, dp0, uniform_grid, limiter)
subroutine, public del6_vt_flux(nord, npx, npy, damp, q, d2, fx2, fy2, gridstruct, bd)
subroutine, public update_dz_c_tlm(is, ie, js, je, km, ng, dt, dp0, zs, area, ut, ut_tl, vt, vt_tl, gz, gz_tl, ws, ws_tl, npx, npy, sw_corner, se_corner, ne_corner, nw_corner, bd, grid_type)
subroutine, public rim_2d(ms, bdt, is, ie, km, rgas, gama, gm2, pe2, dm2, pm2, w2, dz2, pt2, ws, c_core)
subroutine, public sim_solver_tlm(dt, is, ie, km, rgas, gama, gm2, cp2, kappa, pe2, pe2_tl, dm2, dm2_tl, pm2, pm2_tl, pem, pem_tl, w2, w2_tl, dz2, dz2_tl, pt2, pt2_tl, ws, ws_tl, alpha, p_fac, scale_m)
Derived type containing the data.
subroutine riem_solver3test(ms, dt, is, ie, js, je, km, ng, isd, ied, jsd, jed, akap, cappa, cp, ptop, zs, q_con, w, delz, pt, delp, zh, pe, ppe, pk3, pk, peln, ws, scale_m, p_fac, a_imp, use_logp, last_call, fp_out)
subroutine imp_diff_w(j, is, ie, js, je, ng, km, cd, delz, ws, w, w3)
subroutine, public sim3p0_solver_tlm(dt, is, ie, km, rgas, gama, kappa, pe2, pe2_tl, dm, dm_tl, pem, pem_tl, w2, w2_tl, dz2, dz2_tl, pt2, pt2_tl, ws, ws_tl, p_fac, scale_m)
subroutine, public nest_halo_nh(ptop, grav, kappa, cp, delp, delz, pt, phis, pkc, gz, pk3, npx, npy, npz, nested, pkc_pertn, computepk3, fullhalo, bd)
subroutine, public sim1_solver(dt, is, ie, km, rgas, gama, gm2, cp2, kappa, pe, dm2, pm2, pem, w2, dz2, pt2, ws, p_fac)