From 5f063044c7b845308b0599d7f5153099b1a8ffb6 Mon Sep 17 00:00:00 2001 From: John Krasting Date: Fri, 2 Apr 2021 10:04:59 -0400 Subject: [PATCH] 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)