Skip to content

Commit

Permalink
Fixed downsampling summation for more diag types
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
jkrasting committed Apr 2, 2021
1 parent 9792b23 commit 5f06304
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/framework/MOM_diag_mediator.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5f06304

Please sign in to comment.