Skip to content

Commit 8f4af3d

Browse files
committed
Implement changes suggested by @Hallberg-NOAA
On PR#670, @Hallberg-NOAA pointed out two aspects of the code that could be changed. As detailed in a reply to those comments, one of these was a non-answer changing bit of logic that could safely be removed and the other involved changing array syntax arithmetic to explicit loops.
1 parent 2666b3e commit 8f4af3d

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

src/tracer/MOM_neutral_diffusion.F90

+16-8
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,9 @@ subroutine neutral_diffusion_calc_coeffs(G, GV, h, T, S, CS)
389389
integer :: iMethod
390390
real, dimension(SZI_(G)) :: ref_pres ! Reference pressure used to calculate alpha/beta
391391
real :: h_neglect, h_neglect_edge
392+
real :: pa_to_H
393+
394+
pa_to_H = 1. / GV%H_to_pa
392395

393396
!### Try replacing both of these with GV%H_subroundoff
394397
if (GV%Boussinesq) then
@@ -444,15 +447,13 @@ subroutine neutral_diffusion_calc_coeffs(G, GV, h, T, S, CS)
444447
else ! Discontinuous reconstruction
445448
do k = 1, G%ke
446449
if (CS%ref_pres<0) ref_pres(:) = CS%Pint(:,j,k)
447-
if (CS%stable_cell(i,j,k)) &
448-
call calculate_density_derivs(CS%T_i(:,j,k,1), CS%S_i(:,j,k,1), ref_pres, &
449-
CS%dRdT_i(:,j,k,1), CS%dRdS_i(:,j,k,1), G%isc-1, G%iec-G%isc+3, CS%EOS)
450+
call calculate_density_derivs(CS%T_i(:,j,k,1), CS%S_i(:,j,k,1), ref_pres, &
451+
CS%dRdT_i(:,j,k,1), CS%dRdS_i(:,j,k,1), G%isc-1, G%iec-G%isc+3, CS%EOS)
450452
if (CS%ref_pres<0) then
451453
ref_pres(:) = CS%Pint(:,j,k+1)
452454
endif
453-
if (CS%stable_cell(i,j,k)) &
454-
call calculate_density_derivs(CS%T_i(:,j,k,2), CS%S_i(:,j,k,2), ref_pres, &
455-
CS%dRdT_i(:,j,k,2), CS%dRdS_i(:,j,k,2), G%isc-1, G%iec-G%isc+3, CS%EOS)
455+
call calculate_density_derivs(CS%T_i(:,j,k,2), CS%S_i(:,j,k,2), ref_pres, &
456+
CS%dRdT_i(:,j,k,2), CS%dRdS_i(:,j,k,2), G%isc-1, G%iec-G%isc+3, CS%EOS)
456457
enddo
457458
endif
458459
enddo
@@ -518,9 +519,16 @@ subroutine neutral_diffusion_calc_coeffs(G, GV, h, T, S, CS)
518519
endif
519520
enddo ; enddo
520521

522+
! Continuous reconstructions calculate hEff as the difference between the pressures of the neutral surfaces which
523+
! need to be reconverted to thickness units. The discontinuous version calculates hEff from the fraction of the
524+
! nondimensional fraction of the layer occupied by the
521525
if (CS%continuous_reconstruction) then
522-
CS%uhEff(:,:,:) = CS%uhEff(:,:,:) / GV%H_to_pa
523-
CS%vhEff(:,:,:) = CS%vhEff(:,:,:) / GV%H_to_pa
526+
do k = 1, CS%nsurf-1 ; do j = G%jsc, G%jec ; do I = G%isc-1, G%iec
527+
if (G%mask2dCu(I,j) > 0.) CS%uhEff(I,j,k) = CS%uhEff(I,j,k) * pa_to_H
528+
enddo ; enddo ; enddo
529+
do k = 1, CS%nsurf-1 ; do J = G%jsc-1, G%jec ; do i = G%isc, G%iec
530+
if (G%mask2dCv(i,J) > 0.) CS%vhEff(i,J,k) = CS%vhEff(i,J,k) * pa_to_H
531+
enddo ; enddo ; enddo
524532
endif
525533

526534
if (CS%id_uhEff_2d>0) then

src/tracer/MOM_neutral_diffusion_aux.F90

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ real function calc_drho(T1, S1, dRdT1, dRdS1, T2, S2, dRdT2, dRdS2)
161161
end function calc_drho
162162

163163
!> Calculate the difference in neutral density between a reference T, S, alpha, and beta
164-
!! and a poiet on the polynomial reconstructions of T, S
164+
!! at a point on the polynomial reconstructions of T, S
165165
subroutine drho_at_pos(CS, T_ref, S_ref, alpha_ref, beta_ref, P_top, P_bot, ppoly_T, ppoly_S, x0, &
166166
delta_rho, P_out, T_out, S_out, alpha_avg_out, beta_avg_out, delta_T_out, delta_S_out)
167167
type(ndiff_aux_CS_type), intent(in) :: CS !< Control structure with parameters for this module

0 commit comments

Comments
 (0)