From 7da83db8b366182d125899c6542d3763beff30e6 Mon Sep 17 00:00:00 2001 From: Raphael Dussin Date: Fri, 11 Jun 2021 17:06:09 -0400 Subject: [PATCH 1/4] fix reflect for internal tides * En array defined with wrong size leading to energy leakage * clean initialization for local arrays --- .../lateral/MOM_internal_tides.F90 | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/parameterizations/lateral/MOM_internal_tides.F90 b/src/parameterizations/lateral/MOM_internal_tides.F90 index a862dd373d..2f9181f7a5 100644 --- a/src/parameterizations/lateral/MOM_internal_tides.F90 +++ b/src/parameterizations/lateral/MOM_internal_tides.F90 @@ -1610,7 +1610,7 @@ subroutine reflect(En, NAngle, CS, G, LB) type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure integer, intent(in) :: NAngle !< The number of wave orientations in the !! discretized wave energy spectrum. - real, dimension(G%isd:G%ied,G%jsd:G%jed,NAngle), & + real, dimension(SZI_(G),SZJB_(G),Nangle), & intent(inout) :: En !< The internal gravity wave energy density as a !! function of space and angular resolution !! [R Z3 T-2 ~> J m-2]. @@ -1653,9 +1653,16 @@ subroutine reflect(En, NAngle, CS, G, LB) angle_i(a) = Angle_size * real(a - 1) ! for a=1 aligned with x-axis enddo - angle_c = CS%refl_angle - part_refl = CS%refl_pref - ridge = CS%refl_dbl + ! init local arrays + angle_c(:,:) = CS%nullangle + part_refl(:,:) = 0. + ridge(:,:) = .false. + + do j=jsh,jeh ; do i=ish,ieh + angle_c(i,j) = CS%refl_angle(i,j) + part_refl(i,j) = CS%refl_pref(i,j) + ridge(i,j) = CS%refl_dbl(i,j) + enddo ; enddo En_reflected(:) = 0.0 do j=jsh,jeh ; do i=ish,ieh From 0f76e34d793c96e0bd69b134a0ecc5640c82ff64 Mon Sep 17 00:00:00 2001 From: Raphael Dussin Date: Thu, 17 Jun 2021 21:28:10 -0400 Subject: [PATCH 2/4] corrected indexing --- src/parameterizations/lateral/MOM_internal_tides.F90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/parameterizations/lateral/MOM_internal_tides.F90 b/src/parameterizations/lateral/MOM_internal_tides.F90 index 2f9181f7a5..8c08691675 100644 --- a/src/parameterizations/lateral/MOM_internal_tides.F90 +++ b/src/parameterizations/lateral/MOM_internal_tides.F90 @@ -1389,7 +1389,7 @@ subroutine propagate_x(En, speed_x, Cgx_av, dCgx, dt, G, US, Nangle, CS, LB) real, dimension(SZIB_(G)) :: & cg_p, cg_m, flux1, flux2 !real, dimension(SZI_(G),SZJB_(G),Nangle) :: En_m, En_p - real, dimension(SZI_(G),SZJB_(G),Nangle) :: & + real, dimension(G%isd:G%ied,G%jsd:G%jed,Nangle) :: & Fdt_m, Fdt_p! Left and right energy fluxes [J] integer :: i, j, k, ish, ieh, jsh, jeh, a @@ -1464,7 +1464,7 @@ subroutine propagate_y(En, speed_y, Cgy_av, dCgy, dt, G, US, Nangle, CS, LB) real, dimension(SZI_(G)) :: & cg_p, cg_m, flux1, flux2 !real, dimension(SZI_(G),SZJB_(G),Nangle) :: En_m, En_p - real, dimension(SZI_(G),SZJB_(G),Nangle) :: & + real, dimension(G%isd:G%ied,G%jsd:G%jed,Nangle) :: & Fdt_m, Fdt_p! South and north energy fluxes [J] character(len=160) :: mesg ! The text of an error message integer :: i, j, k, ish, ieh, jsh, jeh, a @@ -1610,7 +1610,7 @@ subroutine reflect(En, NAngle, CS, G, LB) type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure integer, intent(in) :: NAngle !< The number of wave orientations in the !! discretized wave energy spectrum. - real, dimension(SZI_(G),SZJB_(G),Nangle), & + real, dimension(G%isd:G%ied,G%jsd:G%jed,NAngle), & intent(inout) :: En !< The internal gravity wave energy density as a !! function of space and angular resolution !! [R Z3 T-2 ~> J m-2]. From 35409ced4337142c2cf95179381cccb72ca0967f Mon Sep 17 00:00:00 2001 From: Raphael Dussin Date: Fri, 11 Jun 2021 17:06:09 -0400 Subject: [PATCH 3/4] fix reflect for internal tides * En array defined with wrong size leading to energy leakage * clean initialization for local arrays --- src/parameterizations/lateral/MOM_internal_tides.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parameterizations/lateral/MOM_internal_tides.F90 b/src/parameterizations/lateral/MOM_internal_tides.F90 index 8c08691675..491e361508 100644 --- a/src/parameterizations/lateral/MOM_internal_tides.F90 +++ b/src/parameterizations/lateral/MOM_internal_tides.F90 @@ -1610,7 +1610,7 @@ subroutine reflect(En, NAngle, CS, G, LB) type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure integer, intent(in) :: NAngle !< The number of wave orientations in the !! discretized wave energy spectrum. - real, dimension(G%isd:G%ied,G%jsd:G%jed,NAngle), & + real, dimension(SZI_(G),SZJB_(G),Nangle), & intent(inout) :: En !< The internal gravity wave energy density as a !! function of space and angular resolution !! [R Z3 T-2 ~> J m-2]. From 540c3750ff00730a5bcb473f85658ffa58d92c11 Mon Sep 17 00:00:00 2001 From: Raphael Dussin Date: Thu, 17 Jun 2021 21:28:10 -0400 Subject: [PATCH 4/4] corrected indexing --- src/parameterizations/lateral/MOM_internal_tides.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parameterizations/lateral/MOM_internal_tides.F90 b/src/parameterizations/lateral/MOM_internal_tides.F90 index 491e361508..8c08691675 100644 --- a/src/parameterizations/lateral/MOM_internal_tides.F90 +++ b/src/parameterizations/lateral/MOM_internal_tides.F90 @@ -1610,7 +1610,7 @@ subroutine reflect(En, NAngle, CS, G, LB) type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure integer, intent(in) :: NAngle !< The number of wave orientations in the !! discretized wave energy spectrum. - real, dimension(SZI_(G),SZJB_(G),Nangle), & + real, dimension(G%isd:G%ied,G%jsd:G%jed,NAngle), & intent(inout) :: En !< The internal gravity wave energy density as a !! function of space and angular resolution !! [R Z3 T-2 ~> J m-2].