Index: NEMO/branches/2020/dev_r13787_OSMOSIS_IMMERSE/src/SAS/nemogcm.F90
===================================================================
--- NEMO/branches/2020/dev_r13787_OSMOSIS_IMMERSE/src/SAS/nemogcm.F90	(revision 13860)
+++ NEMO/branches/2020/dev_r13787_OSMOSIS_IMMERSE/src/SAS/nemogcm.F90	(revision 14043)
@@ -34,4 +34,5 @@
    USE diu_layers     ! diurnal bulk SST and coolskin
    USE step_diu       ! diurnal bulk SST timestepping (called from here if run offline)
+   USE icb_oce        ! icebergs
    !
    USE prtctl         ! Print control
@@ -374,5 +375,5 @@
      CALL Agrif_Declare_Var_ini   !  "      "   "   "      "  DOM
 #endif
-                           CALL dom_init( Nbb, Nnn, Naa, 'SAS') ! Domain
+                           CALL dom_init( Nbb, Nnn, Naa ) ! Domain
       IF( sn_cfctl%l_prtctl )   &
          &                 CALL prt_ctl_init        ! Print control
@@ -393,4 +394,10 @@
       ! ==>
                            CALL icb_init( rn_Dt, nit000)   ! initialise icebergs instance
+
+      ! compatibility check
+      IF( ln_icebergs .AND. ln_M2016 ) THEN
+         IF( lwp ) WRITE(numout,*) '         ==>>>   ln_iceberg and ln_M2016 not compatible with SAS (need 3d data)'
+         CALL ctl_stop('ln_iceberg and ln_M2016 not compatible with SAS (need 3d data)')
+      END IF
       !
       IF(lwp) WRITE(numout,cform_aaa)           ! Flag AAAAAAA
Index: NEMO/branches/2020/dev_r13787_OSMOSIS_IMMERSE/src/SAS/sbcssm.F90
===================================================================
--- NEMO/branches/2020/dev_r13787_OSMOSIS_IMMERSE/src/SAS/sbcssm.F90	(revision 13860)
+++ NEMO/branches/2020/dev_r13787_OSMOSIS_IMMERSE/src/SAS/sbcssm.F90	(revision 14043)
@@ -21,4 +21,5 @@
    USE zpshde         ! z-coord. with partial steps: horizontal derivatives
    USE closea         ! for ln_closea
+   USE icb_oce        ! for icebergs
    !
    USE in_out_manager ! I/O manager
@@ -226,5 +227,8 @@
          ln_closea = .false.
       ENDIF
-
+      IF( ln_icebergs .AND. ln_M2016 ) THEN
+         IF( lwp ) WRITE(numout,*) '         ==>>>   ln_iceberg and ln_M2016 not compatible with SAS (need 3d data)'
+         CALL ctl_stop('ln_iceberg and ln_M2016 not compatible with SAS (need 3d data)')
+      END IF
       !
       IF( l_sasread ) THEN                       ! store namelist information in an array
Index: NEMO/branches/2020/dev_r13787_OSMOSIS_IMMERSE/src/SAS/step.F90
===================================================================
--- NEMO/branches/2020/dev_r13787_OSMOSIS_IMMERSE/src/SAS/step.F90	(revision 13860)
+++ NEMO/branches/2020/dev_r13787_OSMOSIS_IMMERSE/src/SAS/step.F90	(revision 14043)
@@ -89,6 +89,24 @@
 #endif   
       IF( kstp == nit000 )   CALL iom_init( cxios_context ) ! iom_put initialization (must be done after nemo_init for AGRIF+XIOS+OASIS)
+                             CALL iom_setkt( kstp - nit000 + 1, cxios_context )   ! tell iom we are at time step kstp
+      IF((kstp == nitrst) .AND. lwxios) THEN
+         CALL iom_swap(      cw_ocerst_cxt          )
+         CALL iom_init_closedef(cw_ocerst_cxt)
+         CALL iom_setkt( kstp - nit000 + 1,      cw_ocerst_cxt          )
+#if defined key_top
+         CALL iom_swap(      cw_toprst_cxt          )
+         CALL iom_init_closedef(cw_toprst_cxt)
+         CALL iom_setkt( kstp - nit000 + 1,      cw_toprst_cxt          )
+#endif
+      ENDIF
       IF( kstp /= nit000 )   CALL day( kstp )             ! Calendar (day was already called at nit000 in day_init)
-                             CALL iom_setkt( kstp - nit000 + 1, cxios_context )   ! tell iom we are at time step kstp
+
+#if defined key_si3
+      IF(((kstp + nn_fsbc - 1) == nitrst) .AND. lwxios) THEN
+         CALL iom_swap(      cw_icerst_cxt          )
+         CALL iom_init_closedef(cw_icerst_cxt)
+         CALL iom_setkt( kstp - nit000 + 1,      cw_icerst_cxt          )
+      ENDIF
+#endif
 
       ! ==> clem: open boundaries is mandatory for sea-ice because ice BDY is not decoupled from  
@@ -128,5 +146,8 @@
       ! File manipulation at the end of the first time step
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<                         
-      IF( kstp == nit000   ) CALL iom_close( numror )                          ! close input  ocean restart file
+      IF( kstp == nit000   ) THEN
+            CALL iom_close( numror )                          ! close input  ocean restart file
+            IF( lrxios )     CALL iom_context_finalize(      cr_ocerst_cxt      )
+      ENDIF
       
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -140,5 +161,7 @@
             CALL iom_close( numrow )     
          ELSE
-            CALL iom_context_finalize( cwxios_context )
+            CALL iom_context_finalize( cw_ocerst_cxt )
+            iom_file(numrow)%nfid       = 0
+            numrow = 0
          ENDIF
          lrst_oce = .FALSE.
