From 8d680404f60774321149037cdb7107df77944942 Mon Sep 17 00:00:00 2001 From: Marshall Ward Date: Thu, 2 Jan 2020 18:09:25 -0500 Subject: [PATCH 1/2] * Fixed sign error in thickness diffuse work This patch fixes a bug in the sign of the tendency of the work by thickness diffusion in the top layer along the u-points. This resolves a variance in model runs after a 90-degree rotation, and results are now consistent with the work_v calculation. This patch will change answers for any runs using work-based thickness diffusion. --- src/parameterizations/lateral/MOM_thickness_diffuse.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parameterizations/lateral/MOM_thickness_diffuse.F90 b/src/parameterizations/lateral/MOM_thickness_diffuse.F90 index a567edb4be..29b91e08aa 100644 --- a/src/parameterizations/lateral/MOM_thickness_diffuse.F90 +++ b/src/parameterizations/lateral/MOM_thickness_diffuse.F90 @@ -1235,7 +1235,7 @@ subroutine thickness_diffuse_full(h, e, Kh_u, Kh_v, tv, uhD, vhD, cg1, dt, G, GV drdiB = drho_dT_u(I) * (T(i+1,j,1)-T(i,j,1)) + & drho_dS_u(I) * (S(i+1,j,1)-S(i,j,1)) endif - Work_u(I,j) = Work_u(I,j) + G_scale * & + Work_u(I,j) = Work_u(I,j) - G_scale * & ( (uhD(I,j,1) * drdiB) * 0.25 * & ((e(i,j,1) + e(i,j,2)) + (e(i+1,j,1) + e(i+1,j,2))) ) From b598a2d102739787acfee89115b9b84203e97d9d Mon Sep 17 00:00:00 2001 From: Marshall Ward Date: Tue, 7 Jan 2020 00:10:54 -0500 Subject: [PATCH 2/2] Flag to reproduce old incorrect GM work Added a flag to reproduce the old GM work calculation in the top layer with the incorrect sign. The flag is currently enabled on default, which uses the old incorrect expression. --- .../lateral/MOM_thickness_diffuse.F90 | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/parameterizations/lateral/MOM_thickness_diffuse.F90 b/src/parameterizations/lateral/MOM_thickness_diffuse.F90 index 29b91e08aa..a79e6e1e82 100644 --- a/src/parameterizations/lateral/MOM_thickness_diffuse.F90 +++ b/src/parameterizations/lateral/MOM_thickness_diffuse.F90 @@ -72,6 +72,8 @@ module MOM_thickness_diffuse logical :: Use_KH_in_MEKE !< If true, uses the thickness diffusivity calculated here to diffuse MEKE. logical :: GM_src_alt !< If true, use the GM energy conversion form S^2*N^2*kappa rather !! than the streamfunction for the GM source term. + logical :: use_GM_work_bug !< If true, use the incorrect sign for the + !! top-level work tendency on the top layer. type(diag_ctrl), pointer :: diag => NULL() !< structure used to regulate timing of diagnostics real, pointer :: GMwork(:,:) => NULL() !< Work by thickness diffusivity [R Z L2 T-3 ~> W m-2] real, pointer :: diagSlopeX(:,:,:) => NULL() !< Diagnostic: zonal neutral slope [nondim] @@ -1235,10 +1237,15 @@ subroutine thickness_diffuse_full(h, e, Kh_u, Kh_v, tv, uhD, vhD, cg1, dt, G, GV drdiB = drho_dT_u(I) * (T(i+1,j,1)-T(i,j,1)) + & drho_dS_u(I) * (S(i+1,j,1)-S(i,j,1)) endif - Work_u(I,j) = Work_u(I,j) - G_scale * & - ( (uhD(I,j,1) * drdiB) * 0.25 * & - ((e(i,j,1) + e(i,j,2)) + (e(i+1,j,1) + e(i+1,j,2))) ) - + if (CS%use_GM_work_bug) then + Work_u(I,j) = Work_u(I,j) + G_scale * & + ( (uhD(I,j,1) * drdiB) * 0.25 * & + ((e(i,j,1) + e(i,j,2)) + (e(i+1,j,1) + e(i+1,j,2))) ) + else + Work_u(I,j) = Work_u(I,j) - G_scale * & + ( (uhD(I,j,1) * drdiB) * 0.25 * & + ((e(i,j,1) + e(i,j,2)) + (e(i+1,j,1) + e(i+1,j,2))) ) + endif enddo enddo @@ -1869,6 +1876,11 @@ subroutine thickness_diffuse_init(Time, G, GV, US, param_file, diag, CDp, CS) "If true, use the GM+E backscatter scheme in association \n"//& "with the Gent and McWilliams parameterization.", default=.false.) + call get_param(param_file, mdl, "USE_GM_WORK_BUG", CS%use_GM_work_bug, & + "If true, compute the top-layer work tendency on the u-grid " // & + "with the incorrect sign, for legacy reproducibility.", & + default=.true.) + if (CS%use_GME_thickness_diffuse) then call safe_alloc_ptr(CS%KH_u_GME,G%IsdB,G%IedB,G%jsd,G%jed,G%ke+1) call safe_alloc_ptr(CS%KH_v_GME,G%isd,G%ied,G%JsdB,G%JedB,G%ke+1)