Skip to content

Commit

Permalink
(*)More parentheses in density_integrals for FMAs
Browse files Browse the repository at this point in the history
  Added parentheses around the full expressions for intz and intp in 10 more
lines in 4 generic density integral routines (int_density_dz_generic_pcm,
int_density_dz_generic_ppm, int_spec_vol_dp_generic_pcm and
int_spec_vol_dp_generic_plm) in the MOM_density_integrals module so that
non-Boussinesq cases will be rotationally invariant when fused-multiply-adds are
enabled.  Although this might not seem to do anything, these parentheses do
matter if these expressions are in-lined in the sums where they are used a few
lines later.  The analogous parentheses had previously been added to
int_density_dz_generic_plm.  All answers are bitwise identical in cases without
FMAs, but answers could change with FMAs.
  • Loading branch information
Hallberg-NOAA committed Jul 31, 2024
1 parent e810ac5 commit ffa766b
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/core/MOM_density_integrals.F90
Original file line number Diff line number Diff line change
Expand Up @@ -279,16 +279,16 @@ subroutine int_density_dz_generic_pcm(T, S, z_t, z_b, rho_ref, rho_0, G_e, HI, &
if (use_rho_ref) then
do m=2,4
pos = i*15+(m-2)*5
intz(m) = G_e*dz_x(m,i)*( C1_90*( 7.0*(r15(pos+1)+r15(pos+5)) + &
intz(m) = (G_e*dz_x(m,i)*(C1_90*( 7.0*(r15(pos+1)+r15(pos+5)) + &
32.0*(r15(pos+2)+r15(pos+4)) + &
12.0*r15(pos+3)))
12.0*r15(pos+3)) ))
enddo
else
do m=2,4
pos = i*15+(m-2)*5
intz(m) = G_e*dz_x(m,i)*( C1_90*( 7.0*(r15(pos+1)+r15(pos+5)) + &
intz(m) = (G_e*dz_x(m,i)*(C1_90*( 7.0*(r15(pos+1)+r15(pos+5)) + &
32.0*(r15(pos+2)+r15(pos+4)) + &
12.0*r15(pos+3)) - rho_ref )
12.0*r15(pos+3)) - rho_ref ))
enddo
endif
! Use Boole's rule to integrate the bottom pressure anomaly values in x.
Expand Down Expand Up @@ -347,13 +347,13 @@ subroutine int_density_dz_generic_pcm(T, S, z_t, z_b, rho_ref, rho_0, G_e, HI, &
do m=2,4
pos = i*15+(m-2)*5
if (use_rho_ref) then
intz(m) = G_e*dz_y(m,i)*( C1_90*(7.0*(r15(pos+1)+r15(pos+5)) + &
intz(m) = (G_e*dz_y(m,i)*(C1_90*(7.0*(r15(pos+1)+r15(pos+5)) + &
32.0*(r15(pos+2)+r15(pos+4)) + &
12.0*r15(pos+3)))
12.0*r15(pos+3)) ))
else
intz(m) = G_e*dz_y(m,i)*( C1_90*(7.0*(r15(pos+1)+r15(pos+5)) + &
intz(m) = (G_e*dz_y(m,i)*(C1_90*(7.0*(r15(pos+1)+r15(pos+5)) + &
32.0*(r15(pos+2)+r15(pos+4)) + &
12.0*r15(pos+3)) - rho_ref )
12.0*r15(pos+3)) - rho_ref ))
endif
enddo
! Use Boole's rule to integrate the values.
Expand Down Expand Up @@ -1054,9 +1054,9 @@ subroutine int_density_dz_generic_ppm(k, tv, T_t, T_b, S_t, S_b, e, &
do m=2,4
pos = i*15+(m-2)*5
! Use Boole's rule to estimate the pressure anomaly change.
intz(m) = G_e*dz_x(m,i)*( C1_90*( 7.0*(r15(pos+1)+r15(pos+5)) + &
intz(m) = (G_e*dz_x(m,i)*(C1_90*( 7.0*(r15(pos+1)+r15(pos+5)) + &
32.0*(r15(pos+2)+r15(pos+4)) + &
12.0*r15(pos+3)) )
12.0*r15(pos+3)) ))
enddo ! m
intz(1) = dpa(i,j) ; intz(5) = dpa(i+1,j)

Expand Down Expand Up @@ -1158,9 +1158,9 @@ subroutine int_density_dz_generic_ppm(k, tv, T_t, T_b, S_t, S_b, e, &
do m=2,4
! Use Boole's rule to estimate the pressure anomaly change.
pos = i*15+(m-2)*5
intz(m) = G_e*dz_y(m,i)*( C1_90*( 7.0*(r15(pos+1)+r15(pos+5)) + &
intz(m) = (G_e*dz_y(m,i)*(C1_90*( 7.0*(r15(pos+1)+r15(pos+5)) + &
32.0*(r15(pos+2)+r15(pos+4)) + &
12.0*r15(pos+3)) )
12.0*r15(pos+3)) ))
enddo ! m
intz(1) = dpa(i,j) ; intz(5) = dpa(i,j+1)

Expand Down Expand Up @@ -1406,8 +1406,8 @@ subroutine int_spec_vol_dp_generic_pcm(T, S, p_t, p_b, alpha_ref, HI, EOS, US, d
! Use Boole's rule to estimate the interface height anomaly change.
do m=2,4
pos = i*15+(m-2)*5
intp(m) = dp_x(m,I)*( C1_90*(7.0*(a15(pos+1)+a15(pos+5)) + 32.0*(a15(pos+2)+a15(pos+4)) + &
12.0*a15(pos+3)))
intp(m) = (dp_x(m,I)*( C1_90*(7.0*(a15(pos+1)+a15(pos+5)) + 32.0*(a15(pos+2)+a15(pos+4)) + &
12.0*a15(pos+3)) ))
enddo
! Use Boole's rule to integrate the interface height anomaly values in x.
intx_dza(i,j) = C1_90*(7.0*(intp(1)+intp(5)) + 32.0*(intp(2)+intp(4)) + &
Expand Down Expand Up @@ -1461,8 +1461,8 @@ subroutine int_spec_vol_dp_generic_pcm(T, S, p_t, p_b, alpha_ref, HI, EOS, US, d
! Use Boole's rule to estimate the interface height anomaly change.
do m=2,4
pos = i*15+(m-2)*5
intp(m) = dp_y(m,i)*( C1_90*(7.0*(a15(pos+1)+a15(pos+5)) + 32.0*(a15(pos+2)+a15(pos+4)) + &
12.0*a15(pos+3)))
intp(m) = (dp_y(m,i)*( C1_90*(7.0*(a15(pos+1)+a15(pos+5)) + 32.0*(a15(pos+2)+a15(pos+4)) + &
12.0*a15(pos+3)) ))
enddo
! Use Boole's rule to integrate the interface height anomaly values in y.
inty_dza(i,j) = C1_90*(7.0*(intp(1)+intp(5)) + 32.0*(intp(2)+intp(4)) + &
Expand Down Expand Up @@ -1652,8 +1652,8 @@ subroutine int_spec_vol_dp_generic_plm(T_t, T_b, S_t, S_b, p_t, p_b, alpha_ref,
! Use Boole's rule to estimate the interface height anomaly change.
! The integrals at the ends of the segment are already known.
pos = I*15+(m-2)*5
intp(m) = dp_90(m,I)*((7.0*(a15(pos+1)+a15(pos+5)) + &
32.0*(a15(pos+2)+a15(pos+4))) + 12.0*a15(pos+3))
intp(m) = (dp_90(m,I)*((7.0*(a15(pos+1)+a15(pos+5)) + &
32.0*(a15(pos+2)+a15(pos+4))) + 12.0*a15(pos+3) ))
enddo
! Use Boole's rule to integrate the interface height anomaly values in x.
intx_dza(I,j) = C1_90*((7.0*(intp(1)+intp(5)) + 32.0*(intp(2)+intp(4))) + &
Expand Down Expand Up @@ -1714,8 +1714,8 @@ subroutine int_spec_vol_dp_generic_plm(T_t, T_b, S_t, S_b, p_t, p_b, alpha_ref,
! Use Boole's rule to estimate the interface height anomaly change.
! The integrals at the ends of the segment are already known.
pos = i*15+(m-2)*5
intp(m) = dp_90(m,i) * ((7.0*(a15(pos+1)+a15(pos+5)) + &
32.0*(a15(pos+2)+a15(pos+4))) + 12.0*a15(pos+3))
intp(m) = (dp_90(m,i) * ((7.0*(a15(pos+1)+a15(pos+5)) + &
32.0*(a15(pos+2)+a15(pos+4))) + 12.0*a15(pos+3)))
enddo
! Use Boole's rule to integrate the interface height anomaly values in x.
inty_dza(i,J) = C1_90*((7.0*(intp(1)+intp(5)) + 32.0*(intp(2)+intp(4))) + &
Expand Down

0 comments on commit ffa766b

Please sign in to comment.