Skip to content

Commit

Permalink
Better variables for updated masks in fill_miss_2d
Browse files Browse the repository at this point in the history
  Within fill_miss_2d, there are 2 sets of masked values used for remapping -
masked values in neighboring points in arbitrary units (with names like "south")
and the updated valid mask with values of 0 or 1 (with names like "gs").  At one
point in the code, the former were being used where the latter were more
appropriate.  This commit changes this to help with the understandability of the
code.  All answers and output are bitwise identical.
  • Loading branch information
Hallberg-NOAA committed Apr 17, 2024
1 parent 3a3baf1 commit b78c567
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/framework/MOM_horizontal_regridding.F90
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ subroutine fill_miss_2d(aout, good, fill, prev, G, acrit, num_pass, relc, debug,
real, dimension(SZI_(G),SZJ_(G)) :: good_new ! The values of good_ to use for the next iteration [nondim]

real :: east, west, north, south ! Valid neighboring values or 0 for invalid values [arbitrary]
real :: ge, gw, gn, gs ! Flags indicating which neighbors have valid values [nondim]
real :: ge, gw, gn, gs ! Flags set to 0 or 1 indicating which neighbors have valid values [nondim]
real :: ngood ! The number of valid values in neighboring points [nondim]
real :: nfill ! The remaining number of points to fill [nondim]
real :: nfill_prev ! The previous value of nfill [nondim]
Expand Down Expand Up @@ -229,16 +229,16 @@ subroutine fill_miss_2d(aout, good, fill, prev, G, acrit, num_pass, relc, debug,
call pass_var(aout,G%Domain)
do j=js,je ; do i=is,ie
if (fill(i,j) == 1) then
east = max(good(i+1,j),fill(i+1,j)) ; west = max(good(i-1,j),fill(i-1,j))
north = max(good(i,j+1),fill(i,j+1)) ; south = max(good(i,j-1),fill(i,j-1))
ge = max(good(i+1,j),fill(i+1,j)) ; gw = max(good(i-1,j),fill(i-1,j))
gn = max(good(i,j+1),fill(i,j+1)) ; gs = max(good(i,j-1),fill(i,j-1))
if (ans_2018) then
a_chg(i,j) = relax_coeff*(south*aout(i,j-1)+north*aout(i,j+1) + &
west*aout(i-1,j)+east*aout(i+1,j) - &
(south+north+west+east)*aout(i,j))
a_chg(i,j) = relax_coeff*(gs*aout(i,j-1) + gn*aout(i,j+1) + &
gw*aout(i-1,j) + ge*aout(i+1,j) - &
(gs + gn + gw + ge)*aout(i,j))
else
a_chg(i,j) = relax_coeff*( ((south*aout(i,j-1) + north*aout(i,j+1)) + &
(west*aout(i-1,j)+east*aout(i+1,j))) - &
((south+north)+(west+east))*aout(i,j) )
a_chg(i,j) = relax_coeff*( ((gs*aout(i,j-1) + gn*aout(i,j+1)) + &
(gw*aout(i-1,j) + ge*aout(i+1,j))) - &
((gs + gn) + (gw + ge))*aout(i,j) )
endif
else
a_chg(i,j) = 0.
Expand Down

0 comments on commit b78c567

Please sign in to comment.