Skip to content

Commit

Permalink
Merge pull request #1022 from nikizadehgfdl/fix_downsampled_transport…
Browse files Browse the repository at this point in the history
…_diags

Fix the downsampled diagnostics that have to be summed but are averaged instead
  • Loading branch information
adcroft authored Nov 8, 2019
2 parents 802f830 + cafd3e8 commit 9a44252
Showing 1 changed file with 3 additions and 24 deletions.
27 changes: 3 additions & 24 deletions src/framework/MOM_diag_mediator.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9a44252

Please sign in to comment.