Index: branches/UKMO/dev_isf_remapping_UKESM_GO6package_r9314/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90
===================================================================
--- branches/UKMO/dev_isf_remapping_UKESM_GO6package_r9314/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 9513)
+++ branches/UKMO/dev_isf_remapping_UKESM_GO6package_r9314/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 9732)
@@ -1269,5 +1269,5 @@
       !!                          1.0 = set iceshelf to the minimum depth allowed
       !!                          1.1 = ground ice shelf if water column less than X m
-      !!                          1.2 = ensure a minimum thickness for iceshelf cavity in shallow water
+      !!                          1.2 = ensure a minimum thickness for iceshelf cavity
       !!                          1.3 = remove channels and single point 'bay'
       !!                          1.4 = close single isolated point
@@ -1298,5 +1298,6 @@
       INTEGER  :: nn_kisfmax    = 999.                              !  
       REAL(wp) :: rn_isfdep_min = 10.0_wp                           ! ice shelf minimal thickness 
-      REAL(wp) :: rn_isfhw_deep = 1.e-3 , rn_isfhw_shallow = 1.0e-3 ! threshold to define grounding line in deep/shallow water
+      REAL(wp) :: rn_glhw_min   = 1.0e-3                             ! threshold on hw to define grounding line water
+      REAL(wp) :: rn_isfhw_min  = 1.0e-3                            ! threshold on hw to define isf draft into the cavity
       REAL(wp) :: rn_isfshallow = 0.0_wp                            ! threshold to define shallow ice shelf cavity
       REAL(wp) :: rn_zisfmax    = 6000.0_wp                         ! maximun meter of ice we are allowed to dig to assure connectivity
@@ -1304,5 +1305,5 @@
       !!---------------------------------------------------------------------
       NAMELIST/namzgr_isf/nn_kisfmax, rn_zisfmax, &
-              &           rn_isfdep_min, rn_isfhw_deep, rn_isfhw_shallow, rn_isfshallow, &
+              &           rn_isfdep_min, rn_glhw_min, rn_isfhw_min, &
               &           ln_isfcheminey, ln_isfconnect, ln_isfchannel, ln_isfsubgl, rn_isfsubgllon, rn_isfsubgllat
       !
@@ -1326,7 +1327,6 @@
          WRITE(numout,*) ' rn_zisfmax       = ',rn_zisfmax           !
          WRITE(numout,*) ' rn_isfdep_min    = ',rn_isfdep_min        !
-         WRITE(numout,*) ' rn_isfhw_deep    = ',rn_isfhw_deep        !
-         WRITE(numout,*) ' rn_isfhw_shallow = ',rn_isfhw_shallow     !
-         WRITE(numout,*) ' rn_isfshallow    = ',rn_isfshallow        !
+         WRITE(numout,*) ' rn_isfhw_min     = ',rn_isfhw_min         !
+         WRITE(numout,*) ' rn_glhw_min      = ',rn_glhw_min          !
          WRITE(numout,*) ' ln_isfcheminey   = ',ln_isfcheminey       !
          WRITE(numout,*) ' ln_isfconnect    = ',ln_isfconnect        !
@@ -1339,15 +1339,25 @@
       END WHERE
       !  
-      ! 1.1 ground ice shelf if water column less than X m
-      WHERE( bathy(:,:) - risfdep(:,:) < rn_isfhw_deep .AND. (bathy(:,:) > rn_isfshallow) ) 
+      ! 1.1 ground ice shelf if water column less than X m => set the grounding
+      ! line position
+      WHERE( bathy(:,:) - risfdep(:,:) < rn_glhw_min ) 
          risfdep(:,:)=0.0 ; misfdep(:,:) = 1
          bathy  (:,:)=0.0 ; mbathy (:,:) = 0
       END WHERE
       !
-      ! 1.2 ensure a minimum thickness for iceshelf cavity in shallow water
-      WHERE( (bathy(:,:) <= rn_isfshallow) .AND. (bathy(:,:) - risfdep(:,:) < rn_isfhw_shallow) ) 
-         risfdep(:,:)=0.0 ; misfdep(:,:) = 1
-         bathy  (:,:)=0.0 ; mbathy (:,:) = 0
-      END WHERE
+      ! 1.2 ensure a minimum thickness for iceshelf cavity => avoid to negative
+      ! e3t if ssh + sum(e3t*tmask) < 0
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF (bathy(ji,jj)-risfdep(ji,jj) < rn_isfhw_min) THEN
+               IF ((bathy(ji,jj) - rn_isfhw_min) > MAX(rn_isfdep_min,e3t_1d(1))) THEN 
+                  risfdep(ji,jj) = bathy(ji,jj) - rn_isfhw_min
+               ELSE
+                  risfdep(ji,jj)=0.0 ; misfdep(ji,jj) = 1
+                  bathy  (ji,jj)=0.0 ; mbathy (ji,jj) = 0
+               END IF
+            END IF
+         END DO
+      END DO
       !
       ! 1.3 Remove channels and single point 'bay'.
