From 9792b23465d78854044d0919ac6dad61216d8368 Mon Sep 17 00:00:00 2001 From: John Krasting Date: Thu, 1 Apr 2021 11:38:26 -0400 Subject: [PATCH 1/2] Fixed downsampling for x:sum y:point z:point diags - previous code had averaging instead of summation for SPP (x:sum,y:point,z:point) diagnostics - corrects an issue where these diagnostics were incorrect by approximately a factor of 2. - Orginially found when analyzing the depth-integrated temperature advection diagnostic (T_ady_2d) --- src/framework/MOM_diag_mediator.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/framework/MOM_diag_mediator.F90 b/src/framework/MOM_diag_mediator.F90 index b4cce081a0..4425a3374f 100644 --- a/src/framework/MOM_diag_mediator.F90 +++ b/src/framework/MOM_diag_mediator.F90 @@ -4181,7 +4181,7 @@ subroutine downsample_field_2d(field_in, field_out, dl, method, mask, diag_cs, d total_weight = total_weight +weight ave = ave+field_in(ii,jj)*weight enddo - field_out(i,j) = ave/(total_weight+epsilon) !Avoid zero mask at all aggregating cells where ave=0.0 + field_out(i,j) = ave !Masked Sum (total_weight=1) enddo ; enddo elseif (method == PMP) then do j=jsv_d,jev_d ; do i=isv_d,iev_d From 5f063044c7b845308b0599d7f5153099b1a8ffb6 Mon Sep 17 00:00:00 2001 From: John Krasting Date: Fri, 2 Apr 2021 10:04:59 -0400 Subject: [PATCH 2/2] Fixed downsampling summation for more diag types - Fixes for SSP (x:sum;y:sum,z:point) and PSP (x:point,y:sum,z:point) diagnostics - Removed unused `total_weight` arrays in these cases --- src/framework/MOM_diag_mediator.F90 | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/framework/MOM_diag_mediator.F90 b/src/framework/MOM_diag_mediator.F90 index 4425a3374f..e9ad88c17e 100644 --- a/src/framework/MOM_diag_mediator.F90 +++ b/src/framework/MOM_diag_mediator.F90 @@ -4146,39 +4146,33 @@ subroutine downsample_field_2d(field_in, field_out, dl, method, mask, diag_cs, d i0 = isv_o+dl*(i-isv_d) j0 = jsv_o+dl*(j-jsv_d) ave = 0.0 - total_weight = 0.0 do jj=j0,j0+dl-1 ; do ii=i0,i0+dl-1 ! do ii=i0,i0+dl-1 ; do jj=j0,j0+dl-1 weight = mask(ii,jj) - total_weight = total_weight + weight ave = ave+field_in(ii,jj)*weight enddo ; enddo - field_out(i,j) = ave/(total_weight+epsilon) !Avoid zero mask at all aggregating cells where ave=0.0 + field_out(i,j) = ave !Masked Sum (total_weight=1) enddo ; enddo elseif (method == PSP) then ! e.g., umo_2d do j=jsv_d,jev_d ; do i=isv_d,iev_d i0 = isv_o+dl*(i-isv_d) j0 = jsv_o+dl*(j-jsv_d) ave = 0.0 - total_weight = 0.0 ii=i0 do jj=j0,j0+dl-1 weight = mask(ii,jj) - total_weight = total_weight +weight ave = ave+field_in(ii,jj)*weight enddo - field_out(i,j) = ave/(total_weight+epsilon) !Avoid zero mask at all aggregating cells where ave=0.0 + field_out(i,j) = ave !Masked Sum (total_weight=1) enddo ; enddo elseif (method == SPP) then ! e.g., vmo_2d do j=jsv_d,jev_d ; do i=isv_d,iev_d i0 = isv_o+dl*(i-isv_d) j0 = jsv_o+dl*(j-jsv_d) ave = 0.0 - total_weight = 0.0 jj=j0 do ii=i0,i0+dl-1 weight = mask(ii,jj) - total_weight = total_weight +weight ave = ave+field_in(ii,jj)*weight enddo field_out(i,j) = ave !Masked Sum (total_weight=1)