Bug fix for 4.2.2 when halo size = 1 and wetting/drying activated

When wetting and drying is activated (ln_wd_dl = T and ln_wd_dl_bc = T) and the halo size is set to one (nn_hls = 1), artifacts are visible in the velocity fields at the edges of each single-cpu tile. Here’s a snapshot of zonal velocity; the meridional velocity also has the artifacts:

If the halo size is two, the artifacts aren’t present. We tracked this down to a missing halo exchange in DYN/dynspg_ts.F90 when the wet/dry mask is calculated, and then adjusted two tile exchanges later in the script to include the halos:

diff --git a/src/OCE/DYN/dynspg_ts.F90 b/src/OCE/DYN/dynspg_ts.F90
index 44cc31e..6fec911 100644
--- a/src/OCE/DYN/dynspg_ts.F90
+++ b/src/OCE/DYN/dynspg_ts.F90
@@ -517,6 +517,7 @@ CONTAINS
          IF( ln_wd_dl ) THEN           ! un_e and vn_e are set to zero at faces where 
             !                          ! the direction of the flow is from dry cells
             CALL wad_Umsk( ztwdmask, zhU, zhV, un_e, vn_e, zuwdmask, zvwdmask )   ! not jpi colomn for U, not jpj row for V
+            CALL lbc_lnk( 'dynspg_ts', zuwdmask, 'U', -1._wp, zvwdmask, 'V', -1._wp ) ! Needed to avoid artifacts 
             !
          ENDIF    
          !
@@ -545,10 +546,10 @@ CONTAINS
          vn_adv(:,:) = vn_adv(:,:) + za2 * zhV(:,:) * r1_e1v(:,:)
          ! sum over sub-time-steps to decide which baroclinic velocities to set to zero (zuwdav2 is only used when ln_wd_dl_bc=True) 
          IF ( ln_wd_dl_bc ) THEN
-            DO_2D( 1, 0, 1, 1 )   ! not jpi-column
+            DO_2D( 1, 1, 1, 1 )   ! include halo
                zuwdav2(ji,jj) = zuwdav2(ji,jj) + za2 * zuwdmask(ji,jj)
             END_2D
-            DO_2D( 1, 1, 1, 0 )   ! not jpj-row
+            DO_2D( 1, 1, 1, 1 )   ! include halo 
                zvwdav2(ji,jj) = zvwdav2(ji,jj) + za2 * zvwdmask(ji,jj)
             END_2D
          END IF

This is from the Canadian CONCEPTS version of NEMO 4.2.2 which has had modifications, so it’s possible the line numbers don’t match what they should be in the official repository. Unfortunately our gitlab is not publicly accessible so I cannot link to a specific commit, but am happy to provide any additional info needed to patch in the bug fix.

Nice find, Stephanne!