When I use the same bathymetric grid as I was using with NEMO 3.6, but with NEMO 4.2.2, the model aborts after a certain number of timesteps because SSH >= 20m at one gridpoint. It appears that this gridpoint has just one vertical layer. If I increase bathymetric values in order to have 2 vertical layers everywhere, the run is going to the end without aborting.
We found that this is the result of the L159-167 of dommsk.F90:
! In case of a coarsened grid, account her for possibly aditionnal
! masked points; these have been read in the mesh file and stored in mbku, mbkv, mbkf
DO_2D( 0, 0, 0, 0 )
! Ugly patch to accomodate batropic case (jpk=2)
! but with possible masked faces in the coarsening case
! A better way would be to keep track of mbku/v/f=0 until here
! but these have been assigned a minimum of 1. TBC
IF (jpk>2) THEN
IF (mbku(ji,jj)==1) umask(ji,jj,:) = 0._wp
IF (mbkv(ji,jj)==1) vmask(ji,jj,:) = 0._wp
IF (mbkf(ji,jj)==1) fmask(ji,jj,:) = 0._wp
ENDIF
Ticket and merge request that lead to this patch:
https://forge.nemo-ocean.eu/nemo/nemo/-/issues/78
https://forge.nemo-ocean.eu/nemo/nemo/-/merge_requests/118
So in case of one vertical layer, tmask is left to 1 but umask, vmask and fmask are set to 0. This can be, in many cases, hidden or hard to detect, but I happened to have a river at this specific gridpoint, which makes SSH growing until it reaches the treshold value of 20m.
When commenting those lines, the run is going to the end without aborting.
Note to mention that this patch also results in differences between the masks produced by the domain_cfg tool and the masks used in NEMO, because the domain_cfg code does not contain these lines of code.
As a bugfix, if this patch was added only for AGRIF, maybe this part can be enclosed in a #key_agrif like this:
#ifdef key_agrif
IF (Agrif_Child()) THEN
IF (jpk>2) THEN
IF (mbku(ji,jj)==1) umask(ji,jj,:) = 0._wp
IF (mbkv(ji,jj)==1) vmask(ji,jj,:) = 0._wp
IF (mbkf(ji,jj)==1) fmask(ji,jj,:) = 0._wp
ENDIF
ENDIF
#endif