Skip to content

Commit

Permalink
(*)Parenthesize calc_isoneutral_slopes for FMAs
Browse files Browse the repository at this point in the history
  Added parentheses to 4 lines in calc_isoneutral_slopes so that they will be rotationally invariant when
fused-multiply-adds are enabled.  All answers are bitwise identical in cases
without FMAs, but answers could change with FMAs.
  • Loading branch information
Hallberg-NOAA committed Jul 29, 2024
1 parent 99fd957 commit 307a4e2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/core/MOM_isopycnal_slopes.F90
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ subroutine calc_isoneutral_slopes(G, GV, US, h, e, tv, dt_kappa_smooth, use_stan
wtA = hg2A*haB ; wtB = hg2B*haA
wtL = hg2L*(haR*dzaR) ; wtR = hg2R*(haL*dzaL)

drdz = (wtL * drdkL + wtR * drdkR) / (dzaL*wtL + dzaR*wtR)
drdz = ((wtL * drdkL) + (wtR * drdkR)) / ((dzaL*wtL) + (dzaR*wtR))
! The expression for drdz above is mathematically equivalent to:
! drdz = ((hg2L/haL) * drdkL/dzaL + (hg2R/haR) * drdkR/dzaR) / &
! ((hg2L/haL) + (hg2R/haR))
Expand Down Expand Up @@ -376,8 +376,8 @@ subroutine calc_isoneutral_slopes(G, GV, US, h, e, tv, dt_kappa_smooth, use_stan
endif
slope_x(I,j,K) = slope
if (present(dzSxN)) &
dzSxN(I,j,K) = sqrt( GxSpV_u(I) * max(0., wtL * ( dzaL * drdkL ) &
+ wtR * ( dzaR * drdkR )) / (wtL + wtR) ) & ! dz * N
dzSxN(I,j,K) = sqrt( GxSpV_u(I) * max(0., (wtL * ( dzaL * drdkL )) &
+ (wtR * ( dzaR * drdkR ))) / (wtL + wtR) ) & ! dz * N
* abs(slope) * G%mask2dCu(I,j) ! x-direction contribution to S^2

enddo ! I
Expand Down Expand Up @@ -485,7 +485,7 @@ subroutine calc_isoneutral_slopes(G, GV, US, h, e, tv, dt_kappa_smooth, use_stan
wtA = hg2A*haB ; wtB = hg2B*haA
wtL = hg2L*(haR*dzaR) ; wtR = hg2R*(haL*dzaL)

drdz = (wtL * drdkL + wtR * drdkR) / (dzaL*wtL + dzaR*wtR)
drdz = ((wtL * drdkL) + (wtR * drdkR)) / ((dzaL*wtL) + (dzaR*wtR))
! The expression for drdz above is mathematically equivalent to:
! drdz = ((hg2L/haL) * drdkL/dzaL + (hg2R/haR) * drdkR/dzaR) / &
! ((hg2L/haL) + (hg2R/haR))
Expand Down Expand Up @@ -527,8 +527,8 @@ subroutine calc_isoneutral_slopes(G, GV, US, h, e, tv, dt_kappa_smooth, use_stan
endif
slope_y(i,J,K) = slope
if (present(dzSyN)) &
dzSyN(i,J,K) = sqrt( GxSpV_v(i) * max(0., wtL * ( dzaL * drdkL ) &
+ wtR * ( dzaR * drdkR )) / (wtL + wtR) ) & ! dz * N
dzSyN(i,J,K) = sqrt( GxSpV_v(i) * max(0., (wtL * ( dzaL * drdkL )) &
+ (wtR * ( dzaR * drdkR ))) / (wtL + wtR) ) & ! dz * N
* abs(slope) * G%mask2dCv(i,J) ! x-direction contribution to S^2

enddo ! i
Expand Down

0 comments on commit 307a4e2

Please sign in to comment.