Index: /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/1_nemo_rstw.xml
===================================================================
--- /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/1_nemo_rstw.xml	(revision 11901)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/1_nemo_rstw.xml	(revision 11901)
@@ -0,0 +1,5 @@
+<context id="1_nemo_rstw">
+  
+    <grid_definition src="./grid_def_nemo.xml"/>
+    
+</context>
Index: /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/1_si3_rst.xml
===================================================================
--- /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/1_si3_rst.xml	(revision 11901)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/1_si3_rst.xml	(revision 11901)
@@ -0,0 +1,5 @@
+<context id="1_si3_rst">
+  
+    <grid_definition src="./grid_def_nemo.xml"/>
+    
+</context>
Index: /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/2_nemo_rstw.xml
===================================================================
--- /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/2_nemo_rstw.xml	(revision 11901)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/2_nemo_rstw.xml	(revision 11901)
@@ -0,0 +1,5 @@
+<context id="2_nemo_rstw">
+  
+    <grid_definition src="./grid_def_nemo.xml"/>
+    
+</context>
Index: /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/2_si3_rst.xml
===================================================================
--- /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/2_si3_rst.xml	(revision 11901)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/2_si3_rst.xml	(revision 11901)
@@ -0,0 +1,5 @@
+<context id="2_si3_rst">
+  
+    <grid_definition src="./grid_def_nemo.xml"/>
+    
+</context>
Index: /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/3_nemo_rstw.xml
===================================================================
--- /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/3_nemo_rstw.xml	(revision 11901)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/3_nemo_rstw.xml	(revision 11901)
@@ -0,0 +1,5 @@
+<context id="3_nemo_rstw">
+  
+    <grid_definition src="./grid_def_nemo.xml"/>
+    
+</context>
Index: /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/3_si3_rst.xml
===================================================================
--- /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/3_si3_rst.xml	(revision 11901)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/3_si3_rst.xml	(revision 11901)
@@ -0,0 +1,5 @@
+<context id="3_si3_rst">
+  
+    <grid_definition src="./grid_def_nemo.xml"/>
+    
+</context>
Index: /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/iodef.xml
===================================================================
--- /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/iodef.xml	(revision 11900)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/iodef.xml	(revision 11901)
@@ -26,3 +26,11 @@
   <context id="2_nemo" src="./2_context_nemo.xml"/>   <!--  NEMO       -->
   <context id="3_nemo" src="./3_context_nemo.xml"/>   <!--  NEMO       -->
+  <context id="nemo_rstw" src="./nemo_rstw.xml"/>       <!--  NEMO RESTART -->
+  <context id="1_nemo_rstw" src="./1_nemo_rstw.xml"/>   <!--  NEMO RESTART -->
+  <context id="2_nemo_rstw" src="./2_nemo_rstw.xml"/>   <!--  NEMO RESTART -->
+  <context id="3_nemo_rstw" src="./3_nemo_rstw.xml"/>   <!--  NEMO RESTART -->
+  <context id="si3_rst" src="./si3_rst.xml"/>       <!--  SI3 restart      -->
+  <context id="1_si3_rst" src="./1_si3_rst.xml"/>   <!--  SI3 restart      -->
+  <context id="2_si3_rst" src="./2_si3_rst.xml"/>   <!--  SI3 restart      -->
+  <context id="3_si3_rst" src="./3_si3_rst.xml"/>   <!--  SI3 restart      -->
 </simulation>
Index: /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/nemo_rstw.xml
===================================================================
--- /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/nemo_rstw.xml	(revision 11901)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/nemo_rstw.xml	(revision 11901)
@@ -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/AGRIF_DEMO/EXPREF/si3_rst.xml
===================================================================
--- /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/si3_rst.xml	(revision 11901)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/cfgs/AGRIF_DEMO/EXPREF/si3_rst.xml	(revision 11901)
@@ -0,0 +1,5 @@
+<context id="si3_rst">
+  
+    <grid_definition src="./grid_def_nemo.xml"/>
+    
+</context>
Index: /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/ICE/icerst.F90
===================================================================
--- /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/ICE/icerst.F90	(revision 11900)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/ICE/icerst.F90	(revision 11901)
@@ -220,6 +220,13 @@
          IF(lrxios) THEN
            crixios_context = 'si3_rst'
-           CALL iom_init( crixios_context, TRIM(cn_icerst_indir)//'/'//cn_icerst_in, ld_tmppatch = .false. )
            lxios_set = .TRUE.
+           IF( TRIM(Agrif_CFixed()) /= '0') THEN
+              IF(lwp) WRITE(numout,*) 'Enable SI3 restart reading by XIOS for AGRIF'
+              CALL iom_init( crixios_context, &
+                   TRIM(cn_icerst_indir)//'/'//TRIM(Agrif_CFixed())//"_"//cn_icerst_in, ld_tmppatch = .false. )
+           ELSE
+              IF(lwp) WRITE(numout,*) 'Enable SI3 restart reading by XIOS for AGRIF'
+              CALL iom_init( crixios_context, TRIM(cn_icerst_indir)//'/'//cn_icerst_in, ld_tmppatch = .false. )
+           ENDIF
          ENDIF
 
Index: /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/OCE/DOM/domain.F90
===================================================================
--- /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/OCE/DOM/domain.F90	(revision 11900)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/OCE/DOM/domain.F90	(revision 11901)
@@ -344,11 +344,6 @@
          WRITE(numout,*) '      NetCDF chunksize (bytes)        nn_chunksz      = ', nn_chunksz
          WRITE(numout,*) '      IS coupling at the restart step ln_iscpl        = ', ln_iscpl
-         IF( TRIM(Agrif_CFixed()) == '0' ) THEN
-            WRITE(numout,*) '      READ restart for a single file using XIOS ln_xios_read =', ln_xios_read
-            WRITE(numout,*) '      Write restart using XIOS        nn_wxios   = ', nn_wxios
-         ELSE
-            WRITE(numout,*) "      AGRIF: nn_wxios will be ingored. See setting for parent"
-            WRITE(numout,*) "      AGRIF: ln_xios_read will be ingored. See setting for parent"
-         ENDIF
+         WRITE(numout,*) '      READ restart for a single file using XIOS ln_xios_read =', ln_xios_read
+         WRITE(numout,*) '      Write restart using XIOS        nn_wxios   = ', nn_wxios
       ENDIF
 
@@ -427,10 +422,8 @@
       rdt  = rn_rdt
 
-      IF( TRIM(Agrif_CFixed()) == '0' ) THEN
-         lrxios = ln_xios_read.AND.ln_rstart
+      lrxios = ln_xios_read.AND.ln_rstart
 !set output file type for XIOS based on NEMO namelist 
-         IF (nn_wxios > 0) lwxios = .TRUE. 
-         nxioso = nn_wxios
-      ENDIF
+      IF (nn_wxios > 0) lwxios = .TRUE. 
+      nxioso = nn_wxios
 
 #if defined key_netcdf4
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 11900)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/OCE/IOM/iom.F90	(revision 11901)
@@ -309,8 +309,11 @@
                ! create the file
                clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_ocerst_out)
+!handle AGRIF
+               IF ( .NOT. Agrif_Root() ) clname=TRIM(Agrif_CFixed())//'_'//TRIM(clname)
+
                clpath = TRIM(cn_ocerst_outdir)
                IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
                IF(lwp) THEN
-                  write(numout, *) 'Create restart file at the step: ', kt
+                  write(numout, *) 'Create restart file for the step: ', kt
                ENDIF
                CALL iom_set_rstw_active(rst_wfields, TRIM(clpath)//TRIM(clname), nitrstx)
@@ -327,4 +330,7 @@
                ! create the file
                clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_icerst_out)
+!handle AGRIF
+               IF ( .NOT. Agrif_Root() ) clname=TRIM(Agrif_CFixed())//'_'//TRIM(clname)
+
                clpath = TRIM(cn_icerst_outdir) 
                IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath)//'/'
@@ -438,5 +444,5 @@
 
 !set name of the restart file and enable available fields
-        if(lwp) WRITE(numout,*) 'Setting restart filename (for XIOS) to: ',rst_file
+        if(lwp) WRITE(numout,*) 'Setting restart filename (for XIOS) to: ', TRIM(rst_file)
         CALL xios_get_handle("file_definition", filegroup_hdl )
         CALL xios_add_child(filegroup_hdl, file_hdl, 'rrestart')
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 11900)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/OCE/IOM/iom_def.F90	(revision 11901)
@@ -35,7 +35,4 @@
    INTEGER, PARAMETER, PUBLIC ::   jpmax_digits =  5   !: maximum number of digits for the cpu number in the file name
 
-
-!$AGRIF_DO_NOT_TREAT
-   INTEGER, PUBLIC            ::   iom_open_init = 0   !: used to initialize iom_file(:)%nfid to 0
 !XIOS write restart   
    LOGICAL, PUBLIC            ::   lwxios          !: write single file restart using XIOS
@@ -44,7 +41,8 @@
    LOGICAL, PUBLIC            ::   lrxios          !: read single file restart using XIOS
    LOGICAL, PUBLIC            ::   lxios_sini = .FALSE. ! is restart in a single file
-   LOGICAL, PUBLIC            ::   lxios_set  = .FALSE. 
+   LOGICAL, PUBLIC            ::   lxios_set  = .FALSE.
 
-
+!$AGRIF_DO_NOT_TREAT
+   INTEGER, PUBLIC            ::   iom_open_init = 0   !: used to initialize iom_file(:)%nfid to 0
 
    TYPE, PUBLIC ::   file_descriptor
Index: /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/OCE/IOM/restart.F90
===================================================================
--- /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/OCE/IOM/restart.F90	(revision 11900)
+++ /NEMO/branches/2019/dev_r11756_SI3restart_XIOS/src/OCE/IOM/restart.F90	(revision 11901)
@@ -131,4 +131,5 @@
       INTEGER, INTENT(in) ::   kt   ! ocean time-step
       !!----------------------------------------------------------------------
+
                      IF(lwxios) CALL iom_swap(      cwxios_context          )
                      CALL iom_rstput( kt, nitrst, numrow, 'rdt'    , rdt       , ldxios = lwxios)   ! dynamics time step
@@ -207,16 +208,14 @@
 ! restart)
          IF(.NOT.lxios_set) lrxios = lrxios.AND.lxios_sini
-         IF( lrxios) THEN
+         IF( lrxios .AND. (.NOT. lxios_set)) THEN
              crxios_context = 'nemo_rst'
-             IF( .NOT. lxios_set ) THEN
-                 IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS'
-                 CALL iom_init( crxios_context, TRIM(clpath)//cn_ocerst_in, ld_tmppatch = .false. )
-                 lxios_set = .TRUE.
+             lxios_set = .TRUE.
+             IF( TRIM(Agrif_CFixed()) /= '0') THEN
+                IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS for AGRIF'
+                CALL iom_init( crxios_context, TRIM(clpath)//TRIM(Agrif_CFixed())//"_"//cn_ocerst_in, ld_tmppatch = .false. )
+             ELSE
+                IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS'
+                CALL iom_init( crxios_context, TRIM(clpath)//cn_ocerst_in, ld_tmppatch = .false. )
              ENDIF
-         ENDIF
-         IF( TRIM(Agrif_CFixed()) /= '0' .AND. lrxios) THEN
-             CALL iom_init( crxios_context, TRIM(clpath)//cn_ocerst_in, ld_tmppatch = .false. )
-             IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS for AGRIF'
-             lxios_set = .TRUE.
          ENDIF 
       ENDIF
