From e4e3d04c0e9e5414702b9387fff3fc4c9441c801 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Chanut?=
 <jerome.chanut@mercator-ocean.fr>
Date: Thu, 10 Mar 2022 15:01:21 +0000
Subject: [PATCH] Allow an AGRIF zoom to run without a sea ice model even if
 the parent does have one.

---
 cfgs/AGRIF_DEMO/EXPREF/1_context_nemo.xml |  1 -
 cfgs/AGRIF_DEMO/EXPREF/1_namelist_cfg     |  5 ++++-
 src/OCE/SBC/sbcmod.F90                    | 11 +++++++++--
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/cfgs/AGRIF_DEMO/EXPREF/1_context_nemo.xml b/cfgs/AGRIF_DEMO/EXPREF/1_context_nemo.xml
index 87b0d3b2c..ee852b604 100644
--- a/cfgs/AGRIF_DEMO/EXPREF/1_context_nemo.xml
+++ b/cfgs/AGRIF_DEMO/EXPREF/1_context_nemo.xml
@@ -27,7 +27,6 @@
 
 <!-- Files definition -->
     <file_definition src="./file_def_nemo-oce.xml"/>     <!--  NEMO ocean dynamics                     -->
-    <file_definition src="./file_def_nemo-ice.xml"/>     <!--  NEMO ocean sea ice                      -->
     <file_definition src="./file_def_nemo-innerttrc.xml"/> <!--  NEMO ocean inert passive tracer           -->
 
 <!-- Axis definition -->
diff --git a/cfgs/AGRIF_DEMO/EXPREF/1_namelist_cfg b/cfgs/AGRIF_DEMO/EXPREF/1_namelist_cfg
index fb7cc8224..0b63dd2e3 100644
--- a/cfgs/AGRIF_DEMO/EXPREF/1_namelist_cfg
+++ b/cfgs/AGRIF_DEMO/EXPREF/1_namelist_cfg
@@ -85,7 +85,7 @@
                      ! Type of air-sea fluxes 
    ln_blk      = .true.    !  Bulk formulation                          (T => fill namsbc_blk )
                      ! Sea-ice :
-   nn_ice      = 2         !  =0 no ice boundary condition
+   nn_ice      = 0         !  =0 no ice boundary condition
       !                    !  =1 use observed ice-cover                 (  => fill namsbc_iif )
       !                    !  =2 or 3 for SI3 and CICE, respectively
                      ! Misc. options of sbc : 
@@ -361,6 +361,9 @@
 !-----------------------------------------------------------------------
 &namzdf_tke    !   turbulent eddy kinetic dependent vertical diffusion  (ln_zdftke =T)
 !-----------------------------------------------------------------------
+   ln_mxl0     = .true.    !  surface mixing length scale = F(wind stress) (T) or not (F)
+      nn_mxlice    = 0        ! type of scaling under sea-ice
+      !                       !    = 0 no scaling under sea-ice
 /
 !!======================================================================
 !!                  ***  Diagnostics namelists  ***                   !!
diff --git a/src/OCE/SBC/sbcmod.F90 b/src/OCE/SBC/sbcmod.F90
index 12fcf66de..86ec97aa1 100644
--- a/src/OCE/SBC/sbcmod.F90
+++ b/src/OCE/SBC/sbcmod.F90
@@ -39,6 +39,7 @@ MODULE sbcmod
    USE sbcice_if      ! surface boundary condition: ice-if sea-ice model
 #if defined key_si3
    USE icestp         ! surface boundary condition: SI3 sea-ice model
+   USE ice
 #endif
    USE sbcice_cice    ! surface boundary condition: CICE sea-ice model
    USE sbccpl         ! surface boundary condition: coupled formulation
@@ -325,8 +326,14 @@ CONTAINS
       IF( ln_apr_dyn )    CALL sbc_apr_init              ! Atmo Pressure Forcing initialization
       !
 #if defined key_si3
-      IF( lk_agrif .AND. nn_ice == 0 ) THEN            ! allocate ice arrays in case agrif + ice-model + no-ice in child grid
-                          IF( sbc_ice_alloc() /= 0 )   CALL ctl_stop('STOP', 'sbc_ice_alloc : unable to allocate arrays' )
+      IF( nn_ice == 0 ) THEN
+#if defined key_agrif
+         ! allocate ice arrays in case agrif + ice-model + no-ice in child grid
+         jpl = 1 ; nlay_i = 1 ; nlay_s = 1
+         IF( sbc_ice_alloc() /= 0 )   CALL ctl_stop('STOP', 'sbc_ice_alloc : unable to allocate arrays' )
+         CALL Agrif_Declare_Var_ice  !  "      "   "   "      "  Sea ice
+#endif
+
       ELSEIF( nn_ice == 2 ) THEN
                           CALL ice_init( Kbb, Kmm, Kaa )         ! ICE initialization
       ENDIF
-- 
GitLab