Skip to content

Commit 3cb66ec

Browse files
committed
apply tripolar stitch fix in auto mask_table generation
1 parent 4202b78 commit 3cb66ec

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/framework/MOM_domains.F90

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,16 @@ subroutine gen_auto_mask_table(n_global, reentrant, tripolar_N, npes, param_file
520520
mask(i, jbuf+ny+j) = mask(nx+2*ibuf+1-i, jbuf+ny+1-j)
521521
enddo
522522
enddo
523-
!mask(:, jbuf+ny) = 1 ! TODO - REMOVE
523+
endif
524+
525+
! Tripolar Stitch Fix: In cases where masking is asymmetrical across the tripolar stitch, there's a possibility
526+
! that certain unmasked blocks won't be able to obtain grid metrics from the halo points. This occurs when the
527+
! neighboring block on the opposite side of the tripolar stitch is masked. As a consequence, certain metrics like
528+
! dxT and dyT may be calculated through extrapolation (refer to extrapolate_metric), potentially leading to the
529+
! generation of non-positive values. This can result in divide-by-zero errors elsewhere, e.g., in MOM_hor_visc.F90.
530+
! Currently, the safest and most general solution is to prohibit masking along the tripolar stitch:
531+
if (tripolar_N) then
532+
mask(:, jbuf+ny) = 1
524533
endif
525534

526535
glob_ocn_frac = real(sum(mask(1+ibuf:nx+ibuf, 1+jbuf:ny+jbuf))) / (nx * ny)

0 commit comments

Comments
 (0)