From b78c567b58813ac1b3d6996ccd53559a23796e26 Mon Sep 17 00:00:00 2001 From: Robert Hallberg Date: Tue, 5 Mar 2024 05:30:22 -0500 Subject: [PATCH] Better variables for updated masks in fill_miss_2d 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. --- src/framework/MOM_horizontal_regridding.F90 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/framework/MOM_horizontal_regridding.F90 b/src/framework/MOM_horizontal_regridding.F90 index b718f65b5e..82637183b7 100644 --- a/src/framework/MOM_horizontal_regridding.F90 +++ b/src/framework/MOM_horizontal_regridding.F90 @@ -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] @@ -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.