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 11837)
+++ NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/OCE/IOM/iom.F90	(revision 11840)
@@ -244,7 +244,11 @@
 !set names of the fields in restart file IF using XIOS to write data
           CALL iom_set_rst_context(.FALSE.)
-          CALL iom_set_rst_vars(rst_wfields)
 !set which fields are to be written to a restart file
           CALL iom_set_rstw_active(rst_wfields, fname)
+      ELSE IF( TRIM(cdname) == TRIM(cwixios_context) ) THEN
+!set names of the fields in restart file IF using XIOS to write data
+          CALL iom_set_rst_context(.FALSE.)
+!set which fields are to be written to a restart file
+          CALL iom_set_rstw_active(rsti_wfields, fname)
       ELSE
           CALL set_xmlatt
@@ -361,5 +365,5 @@
    END SUBROUTINE iom_set_rstr_active
 
-   SUBROUTINE iom_set_rstw_core(cdmdl)
+   SUBROUTINE iom_set_rstw_core(drst_wfields, cdmdl)
       !!---------------------------------------------------------------------
       !!                   ***  SUBROUTINE  iom_set_rstw_core  ***
@@ -367,39 +371,67 @@
       !! ** Purpose :  set variables which are always in restart file 
       !!---------------------------------------------------------------------
-   CHARACTER (len=*), INTENT (IN) :: cdmdl ! model OPA or SAS
-   CHARACTER(LEN=256)             :: clinfo    ! info character
+   CHARACTER (len=*), INTENT (IN)   :: cdmdl ! model OPA, SAS or SI3
+   TYPE(RST_FIELD),   INTENT(INOUT) :: drst_wfields(max_rst_fields)
+   CHARACTER(LEN=256)               :: clinfo    ! info character
+   CHARACTER(len=25) ::   znam
+   CHARACTER(len=2)  ::   zchar1
+   INTEGER           ::   jk
 #if defined key_iomput
    IF(cdmdl == "OPA") THEN
 !from restart.F90
-   CALL iom_set_rstw_var_active(rst_wfields, "rdt")
+   CALL iom_set_rstw_var_active(drst_wfields, "rdt")
    IF ( .NOT. ln_diurnal_only ) THEN
-        CALL iom_set_rstw_var_active(rst_wfields, 'ub'  )
-        CALL iom_set_rstw_var_active(rst_wfields, 'vb'  )
-        CALL iom_set_rstw_var_active(rst_wfields, 'tb'  )
-        CALL iom_set_rstw_var_active(rst_wfields, 'sb'  )
-        CALL iom_set_rstw_var_active(rst_wfields, 'sshb')
+        CALL iom_set_rstw_var_active(drst_wfields, 'ub'  )
+        CALL iom_set_rstw_var_active(drst_wfields, 'vb'  )
+        CALL iom_set_rstw_var_active(drst_wfields, 'tb'  )
+        CALL iom_set_rstw_var_active(drst_wfields, 'sb'  )
+        CALL iom_set_rstw_var_active(drst_wfields, 'sshb')
         !
-        CALL iom_set_rstw_var_active(rst_wfields, 'un'  )
-        CALL iom_set_rstw_var_active(rst_wfields, 'vn'  )
-        CALL iom_set_rstw_var_active(rst_wfields, 'tn'  )
-        CALL iom_set_rstw_var_active(rst_wfields, 'sn'  )
-        CALL iom_set_rstw_var_active(rst_wfields, 'sshn')
-        CALL iom_set_rstw_var_active(rst_wfields, 'rhop')
+        CALL iom_set_rstw_var_active(drst_wfields, 'un'  )
+        CALL iom_set_rstw_var_active(drst_wfields, 'vn'  )
+        CALL iom_set_rstw_var_active(drst_wfields, 'tn'  )
+        CALL iom_set_rstw_var_active(drst_wfields, 'sn'  )
+        CALL iom_set_rstw_var_active(drst_wfields, 'sshn')
+        CALL iom_set_rstw_var_active(drst_wfields, 'rhop')
      ! extra variable needed for the ice sheet coupling
         IF ( ln_iscpl ) THEN
-             CALL iom_set_rstw_var_active(rst_wfields, 'tmask')
-             CALL iom_set_rstw_var_active(rst_wfields, 'umask')
-             CALL iom_set_rstw_var_active(rst_wfields, 'vmask')
-             CALL iom_set_rstw_var_active(rst_wfields, 'smask')
-             CALL iom_set_rstw_var_active(rst_wfields, 'e3t_n')
-             CALL iom_set_rstw_var_active(rst_wfields, 'e3u_n')
-             CALL iom_set_rstw_var_active(rst_wfields, 'e3v_n')
-             CALL iom_set_rstw_var_active(rst_wfields, 'gdepw_n')
+             CALL iom_set_rstw_var_active(drst_wfields, 'tmask')
+             CALL iom_set_rstw_var_active(drst_wfields, 'umask')
+             CALL iom_set_rstw_var_active(drst_wfields, 'vmask')
+             CALL iom_set_rstw_var_active(drst_wfields, 'smask')
+             CALL iom_set_rstw_var_active(drst_wfields, 'e3t_n')
+             CALL iom_set_rstw_var_active(drst_wfields, 'e3u_n')
+             CALL iom_set_rstw_var_active(drst_wfields, 'e3v_n')
+             CALL iom_set_rstw_var_active(drst_wfields, 'gdepw_n')
         END IF
       ENDIF
-      IF(ln_diurnal) CALL iom_set_rstw_var_active(rst_wfields, 'Dsst')
+      IF(ln_diurnal) CALL iom_set_rstw_var_active(drst_wfields, 'Dsst')
 !from trasbc.F90
-         CALL iom_set_rstw_var_active(rst_wfields, 'sbc_hc_b')
-         CALL iom_set_rstw_var_active(rst_wfields, 'sbc_sc_b')
+         CALL iom_set_rstw_var_active(drst_wfields, 'sbc_hc_b')
+         CALL iom_set_rstw_var_active(drst_wfields, 'sbc_sc_b')
+   ELSE IF(cdmdl == "SI3") THEN
+      CALL iom_set_rstw_var_active(drst_wfields, 'nn_fsbc')
+      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
    ENDIF
 #else
@@ -689,4 +721,7 @@
                 CALL xios_add_child(file_hdl, field_hdl, TRIM(drst_wfields(i)%vname))
                 SELECT CASE (TRIM(drst_wfields(i)%grid))
+                 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 = "instant")
                  CASE ("grid_N_3D")
                     CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(drst_wfields(i)%vname), &
