From 5f81b735947290c90312e87a5f867ff0870c19c9 Mon Sep 17 00:00:00 2001 From: Niki Zadeh Date: Fri, 18 Oct 2019 11:51:06 -0400 Subject: [PATCH] Fix the downsampled "summed" diagnostics - Steve and Mike noticed that the downsampled2 umo,vmo in 1/8 degree runs are smaller than the corresponding 1/4 degree run diagnostics by almost a factor of 2. I have confirmed this discrepancy for the magnitudes of umo,vmo in the same 1/8 degree run between the downsampled and original. - The issue stems from calculating the mean rather the sum for diagnostics PSS and SPS where the quantities have to be summed over the two fine cells. - This bug also affects SSS d2 diagnostics such as volcello. - Also, I deleted the suspect logic for PSM diagnostics which I think are non-existant in MOM6. - I have tested this in a low resolution model run and it seems to have worked. --- src/framework/MOM_diag_mediator.F90 | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/src/framework/MOM_diag_mediator.F90 b/src/framework/MOM_diag_mediator.F90 index 674046a750..8f762dedd5 100644 --- a/src/framework/MOM_diag_mediator.F90 +++ b/src/framework/MOM_diag_mediator.F90 @@ -3880,14 +3880,11 @@ subroutine downsample_field_3d(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,k) - total_weight = total_weight + weight ave=ave+field_in(ii,jj,k)*weight enddo; enddo - field_out(i,j,k) = ave/(total_weight+epsilon) !Avoid zero mask at all aggregating cells where ave=0.0 + field_out(i,j,k) = ave !Masked Sum (total_weight=1) enddo; enddo; enddo elseif(method .eq. MMP .or. method .eq. MMS) then !e.g., T_advection_xy do k= ks,ke ; do j=jsv_d,jev_d ; do i=isv_d,iev_d @@ -3917,47 +3914,29 @@ subroutine downsample_field_3d(field_in, field_out, dl, method, mask, diag_cs, d enddo field_out(i,j,k) = ave/(total_weight+epsilon) !Avoid zero mask at all aggregating cells where ave=0.0 enddo; enddo; enddo - elseif(method .eq. PSM) then - do k= ks,ke ; 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,k)*diag_cs%h(ii,jj,k) - total_weight = total_weight +weight - ave=ave+field_in(ii,jj,k)*weight - enddo - field_out(i,j,k) = ave/(total_weight+epsilon) !Avoid zero mask at all aggregating cells where ave=0.0 - enddo; enddo; enddo elseif(method .eq. PSS) then !e.g. umo do k= ks,ke ; 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,k) - total_weight = total_weight +weight ave=ave+field_in(ii,jj,k)*weight enddo - field_out(i,j,k) = ave/(total_weight+epsilon) !Avoid zero mask at all aggregating cells where ave=0.0 + field_out(i,j,k) = ave !Masked Sum (total_weight=1) enddo; enddo; enddo elseif(method .eq. SPS) then !e.g. vmo do k= ks,ke ; 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,k) - total_weight = total_weight +weight ave=ave+field_in(ii,jj,k)*weight enddo - field_out(i,j,k) = ave/(total_weight+epsilon) !Avoid zero mask at all aggregating cells where ave=0.0 + field_out(i,j,k) = ave !Masked Sum (total_weight=1) enddo; enddo; enddo elseif(method .eq. MPM) then do k= ks,ke ; do j=jsv_d,jev_d ; do i=isv_d,iev_d