Index: /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AMM12/EXPREF/iodef.xml
===================================================================
--- /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AMM12/EXPREF/iodef.xml	(revision 11892)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AMM12/EXPREF/iodef.xml	(revision 11893)
@@ -24,4 +24,6 @@
 
   <context id="nemo" src="./context_nemo.xml"/>       <!--  NEMO       -->
+  <context id="nemo_rstw" src="./nemo_rstw.xml"/>
+  <context id="si3_rst" src="./si3_rst.xml"/>
   
 </simulation>
Index: /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/ORCA2_ICE_PISCES/EXPREF/iodef.xml
===================================================================
--- /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/ORCA2_ICE_PISCES/EXPREF/iodef.xml	(revision 11892)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/ORCA2_ICE_PISCES/EXPREF/iodef.xml	(revision 11893)
@@ -23,4 +23,6 @@
 
   <context id="nemo" src="./context_nemo.xml"/>       <!--  NEMO       -->
+  <context id="nemo_rstw" src="./nemo_rstw.xml"/>     <!-- NEMO restart write context --> 
+  <context id="si3_rst" src="./si3_rst.xml"/>         <!-- SI3  restart read context -->
 
 </simulation>
Index: /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/ORCA2_ICE_PISCES/EXPREF/nemo_rstw.xml
===================================================================
--- /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/ORCA2_ICE_PISCES/EXPREF/nemo_rstw.xml	(revision 11893)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/ORCA2_ICE_PISCES/EXPREF/nemo_rstw.xml	(revision 11893)
@@ -0,0 +1,5 @@
+<context id="nemo_rstw">
+  
+    <grid_definition src="./grid_def_nemo.xml"/>
+    
+</context>
Index: /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/ORCA2_ICE_PISCES/EXPREF/si3_rst.xml
===================================================================
--- /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/ORCA2_ICE_PISCES/EXPREF/si3_rst.xml	(revision 11893)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/ORCA2_ICE_PISCES/EXPREF/si3_rst.xml	(revision 11893)
@@ -0,0 +1,5 @@
+<context id="si3_rst">
+  
+    <grid_definition src="./grid_def_nemo.xml"/>
+    
+</context>
Index: /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/ORCA2_SAS_ICE/EXPREF/iodef.xml
===================================================================
--- /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/ORCA2_SAS_ICE/EXPREF/iodef.xml	(revision 11892)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/ORCA2_SAS_ICE/EXPREF/iodef.xml	(revision 11893)
@@ -23,4 +23,6 @@
 
   <context id="nemo" src="./context_nemo.xml"/>       <!--  NEMO       -->
+  <context id="nemo_rstw" src="./nemo_rstw.xml"/>
+  <context id="si3_rst" src="./si3_rst.xml"/>
 
 </simulation>
Index: /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/SHARED/grid_def_nemo.xml
===================================================================
--- /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/SHARED/grid_def_nemo.xml	(revision 11892)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/SHARED/grid_def_nemo.xml	(revision 11893)
@@ -57,4 +57,19 @@
         <scalar/>
       </grid>
+        <!-- writeng/reading SI3 4D restart -->
+       <grid id="grid_Ni_4D" >
+         <domain id="grid_N" />
+         <axis id="nlay_i" />
+         <axis id="numcat" /> 
+       </grid>
+        <!-- writeng/reading SI3 4D restart -->
+       <grid id="grid_Ns_4D" >
+         <domain id="grid_N" />
+         <axis id="nlay_s" />
+         <axis id="numcat" />
+       </grid>
+
+        <!--  -->
+
 
     </grid_definition>
Index: /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/SPITZ12/EXPREF/iodef.xml
===================================================================
--- /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/SPITZ12/EXPREF/iodef.xml	(revision 11892)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/SPITZ12/EXPREF/iodef.xml	(revision 11893)
@@ -23,4 +23,5 @@
 
   <context id="nemo" src="./context_nemo.xml"/>       <!--  NEMO       -->
-
+  <context id="nemo_rstw" src="./nemo_rstw.xml"/>
+  <context id="si3_rst" src="./si3_rst.xml"/>
 </simulation>
Index: /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/ICE/icedyn_adv_pra.F90
===================================================================
--- /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/ICE/icedyn_adv_pra.F90	(revision 11892)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/ICE/icedyn_adv_pra.F90	(revision 11893)
@@ -702,30 +702,16 @@
          CALL iom_set_rstw_var_active(rsti_wfields, 'syyage')
          CALL iom_set_rstw_var_active(rsti_wfields, 'sxyage')
-         DO jk = 1, nlay_s
-            WRITE(zchar1,'(I2.2)') jk
-            znam = 'sxc0'//'_l'//zchar1  
-            CALL iom_set_rstw_var_active(rsti_wfields, znam )
-            znam = 'syc0'//'_l'//zchar1  
-            CALL iom_set_rstw_var_active(rsti_wfields, znam )
-            znam = 'sxxc0'//'_l'//zchar1 
-            CALL iom_set_rstw_var_active(rsti_wfields, znam )
-            znam = 'syyc0'//'_l'//zchar1 
-            CALL iom_set_rstw_var_active(rsti_wfields, znam )
-            znam = 'sxyc0'//'_l'//zchar1 
-            CALL iom_set_rstw_var_active(rsti_wfields, znam )
-         END DO
-         DO jk = 1, nlay_i
-            WRITE(zchar1,'(I2.2)') jk
-            znam = 'sxe'//'_l'//zchar1   
-            CALL iom_set_rstw_var_active(rsti_wfields, znam )
-            znam = 'sye'//'_l'//zchar1   
-            CALL iom_set_rstw_var_active(rsti_wfields, znam )
-            znam = 'sxxe'//'_l'//zchar1  
-            CALL iom_set_rstw_var_active(rsti_wfields, znam )
-            znam = 'syye'//'_l'//zchar1  
-            CALL iom_set_rstw_var_active(rsti_wfields, znam )
-            znam = 'sxye'//'_l'//zchar1  
-            CALL iom_set_rstw_var_active(rsti_wfields, znam )
-         END DO
+       
+         CALL iom_set_rstw_var_active(rsti_wfields, 'sxc0')
+         CALL iom_set_rstw_var_active(rsti_wfields, 'syc0')
+         CALL iom_set_rstw_var_active(rsti_wfields, 'sxxc0')
+         CALL iom_set_rstw_var_active(rsti_wfields, 'syyc0')
+         CALL iom_set_rstw_var_active(rsti_wfields, 'sxyc0')
+
+         CALL iom_set_rstw_var_active(rsti_wfields, 'sxe')
+         CALL iom_set_rstw_var_active(rsti_wfields, 'sye')
+         CALL iom_set_rstw_var_active(rsti_wfields, 'sxxe')
+         CALL iom_set_rstw_var_active(rsti_wfields, 'syye')
+         CALL iom_set_rstw_var_active(rsti_wfields, 'sxye')
          !
          IF( ln_pnd_H12 ) THEN                                       ! melt pond fraction
@@ -842,9 +828,9 @@
                CALL iom_get( numrir, jpdom_autoglo, "syyc0", syyc0, ldxios = lrxios )
                CALL iom_get( numrir, jpdom_autoglo, "sxyc0", sxyc0, ldxios = lrxios )
-               CALL iom_get( numrir, jpdom_autoglo, "sxe", sxc0, ldxios = lrxios )
-               CALL iom_get( numrir, jpdom_autoglo, "sye", syc0, ldxios = lrxios )
-               CALL iom_get( numrir, jpdom_autoglo, "sxxe", sxxc0, ldxios = lrxios )
-               CALL iom_get( numrir, jpdom_autoglo, "syye", syyc0, ldxios = lrxios )
-               CALL iom_get( numrir, jpdom_autoglo, "sxye", sxyc0, ldxios = lrxios )
+               CALL iom_get( numrir, jpdom_autoglo, "sxe", sxe, ldxios = lrxios )
+               CALL iom_get( numrir, jpdom_autoglo, "sye", sye, ldxios = lrxios )
+               CALL iom_get( numrir, jpdom_autoglo, "sxxe", sxxe, ldxios = lrxios )
+               CALL iom_get( numrir, jpdom_autoglo, "syye", syye, ldxios = lrxios )
+               CALL iom_get( numrir, jpdom_autoglo, "sxye", sxye, ldxios = lrxios )
             ENDIF
             !
@@ -924,45 +910,60 @@
          CALL iom_rstput( iter, nitrst, numriw, 'sxyage', sxyage, ldxios = lwxios ) 
          !                                                           ! snow layers heat content
-         DO jk = 1, nlay_s
-            WRITE(zchar1,'(I2.2)') jk
-            znam = 'sxc0'//'_l'//zchar1  
-            z3d(:,:,:) = sxc0 (:,:,jk,:)  
-            CALL iom_rstput( iter, nitrst, numriw, znam , z3d,  ldxios = lwxios )
-
-            znam = 'syc0'//'_l'//zchar1  
-            z3d(:,:,:) = syc0 (:,:,jk,:)  
-            CALL iom_rstput( iter, nitrst, numriw, znam , z3d,  ldxios = lwxios )
-
-            znam = 'sxxc0'//'_l'//zchar1 
-            z3d(:,:,:) = sxxc0(:,:,jk,:)  
-            CALL iom_rstput( iter, nitrst, numriw, znam , z3d,  ldxios = lwxios )
-
-            znam = 'syyc0'//'_l'//zchar1 
-            z3d(:,:,:) = syyc0(:,:,jk,:)  
-            CALL iom_rstput( iter, nitrst, numriw, znam , z3d,  ldxios = lwxios )
-
-            znam = 'sxyc0'//'_l'//zchar1 
-            z3d(:,:,:) = sxyc0(:,:,jk,:)  
-            CALL iom_rstput( iter, nitrst, numriw, znam , z3d,  ldxios = lwxios )
-         END DO
-         !                                                           ! ice layers heat content
-         DO jk = 1, nlay_i
-            WRITE(zchar1,'(I2.2)') jk
-            znam = 'sxe'//'_l'//zchar1   
-            z3d(:,:,:) = sxe (:,:,jk,:)   
-            CALL iom_rstput( iter, nitrst, numriw, znam , z3d,  ldxios = lwxios )
-            znam = 'sye'//'_l'//zchar1   
-            z3d(:,:,:) = sye (:,:,jk,:)   
-            CALL iom_rstput( iter, nitrst, numriw, znam , z3d,  ldxios = lwxios )
-            znam = 'sxxe'//'_l'//zchar1  
-            z3d(:,:,:) = sxxe(:,:,jk,:)   
-            CALL iom_rstput( iter, nitrst, numriw, znam , z3d,  ldxios = lwxios )
-            znam = 'syye'//'_l'//zchar1  
-            z3d(:,:,:) = syye(:,:,jk,:)   
-            CALL iom_rstput( iter, nitrst, numriw, znam , z3d,  ldxios = lwxios )
-            znam = 'sxye'//'_l'//zchar1  
-            z3d(:,:,:) = sxye(:,:,jk,:)   
-            CALL iom_rstput( iter, nitrst, numriw, znam , z3d,  ldxios = lwxios )
-         END DO
+         IF(lwxios) THEN
+            CALL iom_rstput( iter, nitrst, numriw, 'sxc0' ,  sxc0,  ldxios = lwxios )
+            CALL iom_rstput( iter, nitrst, numriw, 'syc0' ,  syc0,  ldxios = lwxios )
+            CALL iom_rstput( iter, nitrst, numriw, 'sxxc0', sxxc0,  ldxios = lwxios )
+            CALL iom_rstput( iter, nitrst, numriw, 'syyc0', syyc0,  ldxios = lwxios )
+            CALL iom_rstput( iter, nitrst, numriw, 'sxyc0', sxyc0,  ldxios = lwxios )
+
+
+            CALL iom_rstput( iter, nitrst, numriw, 'sxe' ,  sxe,  ldxios = lwxios )
+            CALL iom_rstput( iter, nitrst, numriw, 'sye' ,  sye,  ldxios = lwxios )
+            CALL iom_rstput( iter, nitrst, numriw, 'sxxe', sxxe,  ldxios = lwxios )
+            CALL iom_rstput( iter, nitrst, numriw, 'syye', syye,  ldxios = lwxios )
+            CALL iom_rstput( iter, nitrst, numriw, 'sxye', sxye,  ldxios = lwxios )
+         ELSE
+            DO jk = 1, nlay_s
+               WRITE(zchar1,'(I2.2)') jk
+               znam = 'sxc0'//'_l'//zchar1  
+               z3d(:,:,:) = sxc0 (:,:,jk,:)  
+               CALL iom_rstput( iter, nitrst, numriw, znam , z3d,  ldxios = lwxios )
+
+               znam = 'syc0'//'_l'//zchar1  
+               z3d(:,:,:) = syc0 (:,:,jk,:)  
+               CALL iom_rstput( iter, nitrst, numriw, znam , z3d,  ldxios = lwxios )
+
+               znam = 'sxxc0'//'_l'//zchar1 
+               z3d(:,:,:) = sxxc0(:,:,jk,:)  
+               CALL iom_rstput( iter, nitrst, numriw, znam , z3d,  ldxios = lwxios )
+   
+               znam = 'syyc0'//'_l'//zchar1 
+               z3d(:,:,:) = syyc0(:,:,jk,:)  
+               CALL iom_rstput( iter, nitrst, numriw, znam , z3d,  ldxios = lwxios )
+   
+               znam = 'sxyc0'//'_l'//zchar1 
+               z3d(:,:,:) = sxyc0(:,:,jk,:)  
+               CALL iom_rstput( iter, nitrst, numriw, znam , z3d,  ldxios = lwxios )
+            END DO
+            !                                                           ! ice layers heat content
+            DO jk = 1, nlay_i
+               WRITE(zchar1,'(I2.2)') jk
+               znam = 'sxe'//'_l'//zchar1   
+               z3d(:,:,:) = sxe (:,:,jk,:)   
+               CALL iom_rstput( iter, nitrst, numriw, znam , z3d,  ldxios = lwxios )
+               znam = 'sye'//'_l'//zchar1   
+               z3d(:,:,:) = sye (:,:,jk,:)   
+               CALL iom_rstput( iter, nitrst, numriw, znam , z3d,  ldxios = lwxios )
+               znam = 'sxxe'//'_l'//zchar1  
+               z3d(:,:,:) = sxxe(:,:,jk,:)   
+               CALL iom_rstput( iter, nitrst, numriw, znam , z3d,  ldxios = lwxios )
+               znam = 'syye'//'_l'//zchar1  
+               z3d(:,:,:) = syye(:,:,jk,:)   
+               CALL iom_rstput( iter, nitrst, numriw, znam , z3d,  ldxios = lwxios )
+               znam = 'sxye'//'_l'//zchar1  
+               z3d(:,:,:) = sxye(:,:,jk,:)   
+               CALL iom_rstput( iter, nitrst, numriw, znam , z3d,  ldxios = lwxios )
+            END DO
+         ENDIF
          !
          IF( ln_pnd_H12 ) THEN                                       ! melt pond fraction
Index: /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/ICE/icerst.F90
===================================================================
--- /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/ICE/icerst.F90	(revision 11892)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/ICE/icerst.F90	(revision 11893)
@@ -138,18 +138,23 @@
       CALL iom_rstput( iter, nitrst, numriw, 'a_ip' , a_ip, ldxios = lwxios  )
       CALL iom_rstput( iter, nitrst, numriw, 'v_ip' , v_ip, ldxios = lwxios  )
+      IF(lwxios) THEN
+         CALL iom_rstput( iter, nitrst, numriw, 'e_s' , e_s, ldxios = lwxios )
+         CALL iom_rstput( iter, nitrst, numriw, 'e_i' , e_i, ldxios = lwxios )
+      ELSE
       ! Snow enthalpy
-      DO jk = 1, nlay_s 
-         WRITE(zchar1,'(I2.2)') jk
-         znam = 'e_s'//'_l'//zchar1
-         z3d(:,:,:) = e_s(:,:,jk,:)
-         CALL iom_rstput( iter, nitrst, numriw, znam , z3d, ldxios = lwxios )
-      END DO
-      ! Ice enthalpy
-      DO jk = 1, nlay_i 
-         WRITE(zchar1,'(I2.2)') jk
-         znam = 'e_i'//'_l'//zchar1
-         z3d(:,:,:) = e_i(:,:,jk,:)
-         CALL iom_rstput( iter, nitrst, numriw, znam , z3d, ldxios = lwxios )
-      END DO
+         DO jk = 1, nlay_s 
+            WRITE(zchar1,'(I2.2)') jk
+            znam = 'e_s'//'_l'//zchar1
+            z3d(:,:,:) = e_s(:,:,jk,:)
+            CALL iom_rstput( iter, nitrst, numriw, znam , z3d, ldxios = lwxios )
+         END DO
+         ! Ice enthalpy
+         DO jk = 1, nlay_i 
+            WRITE(zchar1,'(I2.2)') jk
+            znam = 'e_i'//'_l'//zchar1
+            z3d(:,:,:) = e_i(:,:,jk,:)
+            CALL iom_rstput( iter, nitrst, numriw, znam , z3d, ldxios = lwxios )
+         END DO
+      ENDIF
       ! fields needed for Met Office (Jules) coupling
       IF( ln_cpl ) THEN
Index: /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/OCE/IOM/iom.F90
===================================================================
--- /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/OCE/IOM/iom.F90	(revision 11892)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/OCE/IOM/iom.F90	(revision 11893)
@@ -64,5 +64,5 @@
    PUBLIC iom_use, iom_context_finalize, iom_miss_val
 
-   PRIVATE iom_rp0d, iom_rp1d, iom_rp2d, iom_rp3d
+   PRIVATE iom_rp0d, iom_rp1d, iom_rp2d, iom_rp3d, iom_rp4d
    PRIVATE iom_g0d, iom_g1d, iom_g2d, iom_g3d, iom_g4d, iom_get_123d
    PRIVATE iom_p1d, iom_p2d, iom_p3d
@@ -89,5 +89,5 @@
    END INTERFACE
    INTERFACE iom_rstput
-      MODULE PROCEDURE iom_rp0d, iom_rp1d, iom_rp2d, iom_rp3d
+      MODULE PROCEDURE iom_rp0d, iom_rp1d, iom_rp2d, iom_rp3d, iom_rp4d
    END INTERFACE
    INTERFACE iom_put
@@ -451,19 +451,21 @@
                 CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_rfields(i)%vname))
                 SELECT CASE (TRIM(rst_rfields(i)%grid))
-!                CASE ("grid_Ni_4D")
-!                   CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(rst_rfields(i)%vname), &
-!                       domain_ref="grid_N", axis_ref="nlay_i", axis_ref="numcat", operation = "instant")
-!                CASE ("grid_Ns_4D")
-!                   CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(rst_rfields(i)%vname), &
-!                       domain_ref="grid_N", axis_ref="nlay_s", axis_ref="numcat", operation = "instant")
+#if defined key_si3
+                 CASE ("grid_Ni_4D")
+                    CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(rst_rfields(i)%vname), &
+                         grid_ref="grid_Ni_4D", operation = "instant")
+                 CASE ("grid_Ns_4D")
+                    CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(rst_rfields(i)%vname), &
+                         grid_ref="grid_Ns_4D", operation = "instant")
                  CASE ("grid_Ni_3D")
                     CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(rst_rfields(i)%vname), &
-                        domain_ref="grid_N", axis_ref="numcat", operation = "instant")
+                         domain_ref="grid_N", axis_ref="numcat", operation = "instant")
+#endif
                  CASE ("grid_N_3D")
                     CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(rst_rfields(i)%vname), &
-                        domain_ref="grid_N", axis_ref="nav_lev", operation = "instant")
+                         domain_ref="grid_N", axis_ref="nav_lev", operation = "instant")
                  CASE ("grid_N")
                     CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(rst_rfields(i)%vname), &
-                        domain_ref="grid_N", operation = "instant") 
+                         domain_ref="grid_N", operation = "instant") 
                 CASE ("grid_vector")
                     CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(rst_rfields(i)%vname), &
@@ -471,5 +473,5 @@
                  CASE ("grid_scalar")
                     CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(rst_rfields(i)%vname), &
-                        scalar_ref = "grid_scalar", operation = "instant")
+                         scalar_ref = "grid_scalar", operation = "instant")
                 END SELECT
                 IF(lwp) WRITE(numout,*) 'XIOS read: ', TRIM(rst_rfields(i)%vname), ' enabled in ', TRIM(rst_file)
@@ -526,27 +528,20 @@
          CALL iom_set_rstw_var_active(drst_wfields, 'sbc_sc_b')
    ELSE IF(cdmdl == "SI3") THEN
+#if defined key_si3
       CALL iom_set_rstw_var_active(drst_wfields, 'nn_fsbc_ice')
-      CALL iom_set_rstw_var_active(drst_wfields, 'kt_ice')
-      CALL iom_set_rstw_var_active(drst_wfields, 'v_i')
-      CALL iom_set_rstw_var_active(drst_wfields, 'v_s')
-      CALL iom_set_rstw_var_active(drst_wfields, 'sv_i')
-      CALL iom_set_rstw_var_active(drst_wfields, 'a_i')
-      CALL iom_set_rstw_var_active(drst_wfields, 't_su')
-      CALL iom_set_rstw_var_active(drst_wfields, 'u_ice')
-      CALL iom_set_rstw_var_active(drst_wfields, 'v_ice')
-      CALL iom_set_rstw_var_active(drst_wfields, 'oa_i')
-      CALL iom_set_rstw_var_active(drst_wfields, 'a_ip')
-      CALL iom_set_rstw_var_active(drst_wfields, 'v_ip')
-      DO jk = 1, nlay_s 
-         WRITE(zchar1,'(I2.2)') jk
-         znam = 'e_s'//'_l'//zchar1
-         CALL iom_set_rstw_var_active(drst_wfields, znam )
-      END DO
-      ! Ice enthalpy
-      DO jk = 1, nlay_i 
-         WRITE(zchar1,'(I2.2)') jk
-         znam = 'e_i'//'_l'//zchar1
-         CALL iom_set_rstw_var_active(drst_wfields, znam )
-      END DO
+      CALL iom_set_rstw_var_active(drst_wfields, 'kt_ice'     )
+      CALL iom_set_rstw_var_active(drst_wfields, 'v_i'        )
+      CALL iom_set_rstw_var_active(drst_wfields, 'v_s'        )
+      CALL iom_set_rstw_var_active(drst_wfields, 'sv_i'       )
+      CALL iom_set_rstw_var_active(drst_wfields, 'a_i'        )
+      CALL iom_set_rstw_var_active(drst_wfields, 't_su'       )
+      CALL iom_set_rstw_var_active(drst_wfields, 'u_ice'      )
+      CALL iom_set_rstw_var_active(drst_wfields, 'v_ice'      )
+      CALL iom_set_rstw_var_active(drst_wfields, 'oa_i'       )
+      CALL iom_set_rstw_var_active(drst_wfields, 'a_ip'       )
+      CALL iom_set_rstw_var_active(drst_wfields, 'v_ip'       )
+      CALL iom_set_rstw_var_active(drst_wfields, 'e_s'        )
+      CALL iom_set_rstw_var_active(drst_wfields, 'e_i'        )
+#endif
    ENDIF
 #else
@@ -707,5 +702,5 @@
         i = iom_add(i); fields(i)%vname="syyage";         fields(i)%grid="grid_Ni_3D"
         i = iom_add(i); fields(i)%vname="sxyage";         fields(i)%grid="grid_Ni_3D"
-!this part is in addition to 4D grids, to handle old format of SI3 resart
+!this part is in addition to 4D grids, to handle old format for SI3 resart
 !NEMO format restart
         DO jk = 1, nlay_s
@@ -727,5 +722,5 @@
         i = iom_add(i); fields(i)%vname="sxxc0";          fields(i)%grid="grid_Ns_4D"
         i = iom_add(i); fields(i)%vname="syyc0";          fields(i)%grid="grid_Ns_4D"
-        i = iom_add(i); fields(i)%vname="sxxc0";          fields(i)%grid="grid_Ns_4D"
+        i = iom_add(i); fields(i)%vname="sxyc0";          fields(i)%grid="grid_Ns_4D"
         !
 !NEMO format restart
@@ -839,24 +834,27 @@
                 CALL xios_add_child(file_hdl, field_hdl, TRIM(drst_wfields(i)%vname)//"_"//TRIM(ADJUSTL(snr)))
                 SELECT CASE (TRIM(drst_wfields(i)%grid))
+#if defined key_si3
+                 CASE ("grid_Ni_4D")
+                    CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(drst_wfields(i)%vname), &
+                         grid_ref="grid_Ni_4D", prec = 8, operation = "instant")
+                 CASE ("grid_Ns_4D")
+                    CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(drst_wfields(i)%vname), &
+                         grid_ref="grid_Ns_4D", prec = 8, operation = "instant")
                  CASE ("grid_Ni_3D")
                     CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(drst_wfields(i)%vname), &
-                        domain_ref="grid_N", axis_ref="numcat", prec = 8, operation = "once",            &
-                        freq_offset=(kdstep -1) * xios_timestep)
+                         domain_ref="grid_N", axis_ref="numcat", prec = 8, operation = "instant")
+#endif
                  CASE ("grid_N_3D")
                     CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(drst_wfields(i)%vname), &
-                        domain_ref="grid_N", axis_ref="nav_lev", prec = 8, operation = "once",           &
-                        freq_offset=(kdstep -1) * xios_timestep)
+                         domain_ref="grid_N", axis_ref="nav_lev", prec = 8, operation = "instant")
                  CASE ("grid_N")
                     CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(drst_wfields(i)%vname), &
-                        domain_ref="grid_N", prec = 8, operation = "once",                               &
-                        freq_offset=(kdstep -1) * xios_timestep)
+                         domain_ref="grid_N", prec = 8, operation = "instant")
                  CASE ("grid_vector")
                     CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(drst_wfields(i)%vname), &
-                         axis_ref="nav_lev", prec = 8, operation = "once",                               &
-                        freq_offset=(kdstep -1) * xios_timestep)
+                         axis_ref="nav_lev", prec = 8, operation = "instant")
                  CASE ("grid_scalar")
                     CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(drst_wfields(i)%vname), &
-                        scalar_ref = "grid_scalar", prec = 8, operation = "once",                        &
-                        freq_offset=(kdstep -1) * xios_timestep)
+                         scalar_ref = "grid_scalar", prec = 8, operation = "instant")
                 END SELECT
          ENDIF
@@ -1953,6 +1951,32 @@
    END SUBROUTINE iom_rp3d
 
-
-  SUBROUTINE iom_delay_rst( cdaction, cdcpnt, kncid )
+   SUBROUTINE iom_rp4d( kt, kwrite, kiomid, cdvar, pvar, ktype, ldxios )
+      INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
+      INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
+      INTEGER         , INTENT(in)                         ::   kiomid   ! Identifier of the file 
+      CHARACTER(len=*), INTENT(in)                         ::   cdvar    ! time axis name
+      REAL(wp)        , INTENT(in),     DIMENSION(:,:,:,:) ::   pvar     ! written field
+      INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
+      LOGICAL, OPTIONAL :: ldxios   ! xios write flag
+      LOGICAL :: llx                 ! local xios write flag
+      INTEGER :: ivid   ! variable id
+
+      llx = .FALSE.
+      IF(PRESENT(ldxios)) llx = ldxios
+      IF( llx ) THEN
+#ifdef key_iomput
+      IF( kt == kwrite ) THEN
+         IF(lwp) write(numout,*) 'RESTART: write (XIOS 4D) ',trim(cdvar)
+         write(snr, *) nitrst
+         CALL xios_send_field(trim(cdvar)//"_"//TRIM(ADJUSTL(snr)), pvar)
+      ENDIF
+#endif
+      ELSE
+        CALL ctl_stop('Error in the name  iom_rp4d for variable '//TRIM(cdvar),   &
+           & 'Restart with iom_nf90_rstput can not handle 4D cases' )
+      ENDIF
+   END SUBROUTINE iom_rp4d
+
+   SUBROUTINE iom_delay_rst( cdaction, cdcpnt, kncid )
       !!---------------------------------------------------------------------
       !!   Routine iom_delay_rst: used read/write restart related to mpp_delay
@@ -1970,5 +1994,9 @@
       !
       !return for now. When XIOS is used to write restart it also should be used to write this attribute
-      IF(lwxios) return
+      IF(lwxios) THEN
+         CALL ctl_warn( 'From iom_delay_rst: ', 'Can not '//cdaction//' mpp_delay information with XIOS')
+         RETURN
+      ENDIF
+
       !                                      ===================================
       IF( TRIM(cdaction) == 'READ' ) THEN   ! read restart related to mpp_delay !
@@ -2740,5 +2768,5 @@
    IF( iom_add > max_rst_fields) THEN
      WRITE(ctmp1,*) 'E R R O R : iom_set_rst_vars SIZE of RST_FIELD array is too small'
-     CALL ctl_stop( 'iom_add:', ctmp1 )
+     CALL ctl_stop( 'iom_add:', ctmp1, 'Increase parameter max_rst_fields')
    ENDIF
 
Index: /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/OCE/IOM/iom_def.F90
===================================================================
--- /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/OCE/IOM/iom_def.F90	(revision 11892)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/OCE/IOM/iom_def.F90	(revision 11893)
@@ -67,5 +67,5 @@
    END TYPE file_descriptor
    TYPE(file_descriptor), DIMENSION(jpmax_files), PUBLIC ::   iom_file !: array containing the info for all opened files
-   INTEGER, PARAMETER, PUBLIC                   :: max_rst_fields = 190!: maximum number of restart variables defined in iom_set_rst_vars
+   INTEGER, PARAMETER, PUBLIC                   :: max_rst_fields = 250!: maximum number of restart variables defined in iom_set_rst_vars
    TYPE, PUBLIC :: RST_FIELD  
     CHARACTER(len=30) :: vname = "NO_NAME" ! names of variables in restart file
Index: /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/OCE/step.F90
===================================================================
--- /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/OCE/step.F90	(revision 11892)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/OCE/step.F90	(revision 11893)
@@ -311,12 +311,13 @@
 #if defined key_iomput
       IF( kstp == nitend .OR. indic < 0 ) THEN 
-                      CALL iom_context_finalize(      cxios_context          ) ! needed for XIOS+AGRIF
-                      IF(lrxios) THEN
-                         CALL iom_context_finalize(      crxios_context          )
+         IF(lrxios) THEN
+            CALL iom_context_finalize(      crxios_context          )
 #if defined key_si3
-                         CALL iom_context_finalize(      crixios_context          )
-#endif
-                      ENDIF
+            CALL iom_context_finalize(      crixios_context          )
+#endif
+         ENDIF
+         IF(lwxios) CALL iom_context_finalize(      cwxios_context          )
          IF( ln_crs ) CALL iom_context_finalize( trim(cxios_context)//"_crs" ) ! 
+         CALL iom_context_finalize(      cxios_context          ) ! needed for XIOS+AGRIF
       ENDIF
 #endif
