Skip to content

Commit

Permalink
Merge pull request #1364 from jkrasting/downsampled_diag_fix
Browse files Browse the repository at this point in the history
Fixed downsampling for x:sum y:point z:point diags
  • Loading branch information
Hallberg-NOAA authored Apr 7, 2021
2 parents d485a51 + a5fb365 commit c5c7441
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/framework/MOM_diag_mediator.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4146,42 +4146,36 @@ 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/(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
Expand Down

0 comments on commit c5c7441

Please sign in to comment.