Skip to content

Commit

Permalink
Changes the order of calculation
Browse files Browse the repository at this point in the history
In a previous commit, the expression

tr(i,j,1) = (b1(i)*h_tr)*tr(i,j,1) + sfc_src(i,j)

was change to

tr(i,j,1) = b1(i)*(h_tr*tr(i,j,1) + sfc_src(i,j))

in 4 lines. This changed the order in which b1(i)*h_tr*tr(i,j,1) is evaluated,
even if sfc_src(i,j) is 0.0. Because the CESM configurations use the
passive tracer tridiagonal solver for T and S, the modification above changed
answers in these configurations. To recover previous answers the expression must
be

tr(i,j,1) = (b1(i)*h_tr)*tr(i,j,1) + b1(i)*sfc_src(i,j)
  • Loading branch information
gustavo-marques committed Jul 23, 2021
1 parent 230a8b8 commit 7622911
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/tracer/MOM_tracer_diabatic.F90
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ subroutine tracer_vertdiff(h_old, ea, eb, dt, tr, G, GV, &
b1(i) = 1.0 / (b_denom_1 + eb(i,j,1))
d1(i) = b_denom_1 * b1(i)
h_tr = h_old(i,j,1) + h_neglect
tr(i,j,1) = b1(i)*(h_tr*tr(i,j,1) + sfc_src(i,j))
tr(i,j,1) = (b1(i)*h_tr)*tr(i,j,1) + b1(i)*sfc_src(i,j)
endif ; enddo
do k=2,nz-1 ; do i=is,ie ; if (G%mask2dT(i,j) > 0.5) then
c1(i,k) = eb(i,j,k-1) * b1(i)
Expand Down Expand Up @@ -190,7 +190,7 @@ subroutine tracer_vertdiff(h_old, ea, eb, dt, tr, G, GV, &
b_denom_1 = h_tr + ea(i,j,1)
b1(i) = 1.0 / (b_denom_1 + eb(i,j,1))
d1(i) = h_tr * b1(i)
tr(i,j,1) = b1(i)*(h_tr*tr(i,j,1) + sfc_src(i,j))
tr(i,j,1) = (b1(i)*h_tr)*tr(i,j,1) + b1(i)*sfc_src(i,j)
endif ; enddo
do k=2,nz-1 ; do i=is,ie ; if (G%mask2dT(i,j) > 0.5) then
c1(i,k) = eb(i,j,k-1) * b1(i)
Expand Down Expand Up @@ -351,7 +351,7 @@ subroutine tracer_vertdiff_Eulerian(h_old, ent, dt, tr, G, GV, &
b1(i) = 1.0 / (b_denom_1 + ent(i,j,2))
d1(i) = b_denom_1 * b1(i)
h_tr = h_old(i,j,1) + h_neglect
tr(i,j,1) = b1(i)*(h_tr*tr(i,j,1) + sfc_src(i,j))
tr(i,j,1) = (b1(i)*h_tr)*tr(i,j,1) + b1(i)*sfc_src(i,j)
endif ; enddo
do k=2,nz-1 ; do i=is,ie ; if (G%mask2dT(i,j) > 0.5) then
c1(i,k) = ent(i,j,K) * b1(i)
Expand Down Expand Up @@ -389,7 +389,7 @@ subroutine tracer_vertdiff_Eulerian(h_old, ent, dt, tr, G, GV, &
b_denom_1 = h_tr + ent(i,j,1)
b1(i) = 1.0 / (b_denom_1 + ent(i,j,2))
d1(i) = h_tr * b1(i)
tr(i,j,1) = b1(i)*(h_tr*tr(i,j,1) + sfc_src(i,j))
tr(i,j,1) = (b1(i)*h_tr)*tr(i,j,1) + b1(i)*sfc_src(i,j)
endif ; enddo
do k=2,nz-1 ; do i=is,ie ; if (G%mask2dT(i,j) > 0.5) then
c1(i,k) = ent(i,j,K) * b1(i)
Expand Down

0 comments on commit 7622911

Please sign in to comment.