Skip to content

Commit

Permalink
(*)Parenthesize tracer_advect PPM edge values
Browse files Browse the repository at this point in the history
  Added parentheses to 4 tracer edge value calculations used with PPM tracer
advection to give rotationally consistent solutions when fused-multiply-adds are
enabled.  Although these lines may not appear to need parentheses, some
compliers appear to be putting these expressions directly into others, where the
direction of the flow seems to determine which multiplications are incorporated
into FMAs.  All answers are bitwise identical in cases without FMAs, but answers
could change when FMAs are enabled.
  • Loading branch information
Hallberg-NOAA committed May 5, 2024
1 parent 3218192 commit 20003f7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/tracer/MOM_tracer_advect.F90
Original file line number Diff line number Diff line change
Expand Up @@ -537,9 +537,9 @@ subroutine advect_x(Tr, hprev, uhr, uh_neglect, OBC, domore_u, ntr, Idt, &
if (G%mask2dCu(I_up,j)*G%mask2dCu(I_up-1,j)*(Tp-Tc)*(Tc-Tm) <= 0.) then
aL = Tc ; aR = Tc ! PCM for local extrema and boundary cells
elseif ( dA*(Tc-mA) > (dA*dA)/6. ) then
aL = 3.*Tc - 2.*aR
aL = (3.*Tc) - 2.*aR
elseif ( dA*(Tc-mA) < - (dA*dA)/6. ) then
aR = 3.*Tc - 2.*aL
aR = (3.*Tc) - 2.*aL
endif

a6 = 6.*Tc - 3. * (aR + aL) ! Curvature
Expand Down Expand Up @@ -922,9 +922,9 @@ subroutine advect_y(Tr, hprev, vhr, vh_neglect, OBC, domore_v, ntr, Idt, &
if (G%mask2dCv(i,J_up)*G%mask2dCv(i,J_up-1)*(Tp-Tc)*(Tc-Tm) <= 0.) then
aL = Tc ; aR = Tc ! PCM for local extrema and boundary cells
elseif ( dA*(Tc-mA) > (dA*dA)/6. ) then
aL = 3.*Tc - 2.*aR
aL = (3.*Tc) - 2.*aR
elseif ( dA*(Tc-mA) < - (dA*dA)/6. ) then
aR = 3.*Tc - 2.*aL
aR = (3.*Tc) - 2.*aL
endif

a6 = 6.*Tc - 3. * (aR + aL) ! Curvature
Expand Down

0 comments on commit 20003f7

Please sign in to comment.