72 & domain, npx, npy, npz, nq, hord, q_split, dt, id_divg, q_pack, &
73 & nord_tr, trdm, hord_pert, nord_tr_pert, trdm_pert, split_damp_tr, &
77 INTEGER,
INTENT(IN) :: npx
78 INTEGER,
INTENT(IN) :: npy
79 INTEGER,
INTENT(IN) :: npz
81 INTEGER,
INTENT(IN) :: nq
82 INTEGER,
INTENT(IN) :: hord, nord_tr
83 INTEGER,
INTENT(IN) :: hord_pert, nord_tr_pert
84 LOGICAL,
INTENT(IN) :: split_damp_tr
85 INTEGER,
INTENT(IN) :: q_split
86 INTEGER,
INTENT(IN) :: id_divg
87 REAL,
INTENT(IN) :: dt, trdm, trdm_pert
88 TYPE(group_halo_update_type),
INTENT(INOUT) :: q_pack
90 REAL,
INTENT(INOUT) :: q(bd%isd:bd%ied, bd%jsd:bd%jed, npz, nq)
92 REAL,
INTENT(INOUT) :: dp1(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
94 REAL,
INTENT(INOUT) :: mfx(bd%is:bd%ie+1, bd%js:bd%je, npz)
96 REAL,
INTENT(INOUT) :: mfy(bd%is:bd%ie, bd%js:bd%je+1, npz)
98 REAL,
INTENT(INOUT) :: cx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
100 REAL,
INTENT(INOUT) :: cy(bd%isd:bd%ied, bd%js:bd%je+1, npz)
102 REAL,
OPTIONAL,
INTENT(OUT) :: dpa(bd%is:bd%ie, bd%js:bd%je)
104 TYPE(
domain2d),
INTENT(INOUT) :: domain
107 REAL :: qn2(bd%isd:bd%ied, bd%jsd:bd%jed, nq)
108 REAL :: dp2(bd%is:bd%ie, bd%js:bd%je)
109 REAL :: fx(bd%is:bd%ie+1, bd%js:bd%je)
110 REAL :: fy(bd%is:bd%ie, bd%js:bd%je+1)
111 REAL :: ra_x(bd%is:bd%ie, bd%jsd:bd%jed)
112 REAL :: ra_y(bd%isd:bd%ied, bd%js:bd%je)
113 REAL :: xfx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
114 REAL :: yfx(bd%isd:bd%ied, bd%js:bd%je+1, npz)
118 INTEGER :: i, j, k, it, iq
119 REAL,
DIMENSION(:, :),
POINTER :: area, rarea
120 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg
121 REAL,
DIMENSION(:, :),
POINTER :: dxa, dya, dx, dy
122 INTEGER :: is, ie, js, je
123 INTEGER :: isd, ied, jsd, jed
170 area => gridstruct%area
171 rarea => gridstruct%rarea
172 sin_sg => gridstruct%sin_sg
173 dxa => gridstruct%dxa
174 dya => gridstruct%dya
182 IF (cx(i, j, k) .GT. 0.)
THEN 183 xfx(i, j, k) = cx(i, j, k)*dxa(i-1, j)*dy(i, j)*sin_sg(i-1, &
187 xfx(i, j, k) = cx(i, j, k)*dxa(i, j)*dy(i, j)*sin_sg(i, j, 1&
195 IF (cy(i, j, k) .GT. 0.)
THEN 196 yfx(i, j, k) = cy(i, j, k)*dya(i, j-1)*dx(i, j)*sin_sg(i, j-&
200 yfx(i, j, k) = cy(i, j, k)*dya(i, j)*dx(i, j)*sin_sg(i, j, 2&
207 IF (k .LT. npz/6)
THEN 210 IF (cx(i, j, k) .GE. 0.)
THEN 215 IF (cy(i, j, k) .GE. 0.)
THEN 220 IF (cmax(k) .LT. y1)
THEN 228 ELSE IF (cmax(k) .LT. z1)
THEN 241 IF (cx(i, j, k) .GE. 0.)
THEN 246 IF (cy(i, j, k) .GE. 0.)
THEN 256 y2 = max1 + 1. - sin_sg(i, j, 5)
257 IF (cmax(k) .LT. y2)
THEN 270 CALL mp_reduce_max(cmax, npz)
275 nsplt = int(1. + cmax(k))
276 IF (nsplt .GT. 1)
THEN 278 frac = 1./
REAL(nsplt)
282 cx(i, j, k) = cx(i, j, k)*frac
283 xfx(i, j, k) = xfx(i, j, k)*frac
289 mfx(i, j, k) = mfx(i, j, k)*frac
295 cy(i, j, k) = cy(i, j, k)*frac
296 yfx(i, j, k) = yfx(i, j, k)*frac
302 mfy(i, j, k) = mfy(i, j, k)*frac
316 ra_x(i, j) = area(i, j) + (xfx(i, j, k)-xfx(i+1, j, k))
318 IF (j .GE. js .AND. j .LE. je)
THEN 321 ra_y(i, j) = area(i, j) + (yfx(i, j, k)-yfx(i, j+1, k))
328 nsplt = int(1. + cmax(k))
334 dp2(i, j) = dp1(i, j, k) + (mfx(i, j, k)-mfx(i+1, j, k)+(mfy&
335 & (i, j, k)-mfy(i, j+1, k)))*rarea(i, j)
342 IF (nsplt .NE. 1)
THEN 347 qn2(i, j, iq) = q(i, j, k, iq)
354 IF (hord .EQ. hord_pert)
THEN 355 CALL fv_tp_2d_fwd(qn2(isd:ied, jsd:jed, iq), cx(is:ie+1&
356 & , jsd:jed, k), cy(isd:ied, js:je+1, k), npx&
357 & , npy, hord, fx, fy, xfx(is:ie+1, jsd:jed, &
358 & k), yfx(isd:ied, js:je+1, k), gridstruct, &
359 & bd, ra_x, ra_y, mfx=mfx(is:ie+1, js:je, k)&
360 & , mfy=mfy(is:ie, js:je+1, k))
367 CALL fv_tp_2d(qn2(isd:ied, jsd:jed, iq), cx(is:ie+1, jsd:&
368 & jed, k), cy(isd:ied, js:je+1, k), npx, npy, &
369 & hord, fx, fy, xfx(is:ie+1, jsd:jed, k), yfx(&
370 & isd:ied, js:je+1, k), gridstruct, bd, ra_x, ra_y, &
371 & mfx=mfx(is:ie+1, js:je, k), mfy=mfy(is:ie, js:je+1&
375 IF (it .LT. nsplt)
THEN 380 qn2(i, j, iq) = (qn2(i, j, iq)*dp1(i, j, k)+(fx(i, j)-&
381 & fx(i+1, j)+(fy(i, j)-fy(i, j+1)))*rarea(i, j))/dp2(i&
390 q(i, j, k, iq) = (qn2(i, j, iq)*dp1(i, j, k)+(fx(i, j)&
391 & -fx(i+1, j)+(fy(i, j)-fy(i, j+1)))*rarea(i, j))/dp2(&
398 IF (hord .EQ. hord_pert)
THEN 399 CALL fv_tp_2d_fwd(q(isd:ied, jsd:jed, k, iq), cx(is:ie+&
400 & 1, jsd:jed, k), cy(isd:ied, js:je+1, k), &
401 & npx, npy, hord, fx, fy, xfx(is:ie+1, jsd:&
402 & jed, k), yfx(isd:ied, js:je+1, k), &
403 & gridstruct, bd, ra_x, ra_y, mfx=mfx(is:ie+1&
404 & , js:je, k), mfy=mfy(is:ie, js:je+1, k))
411 CALL fv_tp_2d(q(isd:ied, jsd:jed, k, iq), cx(is:ie+1, jsd:&
412 & jed, k), cy(isd:ied, js:je+1, k), npx, npy, &
413 & hord, fx, fy, xfx(is:ie+1, jsd:jed, k), yfx(&
414 & isd:ied, js:je+1, k), gridstruct, bd, ra_x, ra_y, &
415 & mfx=mfx(is:ie+1, js:je, k), mfy=mfy(is:ie, js:je+1&
422 q(i, j, k, iq) = (q(i, j, k, iq)*dp1(i, j, k)+(fx(i, j)-&
423 & fx(i+1, j)+(fy(i, j)-fy(i, j+1)))*rarea(i, j))/dp2(i, &
431 IF (it .LT. nsplt)
THEN 436 dp1(i, j, k) = dp2(i, j)
439 CALL pushrealarray(qn2, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*&
451 CALL pushrealarray(yfx, (bd%ied-bd%isd+1)*(bd%je-bd%js+2)*npz)
454 CALL pushrealarray(qn2, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*nq)
457 CALL pushrealarray(xfx, (bd%ie-bd%is+2)*(bd%jed-bd%jsd+1)*npz)
483 & mfy_ad, cx, cx_ad, cy, cy_ad, gridstruct, bd, domain, npx, npy, npz&
484 & , nq, hord, q_split, dt, id_divg, q_pack, nord_tr, trdm, hord_pert, &
485 & nord_tr_pert, trdm_pert, split_damp_tr, dpa)
488 INTEGER,
INTENT(IN) :: npx
489 INTEGER,
INTENT(IN) :: npy
490 INTEGER,
INTENT(IN) :: npz
491 INTEGER,
INTENT(IN) :: nq
492 INTEGER,
INTENT(IN) :: hord, nord_tr
493 INTEGER,
INTENT(IN) :: hord_pert, nord_tr_pert
494 LOGICAL,
INTENT(IN) :: split_damp_tr
495 INTEGER,
INTENT(IN) :: q_split
496 INTEGER,
INTENT(IN) :: id_divg
497 REAL,
INTENT(IN) :: dt, trdm, trdm_pert
498 TYPE(group_halo_update_type),
INTENT(INOUT) :: q_pack
499 REAL,
INTENT(INOUT) :: q(bd%isd:bd%ied, bd%jsd:bd%jed, npz, nq)
500 REAL,
INTENT(INOUT) :: q_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz, nq)
501 REAL,
INTENT(INOUT) :: dp1(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
502 REAL,
INTENT(INOUT) :: dp1_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
503 REAL,
INTENT(INOUT) :: mfx(bd%is:bd%ie+1, bd%js:bd%je, npz)
504 REAL,
INTENT(INOUT) :: mfx_ad(bd%is:bd%ie+1, bd%js:bd%je, npz)
505 REAL,
INTENT(INOUT) :: mfy(bd%is:bd%ie, bd%js:bd%je+1, npz)
506 REAL,
INTENT(INOUT) :: mfy_ad(bd%is:bd%ie, bd%js:bd%je+1, npz)
507 REAL,
INTENT(INOUT) :: cx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
508 REAL,
INTENT(INOUT) :: cx_ad(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
509 REAL,
INTENT(INOUT) :: cy(bd%isd:bd%ied, bd%js:bd%je+1, npz)
510 REAL,
INTENT(INOUT) :: cy_ad(bd%isd:bd%ied, bd%js:bd%je+1, npz)
511 REAL,
OPTIONAL,
INTENT(OUT) :: dpa(bd%is:bd%ie, bd%js:bd%je)
513 TYPE(
domain2d),
INTENT(INOUT) :: domain
514 REAL :: qn2(bd%isd:bd%ied, bd%jsd:bd%jed, nq)
515 REAL :: qn2_ad(bd%isd:bd%ied, bd%jsd:bd%jed, nq)
516 REAL :: dp2(bd%is:bd%ie, bd%js:bd%je)
517 REAL :: dp2_ad(bd%is:bd%ie, bd%js:bd%je)
518 REAL :: fx(bd%is:bd%ie+1, bd%js:bd%je)
519 REAL :: fx_ad(bd%is:bd%ie+1, bd%js:bd%je)
520 REAL :: fy(bd%is:bd%ie, bd%js:bd%je+1)
521 REAL :: fy_ad(bd%is:bd%ie, bd%js:bd%je+1)
522 REAL :: ra_x(bd%is:bd%ie, bd%jsd:bd%jed)
523 REAL :: ra_x_ad(bd%is:bd%ie, bd%jsd:bd%jed)
524 REAL :: ra_y(bd%isd:bd%ied, bd%js:bd%je)
525 REAL :: ra_y_ad(bd%isd:bd%ied, bd%js:bd%je)
526 REAL :: xfx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
527 REAL :: xfx_ad(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
528 REAL :: yfx(bd%isd:bd%ied, bd%js:bd%je+1, npz)
529 REAL :: yfx_ad(bd%isd:bd%ied, bd%js:bd%je+1, npz)
533 INTEGER :: i, j, k, it, iq
534 REAL,
DIMENSION(:, :),
POINTER :: area, rarea
535 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg
536 REAL,
DIMENSION(:, :),
POINTER :: dxa, dya, dx, dy
537 INTEGER :: is, ie, js, je
538 INTEGER :: isd, ied, jsd, jed
589 CALL poprealarray(xfx, (bd%ie-bd%is+2)*(bd%jed-bd%jsd+1)*npz)
592 CALL poprealarray(qn2, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*nq)
593 CALL poprealarray(ra_x, (bd%ie-bd%is+1)*(bd%jed-bd%jsd+1))
594 CALL poprealarray(ra_y, (bd%ied-bd%isd+1)*(bd%je-bd%js+1))
595 CALL poprealarray(yfx, (bd%ied-bd%isd+1)*(bd%je-bd%js+2)*npz)
599 rarea => gridstruct%rarea
623 IF (branch .NE. 0)
THEN 624 CALL poprealarray(qn2, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*nq&
630 dp2_ad(i, j) = dp2_ad(i, j) + dp1_ad(i, j, k)
631 dp1_ad(i, j, k) = 0.0
637 IF (branch .EQ. 0)
THEN 641 temp_ad4 = q_ad(i, j, k, iq)/dp2(i, j)
642 temp = q(i, j, k, iq)
643 temp_ad5 = rarea(i, j)*temp_ad4
644 dp1_ad(i, j, k) = dp1_ad(i, j, k) + temp*temp_ad4
645 fx_ad(i, j) = fx_ad(i, j) + temp_ad5
646 fx_ad(i+1, j) = fx_ad(i+1, j) - temp_ad5
647 fy_ad(i, j) = fy_ad(i, j) + temp_ad5
648 fy_ad(i, j+1) = fy_ad(i, j+1) - temp_ad5
649 dp2_ad(i, j) = dp2_ad(i, j) - (temp*dp1(i, j, k)+rarea(i&
650 & , j)*(fx(i, j)-fx(i+1, j)+fy(i, j)-fy(i, j+1)))*&
652 q_ad(i, j, k, iq) = dp1(i, j, k)*temp_ad4
656 IF (branch .EQ. 0)
THEN 657 CALL poprealarray(q(isd:ied, jsd:jed, k, iq), (ied-isd+1)&
661 CALL fv_tp_2d_adm(q(isd:ied, jsd:jed, k, iq), q_ad(isd:ied&
662 & , jsd:jed, k, iq), cx(is:ie+1, jsd:jed, k), &
663 & cx_ad(is:ie+1, jsd:jed, k), cy(isd:ied, js:je+&
664 & 1, k), cy_ad(isd:ied, js:je+1, k), npx, npy, &
665 & hord_pert, fx, fx_ad, fy, fy_ad, xfx(is:ie+1, &
666 & jsd:jed, k), xfx_ad(is:ie+1, jsd:jed, k), yfx(&
667 & isd:ied, js:je+1, k), yfx_ad(isd:ied, js:je+1&
668 & , k), gridstruct, bd, ra_x, ra_x_ad, ra_y, &
669 & ra_y_ad, mfx(is:ie+1, js:je, k), mfx_ad(is:ie+&
670 & 1, js:je, k), mfy(is:ie, js:je+1, k), mfy_ad(&
671 & is:ie, js:je+1, k))
673 CALL fv_tp_2d_bwd(q(isd:ied, jsd:jed, k, iq), q_ad(isd:&
674 & ied, jsd:jed, k, iq), cx(is:ie+1, jsd:jed, &
675 & k), cx_ad(is:ie+1, jsd:jed, k), cy(isd:ied&
676 & , js:je+1, k), cy_ad(isd:ied, js:je+1, k), &
677 & npx, npy, hord, fx, fx_ad, fy, fy_ad, xfx(&
678 & is:ie+1, jsd:jed, k), xfx_ad(is:ie+1, jsd:&
679 & jed, k), yfx(isd:ied, js:je+1, k), yfx_ad(&
680 & isd:ied, js:je+1, k), gridstruct, bd, ra_x&
681 & , ra_x_ad, ra_y, ra_y_ad, mfx(is:ie+1, js:&
682 & je, k), mfx_ad(is:ie+1, js:je, k), mfy(is:&
683 & ie, js:je+1, k), mfy_ad(is:ie, js:je+1, k))
686 IF (branch .EQ. 1)
THEN 690 temp_ad2 = q_ad(i, j, k, iq)/dp2(i, j)
691 temp_ad3 = rarea(i, j)*temp_ad2
692 qn2_ad(i, j, iq) = qn2_ad(i, j, iq) + dp1(i, j, k)*&
694 dp1_ad(i, j, k) = dp1_ad(i, j, k) + qn2(i, j, iq)*&
696 fx_ad(i, j) = fx_ad(i, j) + temp_ad3
697 fx_ad(i+1, j) = fx_ad(i+1, j) - temp_ad3
698 fy_ad(i, j) = fy_ad(i, j) + temp_ad3
699 fy_ad(i, j+1) = fy_ad(i, j+1) - temp_ad3
700 dp2_ad(i, j) = dp2_ad(i, j) - (qn2(i, j, iq)*dp1(i, j&
701 & , k)+rarea(i, j)*(fx(i, j)-fx(i+1, j)+fy(i, j)-fy(i&
702 & , j+1)))*temp_ad2/dp2(i, j)
703 q_ad(i, j, k, iq) = 0.0
710 temp_ad0 = qn2_ad(i, j, iq)/dp2(i, j)
711 temp_ad1 = rarea(i, j)*temp_ad0
712 dp1_ad(i, j, k) = dp1_ad(i, j, k) + qn2(i, j, iq)*&
714 fx_ad(i, j) = fx_ad(i, j) + temp_ad1
715 fx_ad(i+1, j) = fx_ad(i+1, j) - temp_ad1
716 fy_ad(i, j) = fy_ad(i, j) + temp_ad1
717 fy_ad(i, j+1) = fy_ad(i, j+1) - temp_ad1
718 dp2_ad(i, j) = dp2_ad(i, j) - (qn2(i, j, iq)*dp1(i, j&
719 & , k)+rarea(i, j)*(fx(i, j)-fx(i+1, j)+fy(i, j)-fy(i&
720 & , j+1)))*temp_ad0/dp2(i, j)
721 qn2_ad(i, j, iq) = dp1(i, j, k)*temp_ad0
726 IF (branch .EQ. 0)
THEN 727 CALL fv_tp_2d_bwd(qn2(isd:ied, jsd:jed, iq), qn2_ad(isd&
728 & :ied, jsd:jed, iq), cx(is:ie+1, jsd:jed, k)&
729 & , cx_ad(is:ie+1, jsd:jed, k), cy(isd:ied, &
730 & js:je+1, k), cy_ad(isd:ied, js:je+1, k), &
731 & npx, npy, hord, fx, fx_ad, fy, fy_ad, xfx(&
732 & is:ie+1, jsd:jed, k), xfx_ad(is:ie+1, jsd:&
733 & jed, k), yfx(isd:ied, js:je+1, k), yfx_ad(&
734 & isd:ied, js:je+1, k), gridstruct, bd, ra_x&
735 & , ra_x_ad, ra_y, ra_y_ad, mfx(is:ie+1, js:&
736 & je, k), mfx_ad(is:ie+1, js:je, k), mfy(is:&
737 & ie, js:je+1, k), mfy_ad(is:ie, js:je+1, k))
739 CALL poprealarray(qn2(isd:ied, jsd:jed, iq), (ied-isd+1)*&
743 CALL fv_tp_2d_adm(qn2(isd:ied, jsd:jed, iq), qn2_ad(isd:&
744 & ied, jsd:jed, iq), cx(is:ie+1, jsd:jed, k), &
745 & cx_ad(is:ie+1, jsd:jed, k), cy(isd:ied, js:je+&
746 & 1, k), cy_ad(isd:ied, js:je+1, k), npx, npy, &
747 & hord_pert, fx, fx_ad, fy, fy_ad, xfx(is:ie+1, &
748 & jsd:jed, k), xfx_ad(is:ie+1, jsd:jed, k), yfx(&
749 & isd:ied, js:je+1, k), yfx_ad(isd:ied, js:je+1&
750 & , k), gridstruct, bd, ra_x, ra_x_ad, ra_y, &
751 & ra_y_ad, mfx(is:ie+1, js:je, k), mfx_ad(is:ie+&
752 & 1, js:je, k), mfy(is:ie, js:je+1, k), mfy_ad(&
753 & is:ie, js:je+1, k))
756 IF (branch .EQ. 0)
THEN 760 q_ad(i, j, k, iq) = q_ad(i, j, k, iq) + qn2_ad(i, j, &
762 qn2_ad(i, j, iq) = 0.0
771 temp_ad = rarea(i, j)*dp2_ad(i, j)
772 dp1_ad(i, j, k) = dp1_ad(i, j, k) + dp2_ad(i, j)
773 mfx_ad(i, j, k) = mfx_ad(i, j, k) + temp_ad
774 mfx_ad(i+1, j, k) = mfx_ad(i+1, j, k) - temp_ad
775 mfy_ad(i, j, k) = mfy_ad(i, j, k) + temp_ad
776 mfy_ad(i, j+1, k) = mfy_ad(i, j+1, k) - temp_ad
783 IF (branch .NE. 0)
THEN 786 yfx_ad(i, j, k) = yfx_ad(i, j, k) + ra_y_ad(i, j)
787 yfx_ad(i, j+1, k) = yfx_ad(i, j+1, k) - ra_y_ad(i, j)
793 xfx_ad(i, j, k) = xfx_ad(i, j, k) + ra_x_ad(i, j)
794 xfx_ad(i+1, j, k) = xfx_ad(i+1, j, k) - ra_x_ad(i, j)
801 IF (branch .NE. 0)
THEN 805 mfy_ad(i, j, k) = frac*mfy_ad(i, j, k)
810 yfx_ad(i, j, k) = frac*yfx_ad(i, j, k)
812 cy_ad(i, j, k) = frac*cy_ad(i, j, k)
818 mfx_ad(i, j, k) = frac*mfx_ad(i, j, k)
823 xfx_ad(i, j, k) = frac*xfx_ad(i, j, k)
825 cx_ad(i, j, k) = frac*cx_ad(i, j, k)
831 dxa => gridstruct%dxa
834 sin_sg => gridstruct%sin_sg
835 dya => gridstruct%dya
838 IF (branch .EQ. 0)
THEN 854 IF (branch .EQ. 0)
THEN 855 cy_ad(i, j, k) = cy_ad(i, j, k) + dya(i, j)*dx(i, j)*sin_sg(&
856 & i, j, 2)*yfx_ad(i, j, k)
857 yfx_ad(i, j, k) = 0.0
859 cy_ad(i, j, k) = cy_ad(i, j, k) + dya(i, j-1)*dx(i, j)*&
860 & sin_sg(i, j-1, 4)*yfx_ad(i, j, k)
861 yfx_ad(i, j, k) = 0.0
868 IF (branch .EQ. 0)
THEN 869 cx_ad(i, j, k) = cx_ad(i, j, k) + dxa(i, j)*dy(i, j)*sin_sg(&
870 & i, j, 1)*xfx_ad(i, j, k)
871 xfx_ad(i, j, k) = 0.0
873 cx_ad(i, j, k) = cx_ad(i, j, k) + dxa(i-1, j)*dy(i, j)*&
874 & sin_sg(i-1, j, 3)*xfx_ad(i, j, k)
875 xfx_ad(i, j, k) = 0.0
884 SUBROUTINE tracer_2d_1l(q, dp1, mfx, mfy, cx, cy, gridstruct, bd, &
885 & domain, npx, npy, npz, nq, hord, q_split, dt, id_divg, q_pack, &
886 & nord_tr, trdm, hord_pert, nord_tr_pert, trdm_pert, split_damp_tr, &
890 INTEGER,
INTENT(IN) :: npx
891 INTEGER,
INTENT(IN) :: npy
892 INTEGER,
INTENT(IN) :: npz
894 INTEGER,
INTENT(IN) :: nq
895 INTEGER,
INTENT(IN) :: hord, nord_tr
896 INTEGER,
INTENT(IN) :: hord_pert, nord_tr_pert
897 LOGICAL,
INTENT(IN) :: split_damp_tr
898 INTEGER,
INTENT(IN) :: q_split
899 INTEGER,
INTENT(IN) :: id_divg
900 REAL,
INTENT(IN) :: dt, trdm, trdm_pert
901 TYPE(group_halo_update_type),
INTENT(INOUT) :: q_pack
903 REAL,
INTENT(INOUT) :: q(bd%isd:bd%ied, bd%jsd:bd%jed, npz, nq)
905 REAL,
INTENT(INOUT) :: dp1(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
907 REAL,
INTENT(INOUT) :: mfx(bd%is:bd%ie+1, bd%js:bd%je, npz)
909 REAL,
INTENT(INOUT) :: mfy(bd%is:bd%ie, bd%js:bd%je+1, npz)
911 REAL,
INTENT(INOUT) :: cx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
913 REAL,
INTENT(INOUT) :: cy(bd%isd:bd%ied, bd%js:bd%je+1, npz)
915 REAL,
OPTIONAL,
INTENT(OUT) :: dpa(bd%is:bd%ie, bd%js:bd%je)
917 TYPE(
domain2d),
INTENT(INOUT) :: domain
920 REAL :: qn2(bd%isd:bd%ied, bd%jsd:bd%jed, nq)
921 REAL :: dp2(bd%is:bd%ie, bd%js:bd%je)
922 REAL :: fx(bd%is:bd%ie+1, bd%js:bd%je)
923 REAL :: fy(bd%is:bd%ie, bd%js:bd%je+1)
924 REAL :: ra_x(bd%is:bd%ie, bd%jsd:bd%jed)
925 REAL :: ra_y(bd%isd:bd%ied, bd%js:bd%je)
926 REAL :: xfx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
927 REAL :: yfx(bd%isd:bd%ied, bd%js:bd%je+1, npz)
931 INTEGER :: i, j, k, it, iq
932 REAL,
DIMENSION(:, :),
POINTER :: area, rarea
933 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg
934 REAL,
DIMENSION(:, :),
POINTER :: dxa, dya, dx, dy
935 INTEGER :: is, ie, js, je
936 INTEGER :: isd, ied, jsd, jed
956 area => gridstruct%area
957 rarea => gridstruct%rarea
958 sin_sg => gridstruct%sin_sg
959 dxa => gridstruct%dxa
960 dya => gridstruct%dya
968 IF (cx(i, j, k) .GT. 0.)
THEN 969 xfx(i, j, k) = cx(i, j, k)*dxa(i-1, j)*dy(i, j)*sin_sg(i-1, &
972 xfx(i, j, k) = cx(i, j, k)*dxa(i, j)*dy(i, j)*sin_sg(i, j, 1&
979 IF (cy(i, j, k) .GT. 0.)
THEN 980 yfx(i, j, k) = cy(i, j, k)*dya(i, j-1)*dx(i, j)*sin_sg(i, j-&
983 yfx(i, j, k) = cy(i, j, k)*dya(i, j)*dx(i, j)*sin_sg(i, j, 2&
989 IF (k .LT. npz/6)
THEN 992 IF (cx(i, j, k) .GE. 0.)
THEN 997 IF (cy(i, j, k) .GE. 0.)
THEN 1002 IF (cmax(k) .LT. y1)
THEN 1003 IF (y1 .LT. z1)
THEN 1008 ELSE IF (cmax(k) .LT. z1)
THEN 1018 IF (cx(i, j, k) .GE. 0.)
THEN 1023 IF (cy(i, j, k) .GE. 0.)
THEN 1028 IF (x1 .LT. y3)
THEN 1033 y2 = max1 + 1. - sin_sg(i, j, 5)
1034 IF (cmax(k) .LT. y2)
THEN 1044 CALL mp_reduce_max(cmax, npz)
1049 nsplt = int(1. + cmax(k))
1050 IF (nsplt .GT. 1)
THEN 1051 frac = 1./
REAL(nsplt)
1054 cx(i, j, k) = cx(i, j, k)*frac
1055 xfx(i, j, k) = xfx(i, j, k)*frac
1060 mfx(i, j, k) = mfx(i, j, k)*frac
1065 cy(i, j, k) = cy(i, j, k)*frac
1066 yfx(i, j, k) = yfx(i, j, k)*frac
1071 mfy(i, j, k) = mfy(i, j, k)*frac
1078 CALL complete_group_halo_update(q_pack, domain)
1086 ra_x(i, j) = area(i, j) + (xfx(i, j, k)-xfx(i+1, j, k))
1088 IF (j .GE. js .AND. j .LE. je)
THEN 1090 ra_y(i, j) = area(i, j) + (yfx(i, j, k)-yfx(i, j+1, k))
1094 nsplt = int(1. + cmax(k))
1099 dp2(i, j) = dp1(i, j, k) + (mfx(i, j, k)-mfx(i+1, j, k)+(mfy&
1100 & (i, j, k)-mfy(i, j+1, k)))*rarea(i, j)
1107 IF (nsplt .NE. 1)
THEN 1111 qn2(i, j, iq) = q(i, j, k, iq)
1115 IF (hord .EQ. hord_pert)
THEN 1116 CALL fv_tp_2d(qn2(isd:ied, jsd:jed, iq), cx(is:ie+1, &
1117 & jsd:jed, k), cy(isd:ied, js:je+1, k), npx, npy&
1118 & , hord, fx, fy, xfx(is:ie+1, jsd:jed, k), yfx(&
1119 & isd:ied, js:je+1, k), gridstruct, bd, ra_x, &
1120 & ra_y, mfx=mfx(is:ie+1, js:je, k), mfy=mfy(is:ie&
1123 CALL fv_tp_2d(qn2(isd:ied, jsd:jed, iq), cx(is:ie+1, jsd:&
1124 & jed, k), cy(isd:ied, js:je+1, k), npx, npy, &
1125 & hord, fx, fy, xfx(is:ie+1, jsd:jed, k), yfx(&
1126 & isd:ied, js:je+1, k), gridstruct, bd, ra_x, ra_y, &
1127 & mfx=mfx(is:ie+1, js:je, k), mfy=mfy(is:ie, js:je+1&
1130 IF (it .LT. nsplt)
THEN 1134 qn2(i, j, iq) = (qn2(i, j, iq)*dp1(i, j, k)+(fx(i, j)-&
1135 & fx(i+1, j)+(fy(i, j)-fy(i, j+1)))*rarea(i, j))/dp2(i&
1142 q(i, j, k, iq) = (qn2(i, j, iq)*dp1(i, j, k)+(fx(i, j)&
1143 & -fx(i+1, j)+(fy(i, j)-fy(i, j+1)))*rarea(i, j))/dp2(&
1149 IF (hord .EQ. hord_pert)
THEN 1150 CALL fv_tp_2d(q(isd:ied, jsd:jed, k, iq), cx(is:ie+1, &
1151 & jsd:jed, k), cy(isd:ied, js:je+1, k), npx, npy&
1152 & , hord, fx, fy, xfx(is:ie+1, jsd:jed, k), yfx(&
1153 & isd:ied, js:je+1, k), gridstruct, bd, ra_x, &
1154 & ra_y, mfx=mfx(is:ie+1, js:je, k), mfy=mfy(is:ie&
1157 CALL fv_tp_2d(q(isd:ied, jsd:jed, k, iq), cx(is:ie+1, jsd:&
1158 & jed, k), cy(isd:ied, js:je+1, k), npx, npy, &
1159 & hord, fx, fy, xfx(is:ie+1, jsd:jed, k), yfx(&
1160 & isd:ied, js:je+1, k), gridstruct, bd, ra_x, ra_y, &
1161 & mfx=mfx(is:ie+1, js:je, k), mfy=mfy(is:ie, js:je+1&
1166 q(i, j, k, iq) = (q(i, j, k, iq)*dp1(i, j, k)+(fx(i, j)-&
1167 & fx(i+1, j)+(fy(i, j)-fy(i, j+1)))*rarea(i, j))/dp2(i, &
1174 IF (it .LT. nsplt)
THEN 1178 dp1(i, j, k) = dp2(i, j)
1191 IF (
PRESENT(dpa)) dpa = dp2
1213 SUBROUTINE tracer_2d_fwd(q, dp1, mfx, mfy, cx, cy, gridstruct, bd, &
1214 & domain, npx, npy, npz, nq, hord, q_split, dt, id_divg, q_pack, &
1215 & nord_tr, trdm, hord_pert, nord_tr_pert, trdm_pert, split_damp_tr, &
1219 INTEGER,
INTENT(IN) :: npx
1220 INTEGER,
INTENT(IN) :: npy
1221 INTEGER,
INTENT(IN) :: npz
1223 INTEGER,
INTENT(IN) :: nq
1224 INTEGER,
INTENT(IN) :: hord, nord_tr
1225 INTEGER,
INTENT(IN) :: hord_pert, nord_tr_pert
1226 LOGICAL,
INTENT(IN) :: split_damp_tr
1227 INTEGER,
INTENT(IN) :: q_split
1228 INTEGER,
INTENT(IN) :: id_divg
1229 REAL,
INTENT(IN) :: dt, trdm, trdm_pert
1230 TYPE(group_halo_update_type),
INTENT(INOUT) :: q_pack
1232 REAL,
INTENT(INOUT) :: q(bd%isd:bd%ied, bd%jsd:bd%jed, npz, nq)
1234 REAL,
INTENT(INOUT) :: dp1(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1236 REAL,
INTENT(INOUT) :: mfx(bd%is:bd%ie+1, bd%js:bd%je, npz)
1238 REAL,
INTENT(INOUT) :: mfy(bd%is:bd%ie, bd%js:bd%je+1, npz)
1240 REAL,
INTENT(INOUT) :: cx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
1242 REAL,
INTENT(INOUT) :: cy(bd%isd:bd%ied, bd%js:bd%je+1, npz)
1244 REAL,
OPTIONAL,
INTENT(OUT) :: dpa(bd%is:bd%ie, bd%js:bd%je, npz)
1246 TYPE(
domain2d),
INTENT(INOUT) :: domain
1248 REAL :: dp2(bd%is:bd%ie, bd%js:bd%je)
1249 REAL :: fx(bd%is:bd%ie+1, bd%js:bd%je)
1250 REAL :: fy(bd%is:bd%ie, bd%js:bd%je+1)
1251 REAL :: ra_x(bd%is:bd%ie, bd%jsd:bd%jed)
1252 REAL :: ra_y(bd%isd:bd%ied, bd%js:bd%je)
1253 REAL :: xfx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
1254 REAL :: yfx(bd%isd:bd%ied, bd%js:bd%je+1, npz)
1258 INTEGER :: ksplt(npz)
1260 INTEGER :: i, j, k, it, iq
1261 REAL,
DIMENSION(:, :),
POINTER :: area, rarea
1262 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg
1263 REAL,
DIMENSION(:, :),
POINTER :: dxa, dya, dx, dy
1264 INTEGER :: is, ie, js, je
1265 INTEGER :: isd, ied, jsd, jed
1315 area => gridstruct%area
1316 rarea => gridstruct%rarea
1317 sin_sg => gridstruct%sin_sg
1318 dxa => gridstruct%dxa
1319 dya => gridstruct%dya
1327 IF (cx(i, j, k) .GT. 0.)
THEN 1328 xfx(i, j, k) = cx(i, j, k)*dxa(i-1, j)*dy(i, j)*sin_sg(i-1, &
1332 xfx(i, j, k) = cx(i, j, k)*dxa(i, j)*dy(i, j)*sin_sg(i, j, 1&
1340 IF (cy(i, j, k) .GT. 0.)
THEN 1341 yfx(i, j, k) = cy(i, j, k)*dya(i, j-1)*dx(i, j)*sin_sg(i, j-&
1345 yfx(i, j, k) = cy(i, j, k)*dya(i, j)*dx(i, j)*sin_sg(i, j, 2&
1351 IF (q_split .EQ. 0)
THEN 1353 IF (k .LT. npz/6)
THEN 1356 IF (cx(i, j, k) .GE. 0.)
THEN 1361 IF (cy(i, j, k) .GE. 0.)
THEN 1366 IF (cmax(k) .LT. y1)
THEN 1367 IF (y1 .LT. z1)
THEN 1374 ELSE IF (cmax(k) .LT. z1)
THEN 1387 IF (cx(i, j, k) .GE. 0.)
THEN 1392 IF (cy(i, j, k) .GE. 0.)
THEN 1397 IF (x1 .LT. y3)
THEN 1402 y2 = max1 + 1. - sin_sg(i, j, 5)
1403 IF (cmax(k) .LT. y2)
THEN 1421 IF (q_split .EQ. 0)
THEN 1422 CALL mp_reduce_max(cmax, npz)
1425 IF (npz .NE. 1)
THEN 1428 IF (cmax(k) .LT. c_global)
THEN 1440 nsplt = int(1. + c_global)
1442 IF (res .AND. nsplt .GT. 4)
THEN 1444 WRITE(*, *)
'Tracer_2d_split=', nsplt, c_global
1453 IF (nsplt .NE. 1)
THEN 1457 ksplt(k) = int(1. + cmax(k))
1459 frac = 1./
REAL(ksplt(k))
1463 cx(i, j, k) = cx(i, j, k)*frac
1464 xfx(i, j, k) = xfx(i, j, k)*frac
1470 mfx(i, j, k) = mfx(i, j, k)*frac
1476 cy(i, j, k) = cy(i, j, k)*frac
1477 yfx(i, j, k) = yfx(i, j, k)*frac
1483 mfy(i, j, k) = mfy(i, j, k)*frac
1497 IF (it .LE. ksplt(k))
THEN 1501 dp2(i, j) = dp1(i, j, k) + (mfx(i, j, k)-mfx(i+1, j, k)+(&
1502 & mfy(i, j, k)-mfy(i, j+1, k)))*rarea(i, j)
1508 ra_x(i, j) = area(i, j) + (xfx(i, j, k)-xfx(i+1, j, k))
1514 ra_y(i, j) = area(i, j) + (yfx(i, j, k)-yfx(i, j+1, k))
1518 IF (it .EQ. 1 .AND. trdm .GT. 1.e-4)
THEN 1519 IF (hord .EQ. hord_pert)
THEN 1521 & ie+1, jsd:jed, k), cy(isd:ied, js:je+1, k&
1522 & ), npx, npy, hord, fx, fy, xfx(is:ie+1, &
1523 & jsd:jed, k), yfx(isd:ied, js:je+1, k), &
1524 & gridstruct, bd, ra_x, ra_y, mfx=mfx(is:ie&
1525 & +1, js:je, k), mfy=mfy(is:ie, js:je+1, k)&
1526 & , mass=dp1(isd:ied, jsd:jed, k), nord=&
1527 & nord_tr, damp_c=trdm)
1534 CALL fv_tp_2d(q(isd:ied, jsd:jed, k, iq), cx(is:ie+1, &
1535 & jsd:jed, k), cy(isd:ied, js:je+1, k), npx, npy, &
1536 & hord, fx, fy, xfx(is:ie+1, jsd:jed, k), yfx&
1537 & (isd:ied, js:je+1, k), gridstruct, bd, ra_x, &
1538 & ra_y, mfx=mfx(is:ie+1, js:je, k), mfy=mfy(is:ie&
1539 & , js:je+1, k), mass=dp1(isd:ied, jsd:jed, k), &
1540 & nord=nord_tr, damp_c=trdm)
1543 ELSE IF (hord .EQ. hord_pert)
THEN 1544 CALL fv_tp_2d_fwd(q(isd:ied, jsd:jed, k, iq), cx(is:ie+&
1545 & 1, jsd:jed, k), cy(isd:ied, js:je+1, k), &
1546 & npx, npy, hord, fx, fy, xfx(is:ie+1, jsd:&
1547 & jed, k), yfx(isd:ied, js:je+1, k), &
1548 & gridstruct, bd, ra_x, ra_y, mfx=mfx(is:ie+1&
1549 & , js:je, k), mfy=mfy(is:ie, js:je+1, k))
1556 CALL fv_tp_2d(q(isd:ied, jsd:jed, k, iq), cx(is:ie+1, jsd:&
1557 & jed, k), cy(isd:ied, js:je+1, k), npx, npy, &
1558 & hord, fx, fy, xfx(is:ie+1, jsd:jed, k), yfx(&
1559 & isd:ied, js:je+1, k), gridstruct, bd, ra_x, ra_y, &
1560 & mfx=mfx(is:ie+1, js:je, k), mfy=mfy(is:ie, js:je+1&
1567 q(i, j, k, iq) = (q(i, j, k, iq)*dp1(i, j, k)+(fx(i, j)-&
1568 & fx(i+1, j)+(fy(i, j)-fy(i, j+1)))*rarea(i, j))/dp2(i, &
1573 IF (it .NE. nsplt)
THEN 1577 dp1(i, j, k) = dp2(i, j)
1589 IF (it .NE. nsplt)
THEN 1590 CALL pushrealarray(q, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*npz*&
1601 CALL pushrealarray(yfx, (bd%ied-bd%isd+1)*(bd%je-bd%js+2)*npz)
1606 CALL pushrealarray(xfx, (bd%ie-bd%is+2)*(bd%jed-bd%jsd+1)*npz)
1628 SUBROUTINE tracer_2d_bwd(q, q_ad, dp1, dp1_ad, mfx, mfx_ad, mfy, &
1629 & mfy_ad, cx, cx_ad, cy, cy_ad, gridstruct, bd, domain, npx, npy, npz&
1630 & , nq, hord, q_split, dt, id_divg, q_pack, nord_tr, trdm, hord_pert, &
1631 & nord_tr_pert, trdm_pert, split_damp_tr, dpa)
1634 INTEGER,
INTENT(IN) :: npx
1635 INTEGER,
INTENT(IN) :: npy
1636 INTEGER,
INTENT(IN) :: npz
1637 INTEGER,
INTENT(IN) :: nq
1638 INTEGER,
INTENT(IN) :: hord, nord_tr
1639 INTEGER,
INTENT(IN) :: hord_pert, nord_tr_pert
1640 LOGICAL,
INTENT(IN) :: split_damp_tr
1641 INTEGER,
INTENT(IN) :: q_split
1642 INTEGER,
INTENT(IN) :: id_divg
1643 REAL,
INTENT(IN) :: dt, trdm, trdm_pert
1644 TYPE(group_halo_update_type),
INTENT(INOUT) :: q_pack
1645 REAL,
INTENT(INOUT) :: q(bd%isd:bd%ied, bd%jsd:bd%jed, npz, nq)
1646 REAL,
INTENT(INOUT) :: q_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz, nq)
1647 REAL,
INTENT(INOUT) :: dp1(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1648 REAL,
INTENT(INOUT) :: dp1_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
1649 REAL,
INTENT(INOUT) :: mfx(bd%is:bd%ie+1, bd%js:bd%je, npz)
1650 REAL,
INTENT(INOUT) :: mfx_ad(bd%is:bd%ie+1, bd%js:bd%je, npz)
1651 REAL,
INTENT(INOUT) :: mfy(bd%is:bd%ie, bd%js:bd%je+1, npz)
1652 REAL,
INTENT(INOUT) :: mfy_ad(bd%is:bd%ie, bd%js:bd%je+1, npz)
1653 REAL,
INTENT(INOUT) :: cx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
1654 REAL,
INTENT(INOUT) :: cx_ad(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
1655 REAL,
INTENT(INOUT) :: cy(bd%isd:bd%ied, bd%js:bd%je+1, npz)
1656 REAL,
INTENT(INOUT) :: cy_ad(bd%isd:bd%ied, bd%js:bd%je+1, npz)
1657 REAL,
OPTIONAL,
INTENT(OUT) :: dpa(bd%is:bd%ie, bd%js:bd%je, npz)
1659 TYPE(
domain2d),
INTENT(INOUT) :: domain
1660 REAL :: dp2(bd%is:bd%ie, bd%js:bd%je)
1661 REAL :: dp2_ad(bd%is:bd%ie, bd%js:bd%je)
1662 REAL :: fx(bd%is:bd%ie+1, bd%js:bd%je)
1663 REAL :: fx_ad(bd%is:bd%ie+1, bd%js:bd%je)
1664 REAL :: fy(bd%is:bd%ie, bd%js:bd%je+1)
1665 REAL :: fy_ad(bd%is:bd%ie, bd%js:bd%je+1)
1666 REAL :: ra_x(bd%is:bd%ie, bd%jsd:bd%jed)
1667 REAL :: ra_x_ad(bd%is:bd%ie, bd%jsd:bd%jed)
1668 REAL :: ra_y(bd%isd:bd%ied, bd%js:bd%je)
1669 REAL :: ra_y_ad(bd%isd:bd%ied, bd%js:bd%je)
1670 REAL :: xfx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
1671 REAL :: xfx_ad(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
1672 REAL :: yfx(bd%isd:bd%ied, bd%js:bd%je+1, npz)
1673 REAL :: yfx_ad(bd%isd:bd%ied, bd%js:bd%je+1, npz)
1677 INTEGER :: ksplt(npz)
1679 INTEGER :: i, j, k, it, iq
1680 REAL,
DIMENSION(:, :),
POINTER :: area, rarea
1681 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg
1682 REAL,
DIMENSION(:, :),
POINTER :: dxa, dya, dx, dy
1683 INTEGER :: is, ie, js, je
1684 INTEGER :: isd, ied, jsd, jed
1731 CALL poprealarray(xfx, (bd%ie-bd%is+2)*(bd%jed-bd%jsd+1)*npz)
1732 CALL poprealarray(dp2, (bd%ie-bd%is+1)*(bd%je-bd%js+1))
1734 CALL poprealarray(ra_x, (bd%ie-bd%is+1)*(bd%jed-bd%jsd+1))
1735 CALL poprealarray(ra_y, (bd%ied-bd%isd+1)*(bd%je-bd%js+1))
1736 CALL poprealarray(yfx, (bd%ied-bd%isd+1)*(bd%je-bd%js+2)*npz)
1741 rarea => gridstruct%rarea
1762 IF (branch .NE. 0)
THEN 1763 CALL poprealarray(q, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*npz*nq&
1769 IF (branch .NE. 0)
THEN 1770 IF (branch .NE. 1)
THEN 1774 dp2_ad(i, j) = dp2_ad(i, j) + dp1_ad(i, j, k)
1775 dp1_ad(i, j, k) = 0.0
1783 temp_ad0 = q_ad(i, j, k, iq)/dp2(i, j)
1784 temp = q(i, j, k, iq)
1785 temp_ad1 = rarea(i, j)*temp_ad0
1786 dp1_ad(i, j, k) = dp1_ad(i, j, k) + temp*temp_ad0
1787 fx_ad(i, j) = fx_ad(i, j) + temp_ad1
1788 fx_ad(i+1, j) = fx_ad(i+1, j) - temp_ad1
1789 fy_ad(i, j) = fy_ad(i, j) + temp_ad1
1790 fy_ad(i, j+1) = fy_ad(i, j+1) - temp_ad1
1791 dp2_ad(i, j) = dp2_ad(i, j) - (temp*dp1(i, j, k)+rarea(i&
1792 & , j)*(fx(i, j)-fx(i+1, j)+fy(i, j)-fy(i, j+1)))*&
1793 & temp_ad0/dp2(i, j)
1794 q_ad(i, j, k, iq) = dp1(i, j, k)*temp_ad0
1798 IF (branch .LT. 2)
THEN 1799 IF (branch .EQ. 0)
THEN 1800 CALL poprealarray(q(isd:ied, jsd:jed, k, iq), (ied-isd+&
1804 CALL fv_tp_2d_adm(q(isd:ied, jsd:jed, k, iq), q_ad(isd:&
1805 & ied, jsd:jed, k, iq), cx(is:ie+1, jsd:jed, k&
1806 & ), cx_ad(is:ie+1, jsd:jed, k), cy(isd:ied, &
1807 & js:je+1, k), cy_ad(isd:ied, js:je+1, k), npx&
1808 & , npy, hord_pert, fx, fx_ad, fy, fy_ad, xfx(&
1809 & is:ie+1, jsd:jed, k), xfx_ad(is:ie+1, jsd:&
1810 & jed, k), yfx(isd:ied, js:je+1, k), yfx_ad(&
1811 & isd:ied, js:je+1, k), gridstruct, bd, ra_x, &
1812 & ra_x_ad, ra_y, ra_y_ad, mfx(is:ie+1, js:je, &
1813 & k), mfx_ad(is:ie+1, js:je, k), mfy(is:ie, js&
1814 & :je+1, k), mfy_ad(is:ie, js:je+1, k))
1817 & isd:ied, jsd:jed, k, iq), cx(is:ie+1, jsd&
1818 & :jed, k), cx_ad(is:ie+1, jsd:jed, k), cy(&
1819 & isd:ied, js:je+1, k), cy_ad(isd:ied, js:&
1820 & je+1, k), npx, npy, hord, fx, fx_ad, fy, &
1821 & fy_ad, xfx(is:ie+1, jsd:jed, k), xfx_ad(&
1822 & is:ie+1, jsd:jed, k), yfx(isd:ied, js:je+&
1823 & 1, k), yfx_ad(isd:ied, js:je+1, k), &
1824 & gridstruct, bd, ra_x, ra_x_ad, ra_y, &
1825 & ra_y_ad, mfx(is:ie+1, js:je, k), mfx_ad(&
1826 & is:ie+1, js:je, k), mfy(is:ie, js:je+1, k&
1827 & ), mfy_ad(is:ie, js:je+1, k))
1829 ELSE IF (branch .EQ. 2)
THEN 1830 CALL poprealarray(q(isd:ied, jsd:jed, k, iq), (ied-isd+1)&
1834 CALL fv_tp_2d_adm(q(isd:ied, jsd:jed, k, iq), q_ad(isd:ied&
1835 & , jsd:jed, k, iq), cx(is:ie+1, jsd:jed, k), &
1836 & cx_ad(is:ie+1, jsd:jed, k), cy(isd:ied, js:je+&
1837 & 1, k), cy_ad(isd:ied, js:je+1, k), npx, npy, &
1838 & hord_pert, fx, fx_ad, fy, fy_ad, xfx(is:ie+1, &
1839 & jsd:jed, k), xfx_ad(is:ie+1, jsd:jed, k), yfx(&
1840 & isd:ied, js:je+1, k), yfx_ad(isd:ied, js:je+1&
1841 & , k), gridstruct, bd, ra_x, ra_x_ad, ra_y, &
1842 & ra_y_ad, mfx(is:ie+1, js:je, k), mfx_ad(is:ie+&
1843 & 1, js:je, k), mfy(is:ie, js:je+1, k), mfy_ad(&
1844 & is:ie, js:je+1, k), dp1(isd:ied, jsd:jed, k), &
1845 & dp1_ad(isd:ied, jsd:jed, k), nord=nord_tr_pert&
1846 & , damp_c=trdm_pert)
1848 CALL fv_tp_2d_bwd(q(isd:ied, jsd:jed, k, iq), q_ad(isd:&
1849 & ied, jsd:jed, k, iq), cx(is:ie+1, jsd:jed, &
1850 & k), cx_ad(is:ie+1, jsd:jed, k), cy(isd:ied&
1851 & , js:je+1, k), cy_ad(isd:ied, js:je+1, k), &
1852 & npx, npy, hord, fx, fx_ad, fy, fy_ad, xfx(&
1853 & is:ie+1, jsd:jed, k), xfx_ad(is:ie+1, jsd:&
1854 & jed, k), yfx(isd:ied, js:je+1, k), yfx_ad(&
1855 & isd:ied, js:je+1, k), gridstruct, bd, ra_x&
1856 & , ra_x_ad, ra_y, ra_y_ad, mfx(is:ie+1, js:&
1857 & je, k), mfx_ad(is:ie+1, js:je, k), mfy(is:&
1858 & ie, js:je+1, k), mfy_ad(is:ie, js:je+1, k)&
1859 & , dp1(isd:ied, jsd:jed, k), dp1_ad(isd:ied&
1860 & , jsd:jed, k), nord=nord_tr, damp_c=trdm)
1866 yfx_ad(i, j, k) = yfx_ad(i, j, k) + ra_y_ad(i, j)
1867 yfx_ad(i, j+1, k) = yfx_ad(i, j+1, k) - ra_y_ad(i, j)
1874 xfx_ad(i, j, k) = xfx_ad(i, j, k) + ra_x_ad(i, j)
1875 xfx_ad(i+1, j, k) = xfx_ad(i+1, j, k) - ra_x_ad(i, j)
1882 temp_ad = rarea(i, j)*dp2_ad(i, j)
1883 dp1_ad(i, j, k) = dp1_ad(i, j, k) + dp2_ad(i, j)
1884 mfx_ad(i, j, k) = mfx_ad(i, j, k) + temp_ad
1885 mfx_ad(i+1, j, k) = mfx_ad(i+1, j, k) - temp_ad
1886 mfy_ad(i, j, k) = mfy_ad(i, j, k) + temp_ad
1887 mfy_ad(i, j+1, k) = mfy_ad(i, j+1, k) - temp_ad
1895 IF (branch .NE. 0)
THEN 1900 mfy_ad(i, j, k) = frac*mfy_ad(i, j, k)
1905 yfx_ad(i, j, k) = frac*yfx_ad(i, j, k)
1907 cy_ad(i, j, k) = frac*cy_ad(i, j, k)
1913 mfx_ad(i, j, k) = frac*mfx_ad(i, j, k)
1918 xfx_ad(i, j, k) = frac*xfx_ad(i, j, k)
1920 cx_ad(i, j, k) = frac*cx_ad(i, j, k)
1927 IF (branch .EQ. 0)
THEN 1929 IF (branch .EQ. 0)
THEN 1935 dxa => gridstruct%dxa
1938 sin_sg => gridstruct%sin_sg
1939 dya => gridstruct%dya
1942 IF (branch .EQ. 0)
THEN 1948 ELSE IF (branch .EQ. 1)
THEN 1958 IF (branch .EQ. 0)
THEN 1959 cy_ad(i, j, k) = cy_ad(i, j, k) + dya(i, j)*dx(i, j)*sin_sg(&
1960 & i, j, 2)*yfx_ad(i, j, k)
1961 yfx_ad(i, j, k) = 0.0
1963 cy_ad(i, j, k) = cy_ad(i, j, k) + dya(i, j-1)*dx(i, j)*&
1964 & sin_sg(i, j-1, 4)*yfx_ad(i, j, k)
1965 yfx_ad(i, j, k) = 0.0
1972 IF (branch .EQ. 0)
THEN 1973 cx_ad(i, j, k) = cx_ad(i, j, k) + dxa(i, j)*dy(i, j)*sin_sg(&
1974 & i, j, 1)*xfx_ad(i, j, k)
1975 xfx_ad(i, j, k) = 0.0
1977 cx_ad(i, j, k) = cx_ad(i, j, k) + dxa(i-1, j)*dy(i, j)*&
1978 & sin_sg(i-1, j, 3)*xfx_ad(i, j, k)
1979 xfx_ad(i, j, k) = 0.0
1985 SUBROUTINE tracer_2d(q, dp1, mfx, mfy, cx, cy, gridstruct, bd, domain&
1986 & , npx, npy, npz, nq, hord, q_split, dt, id_divg, q_pack, nord_tr, &
1987 & trdm, hord_pert, nord_tr_pert, trdm_pert, split_damp_tr, dpa)
1990 INTEGER,
INTENT(IN) :: npx
1991 INTEGER,
INTENT(IN) :: npy
1992 INTEGER,
INTENT(IN) :: npz
1994 INTEGER,
INTENT(IN) :: nq
1995 INTEGER,
INTENT(IN) :: hord, nord_tr
1996 INTEGER,
INTENT(IN) :: hord_pert, nord_tr_pert
1997 LOGICAL,
INTENT(IN) :: split_damp_tr
1998 INTEGER,
INTENT(IN) :: q_split
1999 INTEGER,
INTENT(IN) :: id_divg
2000 REAL,
INTENT(IN) :: dt, trdm, trdm_pert
2001 TYPE(group_halo_update_type),
INTENT(INOUT) :: q_pack
2003 REAL,
INTENT(INOUT) :: q(bd%isd:bd%ied, bd%jsd:bd%jed, npz, nq)
2005 REAL,
INTENT(INOUT) :: dp1(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
2007 REAL,
INTENT(INOUT) :: mfx(bd%is:bd%ie+1, bd%js:bd%je, npz)
2009 REAL,
INTENT(INOUT) :: mfy(bd%is:bd%ie, bd%js:bd%je+1, npz)
2011 REAL,
INTENT(INOUT) :: cx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
2013 REAL,
INTENT(INOUT) :: cy(bd%isd:bd%ied, bd%js:bd%je+1, npz)
2015 REAL,
OPTIONAL,
INTENT(OUT) :: dpa(bd%is:bd%ie, bd%js:bd%je, npz)
2017 TYPE(
domain2d),
INTENT(INOUT) :: domain
2019 REAL :: dp2(bd%is:bd%ie, bd%js:bd%je)
2020 REAL :: fx(bd%is:bd%ie+1, bd%js:bd%je)
2021 REAL :: fy(bd%is:bd%ie, bd%js:bd%je+1)
2022 REAL :: ra_x(bd%is:bd%ie, bd%jsd:bd%jed)
2023 REAL :: ra_y(bd%isd:bd%ied, bd%js:bd%je)
2024 REAL :: xfx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
2025 REAL :: yfx(bd%isd:bd%ied, bd%js:bd%je+1, npz)
2029 INTEGER :: ksplt(npz)
2031 INTEGER :: i, j, k, it, iq
2032 REAL,
DIMENSION(:, :),
POINTER :: area, rarea
2033 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg
2034 REAL,
DIMENSION(:, :),
POINTER :: dxa, dya, dx, dy
2035 INTEGER :: is, ie, js, je
2036 INTEGER :: isd, ied, jsd, jed
2056 area => gridstruct%area
2057 rarea => gridstruct%rarea
2058 sin_sg => gridstruct%sin_sg
2059 dxa => gridstruct%dxa
2060 dya => gridstruct%dya
2068 IF (cx(i, j, k) .GT. 0.)
THEN 2069 xfx(i, j, k) = cx(i, j, k)*dxa(i-1, j)*dy(i, j)*sin_sg(i-1, &
2072 xfx(i, j, k) = cx(i, j, k)*dxa(i, j)*dy(i, j)*sin_sg(i, j, 1&
2079 IF (cy(i, j, k) .GT. 0.)
THEN 2080 yfx(i, j, k) = cy(i, j, k)*dya(i, j-1)*dx(i, j)*sin_sg(i, j-&
2083 yfx(i, j, k) = cy(i, j, k)*dya(i, j)*dx(i, j)*sin_sg(i, j, 2&
2088 IF (q_split .EQ. 0)
THEN 2090 IF (k .LT. npz/6)
THEN 2093 IF (cx(i, j, k) .GE. 0.)
THEN 2098 IF (cy(i, j, k) .GE. 0.)
THEN 2103 IF (cmax(k) .LT. y1)
THEN 2104 IF (y1 .LT. z1)
THEN 2109 ELSE IF (cmax(k) .LT. z1)
THEN 2119 IF (cx(i, j, k) .GE. 0.)
THEN 2124 IF (cy(i, j, k) .GE. 0.)
THEN 2129 IF (x1 .LT. y3)
THEN 2134 y2 = max1 + 1. - sin_sg(i, j, 5)
2135 IF (cmax(k) .LT. y2)
THEN 2148 IF (q_split .EQ. 0)
THEN 2149 CALL mp_reduce_max(cmax, npz)
2152 IF (npz .NE. 1)
THEN 2155 IF (cmax(k) .LT. c_global)
THEN 2162 nsplt = int(1. + c_global)
2163 IF (is_master() .AND. nsplt .GT. 4)
WRITE(*, *)
'Tracer_2d_split='&
2169 IF (nsplt .NE. 1)
THEN 2173 ksplt(k) = int(1. + cmax(k))
2174 frac = 1./
REAL(ksplt(k))
2177 cx(i, j, k) = cx(i, j, k)*frac
2178 xfx(i, j, k) = xfx(i, j, k)*frac
2183 mfx(i, j, k) = mfx(i, j, k)*frac
2188 cy(i, j, k) = cy(i, j, k)*frac
2189 yfx(i, j, k) = yfx(i, j, k)*frac
2194 mfy(i, j, k) = mfy(i, j, k)*frac
2202 CALL complete_group_halo_update(q_pack, domain)
2210 IF (it .LE. ksplt(k))
THEN 2213 dp2(i, j) = dp1(i, j, k) + (mfx(i, j, k)-mfx(i+1, j, k)+(&
2214 & mfy(i, j, k)-mfy(i, j+1, k)))*rarea(i, j)
2219 ra_x(i, j) = area(i, j) + (xfx(i, j, k)-xfx(i+1, j, k))
2224 ra_y(i, j) = area(i, j) + (yfx(i, j, k)-yfx(i, j+1, k))
2228 IF (it .EQ. 1 .AND. trdm .GT. 1.e-4)
THEN 2229 IF (hord .EQ. hord_pert)
THEN 2230 CALL fv_tp_2d(q(isd:ied, jsd:jed, k, iq), cx(is:ie+1&
2231 & , jsd:jed, k), cy(isd:ied, js:je+1, k), npx, &
2232 & npy, hord, fx, fy, xfx(is:ie+1, jsd:jed, k), &
2233 & yfx(isd:ied, js:je+1, k), gridstruct, bd, &
2234 & ra_x, ra_y, mfx(is:ie+1, js:je, k), mfy(is:ie&
2235 & , js:je+1, k), dp1(isd:ied, jsd:jed, k), &
2238 CALL fv_tp_2d(q(isd:ied, jsd:jed, k, iq), cx(is:ie+1, &
2239 & jsd:jed, k), cy(isd:ied, js:je+1, k), npx, npy, &
2240 & hord, fx, fy, xfx(is:ie+1, jsd:jed, k), yfx&
2241 & (isd:ied, js:je+1, k), gridstruct, bd, ra_x, &
2242 & ra_y, mfx(is:ie+1, js:je, k), mfy(is:ie, js:je+1&
2243 & , k), dp1(isd:ied, jsd:jed, k), nord_tr, trdm)
2245 ELSE IF (hord .EQ. hord_pert)
THEN 2246 CALL fv_tp_2d(q(isd:ied, jsd:jed, k, iq), cx(is:ie+1, &
2247 & jsd:jed, k), cy(isd:ied, js:je+1, k), npx, npy&
2248 & , hord, fx, fy, xfx(is:ie+1, jsd:jed, k), yfx(&
2249 & isd:ied, js:je+1, k), gridstruct, bd, ra_x, &
2250 & ra_y, mfx=mfx(is:ie+1, js:je, k), mfy=mfy(is:ie&
2253 CALL fv_tp_2d(q(isd:ied, jsd:jed, k, iq), cx(is:ie+1, jsd:&
2254 & jed, k), cy(isd:ied, js:je+1, k), npx, npy, &
2255 & hord, fx, fy, xfx(is:ie+1, jsd:jed, k), yfx(&
2256 & isd:ied, js:je+1, k), gridstruct, bd, ra_x, ra_y, &
2257 & mfx=mfx(is:ie+1, js:je, k), mfy=mfy(is:ie, js:je+1&
2262 q(i, j, k, iq) = (q(i, j, k, iq)*dp1(i, j, k)+(fx(i, j)-&
2263 & fx(i+1, j)+(fy(i, j)-fy(i, j+1)))*rarea(i, j))/dp2(i, &
2268 IF (it .NE. nsplt)
THEN 2271 dp1(i, j, k) = dp2(i, j)
2278 IF (it .NE. nsplt)
THEN 2287 IF (
PRESENT(dpa)) dpa = dp1(bd%is:bd%ie, bd%js:bd%je, 1:npz)
2310 & bd, domain, npx, npy, npz, nq, hord, q_split, dt, id_divg, q_pack, &
2311 & nord_tr, trdm, k_split, neststruct, parent_grid, hord_pert, &
2312 & nord_tr_pert, trdm_pert, split_damp_tr)
2317 INTEGER,
INTENT(IN) :: npx
2318 INTEGER,
INTENT(IN) :: npy
2319 INTEGER,
INTENT(IN) :: npz
2321 INTEGER,
INTENT(IN) :: nq
2322 INTEGER,
INTENT(IN) :: hord, nord_tr
2323 INTEGER,
INTENT(IN) :: hord_pert, nord_tr_pert
2324 LOGICAL,
INTENT(IN) :: split_damp_tr
2325 INTEGER,
INTENT(IN) :: q_split, k_split
2326 INTEGER,
INTENT(IN) :: id_divg
2327 REAL,
INTENT(IN) :: dt, trdm, trdm_pert
2328 TYPE(group_halo_update_type),
INTENT(INOUT) :: q_pack
2330 REAL,
INTENT(INOUT) :: q(bd%isd:bd%ied, bd%jsd:bd%jed, npz, nq)
2332 REAL,
INTENT(INOUT) :: dp1(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
2334 REAL,
INTENT(INOUT) :: mfx(bd%is:bd%ie+1, bd%js:bd%je, npz)
2336 REAL,
INTENT(INOUT) :: mfy(bd%is:bd%ie, bd%js:bd%je+1, npz)
2338 REAL,
INTENT(INOUT) :: cx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
2340 REAL,
INTENT(INOUT) :: cy(bd%isd:bd%ied, bd%js:bd%je+1, npz)
2344 TYPE(
domain2d),
INTENT(INOUT) :: domain
2346 REAL :: dp2(bd%is:bd%ie, bd%js:bd%je)
2347 REAL :: fx(bd%is:bd%ie+1, bd%js:bd%je)
2348 REAL :: fy(bd%is:bd%ie, bd%js:bd%je+1)
2349 REAL :: ra_x(bd%is:bd%ie, bd%jsd:bd%jed)
2350 REAL :: ra_y(bd%isd:bd%ied, bd%js:bd%je)
2351 REAL :: xfx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
2352 REAL :: yfx(bd%isd:bd%ied, bd%js:bd%je+1, npz)
2357 INTEGER :: nsplt, nsplt_parent
2358 INTEGER,
SAVE :: msg_split_steps=1
2359 INTEGER :: i, j, k, it, iq
2360 REAL,
DIMENSION(:, :),
POINTER :: area, rarea
2361 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg
2362 REAL,
DIMENSION(:, :),
POINTER :: dxa, dya, dx, dy
2363 INTEGER :: is, ie, js, je
2364 INTEGER :: isd, ied, jsd, jed
2418 area => gridstruct%area
2419 rarea => gridstruct%rarea
2420 sin_sg => gridstruct%sin_sg
2421 dxa => gridstruct%dxa
2422 dya => gridstruct%dya
2430 IF (cx(i, j, k) .GT. 0.)
THEN 2431 xfx(i, j, k) = cx(i, j, k)*dxa(i-1, j)*dy(i, j)*sin_sg(i-1, &
2435 xfx(i, j, k) = cx(i, j, k)*dxa(i, j)*dy(i, j)*sin_sg(i, j, 1&
2443 IF (cy(i, j, k) .GT. 0.)
THEN 2444 yfx(i, j, k) = cy(i, j, k)*dya(i, j-1)*dx(i, j)*sin_sg(i, j-&
2448 yfx(i, j, k) = cy(i, j, k)*dya(i, j)*dx(i, j)*sin_sg(i, j, 2&
2456 IF (q_split .EQ. 0)
THEN 2466 IF (cx(i, j, k) .GE. 0.)
THEN 2471 IF (cy(i, j, k) .GE. 0.)
THEN 2476 IF (x1 .LT. y1)
THEN 2481 IF (cmax_t .LT. cmax(k))
THEN 2494 IF (cx(i, j, k) .GE. 0.)
THEN 2499 IF (cy(i, j, k) .GE. 0.)
THEN 2504 IF (x2 .LT. y2)
THEN 2509 cmax_t = max1 + 1. - sin_sg(i, j, 5)
2510 IF (cmax_t .LT. cmax(k))
THEN 2522 CALL mp_reduce_max(cmax, npz)
2525 IF (npz .NE. 1)
THEN 2528 IF (cmax(k) .LT. c_global)
THEN 2540 nsplt = int(1. + c_global)
2542 IF (res .AND. nsplt .GT. 3)
THEN 2544 WRITE(*, *)
'Tracer_2d_split=', nsplt, c_global
2553 frac = 1./
REAL(nsplt)
2554 IF (nsplt .NE. 1)
THEN 2560 cx(i, j, k) = cx(i, j, k)*frac
2561 xfx(i, j, k) = xfx(i, j, k)*frac
2567 mfx(i, j, k) = mfx(i, j, k)*frac
2573 cy(i, j, k) = cy(i, j, k)*frac
2574 yfx(i, j, k) = yfx(i, j, k)*frac
2580 mfy(i, j, k) = mfy(i, j, k)*frac
2589 IF (gridstruct%nested) neststruct%tracer_nest_timestep = &
2590 & neststruct%tracer_nest_timestep + 1
2591 IF (gridstruct%nested)
THEN 2593 arg1 =
REAL(neststruct%tracer_nest_timestep) +
REAL(nsplt*&
2595 arg2 = real(nsplt*k_split)
2596 CALL pushrealarray(q(isd:ied, jsd:jed, :, iq), (ied-isd+1)*(&
2598 CALL nested_grid_bc_apply_intt(q(isd:ied, jsd:jed, :, iq), 0, &
2599 & 0, npx, npy, npz, bd,
REAL(neststruct&
& %tracer_nest_timestep) +
REAL(nsplt*&
& k_split),
REAL(nsplt*k_split), &
2600 & neststruct%q_bc(iq), bctype=&
2601 & neststruct%nestbctype)
2614 dp2(i, j) = dp1(i, j, k) + (mfx(i, j, k)-mfx(i+1, j, k)+(mfy&
2615 & (i, j, k)-mfy(i, j+1, k)))*rarea(i, j)
2621 ra_x(i, j) = area(i, j) + (xfx(i, j, k)-xfx(i+1, j, k))
2627 ra_y(i, j) = area(i, j) + (yfx(i, j, k)-yfx(i, j+1, k))
2631 IF (it .EQ. 1 .AND. trdm .GT. 1.e-4)
THEN 2632 IF (hord .EQ. hord_pert)
THEN 2633 CALL fv_tp_2d_fwd(q(isd:ied, jsd:jed, k, iq), cx(is:ie+&
2634 & 1, jsd:jed, k), cy(isd:ied, js:je+1, k), &
2635 & npx, npy, hord, fx, fy, xfx(is:ie+1, jsd:&
2636 & jed, k), yfx(isd:ied, js:je+1, k), &
2637 & gridstruct, bd, ra_x, ra_y, mfx=mfx(is:ie+1&
2638 & , js:je, k), mfy=mfy(is:ie, js:je+1, k), &
2639 & mass=dp1(isd:ied, jsd:jed, k), nord=nord_tr&
2647 CALL fv_tp_2d(q(isd:ied, jsd:jed, k, iq), cx(is:ie+1, jsd:&
2648 & jed, k), cy(isd:ied, js:je+1, k), npx, npy, &
2649 & hord, fx, fy, xfx(is:ie+1, jsd:jed, k), yfx(&
2650 & isd:ied, js:je+1, k), gridstruct, bd, ra_x, ra_y, &
2651 & mfx=mfx(is:ie+1, js:je, k), mfy=mfy(is:ie, js:je+1&
2652 & , k), mass=dp1(isd:ied, jsd:jed, k), nord=nord_tr&
2656 ELSE IF (hord .EQ. hord_pert)
THEN 2657 CALL fv_tp_2d_fwd(q(isd:ied, jsd:jed, k, iq), cx(is:ie+1&
2658 & , jsd:jed, k), cy(isd:ied, js:je+1, k), npx, &
2659 & npy, hord, fx, fy, xfx(is:ie+1, jsd:jed, k), &
2660 & yfx(isd:ied, js:je+1, k), gridstruct, bd, &
2661 & ra_x, ra_y, mfx=mfx(is:ie+1, js:je, k), mfy=&
2662 & mfy(is:ie, js:je+1, k))
2667 CALL pushrealarray(q(isd:ied, jsd:jed, k, iq), (ied-isd+1)*&
2669 CALL fv_tp_2d(q(isd:ied, jsd:jed, k, iq), cx(is:ie+1, jsd:&
2670 & jed, k), cy(isd:ied, js:je+1, k), npx, npy, &
2671 & hord, fx, fy, xfx(is:ie+1, jsd:jed, k), yfx(isd&
2672 & :ied, js:je+1, k), gridstruct, bd, ra_x, ra_y, mfx=&
2673 & mfx(is:ie+1, js:je, k), mfy=mfy(is:ie, js:je+1, k))
2679 q(i, j, k, iq) = (q(i, j, k, iq)*dp1(i, j, k)+(fx(i, j)-fx&
2680 & (i+1, j)+(fy(i, j)-fy(i, j+1)))*rarea(i, j))/dp2(i, j)
2686 IF (it .NE. nsplt)
THEN 2687 CALL pushrealarray(q, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*npz*&
2695 IF (gridstruct%nested)
THEN 2697 arg1 =
REAL(neststruct%tracer_nest_timestep)
2698 arg2 =
REAL(nsplt*k_split)
2699 CALL pushrealarray(q(isd:ied, jsd:jed, :, iq), (ied-isd+1)*(&
2701 CALL nested_grid_bc_apply_intt(q(isd:ied, jsd:jed, :, iq), 0, &
2702 & 0, npx, npy, npz, bd,
REAL(neststruct&
& %tracer_nest_timestep),
REAL(nsplt*&
& k_split), neststruct%q_bc(iq), bctype&
2703 & =neststruct%nestbctype)
2711 IF (id_divg .GT. 0)
THEN 2718 dp1(i, j, k) = (xfx(i+1, j, k)-xfx(i, j, k)+(yfx(i, j+1, k)-&
2719 & yfx(i, j, k)))*rarea(i, j)*rdt
2729 CALL pushrealarray(yfx, (bd%ied-bd%isd+1)*(bd%je-bd%js+2)*npz)
2736 CALL pushrealarray(xfx, (bd%ie-bd%is+2)*(bd%jed-bd%jsd+1)*npz)
2745 CALL pushrealarray(yfx, (bd%ied-bd%isd+1)*(bd%je-bd%js+2)*npz)
2752 CALL pushrealarray(xfx, (bd%ie-bd%is+2)*(bd%jed-bd%jsd+1)*npz)
2778 & , mfy_ad, cx, cx_ad, cy, cy_ad, gridstruct, bd, domain, npx, npy, &
2779 & npz, nq, hord, q_split, dt, id_divg, q_pack, nord_tr, trdm, k_split&
2780 & , neststruct, parent_grid, hord_pert, nord_tr_pert, trdm_pert, &
2786 INTEGER,
INTENT(IN) :: npx
2787 INTEGER,
INTENT(IN) :: npy
2788 INTEGER,
INTENT(IN) :: npz
2789 INTEGER,
INTENT(IN) :: nq
2790 INTEGER,
INTENT(IN) :: hord, nord_tr
2791 INTEGER,
INTENT(IN) :: hord_pert, nord_tr_pert
2792 LOGICAL,
INTENT(IN) :: split_damp_tr
2793 INTEGER,
INTENT(IN) :: q_split, k_split
2794 INTEGER,
INTENT(IN) :: id_divg
2795 REAL,
INTENT(IN) :: dt, trdm, trdm_pert
2796 TYPE(group_halo_update_type),
INTENT(INOUT) :: q_pack
2797 REAL,
INTENT(INOUT) :: q(bd%isd:bd%ied, bd%jsd:bd%jed, npz, nq)
2798 REAL,
INTENT(INOUT) :: q_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz, nq)
2799 REAL,
INTENT(INOUT) :: dp1(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
2800 REAL,
INTENT(INOUT) :: dp1_ad(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
2801 REAL,
INTENT(INOUT) :: mfx(bd%is:bd%ie+1, bd%js:bd%je, npz)
2802 REAL,
INTENT(INOUT) :: mfx_ad(bd%is:bd%ie+1, bd%js:bd%je, npz)
2803 REAL,
INTENT(INOUT) :: mfy(bd%is:bd%ie, bd%js:bd%je+1, npz)
2804 REAL,
INTENT(INOUT) :: mfy_ad(bd%is:bd%ie, bd%js:bd%je+1, npz)
2805 REAL,
INTENT(INOUT) :: cx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
2806 REAL,
INTENT(INOUT) :: cx_ad(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
2807 REAL,
INTENT(INOUT) :: cy(bd%isd:bd%ied, bd%js:bd%je+1, npz)
2808 REAL,
INTENT(INOUT) :: cy_ad(bd%isd:bd%ied, bd%js:bd%je+1, npz)
2812 TYPE(
domain2d),
INTENT(INOUT) :: domain
2813 REAL :: dp2(bd%is:bd%ie, bd%js:bd%je)
2814 REAL :: dp2_ad(bd%is:bd%ie, bd%js:bd%je)
2815 REAL :: fx(bd%is:bd%ie+1, bd%js:bd%je)
2816 REAL :: fx_ad(bd%is:bd%ie+1, bd%js:bd%je)
2817 REAL :: fy(bd%is:bd%ie, bd%js:bd%je+1)
2818 REAL :: fy_ad(bd%is:bd%ie, bd%js:bd%je+1)
2819 REAL :: ra_x(bd%is:bd%ie, bd%jsd:bd%jed)
2820 REAL :: ra_x_ad(bd%is:bd%ie, bd%jsd:bd%jed)
2821 REAL :: ra_y(bd%isd:bd%ied, bd%js:bd%je)
2822 REAL :: ra_y_ad(bd%isd:bd%ied, bd%js:bd%je)
2823 REAL :: xfx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
2824 REAL :: xfx_ad(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
2825 REAL :: yfx(bd%isd:bd%ied, bd%js:bd%je+1, npz)
2826 REAL :: yfx_ad(bd%isd:bd%ied, bd%js:bd%je+1, npz)
2831 INTEGER :: nsplt, nsplt_parent
2832 INTEGER,
SAVE :: msg_split_steps=1
2833 INTEGER :: i, j, k, it, iq
2834 REAL,
DIMENSION(:, :),
POINTER :: area, rarea
2835 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg
2836 REAL,
DIMENSION(:, :),
POINTER :: dxa, dya, dx, dy
2837 INTEGER :: is, ie, js, je
2838 INTEGER :: isd, ied, jsd, jed
2893 IF (branch .EQ. 0)
THEN 2895 CALL poprealarray(xfx, (bd%ie-bd%is+2)*(bd%jed-bd%jsd+1)*npz)
2897 rarea => gridstruct%rarea
2899 CALL poprealarray(dp2, (bd%ie-bd%is+1)*(bd%je-bd%js+1))
2902 CALL poprealarray(ra_x, (bd%ie-bd%is+1)*(bd%jed-bd%jsd+1))
2903 CALL poprealarray(ra_y, (bd%ied-bd%isd+1)*(bd%je-bd%js+1))
2904 CALL poprealarray(yfx, (bd%ied-bd%isd+1)*(bd%je-bd%js+2)*npz)
2914 CALL poprealarray(xfx, (bd%ie-bd%is+2)*(bd%jed-bd%jsd+1)*npz)
2916 rarea => gridstruct%rarea
2918 CALL poprealarray(dp2, (bd%ie-bd%is+1)*(bd%je-bd%js+1))
2921 CALL poprealarray(ra_x, (bd%ie-bd%is+1)*(bd%jed-bd%jsd+1))
2922 CALL poprealarray(ra_y, (bd%ied-bd%isd+1)*(bd%je-bd%js+1))
2923 CALL poprealarray(yfx, (bd%ied-bd%isd+1)*(bd%je-bd%js+2)*npz)
2936 temp_ad2 = rarea(i, j)*rdt*dp1_ad(i, j, k)
2937 xfx_ad(i+1, j, k) = xfx_ad(i+1, j, k) + temp_ad2
2938 xfx_ad(i, j, k) = xfx_ad(i, j, k) - temp_ad2
2939 yfx_ad(i, j+1, k) = yfx_ad(i, j+1, k) + temp_ad2
2940 yfx_ad(i, j, k) = yfx_ad(i, j, k) - temp_ad2
2941 dp1_ad(i, j, k) = 0.0
2961 IF (branch .NE. 0)
THEN 2963 CALL poprealarray(q(isd:ied, jsd:jed, :, iq), (ied-isd+1)*(&
2966 & , q_ad(isd:ied, jsd:jed, :, iq), &
2967 & 0, 0, npx, npy, npz, bd, arg1, &
2968 & arg2, neststruct%q_bc(iq), &
2969 & neststruct%nestbctype)
2973 IF (branch .EQ. 0)
THEN 2974 CALL poprealarray(q, (bd%ied-bd%isd+1)*(bd%jed-bd%jsd+1)*npz*nq&
2983 temp_ad0 = q_ad(i, j, k, iq)/dp2(i, j)
2984 temp = q(i, j, k, iq)
2985 temp_ad1 = rarea(i, j)*temp_ad0
2986 dp1_ad(i, j, k) = dp1_ad(i, j, k) + temp*temp_ad0
2987 fx_ad(i, j) = fx_ad(i, j) + temp_ad1
2988 fx_ad(i+1, j) = fx_ad(i+1, j) - temp_ad1
2989 fy_ad(i, j) = fy_ad(i, j) + temp_ad1
2990 fy_ad(i, j+1) = fy_ad(i, j+1) - temp_ad1
2991 dp2_ad(i, j) = dp2_ad(i, j) - (temp*dp1(i, j, k)+rarea(i, &
2992 & j)*(fx(i, j)-fx(i+1, j)+fy(i, j)-fy(i, j+1)))*temp_ad0/&
2994 q_ad(i, j, k, iq) = dp1(i, j, k)*temp_ad0
2998 IF (branch .LT. 2)
THEN 2999 IF (branch .EQ. 0)
THEN 3000 CALL poprealarray(q(isd:ied, jsd:jed, k, iq), (ied-isd+1)&
3004 CALL fv_tp_2d_adm(q(isd:ied, jsd:jed, k, iq), q_ad(isd:ied&
3005 & , jsd:jed, k, iq), cx(is:ie+1, jsd:jed, k), &
3006 & cx_ad(is:ie+1, jsd:jed, k), cy(isd:ied, js:je+&
3007 & 1, k), cy_ad(isd:ied, js:je+1, k), npx, npy, &
3008 & hord_pert, fx, fx_ad, fy, fy_ad, xfx(is:ie+1, &
3009 & jsd:jed, k), xfx_ad(is:ie+1, jsd:jed, k), yfx(&
3010 & isd:ied, js:je+1, k), yfx_ad(isd:ied, js:je+1&
3011 & , k), gridstruct, bd, ra_x, ra_x_ad, ra_y, &
3012 & ra_y_ad, mfx(is:ie+1, js:je, k), mfx_ad(is:ie+&
3013 & 1, js:je, k), mfy(is:ie, js:je+1, k), mfy_ad(&
3014 & is:ie, js:je+1, k))
3016 CALL fv_tp_2d_bwd(q(isd:ied, jsd:jed, k, iq), q_ad(isd:&
3017 & ied, jsd:jed, k, iq), cx(is:ie+1, jsd:jed, &
3018 & k), cx_ad(is:ie+1, jsd:jed, k), cy(isd:ied&
3019 & , js:je+1, k), cy_ad(isd:ied, js:je+1, k), &
3020 & npx, npy, hord, fx, fx_ad, fy, fy_ad, xfx(&
3021 & is:ie+1, jsd:jed, k), xfx_ad(is:ie+1, jsd:&
3022 & jed, k), yfx(isd:ied, js:je+1, k), yfx_ad(&
3023 & isd:ied, js:je+1, k), gridstruct, bd, ra_x&
3024 & , ra_x_ad, ra_y, ra_y_ad, mfx(is:ie+1, js:&
3025 & je, k), mfx_ad(is:ie+1, js:je, k), mfy(is:&
3026 & ie, js:je+1, k), mfy_ad(is:ie, js:je+1, k))
3028 ELSE IF (branch .EQ. 2)
THEN 3029 CALL poprealarray(q(isd:ied, jsd:jed, k, iq), (ied-isd+1)*(&
3033 CALL fv_tp_2d_adm(q(isd:ied, jsd:jed, k, iq), q_ad(isd:ied, &
3034 & jsd:jed, k, iq), cx(is:ie+1, jsd:jed, k), cx_ad(&
3035 & is:ie+1, jsd:jed, k), cy(isd:ied, js:je+1, k), &
3036 & cy_ad(isd:ied, js:je+1, k), npx, npy, hord_pert&
3037 & , fx, fx_ad, fy, fy_ad, xfx(is:ie+1, jsd:jed, k)&
3038 & , xfx_ad(is:ie+1, jsd:jed, k), yfx(isd:ied, js:&
3039 & je+1, k), yfx_ad(isd:ied, js:je+1, k), &
3040 & gridstruct, bd, ra_x, ra_x_ad, ra_y, ra_y_ad, &
3041 & mfx(is:ie+1, js:je, k), mfx_ad(is:ie+1, js:je, k&
3042 & ), mfy(is:ie, js:je+1, k), mfy_ad(is:ie, js:je+1&
3043 & , k), dp1(isd:ied, jsd:jed, k), dp1_ad(isd:ied, &
3044 & jsd:jed, k), nord=nord_tr_pert, damp_c=trdm_pert&
3047 CALL fv_tp_2d_bwd(q(isd:ied, jsd:jed, k, iq), q_ad(isd:&
3048 & ied, jsd:jed, k, iq), cx(is:ie+1, jsd:jed, k)&
3049 & , cx_ad(is:ie+1, jsd:jed, k), cy(isd:ied, js:&
3050 & je+1, k), cy_ad(isd:ied, js:je+1, k), npx, &
3051 & npy, hord, fx, fx_ad, fy, fy_ad, xfx(is:ie+1&
3052 & , jsd:jed, k), xfx_ad(is:ie+1, jsd:jed, k), &
3053 & yfx(isd:ied, js:je+1, k), yfx_ad(isd:ied, js:&
3054 & je+1, k), gridstruct, bd, ra_x, ra_x_ad, ra_y&
3055 & , ra_y_ad, mfx(is:ie+1, js:je, k), mfx_ad(is:&
3056 & ie+1, js:je, k), mfy(is:ie, js:je+1, k), &
3057 & mfy_ad(is:ie, js:je+1, k), dp1(isd:ied, jsd:&
3058 & jed, k), dp1_ad(isd:ied, jsd:jed, k), nord=&
3059 & nord_tr, damp_c=trdm)
3065 yfx_ad(i, j, k) = yfx_ad(i, j, k) + ra_y_ad(i, j)
3066 yfx_ad(i, j+1, k) = yfx_ad(i, j+1, k) - ra_y_ad(i, j)
3073 xfx_ad(i, j, k) = xfx_ad(i, j, k) + ra_x_ad(i, j)
3074 xfx_ad(i+1, j, k) = xfx_ad(i+1, j, k) - ra_x_ad(i, j)
3081 temp_ad = rarea(i, j)*dp2_ad(i, j)
3082 dp1_ad(i, j, k) = dp1_ad(i, j, k) + dp2_ad(i, j)
3083 mfx_ad(i, j, k) = mfx_ad(i, j, k) + temp_ad
3084 mfx_ad(i+1, j, k) = mfx_ad(i+1, j, k) - temp_ad
3085 mfy_ad(i, j, k) = mfy_ad(i, j, k) + temp_ad
3086 mfy_ad(i, j+1, k) = mfy_ad(i, j+1, k) - temp_ad
3092 IF (branch .NE. 0)
THEN 3094 CALL poprealarray(q(isd:ied, jsd:jed, :, iq), (ied-isd+1)*(&
3097 & , q_ad(isd:ied, jsd:jed, :, iq), &
3098 & 0, 0, npx, npy, npz, bd, arg1, &
3099 & arg2, neststruct%q_bc(iq), &
3100 & neststruct%nestbctype)
3105 IF (branch .NE. 0)
THEN 3110 mfy_ad(i, j, k) = frac*mfy_ad(i, j, k)
3115 yfx_ad(i, j, k) = frac*yfx_ad(i, j, k)
3117 cy_ad(i, j, k) = frac*cy_ad(i, j, k)
3123 mfx_ad(i, j, k) = frac*mfx_ad(i, j, k)
3128 xfx_ad(i, j, k) = frac*xfx_ad(i, j, k)
3130 cx_ad(i, j, k) = frac*cx_ad(i, j, k)
3136 IF (branch .EQ. 0)
THEN 3138 IF (branch .EQ. 0)
THEN 3143 sin_sg => gridstruct%sin_sg
3146 IF (branch .EQ. 0)
THEN 3161 sin_sg => gridstruct%sin_sg
3163 dxa => gridstruct%dxa
3166 dya => gridstruct%dya
3171 IF (branch .EQ. 0)
THEN 3172 cy_ad(i, j, k) = cy_ad(i, j, k) + dya(i, j)*dx(i, j)*sin_sg(&
3173 & i, j, 2)*yfx_ad(i, j, k)
3174 yfx_ad(i, j, k) = 0.0
3176 cy_ad(i, j, k) = cy_ad(i, j, k) + dya(i, j-1)*dx(i, j)*&
3177 & sin_sg(i, j-1, 4)*yfx_ad(i, j, k)
3178 yfx_ad(i, j, k) = 0.0
3185 IF (branch .EQ. 0)
THEN 3186 cx_ad(i, j, k) = cx_ad(i, j, k) + dxa(i, j)*dy(i, j)*sin_sg(&
3187 & i, j, 1)*xfx_ad(i, j, k)
3188 xfx_ad(i, j, k) = 0.0
3190 cx_ad(i, j, k) = cx_ad(i, j, k) + dxa(i-1, j)*dy(i, j)*&
3191 & sin_sg(i-1, j, 3)*xfx_ad(i, j, k)
3192 xfx_ad(i, j, k) = 0.0
3199 & domain, npx, npy, npz, nq, hord, q_split, dt, id_divg, q_pack, &
3200 & nord_tr, trdm, k_split, neststruct, parent_grid, hord_pert, &
3201 & nord_tr_pert, trdm_pert, split_damp_tr)
3204 INTEGER,
INTENT(IN) :: npx
3205 INTEGER,
INTENT(IN) :: npy
3206 INTEGER,
INTENT(IN) :: npz
3208 INTEGER,
INTENT(IN) :: nq
3209 INTEGER,
INTENT(IN) :: hord, nord_tr
3210 INTEGER,
INTENT(IN) :: hord_pert, nord_tr_pert
3211 LOGICAL,
INTENT(IN) :: split_damp_tr
3212 INTEGER,
INTENT(IN) :: q_split, k_split
3213 INTEGER,
INTENT(IN) :: id_divg
3214 REAL,
INTENT(IN) :: dt, trdm, trdm_pert
3215 TYPE(group_halo_update_type),
INTENT(INOUT) :: q_pack
3217 REAL,
INTENT(INOUT) :: q(bd%isd:bd%ied, bd%jsd:bd%jed, npz, nq)
3219 REAL,
INTENT(INOUT) :: dp1(bd%isd:bd%ied, bd%jsd:bd%jed, npz)
3221 REAL,
INTENT(INOUT) :: mfx(bd%is:bd%ie+1, bd%js:bd%je, npz)
3223 REAL,
INTENT(INOUT) :: mfy(bd%is:bd%ie, bd%js:bd%je+1, npz)
3225 REAL,
INTENT(INOUT) :: cx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
3227 REAL,
INTENT(INOUT) :: cy(bd%isd:bd%ied, bd%js:bd%je+1, npz)
3231 TYPE(
domain2d),
INTENT(INOUT) :: domain
3233 REAL :: dp2(bd%is:bd%ie, bd%js:bd%je)
3234 REAL :: fx(bd%is:bd%ie+1, bd%js:bd%je)
3235 REAL :: fy(bd%is:bd%ie, bd%js:bd%je+1)
3236 REAL :: ra_x(bd%is:bd%ie, bd%jsd:bd%jed)
3237 REAL :: ra_y(bd%isd:bd%ied, bd%js:bd%je)
3238 REAL :: xfx(bd%is:bd%ie+1, bd%jsd:bd%jed, npz)
3239 REAL :: yfx(bd%isd:bd%ied, bd%js:bd%je+1, npz)
3244 INTEGER :: nsplt, nsplt_parent
3245 INTEGER,
SAVE :: msg_split_steps=1
3246 INTEGER :: i, j, k, it, iq
3247 REAL,
DIMENSION(:, :),
POINTER :: area, rarea
3248 REAL,
DIMENSION(:, :, :),
POINTER :: sin_sg
3249 REAL,
DIMENSION(:, :),
POINTER :: dxa, dya, dx, dy
3250 INTEGER :: is, ie, js, je
3251 INTEGER :: isd, ied, jsd, jed
3271 area => gridstruct%area
3272 rarea => gridstruct%rarea
3273 sin_sg => gridstruct%sin_sg
3274 dxa => gridstruct%dxa
3275 dya => gridstruct%dya
3283 IF (cx(i, j, k) .GT. 0.)
THEN 3284 xfx(i, j, k) = cx(i, j, k)*dxa(i-1, j)*dy(i, j)*sin_sg(i-1, &
3287 xfx(i, j, k) = cx(i, j, k)*dxa(i, j)*dy(i, j)*sin_sg(i, j, 1&
3294 IF (cy(i, j, k) .GT. 0.)
THEN 3295 yfx(i, j, k) = cy(i, j, k)*dya(i, j-1)*dx(i, j)*sin_sg(i, j-&
3298 yfx(i, j, k) = cy(i, j, k)*dya(i, j)*dx(i, j)*sin_sg(i, j, 2&
3305 IF (q_split .EQ. 0)
THEN 3315 IF (cx(i, j, k) .GE. 0.)
THEN 3320 IF (cy(i, j, k) .GE. 0.)
THEN 3325 IF (x1 .LT. y1)
THEN 3330 IF (cmax_t .LT. cmax(k))
THEN 3340 IF (cx(i, j, k) .GE. 0.)
THEN 3345 IF (cy(i, j, k) .GE. 0.)
THEN 3350 IF (x2 .LT. y2)
THEN 3355 cmax_t = max1 + 1. - sin_sg(i, j, 5)
3356 IF (cmax_t .LT. cmax(k))
THEN 3365 CALL mp_reduce_max(cmax, npz)
3368 IF (npz .NE. 1)
THEN 3371 IF (cmax(k) .LT. c_global)
THEN 3378 nsplt = int(1. + c_global)
3379 IF (is_master() .AND. nsplt .GT. 3)
WRITE(*, *)
'Tracer_2d_split='&
3383 IF (gridstruct%nested .AND. neststruct%nestbctype .GT. 1)
THEN 3384 IF (q_split/parent_grid%flagstruct%q_split .LT. 1)
THEN 3387 msg_split_steps = q_split/parent_grid%flagstruct%q_split
3392 frac = 1./
REAL(nsplt)
3393 IF (nsplt .NE. 1)
THEN 3398 cx(i, j, k) = cx(i, j, k)*frac
3399 xfx(i, j, k) = xfx(i, j, k)*frac
3404 mfx(i, j, k) = mfx(i, j, k)*frac
3409 cy(i, j, k) = cy(i, j, k)*frac
3410 yfx(i, j, k) = yfx(i, j, k)*frac
3415 mfy(i, j, k) = mfy(i, j, k)*frac
3421 IF (gridstruct%nested) neststruct%tracer_nest_timestep = &
3422 & neststruct%tracer_nest_timestep + 1
3425 CALL complete_group_halo_update(q_pack, domain)
3428 IF (gridstruct%nested)
THEN 3430 arg1 =
REAL(neststruct%tracer_nest_timestep) +
REAL(nsplt*&
3432 arg2 = real(nsplt*k_split)
3433 CALL nested_grid_bc_apply_intt(q(isd:ied, jsd:jed, :, iq), 0, &
3434 & 0, npx, npy, npz, bd, arg1, arg2, &
3435 & neststruct%q_bc(iq), neststruct%&
3445 dp2(i, j) = dp1(i, j, k) + (mfx(i, j, k)-mfx(i+1, j, k)+(mfy&
3446 & (i, j, k)-mfy(i, j+1, k)))*rarea(i, j)
3451 ra_x(i, j) = area(i, j) + (xfx(i, j, k)-xfx(i+1, j, k))
3456 ra_y(i, j) = area(i, j) + (yfx(i, j, k)-yfx(i, j+1, k))
3460 IF (it .EQ. 1 .AND. trdm .GT. 1.e-4)
THEN 3461 IF (hord .EQ. hord_pert)
THEN 3462 CALL fv_tp_2d(q(isd:ied, jsd:jed, k, iq), cx(is:ie+1, &
3463 & jsd:jed, k), cy(isd:ied, js:je+1, k), npx, npy&
3464 & , hord, fx, fy, xfx(is:ie+1, jsd:jed, k), yfx(&
3465 & isd:ied, js:je+1, k), gridstruct, bd, ra_x, &
3466 & ra_y, mfx(is:ie+1, js:je, k), mfy(is:ie, js:je+&
3467 & 1, k), dp1(isd:ied, jsd:jed, k), nord_tr, trdm)
3469 CALL fv_tp_2d(q(isd:ied, jsd:jed, k, iq), cx(is:ie+1, jsd:&
3470 & jed, k), cy(isd:ied, js:je+1, k), npx, npy, &
3471 & hord, fx, fy, xfx(is:ie+1, jsd:jed, k), yfx(&
3472 & isd:ied, js:je+1, k), gridstruct, bd, ra_x, ra_y, &
3473 & mfx(is:ie+1, js:je, k), mfy(is:ie, js:je+1, k), &
3474 & dp1(isd:ied, jsd:jed, k), nord_tr, trdm)
3476 ELSE IF (hord .EQ. hord_pert)
THEN 3477 CALL fv_tp_2d(q(isd:ied, jsd:jed, k, iq), cx(is:ie+1, jsd&
3478 & :jed, k), cy(isd:ied, js:je+1, k), npx, npy, hord&
3479 & , fx, fy, xfx(is:ie+1, jsd:jed, k), yfx(isd:ied, &
3480 & js:je+1, k), gridstruct, bd, ra_x, ra_y, mfx=mfx(&
3481 & is:ie+1, js:je, k), mfy=mfy(is:ie, js:je+1, k))
3483 CALL fv_tp_2d(q(isd:ied, jsd:jed, k, iq), cx(is:ie+1, jsd:&
3484 & jed, k), cy(isd:ied, js:je+1, k), npx, npy, &
3485 & hord, fx, fy, xfx(is:ie+1, jsd:jed, k), yfx(isd&
3486 & :ied, js:je+1, k), gridstruct, bd, ra_x, ra_y, mfx=&
3487 & mfx(is:ie+1, js:je, k), mfy=mfy(is:ie, js:je+1, k))
3491 q(i, j, k, iq) = (q(i, j, k, iq)*dp1(i, j, k)+(fx(i, j)-fx&
3492 & (i+1, j)+(fy(i, j)-fy(i, j+1)))*rarea(i, j))/dp2(i, j)
3498 IF (it .NE. nsplt)
THEN 3506 IF (gridstruct%nested)
THEN 3508 arg1 =
REAL(neststruct%tracer_nest_timestep)
3509 arg2 =
REAL(nsplt*k_split)
3510 CALL nested_grid_bc_apply_intt(q(isd:ied, jsd:jed, :, iq), 0, &
3511 & 0, npx, npy, npz, bd, arg1, arg2, &
3512 & neststruct%q_bc(iq), neststruct%&
3518 IF (id_divg .GT. 0)
THEN 3524 dp1(i, j, k) = (xfx(i+1, j, k)-xfx(i, j, k)+(yfx(i, j+1, k)-&
3525 & yfx(i, j, k)))*rarea(i, j)*rdt
3532
subroutine, public nested_grid_bc_apply_intt(var_nest, istag, jstag, npx, npy, npz, bd, step, split, bc, bctype)
real, dimension(:,:,:), allocatable nest_fx_south_accum
subroutine, public nested_grid_bc_apply_intt_adm(var_nest, var_nest_ad, istag, jstag, npx, npy, npz, bd, step, split, bc, bctype)
subroutine, public pushcontrol(ctype, field)
subroutine, public tracer_2d_bwd(q, q_ad, dp1, dp1_ad, mfx, mfx_ad, mfy, mfy_ad, cx, cx_ad, cy, cy_ad, gridstruct, bd, domain, npx, npy, npz, nq, hord, q_split, dt, id_divg, q_pack, nord_tr, trdm, hord_pert, nord_tr_pert, trdm_pert, split_damp_tr, dpa)
subroutine, public fv_tp_2d_adm(q, q_ad, crx, crx_ad, cry, cry_ad, npx, npy, hord, fx, fx_ad, fy, fy_ad, xfx, xfx_ad, yfx, yfx_ad, gridstruct, bd, ra_x, ra_x_ad, ra_y, ra_y_ad, mfx, mfx_ad, mfy, mfy_ad, mass, mass_ad, nord, damp_c)
subroutine, public fv_tp_2d_fwd(q, crx, cry, npx, npy, hord, fx, fy, xfx, yfx, gridstruct, bd, ra_x, ra_y, mfx, mfy, mass, nord, damp_c)
subroutine, public tracer_2d_nested(q, dp1, mfx, mfy, cx, cy, gridstruct, bd, domain, npx, npy, npz, nq, hord, q_split, dt, id_divg, q_pack, nord_tr, trdm, k_split, neststruct, parent_grid, hord_pert, nord_tr_pert, trdm_pert, split_damp_tr)
subroutine, public tracer_2d_1l(q, dp1, mfx, mfy, cx, cy, gridstruct, bd, domain, npx, npy, npz, nq, hord, q_split, dt, id_divg, q_pack, nord_tr, trdm, hord_pert, nord_tr_pert, trdm_pert, split_damp_tr, dpa)
real, dimension(:,:,:), allocatable nest_fx_west_accum
real, dimension(:,:,:), allocatable nest_fx_north_accum
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)
real, dimension(:,:,:), allocatable nest_fx_east_accum
integer, parameter, public ng
subroutine timing_on(blk_name)
subroutine, public tracer_2d_1l_fwd(q, dp1, mfx, mfy, cx, cy, gridstruct, bd, domain, npx, npy, npz, nq, hord, q_split, dt, id_divg, q_pack, nord_tr, trdm, hord_pert, nord_tr_pert, trdm_pert, split_damp_tr, dpa)
subroutine, public fv_tp_2d_bwd(q, q_ad, crx, crx_ad, cry, cry_ad, npx, npy, hord, fx, fx_ad, fy, fy_ad, xfx, xfx_ad, yfx, yfx_ad, gridstruct, bd, ra_x, ra_x_ad, ra_y, ra_y_ad, mfx, mfx_ad, mfy, mfy_ad, mass, mass_ad, nord, damp_c)
subroutine, public tracer_2d_fwd(q, dp1, mfx, mfy, cx, cy, gridstruct, bd, domain, npx, npy, npz, nq, hord, q_split, dt, id_divg, q_pack, nord_tr, trdm, hord_pert, nord_tr_pert, trdm_pert, split_damp_tr, dpa)
subroutine, public tracer_2d_1l_bwd(q, q_ad, dp1, dp1_ad, mfx, mfx_ad, mfy, mfy_ad, cx, cx_ad, cy, cy_ad, gridstruct, bd, domain, npx, npy, npz, nq, hord, q_split, dt, id_divg, q_pack, nord_tr, trdm, hord_pert, nord_tr_pert, trdm_pert, split_damp_tr, dpa)
subroutine, public tracer_2d(q, dp1, mfx, mfy, cx, cy, gridstruct, bd, domain, npx, npy, npz, nq, hord, q_split, dt, id_divg, q_pack, nord_tr, trdm, hord_pert, nord_tr_pert, trdm_pert, split_damp_tr, dpa)
subroutine, public complete_group_halo_update(group, groupp, domain)
subroutine, public tracer_2d_nested_bwd(q, q_ad, dp1, dp1_ad, mfx, mfx_ad, mfy, mfy_ad, cx, cx_ad, cy, cy_ad, gridstruct, bd, domain, npx, npy, npz, nq, hord, q_split, dt, id_divg, q_pack, nord_tr, trdm, k_split, neststruct, parent_grid, hord_pert, nord_tr_pert, trdm_pert, split_damp_tr)
subroutine, public tracer_2d_nested_fwd(q, dp1, mfx, mfy, cx, cy, gridstruct, bd, domain, npx, npy, npz, nq, hord, q_split, dt, id_divg, q_pack, nord_tr, trdm, k_split, neststruct, parent_grid, hord_pert, nord_tr_pert, trdm_pert, split_damp_tr)
subroutine, public popcontrol(ctype, field)
subroutine timing_off(blk_name)