Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/CONFIG/GYRE_XIOS/EXP00/domain_def.xml
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/CONFIG/GYRE_XIOS/EXP00/domain_def.xml	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/CONFIG/GYRE_XIOS/EXP00/domain_def.xml	(revision 8195)
@@ -191,4 +191,7 @@
 	</domain>  
 
+     <domain_group id="grid_N">
+      <domain id="grid_N" long_name="grid nomask"/>
+     </domain_group>
 
    </domain_definition>    
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/CONFIG/GYRE_XIOS/EXP00/iodef.xml
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/CONFIG/GYRE_XIOS/EXP00/iodef.xml	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/CONFIG/GYRE_XIOS/EXP00/iodef.xml	(revision 8195)
@@ -79,4 +79,55 @@
   </context>
   
+  <context id="nemo_rst" >
+
+   <domain_definition src="./domain_def.xml"/>
+
+   <grid_definition>
+     <grid id="grid_T_2D" >
+       <domain id="grid_T" />
+     </grid>
+     <grid id="grid_T_3D" >
+       <domain id="grid_T" />
+       <axis id="deptht" />
+     </grid>
+     <grid id="grid_U_2D" >
+       <domain id="grid_U" />
+     </grid>
+     <grid id="grid_U_3D" >
+       <domain id="grid_U" />
+       <axis id="depthu" />
+     </grid>
+     <grid id="grid_V_2D" >
+       <domain id="grid_V" />
+     </grid>
+     <grid id="grid_V_3D" >
+       <domain id="grid_V" />
+       <axis id="depthv" />
+     </grid>
+     <grid id="grid_W_2D" >
+       <domain id="grid_W" />
+     </grid>
+     <grid id="grid_W_3D" >
+       <domain id="grid_W" />
+       <axis id="depthw" />
+     </grid>
+     <grid id="scalarpoint" />
+
+     <grid id="Vgrid">
+       <domain domain_ref="ptr" />
+       <axis axis_ref="deptht" />
+     </grid>
+
+     <grid id="grid_N" >
+       <domain domain_ref="grid_N" />
+     </grid>
+     <grid id="grid_N_3D" >
+       <domain domain_ref="grid_N" />
+       <axis axis_ref="deptht" />
+     </grid>
+
+    </grid_definition>
+
+  </context>
 
   <context id="xios">
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/CONFIG/SHARED/namelist_ref
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/CONFIG/SHARED/namelist_ref	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/CONFIG/SHARED/namelist_ref	(revision 8195)
@@ -50,4 +50,5 @@
    ln_clobber  = .false.   !  clobber (overwrite) an existing file
    nn_chunksz  =       0   !  chunksize (bytes) for NetCDF file (works only with iom_nf90 routines)
+   ln_xios_read = .FALSE.  !  use XIOS to read restart file (only for a single file restart)
 /
 !
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/DIA/diahsb.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/DIA/diahsb.F90	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/DIA/diahsb.F90	(revision 8195)
@@ -32,4 +32,5 @@
    USE timing          ! preformance summary
    USE wrk_nemo        ! work arrays
+   USE iom_def, ONLY : lxios_read
 
    IMPLICIT NONE
@@ -254,18 +255,18 @@
            IF(lwp) WRITE(numout,*) ' dia_hsb_rst at it= ', kt,' date= ', ndastp
            IF(lwp) WRITE(numout,*) '~~~~~~~'
-           CALL iom_get( numror, 'frc_v', frc_v )
-           CALL iom_get( numror, 'frc_t', frc_t )
-           CALL iom_get( numror, 'frc_s', frc_s )
+           CALL iom_get( numror, 'frc_v', frc_v, lrxios = lxios_read  )
+           CALL iom_get( numror, 'frc_t', frc_t, lrxios = lxios_read )
+           CALL iom_get( numror, 'frc_s', frc_s, lrxios = lxios_read )
            IF( .NOT. lk_vvl ) THEN
-              CALL iom_get( numror, 'frc_wn_t', frc_wn_t )
-              CALL iom_get( numror, 'frc_wn_s', frc_wn_s )
+              CALL iom_get( numror, 'frc_wn_t', frc_wn_t, lrxios = lxios_read )
+              CALL iom_get( numror, 'frc_wn_s', frc_wn_s, lrxios = lxios_read )
            ENDIF
-           CALL iom_get( numror, jpdom_autoglo, 'ssh_ini', ssh_ini )
-           CALL iom_get( numror, jpdom_autoglo, 'e3t_ini', e3t_ini )
-           CALL iom_get( numror, jpdom_autoglo, 'hc_loc_ini', hc_loc_ini )
-           CALL iom_get( numror, jpdom_autoglo, 'sc_loc_ini', sc_loc_ini )
+           CALL iom_get( numror, jpdom_autoglo, 'ssh_ini', ssh_ini, lrxios = lxios_read )
+           CALL iom_get( numror, jpdom_autoglo, 'e3t_ini', e3t_ini, lrxios = lxios_read )
+           CALL iom_get( numror, jpdom_autoglo, 'hc_loc_ini', hc_loc_ini, lrxios = lxios_read )
+           CALL iom_get( numror, jpdom_autoglo, 'sc_loc_ini', sc_loc_ini, lrxios = lxios_read )
            IF( .NOT. lk_vvl ) THEN
-              CALL iom_get( numror, jpdom_autoglo, 'ssh_hc_loc_ini', ssh_hc_loc_ini )
-              CALL iom_get( numror, jpdom_autoglo, 'ssh_sc_loc_ini', ssh_sc_loc_ini )
+              CALL iom_get( numror, jpdom_autoglo, 'ssh_hc_loc_ini', ssh_hc_loc_ini, lrxios = lxios_read )
+              CALL iom_get( numror, jpdom_autoglo, 'ssh_sc_loc_ini', ssh_sc_loc_ini, lrxios = lxios_read )
            ENDIF
        ELSE
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90	(revision 8195)
@@ -250,8 +250,10 @@
       CALL iom_put( "avt" , avt                        )    ! T vert. eddy diff. coef.
       CALL iom_put( "avm" , avmu                       )    ! T vert. eddy visc. coef.
+#if defined key_zdftke   ||   defined key_esopa
       IF( lk_zdftke ) THEN   
          CALL iom_put( "tke"      , en                               )    ! TKE budget: Turbulent Kinetic Energy   
          CALL iom_put( "tke_niw"  , e_niw                            )    ! TKE budget: Near-inertial waves   
       ENDIF 
+#endif
       CALL iom_put( "avs" , fsavs(:,:,:)               )    ! S vert. eddy diff. coef. (useful only with key_zdfddm)
                                                             ! Log of eddy diff coef
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/DOM/daymod.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/DOM/daymod.F90	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/DOM/daymod.F90	(revision 8195)
@@ -35,4 +35,5 @@
    USE timing          ! Timing
    USE restart         ! restart
+   USE iom_def, ONLY : lxios_read
 
    IMPLICIT NONE
@@ -309,5 +310,5 @@
          IF( iom_varid( numror, 'kt', ldstop = .FALSE. ) > 0 ) THEN
             ! Get Calendar informations
-            CALL iom_get( numror, 'kt', zkt )   ! last time-step of previous run
+            CALL iom_get( numror, 'kt', zkt, lrxios = lxios_read )   ! last time-step of previous run
             IF(lwp) THEN
                WRITE(numout,*) ' *** Info read in restart : '
@@ -328,7 +329,7 @@
             IF ( nrstdt == 2 ) THEN
                ! read the parameters correspondting to nit000 - 1 (last time step of previous run)
-               CALL iom_get( numror, 'ndastp', zndastp )
+               CALL iom_get( numror, 'ndastp', zndastp, lrxios = lxios_read )
                ndastp = NINT( zndastp )
-               CALL iom_get( numror, 'adatrj', adatrj  )
+               CALL iom_get( numror, 'adatrj', adatrj, lrxios = lxios_read )
             ELSE
                ! parameters correspondting to nit000 - 1 (as we start the step loop with a call to day)
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90	(revision 8195)
@@ -38,4 +38,5 @@
    USE timing          ! Timing
    USE lbclnk          ! ocean lateral boundary condition (or mpp link)
+   USE iom_def, ONLY:lxios_read
 
    IMPLICIT NONE
@@ -138,5 +139,6 @@
          &             nn_no   , cn_exp    , cn_ocerst_in, cn_ocerst_out, ln_rstart , ln_rstdate, nn_rstctl,   &
          &             nn_it000, nn_itend  , nn_date0    , nn_leapy     , nn_istate , nn_stock ,   &
-         &             nn_write, ln_dimgnnn, ln_mskland  , ln_cfmeta    , ln_clobber, nn_chunksz, nn_euler
+         &             nn_write, ln_dimgnnn, ln_mskland  , ln_cfmeta    , ln_clobber, nn_chunksz, nn_euler, &
+         &             ln_xios_read
       NAMELIST/namdom/ nn_bathy, rn_bathy , rn_e3zps_min, rn_e3zps_rat, nn_msh, rn_hmin,   &
          &             nn_acc   , rn_atfp     , rn_rdt      , rn_rdtmin ,                  &
@@ -152,5 +154,5 @@
       INTEGER  ::   ios                 ! Local integer output status for namelist read
       !!----------------------------------------------------------------------
-
+      ln_xios_read = .false.            ! set in case ln_xios_read is not in namelist
       REWIND( numnam_ref )              ! Namelist namrun in reference namelist : Parameters of the run
       READ  ( numnam_ref, namrun, IOSTAT = ios, ERR = 901)
@@ -193,4 +195,5 @@
          WRITE(numout,*) '      overwrite an existing file      ln_clobber = ', ln_clobber
          WRITE(numout,*) '      NetCDF chunksize (bytes)        nn_chunksz = ', nn_chunksz
+         WRITE(numout,*) '      READ restart for a single file using XIOS ln_xios_read =', ln_xios_read
       ENDIF
 
@@ -207,4 +210,5 @@
       nwrite = nn_write
       neuler = nn_euler
+      lxios_read = ln_xios_read
       IF ( neuler == 1 .AND. .NOT. ln_rstart ) THEN
          WRITE(ctmp1,*) 'ln_rstart =.FALSE., nn_euler is forced to 0 '
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90	(revision 8195)
@@ -33,4 +33,5 @@
    USE wrk_nemo        ! Memory allocation
    USE timing          ! Timing
+   USE iom_def, ONLY : lxios_read
 
    IMPLICIT NONE
@@ -817,5 +818,5 @@
          IF( ln_rstart ) THEN                   !* Read the restart file
             CALL rst_read_open                  !  open the restart file if necessary
-            CALL iom_get( numror, jpdom_autoglo, 'sshn'   , sshn    )
+            CALL iom_get( numror, jpdom_autoglo, 'sshn'   , sshn, lrxios = lxios_read    )
             !
             id1 = iom_varid( numror, 'fse3t_b', ldstop = .FALSE. )
@@ -828,6 +829,6 @@
             !                             ! --------- !
             IF( MIN( id1, id2 ) > 0 ) THEN       ! all required arrays exist
-               CALL iom_get( numror, jpdom_autoglo, 'fse3t_b', fse3t_b(:,:,:) )
-               CALL iom_get( numror, jpdom_autoglo, 'fse3t_n', fse3t_n(:,:,:) )
+               CALL iom_get( numror, jpdom_autoglo, 'fse3t_b', fse3t_b(:,:,:), lrxios = lxios_read )
+               CALL iom_get( numror, jpdom_autoglo, 'fse3t_n', fse3t_n(:,:,:), lrxios = lxios_read )
                ! needed to restart if land processor not computed 
                IF(lwp) write(numout,*) 'dom_vvl_rst : fse3t_b and fse3t_n found in restart files'
@@ -843,5 +844,5 @@
                IF(lwp) write(numout,*) 'fse3t_n set equal to fse3t_b.'
                IF(lwp) write(numout,*) 'neuler is forced to 0'
-               CALL iom_get( numror, jpdom_autoglo, 'fse3t_b', fse3t_b(:,:,:) )
+               CALL iom_get( numror, jpdom_autoglo, 'fse3t_b', fse3t_b(:,:,:), lrxios = lxios_read )
                fse3t_n(:,:,:) = fse3t_b(:,:,:)
                neuler = 0
@@ -850,5 +851,5 @@
                IF(lwp) write(numout,*) 'fse3t_b set equal to fse3t_n.'
                IF(lwp) write(numout,*) 'neuler is forced to 0'
-               CALL iom_get( numror, jpdom_autoglo, 'fse3t_n', fse3t_n(:,:,:) )
+               CALL iom_get( numror, jpdom_autoglo, 'fse3t_n', fse3t_n(:,:,:), lrxios = lxios_read )
                fse3t_b(:,:,:) = fse3t_n(:,:,:)
                neuler = 0
@@ -875,6 +876,6 @@
                !                          ! ----------------------- !
                IF( MIN( id3, id4 ) > 0 ) THEN  ! all required arrays exist
-                  CALL iom_get( numror, jpdom_autoglo, 'tilde_e3t_b', tilde_e3t_b(:,:,:) )
-                  CALL iom_get( numror, jpdom_autoglo, 'tilde_e3t_n', tilde_e3t_n(:,:,:) )
+                  CALL iom_get( numror, jpdom_autoglo, 'tilde_e3t_b', tilde_e3t_b(:,:,:), lrxios = lxios_read )
+                  CALL iom_get( numror, jpdom_autoglo, 'tilde_e3t_n', tilde_e3t_n(:,:,:), lrxios = lxios_read )
                ELSE                            ! one at least array is missing
                   tilde_e3t_b(:,:,:) = 0.0_wp
@@ -885,5 +886,5 @@
                   !                       ! ------------ !
                   IF( id5 > 0 ) THEN  ! required array exists
-                     CALL iom_get( numror, jpdom_autoglo, 'hdiv_lf', hdiv_lf(:,:,:) )
+                     CALL iom_get( numror, jpdom_autoglo, 'hdiv_lf', hdiv_lf(:,:,:), lrxios = lxios_read )
                   ELSE                ! array is missing
                      hdiv_lf(:,:,:) = 0.0_wp
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_flt.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_flt.F90	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_flt.F90	(revision 8195)
@@ -51,4 +51,5 @@
    USE agrif_opa_interp
 #endif
+   USE iom_def, ONLY : lxios_read
 
    IMPLICIT NONE
@@ -395,6 +396,6 @@
 ! Caution : extra-hallow
 ! gcx and gcxb are defined as: DIMENSION(1-jpr2di:jpi+jpr2di,1-jpr2dj:jpj+jpr2dj)
-            CALL iom_get( numror, jpdom_autoglo, 'gcx' , gcx (1:jpi,1:jpj) )
-            CALL iom_get( numror, jpdom_autoglo, 'gcxb', gcxb(1:jpi,1:jpj) )
+            CALL iom_get( numror, jpdom_autoglo, 'gcx' , gcx (1:jpi,1:jpj), lrxios = lxios_read ) ! make sure domain is fine!!!!
+            CALL iom_get( numror, jpdom_autoglo, 'gcxb', gcxb(1:jpi,1:jpj), lrxios = lxios_read ) ! make sure domain is fine!!!!
             IF( neuler == 0 )   gcxb(:,:) = gcx (:,:)
          ELSE
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_ts.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_ts.F90	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_ts.F90	(revision 8195)
@@ -48,4 +48,5 @@
    USE asminc          ! Assimilation increment
 #endif
+   USE iom_def, ONLY : lxios_read
 
    IMPLICIT NONE
@@ -1019,13 +1020,13 @@
       !
       IF( TRIM(cdrw) == 'READ' ) THEN
-         CALL iom_get( numror, jpdom_autoglo, 'ub2_b'  , ub2_b  (:,:) )   
-         CALL iom_get( numror, jpdom_autoglo, 'vb2_b'  , vb2_b  (:,:) ) 
+         CALL iom_get( numror, jpdom_autoglo, 'ub2_b'  , ub2_b  (:,:), lrxios = lxios_read )   
+         CALL iom_get( numror, jpdom_autoglo, 'vb2_b'  , vb2_b  (:,:), lrxios = lxios_read ) 
          IF( .NOT.ln_bt_av ) THEN
-            CALL iom_get( numror, jpdom_autoglo, 'sshbb_e'  , sshbb_e(:,:) )   
-            CALL iom_get( numror, jpdom_autoglo, 'ubb_e'    ,   ubb_e(:,:) )   
-            CALL iom_get( numror, jpdom_autoglo, 'vbb_e'    ,   vbb_e(:,:) )
-            CALL iom_get( numror, jpdom_autoglo, 'sshb_e'   ,  sshb_e(:,:) ) 
-            CALL iom_get( numror, jpdom_autoglo, 'ub_e'     ,    ub_e(:,:) )   
-            CALL iom_get( numror, jpdom_autoglo, 'vb_e'     ,    vb_e(:,:) )
+            CALL iom_get( numror, jpdom_autoglo, 'sshbb_e'  , sshbb_e(:,:), lrxios = lxios_read )   
+            CALL iom_get( numror, jpdom_autoglo, 'ubb_e'    ,   ubb_e(:,:), lrxios = lxios_read )   
+            CALL iom_get( numror, jpdom_autoglo, 'vbb_e'    ,   vbb_e(:,:), lrxios = lxios_read )
+            CALL iom_get( numror, jpdom_autoglo, 'sshb_e'   ,  sshb_e(:,:), lrxios = lxios_read ) 
+            CALL iom_get( numror, jpdom_autoglo, 'ub_e'     ,    ub_e(:,:), lrxios = lxios_read )   
+            CALL iom_get( numror, jpdom_autoglo, 'vb_e'     ,    vb_e(:,:), lrxios = lxios_read )
          ENDIF
 #if defined key_agrif
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/IOM/in_out_manager.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/IOM/in_out_manager.F90	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/IOM/in_out_manager.F90	(revision 8195)
@@ -49,4 +49,5 @@
    LOGICAL       ::   ln_clobber       !: clobber (overwrite) an existing file
    INTEGER       ::   nn_chunksz       !: chunksize (bytes) for NetCDF file (works only with iom_nf90 routines)
+   LOGICAL       ::   ln_xios_read     !: use xios to read single file restart
 #if defined key_netcdf4
    !!----------------------------------------------------------------------
@@ -152,4 +153,5 @@
    LOGICAL       ::   lsp_area = .TRUE.     !: to make a control print over a specific area
    CHARACTER(lc) ::   cxios_context         !: context name used in xios
+   CHARACTER(lc) ::   rxios_context         !: context name used in xios to read restart
 
    !!----------------------------------------------------------------------
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 8195)
@@ -41,7 +41,9 @@
    USE dianam          ! build name of file
    USE xios
+   USE iom_def, ONLY : max_rst_fields, rst_fields
 # endif
    USE ioipsl, ONLY :  ju2ymds    ! for calendar
    USE crs             ! Grid coarsening
+   USE lib_fortran 
 
    IMPLICIT NONE
@@ -62,4 +64,5 @@
    PRIVATE iom_set_domain_attr, iom_set_axis_attr, iom_set_field_attr, iom_set_file_attr, iom_get_file_attr, iom_set_grid_attr
    PRIVATE set_grid, set_grid_bounds, set_scalar, set_xmlatt, set_mooring, iom_update_file_name, iom_sdate
+   PRIVATE set_rst_vars, set_rstr_active
 # endif
 
@@ -136,4 +139,5 @@
           &                                    start_date = xios_date(nyear,nmonth,nday,0,0,0) )
       END SELECT
+
 #endif
       ! horizontal grid definition
@@ -141,12 +145,13 @@
       CALL set_scalar
 
-      IF( TRIM(cdname) == TRIM(cxios_context) ) THEN  
-         CALL set_grid( "T", glamt, gphit ) 
-         CALL set_grid( "U", glamu, gphiu )
-         CALL set_grid( "V", glamv, gphiv )
-         CALL set_grid( "W", glamt, gphit )
+      IF( TRIM(cdname) == TRIM(cxios_context) .OR. TRIM(cdname) == TRIM(rxios_context)) THEN  
+         CALL set_grid( "T", glamt, gphit, ln_mskland ) 
+         CALL set_grid( "U", glamu, gphiu, ln_mskland )
+         CALL set_grid( "V", glamv, gphiv, ln_mskland )
+         CALL set_grid( "W", glamt, gphit, ln_mskland )
          CALL set_grid_znl( gphit )
+         CALL set_grid("N",glamt, gphit, .FALSE.)        ! not masked values
          !
-         IF( ln_cfmeta ) THEN   ! Add additional grid metadata
+         IF( ln_cfmeta .AND. TRIM(cdname) .NE. TRIM(rxios_context)) THEN   ! Add additional grid metadata
             CALL iom_set_domain_attr("grid_T", area = e12t(nldi:nlei, nldj:nlej))
             CALL iom_set_domain_attr("grid_U", area = e12u(nldi:nlei, nldj:nlej))
@@ -163,13 +168,13 @@
          CALL dom_grid_crs   ! Save the parent grid information  & Switch to coarse grid domain
          !
-         CALL set_grid( "T", glamt_crs, gphit_crs ) 
-         CALL set_grid( "U", glamu_crs, gphiu_crs ) 
-         CALL set_grid( "V", glamv_crs, gphiv_crs ) 
-         CALL set_grid( "W", glamt_crs, gphit_crs ) 
+         CALL set_grid( "T", glamt_crs, gphit_crs, ln_mskland ) 
+         CALL set_grid( "U", glamu_crs, gphiu_crs, ln_mskland ) 
+         CALL set_grid( "V", glamv_crs, gphiv_crs, ln_mskland ) 
+         CALL set_grid( "W", glamt_crs, gphit_crs, ln_mskland ) 
          CALL set_grid_znl( gphit_crs )
           !
          CALL dom_grid_glo   ! Return to parent grid domain
          !
-         IF( ln_cfmeta ) THEN   ! Add additional grid metadata
+         IF( ln_cfmeta .AND. TRIM(cdname) .NE. TRIM(rxios_context)) THEN   ! Add additional grid metadata
             CALL iom_set_domain_attr("grid_T", area = e1e2t_crs(nldi:nlei, nldj:nlej))
             CALL iom_set_domain_attr("grid_U", area = e1u_crs(nldi:nlei, nldj:nlej) * e2u_crs(nldi:nlei, nldj:nlej))
@@ -184,8 +189,8 @@
 
       ! vertical grid definition
-      CALL iom_set_axis_attr( "deptht", gdept_1d )
-      CALL iom_set_axis_attr( "depthu", gdept_1d )
-      CALL iom_set_axis_attr( "depthv", gdept_1d )
-      CALL iom_set_axis_attr( "depthw", gdepw_1d )
+      CALL iom_set_axis_attr( "deptht", paxis = gdept_1d )
+      CALL iom_set_axis_attr( "depthu", paxis = gdept_1d )
+      CALL iom_set_axis_attr( "depthv", paxis = gdept_1d )
+      CALL iom_set_axis_attr( "depthw", paxis = gdepw_1d )
 
       ! Add vertical grid bounds
@@ -227,5 +232,12 @@
       
       ! automatic definitions of some of the xml attributs
-      CALL set_xmlatt
+      IF( TRIM(cdname) == TRIM(rxios_context)) THEN
+!set names of the fields in restart file IF using XIOS to read/write data
+       CALL set_rst_vars()
+!set which fields are to be read from restart file
+       CALL set_rstr_active()
+      ELSE
+       CALL set_xmlatt
+      ENDIF
 
       CALL set_1point
@@ -241,7 +253,145 @@
 
 #endif
-      
+
    END SUBROUTINE iom_init
 
+   
+   SUBROUTINE set_rst_vars()
+!set names for variables in restart file
+
+        rst_fields(:)%vname="NO_NAME";         rst_fields(:)%grid="NO_GRID"
+
+        rst_fields(1)%vname="rdt";             rst_fields(1)% grid="grid_scalar"
+        rst_fields(2)%vname="rdttra1";         rst_fields(2)% grid="grid_scalar"      
+        rst_fields(3)%vname="un";              rst_fields(3)% grid="grid_N_3D"
+        rst_fields(4)%vname="ub";              rst_fields(4)% grid="grid_N_3D"
+        rst_fields(5)%vname="vn";              rst_fields(5)% grid="grid_N_3D"
+        rst_fields(6)%vname="vb";              rst_fields(6)% grid="grid_N_3D"  
+        rst_fields(7)%vname="tn";              rst_fields(7)% grid="grid_N_3D"
+        rst_fields(8)%vname="tb";              rst_fields(8)% grid="grid_N_3D"
+        rst_fields(9)%vname="sn";              rst_fields(9)% grid="grid_N_3D"
+        rst_fields(10)%vname="sb";             rst_fields(10)%grid="grid_N_3D"
+        rst_fields(11)%vname="sshn";           rst_fields(11)%grid="grid_N"
+        rst_fields(12)%vname="sshb";           rst_fields(12)%grid="grid_N"
+        rst_fields(13)%vname="hdivn";          rst_fields(13)%grid="grid_N_3D"
+        rst_fields(14)%vname="hdivb";          rst_fields(14)%grid="grid_N_3D"
+        rst_fields(15)%vname="rhop";           rst_fields(15)%grid="grid_N_3D"
+        rst_fields(16)%vname="rotn";           rst_fields(16)%grid="grid_N_3D"
+        rst_fields(17)%vname="rotb";           rst_fields(17)%grid="grid_N_3D"
+        rst_fields(18)%vname="kt";             rst_fields(18)%grid="grid_scalar"
+        rst_fields(19)%vname="ndastp";         rst_fields(19)%grid="grid_scalar"
+        rst_fields(20)%vname="adatrj";         rst_fields(20)%grid="grid_scalar"
+        rst_fields(21)%vname="utau_b";         rst_fields(21)%grid="grid_N"
+        rst_fields(22)%vname="vtau_b";         rst_fields(22)%grid="grid_N"
+        rst_fields(23)%vname="qns_b";          rst_fields(23)%grid="grid_N"
+        rst_fields(24)%vname="emp_b";          rst_fields(24)%grid="grid_N"
+        rst_fields(25)%vname="sfx_b";          rst_fields(25)%grid="grid_N"
+        rst_fields(26)%vname="en" ;            rst_fields(26)%grid="grid_N_3D" 
+        rst_fields(27)%vname="avt";            rst_fields(27)%grid="grid_N_3D"
+        rst_fields(28)%vname="avm";            rst_fields(28)%grid="grid_N_3D"
+        rst_fields(29)%vname="avmu";           rst_fields(29)%grid="grid_N_3D"
+        rst_fields(30)%vname="avmv";           rst_fields(30)%grid="grid_N_3D"
+        rst_fields(31)%vname="dissl";          rst_fields(31)%grid="grid_N_3D"
+        rst_fields(32)%vname="sbc_hc_b";       rst_fields(32)%grid="grid_N"
+        rst_fields(33)%vname="sbc_sc_b";       rst_fields(33)%grid="grid_N"
+        rst_fields(34)%vname="qsr_hc_b";       rst_fields(34)%grid="grid_N_3D"
+        rst_fields(35)%vname="gcx";            rst_fields(35)%grid="grid_N"
+        rst_fields(36)%vname="gcxb";           rst_fields(36)%grid="grid_N"
+        rst_fields(37)%vname="fraqsr_1lev";    rst_fields(37)%grid="grid_N"
+        rst_fields(38)%vname="greenland_icesheet_mass"
+                                               rst_fields(38)%grid="grid_scalar"
+        rst_fields(39)%vname="greenland_icesheet_timelapsed"
+                                               rst_fields(39)%grid="grid_scalar"
+        rst_fields(40)%vname="greenland_icesheet_mass_roc"
+                                               rst_fields(40)%grid="grid_scalar"
+        rst_fields(41)%vname="antarctica_icesheet_mass"
+                                               rst_fields(41)%grid="grid_scalar"
+        rst_fields(42)%vname="antarctica_icesheet_timelapsed"
+                                               rst_fields(42)%grid="grid_scalar"
+        rst_fields(43)%vname="antarctica_icesheet_mass_roc"
+                                               rst_fields(43)%grid="grid_scalar"
+        rst_fields(44)%vname="rhd";            rst_fields(44)%grid="grid_N_3D"
+        rst_fields(45)%vname="frc_v";          rst_fields(45)%grid="grid_scalar"
+        rst_fields(46)%vname="frc_t";          rst_fields(46)%grid="grid_scalar"
+        rst_fields(47)%vname="frc_s";          rst_fields(47)%grid="grid_scalar"
+        rst_fields(48)%vname="frc_wn_t";       rst_fields(48)%grid="grid_scalar"
+        rst_fields(49)%vname="frc_wn_s";       rst_fields(49)%grid="grid_scalar"
+        rst_fields(50)%vname="ssh_ini";        rst_fields(50)%grid="grid_N"
+        rst_fields(51)%vname="e3t_ini";        rst_fields(51)%grid="grid_N_3D"
+        rst_fields(52)%vname="hc_loc_ini";     rst_fields(52)%grid="grid_N_3D"
+        rst_fields(53)%vname="sc_loc_ini";     rst_fields(53)%grid="grid_N_3D"
+        rst_fields(54)%vname="ssh_hc_loc_ini"; rst_fields(54)%grid="grid_N"
+        rst_fields(55)%vname="ssh_sc_loc_ini"; rst_fields(55)%grid="grid_N"
+        rst_fields(56)%vname="fse3t_b";        rst_fields(56)%grid="grid_N_3D"
+        rst_fields(57)%vname="fse3t_n";        rst_fields(57)%grid="grid_N_3D"
+        rst_fields(58)%vname="tilde_e3t_b";    rst_fields(58)%grid="grid_N"
+        rst_fields(59)%vname="tilde_e3t_n";    rst_fields(59)%grid="grid_N"
+        rst_fields(60)%vname="hdiv_lf";        rst_fields(60)%grid="grid_N"
+        rst_fields(61)%vname="ub2_b";          rst_fields(61)%grid="grid_N"
+        rst_fields(62)%vname="vb2_b";          rst_fields(62)%grid="grid_N"
+        rst_fields(63)%vname="sshbb_e";        rst_fields(63)%grid="grid_N"
+        rst_fields(64)%vname="ubb_e";          rst_fields(64)%grid="grid_N"
+        rst_fields(65)%vname="vbb_e";          rst_fields(65)%grid="grid_N"
+        rst_fields(66)%vname="sshb_e";         rst_fields(66)%grid="grid_N"
+        rst_fields(67)%vname="ub_e";           rst_fields(67)%grid="grid_N"
+        rst_fields(68)%vname="vb_e";           rst_fields(68)%grid="grid_N"
+        rst_fields(69)%vname="fwf_isf_b";      rst_fields(69)%grid="grid_N"
+        rst_fields(70)%vname="isf_sc_b";       rst_fields(70)%grid="grid_N"
+        rst_fields(71)%vname="isf_hc_b";       rst_fields(71)%grid="grid_N"
+        rst_fields(72)%vname="ssh_ibb";        rst_fields(72)%grid="grid_N"
+        rst_fields(73)%vname="rnf_b";          rst_fields(73)%grid="grid_N"
+        rst_fields(74)%vname="rnf_hc_b";       rst_fields(74)%grid="grid_N"
+        rst_fields(75)%vname="rnf_sc_b";       rst_fields(75)%grid="grid_N"
+        rst_fields(76)%vname="nn_fsbc";        rst_fields(76)%grid="grid_scalar"
+        rst_fields(77)%vname="ssu_m";          rst_fields(77)%grid="grid_N"
+        rst_fields(78)%vname="ssv_m";          rst_fields(78)%grid="grid_N"
+        rst_fields(79)%vname="sst_m";          rst_fields(79)%grid="grid_N"
+        rst_fields(80)%vname="sss_m";          rst_fields(80)%grid="grid_N"
+        rst_fields(81)%vname="ssh_m";          rst_fields(81)%grid="grid_N"
+        rst_fields(82)%vname="e3t_m";          rst_fields(82)%grid="grid_N"
+        rst_fields(83)%vname="frq_m";          rst_fields(83)%grid="grid_N"
+        rst_fields(84)%vname="avmb";           rst_fields(84)%grid="Vgrid"
+        rst_fields(85)%vname="avtb";           rst_fields(85)%grid="Vgrid"
+
+   END SUBROUTINE set_rst_vars
+
+
+   SUBROUTINE set_rstr_active()
+!sets enabled = .TRUE. for each field in restart file
+#if defined key_xios2
+   CHARACTER(len=256) :: rst_file
+   TYPE(xios_field) :: field_hdl
+   TYPE(xios_file) :: file_hdl
+   TYPE(xios_filegroup) :: filegroup_hdl
+   INTEGER :: i
+   CHARACTER(lc)  ::   clpath
+
+        clpath = TRIM(cn_ocerst_indir)
+        IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
+        IF( TRIM(Agrif_CFixed()) == '0' ) THEN
+           rst_file = TRIM(cn_ocerst_indir)//TRIM(cn_ocerst_in)
+        ELSE
+           rst_file = TRIM(cn_ocerst_indir)//'1_'//TRIM(cn_ocerst_in)
+        ENDIF
+!set name of the restart file and enable available fields
+        if(lwp) WRITE(numout,*) 'Setting restart filename (for XIOS) to: ',rst_file
+        CALL xios_get_handle("file_definition", filegroup_hdl )
+        CALL xios_add_child(filegroup_hdl, file_hdl, 'rrestart')
+        CALL xios_set_file_attr( "rrestart", name=trim(rst_file), type="one_file", &
+             par_access="collective", enabled=.TRUE., mode="read",                 &
+             output_freq=xios_timestep)
+!defin files for restart context
+        DO i = 1, max_rst_fields
+         IF( TRIM(rst_fields(i)%vname) /= "NO_NAME") THEN
+           IF( iom_varid( numror, TRIM(rst_fields(i)%vname), ldstop = .FALSE. ) > 0 ) THEN
+                CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+                CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(rst_fields(i)%vname), &
+                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+                if(lwp) WRITE(numout,*) TRIM(rst_fields(i)%vname), ' enabled'
+           ENDIF
+         ENDIF
+        END DO
+#endif
+   END SUBROUTINE set_rstr_active
 
    SUBROUTINE iom_swap( cdname )
@@ -378,4 +528,6 @@
             icnt = icnt + 1
          END DO
+      ELSE
+         lxios_sini = .TRUE.
       ENDIF
       IF( llwrt ) THEN
@@ -567,9 +719,10 @@
    !!                   INTERFACE iom_get
    !!----------------------------------------------------------------------
-   SUBROUTINE iom_g0d( kiomid, cdvar, pvar, ktime )
+   SUBROUTINE iom_g0d( kiomid, cdvar, pvar, ktime, lrxios )
       INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file
       CHARACTER(len=*), INTENT(in   )                 ::   cdvar     ! Name of the variable
       REAL(wp)        , INTENT(  out)                 ::   pvar      ! read field
       INTEGER         , INTENT(in   ),     OPTIONAL   ::   ktime     ! record number
+      LOGICAL         , INTENT(in   ),     OPTIONAL   ::   lrxios    ! use xios to read restart
       !
       INTEGER                                         ::   idvar     ! variable id
@@ -579,32 +732,45 @@
       CHARACTER(LEN=100)                              ::   clname    ! file name
       CHARACTER(LEN=1)                                ::   cldmspc   !
-      !
-      itime = 1
-      IF( PRESENT(ktime) ) itime = ktime
-      !
-      clname = iom_file(kiomid)%name
-      clinfo = '          iom_g0d, file: '//trim(clname)//', var: '//trim(cdvar)
-      !
-      IF( kiomid > 0 ) THEN
-         idvar = iom_varid( kiomid, cdvar )
-         IF( iom_file(kiomid)%nfid > 0 .AND. idvar > 0 ) THEN
-            idmspc = iom_file ( kiomid )%ndims( idvar )
-            IF( iom_file(kiomid)%luld(idvar) )  idmspc = idmspc - 1
-            WRITE(cldmspc , fmt='(i1)') idmspc
-            IF( idmspc > 0 )  CALL ctl_stop( TRIM(clinfo), 'When reading to a 0D array, we do not accept data', &
-                                 &                         'with 1 or more spatial dimensions: '//cldmspc//' were found.' , &
-                                 &                         'Use ncwa -a to suppress the unnecessary dimensions' )
-            SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpioipsl )   ;   CALL iom_ioipsl_get(  kiomid, idvar, pvar, itime )
-            CASE (jpnf90   )   ;   CALL iom_nf90_get(    kiomid, idvar, pvar, itime )
-            CASE (jprstdimg)   ;   CALL iom_rstdimg_get( kiomid, idvar, pvar )
-            CASE DEFAULT    
-               CALL ctl_stop( 'iom_g0d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
-            END SELECT
-         ENDIF
-      ENDIF
+      LOGICAL                                         ::   lxios
+      !
+      lxios = .FALSE.
+      IF( PRESENT(lrxios) ) lxios = lrxios
+
+      IF(.NOT.lxios) THEN  ! read data using default library
+          itime = 1
+          IF( PRESENT(ktime) ) itime = ktime
+          !
+          clname = iom_file(kiomid)%name
+          clinfo = '          iom_g0d, file: '//trim(clname)//', var: '//trim(cdvar)
+          !
+          IF( kiomid > 0 ) THEN
+             idvar = iom_varid( kiomid, cdvar )
+             IF( iom_file(kiomid)%nfid > 0 .AND. idvar > 0 ) THEN
+                idmspc = iom_file ( kiomid )%ndims( idvar )
+                IF( iom_file(kiomid)%luld(idvar) )  idmspc = idmspc - 1
+                WRITE(cldmspc , fmt='(i1)') idmspc
+                IF( idmspc > 0 )  CALL ctl_stop( TRIM(clinfo), 'When reading to a 0D array, we do not accept data', &
+                                     &                         'with 1 or more spatial dimensions: '//cldmspc//' were found.' , &
+                                     &                         'Use ncwa -a to suppress the unnecessary dimensions' )
+                SELECT CASE (iom_file(kiomid)%iolib)
+                CASE (jpioipsl )   ;   CALL iom_ioipsl_get(  kiomid, idvar, pvar, itime )
+                CASE (jpnf90   )   ;   CALL iom_nf90_get(    kiomid, idvar, pvar, itime )
+                CASE (jprstdimg)   ;   CALL iom_rstdimg_get( kiomid, idvar, pvar )
+                CASE DEFAULT    
+                   CALL ctl_stop( 'iom_g0d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+                END SELECT
+             ENDIF
+          ENDIF
+      ELSE
+#if defined key_iomput
+       IF(lwp) WRITE(numout,*) 'XIOS RST READ (0D): ', trim(cdvar)
+       CALL iom_swap( TRIM(rxios_context) )
+       CALL xios_recv_field( trim(cdvar), pvar)
+       CALL iom_swap( TRIM(cxios_context) )
+#endif
+      ENDIF   
    END SUBROUTINE iom_g0d
 
-   SUBROUTINE iom_g1d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount )
+   SUBROUTINE iom_g1d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, lrxios )
       INTEGER         , INTENT(in   )                         ::   kiomid    ! Identifier of the file
       INTEGER         , INTENT(in   )                         ::   kdom      ! Type of domain to be read
@@ -614,12 +780,14 @@
       INTEGER         , INTENT(in   ), DIMENSION(1), OPTIONAL ::   kstart    ! start axis position of the reading 
       INTEGER         , INTENT(in   ), DIMENSION(1), OPTIONAL ::   kcount    ! number of points in each axis
+      LOGICAL         , INTENT(in   ),               OPTIONAL ::   lrxios    ! read data using XIOS
       !
       IF( kiomid > 0 ) THEN
          IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r1d=pvar,   &
-              &                                                     ktime=ktime, kstart=kstart, kcount=kcount )
+              &                                                     ktime=ktime, kstart=kstart, kcount=kcount, &
+              &                                                     lrxios=lrxios )
       ENDIF
    END SUBROUTINE iom_g1d
 
-   SUBROUTINE iom_g2d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, lrowattr )
+   SUBROUTINE iom_g2d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, lrowattr, lrxios)
       INTEGER         , INTENT(in   )                           ::   kiomid    ! Identifier of the file
       INTEGER         , INTENT(in   )                           ::   kdom      ! Type of domain to be read
@@ -633,13 +801,14 @@
                                                                                ! called open_ocean_jstart to set the start
                                                                                ! value for the 2nd dimension (netcdf only)
+      LOGICAL         , INTENT(in   ),                 OPTIONAL ::   lrxios    ! read data using XIOS
       !
       IF( kiomid > 0 ) THEN
          IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r2d=pvar,   &
               &                                                     ktime=ktime, kstart=kstart, kcount=kcount, &
-              &                                                     lrowattr=lrowattr )
+              &                                                     lrowattr=lrowattr,  lrxios=lrxios)
       ENDIF
    END SUBROUTINE iom_g2d
 
-   SUBROUTINE iom_g3d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, lrowattr )
+   SUBROUTINE iom_g3d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, lrowattr, lrxios )
       INTEGER         , INTENT(in   )                             ::   kiomid    ! Identifier of the file
       INTEGER         , INTENT(in   )                             ::   kdom      ! Type of domain to be read
@@ -653,9 +822,10 @@
                                                                                  ! called open_ocean_jstart to set the start
                                                                                  ! value for the 2nd dimension (netcdf only)
+      LOGICAL         , INTENT(in   ),                   OPTIONAL ::   lrxios    ! read data using XIOS
       !
       IF( kiomid > 0 ) THEN
          IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r3d=pvar,   &
               &                                                     ktime=ktime, kstart=kstart, kcount=kcount, &
-              &                                                     lrowattr=lrowattr )
+              &                                                     lrowattr=lrowattr, lrxios=lrxios )
       ENDIF
    END SUBROUTINE iom_g3d
@@ -665,5 +835,5 @@
          &                  pv_r1d, pv_r2d, pv_r3d,   &
          &                  ktime , kstart, kcount,   &
-         &                  lrowattr                )
+         &                  lrowattr, lrxios        )
       !!-----------------------------------------------------------------------
       !!                  ***  ROUTINE  iom_get_123d  ***
@@ -686,5 +856,7 @@
                                                                            ! called open_ocean_jstart to set the start
                                                                            ! value for the 2nd dimension (netcdf only)
-      !
+      LOGICAL                    , INTENT(in   ), OPTIONAL ::   lrxios     ! use XIOS to read restart
+      !
+      LOGICAL                        ::   lxios       ! local definition for XIOS read
       LOGICAL                        ::   llnoov      ! local definition to read overlap
       LOGICAL                        ::   luse_jattr  ! local definition to read open_ocean_jstart file attribute
@@ -713,255 +885,291 @@
       !---------------------------------------------------------------------
       !
-      clname = iom_file(kiomid)%name   !   esier to read
-      clinfo = '          iom_get_123d, file: '//trim(clname)//', var: '//trim(cdvar)
-      ! local definition of the domain ?
+      REAL(wp)                       :: gma, gmi
+      lxios = .FALSE.
+      if(PRESENT(lrxios)) lxios = lrxios
+      idvar = iom_varid( kiomid, cdvar ) 
       idom = kdom
-      ! do we read the overlap 
-      ! ugly patch SM+JMM+RB to overwrite global definition in some cases
-      llnoov = (jpni * jpnj ) == jpnij .AND. .NOT. lk_agrif 
-      ! check kcount and kstart optionals parameters...
-      IF( PRESENT(kcount) .AND. (.NOT. PRESENT(kstart)) ) CALL ctl_stop(trim(clinfo), 'kcount present needs kstart present')
-      IF( PRESENT(kstart) .AND. (.NOT. PRESENT(kcount)) ) CALL ctl_stop(trim(clinfo), 'kstart present needs kcount present')
-      IF( PRESENT(kstart) .AND. idom /= jpdom_unknown .AND.  idom /= jpdom_autoglo_xy  ) &
+
+      IF(.NOT.lxios) THEN
+          clname = iom_file(kiomid)%name   !   esier to read
+          clinfo = '          iom_get_123d, file: '//trim(clname)//', var: '//trim(cdvar)
+          ! local definition of the domain ?
+          ! do we read the overlap 
+          ! ugly patch SM+JMM+RB to overwrite global definition in some cases
+          llnoov = (jpni * jpnj ) == jpnij .AND. .NOT. lk_agrif 
+          ! check kcount and kstart optionals parameters...
+          IF( PRESENT(kcount) .AND. (.NOT. PRESENT(kstart)) ) CALL ctl_stop(trim(clinfo), 'kcount present needs kstart present')
+          IF( PRESENT(kstart) .AND. (.NOT. PRESENT(kcount)) ) CALL ctl_stop(trim(clinfo), 'kstart present needs kcount present')
+          IF( PRESENT(kstart) .AND. idom /= jpdom_unknown .AND.  idom /= jpdom_autoglo_xy  ) &
      &           CALL ctl_stop(trim(clinfo), 'kstart present needs kdom = jpdom_unknown or kdom = jpdom_autoglo_xy')
 
-      luse_jattr = .false.
-      IF( PRESENT(lrowattr) ) THEN
-         IF( lrowattr .AND. idom /= jpdom_data   ) CALL ctl_stop(trim(clinfo), 'lrowattr present and true needs kdom = jpdom_data')
-         IF( lrowattr .AND. idom == jpdom_data   ) luse_jattr = .true.
-      ENDIF
-      IF( luse_jattr ) THEN
-         SELECT CASE (iom_file(kiomid)%iolib)
-         CASE (jpioipsl, jprstdimg )
-             CALL ctl_warn(trim(clinfo), 'lrowattr present and true but this only works with netcdf (jpnf90)')
-             luse_jattr = .false.
-         CASE (jpnf90   )   
-             ! Ok
-         CASE DEFAULT    
-            CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
-         END SELECT
-      ENDIF
-
-      ! Search for the variable in the data base (eventually actualize data)
-      istop = nstop
-      idvar = iom_varid( kiomid, cdvar )
-      !
-      IF( idvar > 0 ) THEN
-         ! to write iom_file(kiomid)%dimsz in a shorter way !
-         idimsz(:) = iom_file(kiomid)%dimsz(:, idvar) 
-         inbdim = iom_file(kiomid)%ndims(idvar)            ! number of dimensions in the file
-         idmspc = inbdim                                   ! number of spatial dimensions in the file
-         IF( iom_file(kiomid)%luld(idvar) )   idmspc = inbdim - 1
-         IF( idmspc > 3 )   CALL ctl_stop(trim(clinfo), 'the file has more than 3 spatial dimensions this case is not coded...') 
-         !
-         ! update idom definition...
-         ! Identify the domain in case of jpdom_auto(glo/dta) definition
-         IF( idom == jpdom_autoglo_xy ) THEN
-            ll_depth_spec = .TRUE.
-            idom = jpdom_autoglo
-         ELSE
-            ll_depth_spec = .FALSE.
-         ENDIF
-         IF( idom == jpdom_autoglo .OR. idom == jpdom_autodta ) THEN            
-            IF( idom == jpdom_autoglo ) THEN   ;   idom = jpdom_global 
-            ELSE                               ;   idom = jpdom_data
-            ENDIF
-            ind1 = INDEX( clname, '_', back = .TRUE. ) + 1
-            ind2 = INDEX( clname, '.', back = .TRUE. ) - 1
-            IF( ind2 > ind1 ) THEN   ;   IF( VERIFY( clname(ind1:ind2), '0123456789' ) == 0 )   idom = jpdom_local   ;   ENDIF
-         ENDIF
-         ! Identify the domain in case of jpdom_local definition
-         IF( idom == jpdom_local ) THEN
-            IF(     idimsz(1) == jpi               .AND. idimsz(2) == jpj               ) THEN   ;   idom = jpdom_local_full
-            ELSEIF( idimsz(1) == nlci              .AND. idimsz(2) == nlcj              ) THEN   ;   idom = jpdom_local_noextra
-            ELSEIF( idimsz(1) == (nlei - nldi + 1) .AND. idimsz(2) == (nlej - nldj + 1) ) THEN   ;   idom = jpdom_local_noovlap
-            ELSE   ;   CALL ctl_stop( trim(clinfo), 'impossible to identify the local domain' )
-            ENDIF
-         ENDIF
-         !
-         ! check the consistency between input array and data rank in the file
-         !
-         ! initializations
-         itime = 1
-         IF( PRESENT(ktime) ) itime = ktime
-
-         irankpv = 1 * COUNT( (/PRESENT(pv_r1d)/) ) + 2 * COUNT( (/PRESENT(pv_r2d)/) ) + 3 * COUNT( (/PRESENT(pv_r3d)/) )
-         WRITE(clrankpv, fmt='(i1)') irankpv
-         WRITE(cldmspc , fmt='(i1)') idmspc
-         !
-         IF(     idmspc <  irankpv ) THEN 
-            CALL ctl_stop( TRIM(clinfo), 'The file has only '//cldmspc//' spatial dimension',   &
+          luse_jattr = .false.
+          IF( PRESENT(lrowattr) ) THEN
+             IF( lrowattr .AND. idom /= jpdom_data   ) CALL ctl_stop(trim(clinfo), 'lrowattr present and true needs kdom = jpdom_data')
+             IF( lrowattr .AND. idom == jpdom_data   ) luse_jattr = .true.
+          ENDIF
+          IF( luse_jattr ) THEN
+             SELECT CASE (iom_file(kiomid)%iolib)
+             CASE (jpioipsl, jprstdimg )
+                 CALL ctl_warn(trim(clinfo), 'lrowattr present and true but this only works with netcdf (jpnf90)')
+                 luse_jattr = .false.
+             CASE (jpnf90   )   
+                 ! Ok
+             CASE DEFAULT    
+                CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+             END SELECT
+          ENDIF
+
+          ! Search for the variable in the data base (eventually actualize data)
+          istop = nstop
+          !
+          IF( idvar > 0 ) THEN
+             ! to write iom_file(kiomid)%dimsz in a shorter way !
+             idimsz(:) = iom_file(kiomid)%dimsz(:, idvar) 
+             inbdim = iom_file(kiomid)%ndims(idvar)            ! number of dimensions in the file
+             idmspc = inbdim                                   ! number of spatial dimensions in the file
+             IF( iom_file(kiomid)%luld(idvar) )   idmspc = inbdim - 1
+             IF( idmspc > 3 )   CALL ctl_stop(trim(clinfo), 'the file has more than 3 spatial dimensions this case is not coded...') 
+             !
+             ! update idom definition...
+             ! Identify the domain in case of jpdom_auto(glo/dta) definition
+             IF( idom == jpdom_autoglo_xy ) THEN
+                ll_depth_spec = .TRUE.
+                idom = jpdom_autoglo
+             ELSE
+                ll_depth_spec = .FALSE.
+             ENDIF
+             IF( idom == jpdom_autoglo .OR. idom == jpdom_autodta ) THEN            
+                IF( idom == jpdom_autoglo ) THEN   ;   idom = jpdom_global 
+                ELSE                               ;   idom = jpdom_data
+                ENDIF
+                ind1 = INDEX( clname, '_', back = .TRUE. ) + 1
+                ind2 = INDEX( clname, '.', back = .TRUE. ) - 1
+                IF( ind2 > ind1 ) THEN   ;   IF( VERIFY( clname(ind1:ind2), '0123456789' ) == 0 )   idom = jpdom_local   ;   ENDIF
+             ENDIF
+             ! Identify the domain in case of jpdom_local definition
+             IF( idom == jpdom_local ) THEN
+                IF(     idimsz(1) == jpi               .AND. idimsz(2) == jpj               ) THEN   ;   idom = jpdom_local_full
+                ELSEIF( idimsz(1) == nlci              .AND. idimsz(2) == nlcj              ) THEN   ;   idom = jpdom_local_noextra
+                ELSEIF( idimsz(1) == (nlei - nldi + 1) .AND. idimsz(2) == (nlej - nldj + 1) ) THEN   ;   idom = jpdom_local_noovlap
+                ELSE   ;   CALL ctl_stop( trim(clinfo), 'impossible to identify the local domain' )
+                ENDIF
+             ENDIF
+             !
+             ! check the consistency between input array and data rank in the file
+             !
+             ! initializations
+             itime = 1
+             IF( PRESENT(ktime) ) itime = ktime
+
+             irankpv = 1 * COUNT( (/PRESENT(pv_r1d)/) ) + 2 * COUNT( (/PRESENT(pv_r2d)/) ) + 3 * COUNT( (/PRESENT(pv_r3d)/) )
+             WRITE(clrankpv, fmt='(i1)') irankpv
+             WRITE(cldmspc , fmt='(i1)') idmspc
+             !
+             IF(     idmspc <  irankpv ) THEN 
+                CALL ctl_stop( TRIM(clinfo), 'The file has only '//cldmspc//' spatial dimension',   &
                &                         'it is impossible to read a '//clrankpv//'D array from this file...' )
-         ELSEIF( idmspc == irankpv ) THEN
-            IF( PRESENT(pv_r1d) .AND. idom /= jpdom_unknown )   &
+             ELSEIF( idmspc == irankpv ) THEN
+                IF( PRESENT(pv_r1d) .AND. idom /= jpdom_unknown )   &
                &   CALL ctl_stop( TRIM(clinfo), 'case not coded...You must use jpdom_unknown' )
-         ELSEIF( idmspc >  irankpv ) THEN
-               IF( PRESENT(pv_r2d) .AND. itime == 1 .AND. idimsz(3) == 1 .AND. idmspc == 3 ) THEN
-                  CALL ctl_warn( trim(clinfo), '2D array but 3 spatial dimensions for the data...'              ,   &
+             ELSEIF( idmspc >  irankpv ) THEN
+                   IF( PRESENT(pv_r2d) .AND. itime == 1 .AND. idimsz(3) == 1 .AND. idmspc == 3 ) THEN
+                      CALL ctl_warn( trim(clinfo), '2D array but 3 spatial dimensions for the data...'              ,   &
                         &         'As the size of the z dimension is 1 and as we try to read the first record, ',   &
                         &         'we accept this case, even if there is a possible mix-up between z and time dimension' )   
-                  idmspc = idmspc - 1
-               ELSE
-                  CALL ctl_stop( TRIM(clinfo), 'To keep iom lisibility, when reading a '//clrankpv//'D array,'         ,   &
+                      idmspc = idmspc - 1
+                   ELSE
+                      CALL ctl_stop( TRIM(clinfo), 'To keep iom lisibility, when reading a '//clrankpv//'D array,'         ,   &
                      &                         'we do not accept data with '//cldmspc//' spatial dimensions',   &
                      &                         'Use ncwa -a to suppress the unnecessary dimensions' )
-               ENDIF
-         ENDIF
-
-         !
-         ! definition of istart and icnt
-         !
-         icnt  (:) = 1
-         istart(:) = 1
-         istart(idmspc+1) = itime
-
-         IF( PRESENT(kstart) .AND. .NOT. ll_depth_spec ) THEN ; istart(1:idmspc) = kstart(1:idmspc) ; icnt(1:idmspc) = kcount(1:idmspc)
-         ELSE
-            IF(           idom == jpdom_unknown ) THEN                                                ; icnt(1:idmspc) = idimsz(1:idmspc)
-            ELSE 
-               IF( .NOT. PRESENT(pv_r1d) ) THEN   !   not a 1D array
-                  IF(     idom == jpdom_data    ) THEN
-                     jstartrow = 1
-                     IF( luse_jattr ) THEN
-                        CALL iom_getatt(kiomid, 'open_ocean_jstart', jstartrow ) ! -999 is returned if the attribute is not found
-                        jstartrow = MAX(1,jstartrow)
-                     ENDIF
-                     istart(1:2) = (/ mig(1), mjg(1) + jstartrow - 1 /)  ! icnt(1:2) done below
-                  ELSEIF( idom == jpdom_global  ) THEN ; istart(1:2) = (/ nimpp , njmpp  /)  ! icnt(1:2) done below
-                  ENDIF
-                  ! we do not read the overlap                     -> we start to read at nldi, nldj
+                   ENDIF
+             ENDIF
+
+             !
+             ! definition of istart and icnt
+             !
+             icnt  (:) = 1
+             istart(:) = 1
+             istart(idmspc+1) = itime
+
+             IF( PRESENT(kstart) .AND. .NOT. ll_depth_spec ) THEN ; istart(1:idmspc) = kstart(1:idmspc) ; icnt(1:idmspc) = kcount(1:idmspc)
+             ELSE
+                IF(           idom == jpdom_unknown ) THEN                                                ; icnt(1:idmspc) = idimsz(1:idmspc)
+                ELSE 
+                   IF( .NOT. PRESENT(pv_r1d) ) THEN   !   not a 1D array
+                      IF(     idom == jpdom_data    ) THEN
+                         jstartrow = 1
+                         IF( luse_jattr ) THEN
+                            CALL iom_getatt(kiomid, 'open_ocean_jstart', jstartrow ) ! -999 is returned if the attribute is not found
+                            jstartrow = MAX(1,jstartrow)
+                         ENDIF
+                         istart(1:2) = (/ mig(1), mjg(1) + jstartrow - 1 /)  ! icnt(1:2) done below
+                      ELSEIF( idom == jpdom_global  ) THEN ; istart(1:2) = (/ nimpp , njmpp  /)  ! icnt(1:2) done below
+                      ENDIF
+                      ! we do not read the overlap                     -> we start to read at nldi, nldj
 ! JMM + SM: ugly patch before getting the new version of lib_mpp)
 !                  IF( idom /= jpdom_local_noovlap )   istart(1:2) = istart(1:2) + (/ nldi - 1, nldj - 1 /)
-                  IF( llnoov .AND. idom /= jpdom_local_noovlap ) istart(1:2) = istart(1:2) + (/ nldi - 1, nldj - 1 /)
+                      IF( llnoov .AND. idom /= jpdom_local_noovlap ) istart(1:2) = istart(1:2) + (/ nldi - 1, nldj - 1 /)
                   ! we do not read the overlap and the extra-halos -> from nldi to nlei and from nldj to nlej 
 ! JMM + SM: ugly patch before getting the new version of lib_mpp)
 !                  icnt(1:2) = (/ nlei - nldi + 1, nlej - nldj + 1 /)
-                  IF( llnoov ) THEN   ;   icnt(1:2) = (/ nlei - nldi + 1, nlej - nldj + 1 /)
-                  ELSE                ;   icnt(1:2) = (/ nlci           , nlcj            /)
-                  ENDIF
-                  IF( PRESENT(pv_r3d) ) THEN
-                     IF( idom == jpdom_data ) THEN                                  ; icnt(3) = jpkdta
-                     ELSE IF( ll_depth_spec .AND. PRESENT(kstart) ) THEN            ; istart(3) = kstart(3); icnt(3) = kcount(3)
-                     ELSE                                                           ; icnt(3) = jpk
-                     ENDIF
-                  ENDIF
-               ENDIF
-            ENDIF
-         ENDIF
-
-         ! check that istart and icnt can be used with this file
-         !-
-         DO jl = 1, jpmax_dims
-            itmp = istart(jl)+icnt(jl)-1
-            IF( itmp > idimsz(jl) .AND. idimsz(jl) /= 0 ) THEN
-               WRITE( ctmp1, FMT="('(istart(', i1, ') + icnt(', i1, ') - 1) = ', i5)" ) jl, jl, itmp
-               WRITE( ctmp2, FMT="(' is larger than idimsz(', i1,') = ', i5)"         ) jl, idimsz(jl)
-               CALL ctl_stop( trim(clinfo), 'start and count too big regarding to the size of the data, ', ctmp1, ctmp2 )     
-            ENDIF
-         END DO
-
-         ! check that icnt matches the input array
-         !-     
-         IF( idom == jpdom_unknown ) THEN
-            IF( irankpv == 1 )        ishape(1:1) = SHAPE(pv_r1d)
-            IF( irankpv == 2 )        ishape(1:2) = SHAPE(pv_r2d)
-            IF( irankpv == 3 )        ishape(1:3) = SHAPE(pv_r3d)
-            ctmp1 = 'd'
-         ELSE
-            IF( irankpv == 2 ) THEN
+                      IF( llnoov ) THEN   ;   icnt(1:2) = (/ nlei - nldi + 1, nlej - nldj + 1 /)
+                      ELSE                ;   icnt(1:2) = (/ nlci           , nlcj            /)
+                      ENDIF
+                      IF( PRESENT(pv_r3d) ) THEN
+                         IF( idom == jpdom_data ) THEN                                  ; icnt(3) = jpkdta
+                         ELSE IF( ll_depth_spec .AND. PRESENT(kstart) ) THEN            ; istart(3) = kstart(3); icnt(3) = kcount(3)
+                         ELSE                                                           ; icnt(3) = jpk
+                         ENDIF
+                      ENDIF
+                   ENDIF
+                ENDIF
+             ENDIF
+
+             ! check that istart and icnt can be used with this file
+             !-
+             DO jl = 1, jpmax_dims
+                itmp = istart(jl)+icnt(jl)-1
+                IF( itmp > idimsz(jl) .AND. idimsz(jl) /= 0 ) THEN
+                   WRITE( ctmp1, FMT="('(istart(', i1, ') + icnt(', i1, ') - 1) = ', i5)" ) jl, jl, itmp
+                   WRITE( ctmp2, FMT="(' is larger than idimsz(', i1,') = ', i5)"         ) jl, idimsz(jl)
+                   CALL ctl_stop( trim(clinfo), 'start and count too big regarding to the size of the data, ', ctmp1, ctmp2 )     
+                ENDIF
+             END DO
+
+             ! check that icnt matches the input array
+             !-     
+             IF( idom == jpdom_unknown ) THEN
+                IF( irankpv == 1 )        ishape(1:1) = SHAPE(pv_r1d)
+                IF( irankpv == 2 )        ishape(1:2) = SHAPE(pv_r2d)
+                IF( irankpv == 3 )        ishape(1:3) = SHAPE(pv_r3d)
+                ctmp1 = 'd'
+             ELSE
+                IF( irankpv == 2 ) THEN
 ! JMM + SM: ugly patch before getting the new version of lib_mpp)
 !               ishape(1:2) = SHAPE(pv_r2d(nldi:nlei,nldj:nlej  ))   ;   ctmp1 = 'd(nldi:nlei,nldj:nlej)'
-               IF( llnoov ) THEN ; ishape(1:2)=SHAPE(pv_r2d(nldi:nlei,nldj:nlej  )) ; ctmp1='d(nldi:nlei,nldj:nlej)'
-               ELSE              ; ishape(1:2)=SHAPE(pv_r2d(1   :nlci,1   :nlcj  )) ; ctmp1='d(1:nlci,1:nlcj)'
-               ENDIF
-            ENDIF
-            IF( irankpv == 3 ) THEN 
+                   IF( llnoov ) THEN ; ishape(1:2)=SHAPE(pv_r2d(nldi:nlei,nldj:nlej  )) ; ctmp1='d(nldi:nlei,nldj:nlej)'
+                   ELSE              ; ishape(1:2)=SHAPE(pv_r2d(1   :nlci,1   :nlcj  )) ; ctmp1='d(1:nlci,1:nlcj)'
+                   ENDIF
+                ENDIF
+                IF( irankpv == 3 ) THEN 
 ! JMM + SM: ugly patch before getting the new version of lib_mpp)
 !               ishape(1:3) = SHAPE(pv_r3d(nldi:nlei,nldj:nlej,:))   ;   ctmp1 = 'd(nldi:nlei,nldj:nlej,:)'
-               IF( llnoov ) THEN ; ishape(1:3)=SHAPE(pv_r3d(nldi:nlei,nldj:nlej,:)) ; ctmp1='d(nldi:nlei,nldj:nlej,:)'
-               ELSE              ; ishape(1:3)=SHAPE(pv_r3d(1   :nlci,1   :nlcj,:)) ; ctmp1='d(1:nlci,1:nlcj,:)'
-               ENDIF
-            ENDIF
-         ENDIF
+                   IF( llnoov ) THEN ; ishape(1:3)=SHAPE(pv_r3d(nldi:nlei,nldj:nlej,:)) ; ctmp1='d(nldi:nlei,nldj:nlej,:)'
+                   ELSE              ; ishape(1:3)=SHAPE(pv_r3d(1   :nlci,1   :nlcj,:)) ; ctmp1='d(1:nlci,1:nlcj,:)'
+                   ENDIF
+                ENDIF
+             ENDIF
          
-         DO jl = 1, irankpv
-            WRITE( ctmp2, FMT="(', ', i1,'): ', i5,' /= icnt(', i1,'):', i5)" ) jl, ishape(jl), jl, icnt(jl)
-            IF( ishape(jl) /= icnt(jl) )   CALL ctl_stop( TRIM(clinfo), 'size(pv_r'//clrankpv//TRIM(ctmp1)//TRIM(ctmp2) )
-         END DO
-
-      ENDIF
-
-      ! read the data
-      !-     
-      IF( idvar > 0 .AND. istop == nstop ) THEN   ! no additional errors until this point...
-         !
-         ! find the right index of the array to be read
+             DO jl = 1, irankpv
+                WRITE( ctmp2, FMT="(', ', i1,'): ', i5,' /= icnt(', i1,'):', i5)" ) jl, ishape(jl), jl, icnt(jl)
+                IF( ishape(jl) /= icnt(jl) )   CALL ctl_stop( TRIM(clinfo), 'size(pv_r'//clrankpv//TRIM(ctmp1)//TRIM(ctmp2) )
+             END DO
+
+          ENDIF
+
+          ! read the data
+          !-     
+          IF( idvar > 0 .AND. istop == nstop ) THEN   ! no additional errors until this point...
+             !
+             ! find the right index of the array to be read
 ! JMM + SM: ugly patch before getting the new version of lib_mpp)
 !         IF( idom /= jpdom_unknown ) THEN   ;   ix1 = nldi   ;   ix2 = nlei      ;   iy1 = nldj   ;   iy2 = nlej
 !         ELSE                               ;   ix1 = 1      ;   ix2 = icnt(1)   ;   iy1 = 1      ;   iy2 = icnt(2)
 !         ENDIF
-         IF( llnoov ) THEN
-            IF( idom /= jpdom_unknown ) THEN   ;   ix1 = nldi   ;   ix2 = nlei      ;   iy1 = nldj   ;   iy2 = nlej
-            ELSE                               ;   ix1 = 1      ;   ix2 = icnt(1)   ;   iy1 = 1      ;   iy2 = icnt(2)
-            ENDIF
-         ELSE
-            IF( idom /= jpdom_unknown ) THEN   ;   ix1 = 1      ;   ix2 = nlci      ;   iy1 = 1      ;   iy2 = nlcj
-            ELSE                               ;   ix1 = 1      ;   ix2 = icnt(1)   ;   iy1 = 1      ;   iy2 = icnt(2)
-            ENDIF
-         ENDIF
+             IF( llnoov ) THEN
+                IF( idom /= jpdom_unknown ) THEN   ;   ix1 = nldi   ;   ix2 = nlei      ;   iy1 = nldj   ;   iy2 = nlej
+                ELSE                               ;   ix1 = 1      ;   ix2 = icnt(1)   ;   iy1 = 1      ;   iy2 = icnt(2)
+                ENDIF
+             ELSE
+                IF( idom /= jpdom_unknown ) THEN   ;   ix1 = 1      ;   ix2 = nlci      ;   iy1 = 1      ;   iy2 = nlcj
+                ELSE                               ;   ix1 = 1      ;   ix2 = icnt(1)   ;   iy1 = 1      ;   iy2 = icnt(2)
+                ENDIF
+             ENDIF
       
-         SELECT CASE (iom_file(kiomid)%iolib)
-         CASE (jpioipsl )   ;   CALL iom_ioipsl_get(  kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2,   &
-            &                                         pv_r1d, pv_r2d, pv_r3d )
-         CASE (jpnf90   )   ;   CALL iom_nf90_get(    kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2,   &
-            &                                         pv_r1d, pv_r2d, pv_r3d )
-         CASE (jprstdimg)   ;   CALL iom_rstdimg_get( kiomid, idom, idvar, ix1, ix2, iy1, iy2,   &
-            &                                         pv_r1d, pv_r2d, pv_r3d )
-         CASE DEFAULT    
-            CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
-         END SELECT
-
-         IF( istop == nstop ) THEN   ! no additional errors until this point...
-            IF(lwp) WRITE(numout,"(10x,' read ',a,' (rec: ',i6,') in ',a,' ok')") TRIM(cdvar), itime, TRIM(iom_file(kiomid)%name)
+             SELECT CASE (iom_file(kiomid)%iolib)
+             CASE (jpioipsl )   ;   CALL iom_ioipsl_get(  kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2,   &
+                &                                         pv_r1d, pv_r2d, pv_r3d )
+             CASE (jpnf90   )   ;   CALL iom_nf90_get(    kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2,   &
+                &                                         pv_r1d, pv_r2d, pv_r3d )
+             CASE (jprstdimg)   ;   CALL iom_rstdimg_get( kiomid, idom, idvar, ix1, ix2, iy1, iy2,   &
+                &                                         pv_r1d, pv_r2d, pv_r3d )
+             CASE DEFAULT    
+                CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+             END SELECT
+
+             IF( istop == nstop ) THEN   ! no additional errors until this point...
+                IF(lwp) WRITE(numout,"(10x,' read ',a,' (rec: ',i6,') in ',a,' ok')") TRIM(cdvar), itime, TRIM(iom_file(kiomid)%name)
           
-            !--- overlap areas and extra hallows (mpp)
-            IF(     PRESENT(pv_r2d) .AND. idom /= jpdom_unknown ) THEN
-               CALL lbc_lnk( pv_r2d,'Z',-999.,'no0' )
-            ELSEIF( PRESENT(pv_r3d) .AND. idom /= jpdom_unknown ) THEN
-               ! this if could be simplified with the new lbc_lnk that works with any size of the 3rd dimension
-               IF( icnt(3) == jpk ) THEN
-                  CALL lbc_lnk( pv_r3d,'Z',-999.,'no0' )
-               ELSE   ! put some arbitrary value (a call to lbc_lnk will be done later...)
-                  DO jj = nlcj+1, jpj   ;   pv_r3d(1:nlci, jj, :) = pv_r3d(1:nlci, nlej, :)   ;   END DO
-                  DO ji = nlci+1, jpi   ;   pv_r3d(ji    , : , :) = pv_r3d(nlei  , :   , :)   ;   END DO
-               ENDIF
-            ENDIF
-            
-            ! C1D case : always call lbc_lnk to replicate the central value over the whole 3X3 domain
-            IF( lk_c1d .AND. PRESENT(pv_r2d) )   CALL lbc_lnk( pv_r2d,'Z',1. )
-            IF( lk_c1d .AND. PRESENT(pv_r3d) )   CALL lbc_lnk( pv_r3d,'Z',1. )
-    
-            !--- Apply scale_factor and offset
-            zscf = iom_file(kiomid)%scf(idvar)      ! scale factor
-            zofs = iom_file(kiomid)%ofs(idvar)      ! offset
-            IF(     PRESENT(pv_r1d) ) THEN
-               IF( zscf /= 1. )   pv_r1d(:) = pv_r1d(:) * zscf 
-               IF( zofs /= 0. )   pv_r1d(:) = pv_r1d(:) + zofs
-            ELSEIF( PRESENT(pv_r2d) ) THEN
+                !--- overlap areas and extra hallows (mpp)
+                IF(     PRESENT(pv_r2d) .AND. idom /= jpdom_unknown ) THEN
+                   CALL lbc_lnk( pv_r2d,'Z',-999.,'no0' )
+                ELSEIF( PRESENT(pv_r3d) .AND. idom /= jpdom_unknown ) THEN
+                   ! this if could be simplified with the new lbc_lnk that works with any size of the 3rd dimension
+                   IF( icnt(3) == jpk ) THEN
+                      CALL lbc_lnk( pv_r3d,'Z',-999.,'no0' )
+                   ELSE   ! put some arbitrary value (a call to lbc_lnk will be done later...)
+                      DO jj = nlcj+1, jpj   ;   pv_r3d(1:nlci, jj, :) = pv_r3d(1:nlci, nlej, :)   ;   END DO
+                      DO ji = nlci+1, jpi   ;   pv_r3d(ji    , : , :) = pv_r3d(nlei  , :   , :)   ;   END DO
+                   ENDIF
+                ENDIF
+                !
+             ELSE
+                ! return if istop == nstop is false
+                RETURN
+             ENDIF
+          ELSE
+             ! return if statment idvar > 0 .AND. istop == nstop is false
+             RETURN
+          ENDIF
+          !
+       ELSE        ! read using XIOS. Only if KEY_IOMPUT is defined
+#if defined key_iomput
+!would be good to be able to check which context is active and swap only if current is not restart
+          CALL iom_swap( TRIM(rxios_context) ) 
+          IF( PRESENT(pv_r3d) ) THEN
+             if(lwp) write(numout,*) 'XIOS RST READ (3D): ',trim(cdvar)
+             CALL xios_recv_field( trim(cdvar), pv_r3d)
+             IF(idom /= jpdom_unknown ) then
+                 CALL lbc_lnk( pv_r3d,'Z',-999.,'no0' )
+             ENDIF
+          ELSEIF( PRESENT(pv_r2d) ) THEN
+             if(lwp) write(numout,*) 'XIOS RST READ (2D): ', trim(cdvar)
+             CALL xios_recv_field( trim(cdvar), pv_r2d)
+             IF(idom /= jpdom_unknown ) THEN
+                 CALL lbc_lnk(pv_r2d,'Z',-999.,'no0')
+             ENDIF
+          ELSEIF( PRESENT(pv_r1d) ) THEN
+             if(lwp) write(numout,*) 'XIOS RST READ (1D): ', trim(cdvar)
+             CALL xios_recv_field( trim(cdvar), pv_r1d)
+          ENDIF
+          CALL iom_swap( TRIM(cxios_context) )
+#else
+          istop = istop + 1 
+          clinfo = 'Can not use XIOS in iom_get_123d, file: '//trim(clname)//', var:'//trim(cdvar)
+#endif
+       ENDIF
+!some final adjustments
+       ! C1D case : always call lbc_lnk to replicate the central value over the whole 3X3 domain
+       IF( lk_c1d .AND. PRESENT(pv_r2d) )   CALL lbc_lnk( pv_r2d,'Z',1. )
+       IF( lk_c1d .AND. PRESENT(pv_r3d) )   CALL lbc_lnk( pv_r3d,'Z',1. )
+
+       !--- Apply scale_factor and offset
+       zscf = iom_file(kiomid)%scf(idvar)      ! scale factor
+       zofs = iom_file(kiomid)%ofs(idvar)      ! offset
+       IF(     PRESENT(pv_r1d) ) THEN
+          IF( zscf /= 1. )   pv_r1d(:) = pv_r1d(:) * zscf 
+          IF( zofs /= 0. )   pv_r1d(:) = pv_r1d(:) + zofs
+       ELSEIF( PRESENT(pv_r2d) ) THEN
 !CDIR COLLAPSE
-               IF( zscf /= 1.)   pv_r2d(:,:) = pv_r2d(:,:) * zscf
+          IF( zscf /= 1.)   pv_r2d(:,:) = pv_r2d(:,:) * zscf
 !CDIR COLLAPSE
-               IF( zofs /= 0.)   pv_r2d(:,:) = pv_r2d(:,:) + zofs
-            ELSEIF( PRESENT(pv_r3d) ) THEN
+          IF( zofs /= 0.)   pv_r2d(:,:) = pv_r2d(:,:) + zofs
+       ELSEIF( PRESENT(pv_r3d) ) THEN
 !CDIR COLLAPSE
-               IF( zscf /= 1.)   pv_r3d(:,:,:) = pv_r3d(:,:,:) * zscf
+          IF( zscf /= 1.)   pv_r3d(:,:,:) = pv_r3d(:,:,:) * zscf
 !CDIR COLLAPSE
-               IF( zofs /= 0.)   pv_r3d(:,:,:) = pv_r3d(:,:,:) + zofs
-            ENDIF
-            !
-         ENDIF
-         !
-      ENDIF
-      !
+          IF( zofs /= 0.)   pv_r3d(:,:,:) = pv_r3d(:,:,:) + zofs
+       ENDIF
    END SUBROUTINE iom_get_123d
 
@@ -1230,5 +1438,5 @@
             &    lonvalue_1D=lonvalue, latvalue_1D=latvalue, mask_1D=mask, nvertex=nvertex, bounds_lon_1D=bounds_lon,                  &
             &    bounds_lat_1D=bounds_lat, area=area, type='curvilinear')
-     ENDIF
+      ENDIF
       IF ( xios_is_valid_domaingroup(cdid) ) THEN
          CALL xios_set_domaingroup_attr( cdid, ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, jbegin=jbegin, ni=ni, nj=nj,   &
@@ -1367,5 +1575,5 @@
 
 
-   SUBROUTINE set_grid( cdgrd, plon, plat )
+   SUBROUTINE set_grid( cdgrd, plon, plat, lmask )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE set_grid  ***
@@ -1380,4 +1588,5 @@
       REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zmask
       INTEGER  :: ni,nj
+      LOGICAL :: lmask
       
       ni=nlei-nldi+1 ; nj=nlej-nldj+1
@@ -1392,5 +1601,5 @@
          &                                     latvalue = RESHAPE(plat(nldi:nlei, nldj:nlej),(/ ni*nj /)))  
 
-      IF ( ln_mskland ) THEN
+      IF ( lmask ) THEN
          ! mask land points, keep values on coast line -> specific mask for U, V and W points
          SELECT CASE ( cdgrd )
@@ -1436,5 +1645,5 @@
       ! Offset of coordinate representing bottom-left corner
       SELECT CASE ( TRIM(cdgrd) )
-         CASE ('T', 'W')
+         CASE ('T', 'W', 'N')
             icnr = -1 ; jcnr = -1
          CASE ('U')
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/IOM/iom_def.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/IOM/iom_def.F90	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/IOM/iom_def.F90	(revision 8195)
@@ -51,4 +51,8 @@
 !$AGRIF_DO_NOT_TREAT
    INTEGER, PUBLIC            ::   iom_open_init = 0   !: used to initialize iom_file(:)%nfid to 0
+!XIOS read restart   
+   LOGICAL, PUBLIC            ::   lxios_read          !: read single file restart using XIOS
+   LOGICAL, PUBLIC            ::   lxios_sini = .FALSE. ! is restart in a single file
+   LOGICAL, PUBLIC            ::   lxios_set  = .FALSE. 
 
    TYPE, PUBLIC ::   file_descriptor
@@ -70,4 +74,14 @@
    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 = 85  
+!  CHARACTER(len=30),DIMENSION(max_rst_fields), PUBLIC   :: rst_fields ! names of variables in restart file
+
+   TYPE, PUBLIC :: RST_FIELD  
+    CHARACTER(len=30) :: vname ! names of variables in restart file
+    CHARACTER(len=30) :: grid
+   END TYPE RST_FIELD
+   TYPE(RST_FIELD), PUBLIC :: rst_fields(max_rst_fields)
+
 !$AGRIF_END_DO_NOT_TREAT
 
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/IOM/iom_nf90.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/IOM/iom_nf90.F90	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/IOM/iom_nf90.F90	(revision 8195)
@@ -122,6 +122,6 @@
             CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'x', kdompar(1,1)  , idmy ), clinfo)
             CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'y', kdompar(2,1)  , idmy ), clinfo)
-            CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'z', jpk           , idmy ), clinfo)
-            CALL iom_nf90_check(NF90_DEF_DIM( if90id, 't', NF90_UNLIMITED, idmy ), clinfo)
+            CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'nav_lev', jpk           , idmy ), clinfo)
+            CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'time_counter', NF90_UNLIMITED, idmy ), clinfo)
             ! global attributes
             CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_number_total'   , jpnij              ), clinfo)
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90	(revision 8195)
@@ -26,4 +26,6 @@
    USE divcur          ! hor. divergence and curl      (div & cur routines)
    USE sbc_oce         ! for icesheet freshwater input variables
+   USE iom_def, ONLY : lxios_read, lxios_set, lxios_sini
+   USE timing
 
    IMPLICIT NONE
@@ -208,5 +210,5 @@
             WRITE(numout,*) '~~~~~~~~'
          ENDIF
-
+         lxios_sini = .FALSE.
          clpath = TRIM(cn_ocerst_indir)
          IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
@@ -218,5 +220,21 @@
          ENDIF
          CALL iom_open( TRIM(clpath)//cn_ocerst_in, numror, kiolib = jlibalt )
-      ENDIF
+! are we using XIOS to read the data? Part above will have to modified once XIOS
+! can handle checking if variable is in the restart file (there will be no need to open
+! restart)
+         IF(.NOT.lxios_set) lxios_read = lxios_read.AND.lxios_sini
+         IF( lxios_read) THEN
+         if(.NOT.lxios_set) then
+             rxios_context = 'nemo_rst'
+             call iom_init( rxios_context )
+             lxios_set = .TRUE.
+         endif
+         ENDIF
+         IF( TRIM(Agrif_CFixed()) /= '0' .AND. lxios_read) THEN
+            rxios_context = 'nemo_rst'
+            call iom_init( rxios_context )
+         ENDIF 
+      ENDIF
+
    END SUBROUTINE rst_read_open
 
@@ -232,4 +250,6 @@
       INTEGER  ::   jk
       LOGICAL  ::   llok
+      TYPE(xios_duration):: dtime
+      integer::ni,nj,nk
       !!----------------------------------------------------------------------
 
@@ -238,37 +258,37 @@
       ! Check dynamics and tracer time-step consistency and force Euler restart if changed
       IF( iom_varid( numror, 'rdt', ldstop = .FALSE. ) > 0 )   THEN
-         CALL iom_get( numror, 'rdt', zrdt )
+         CALL iom_get( numror, 'rdt', zrdt, lrxios = lxios_read )
          IF( zrdt /= rdt )   neuler = 0
       ENDIF
       IF( iom_varid( numror, 'rdttra1', ldstop = .FALSE. ) > 0 )   THEN
-         CALL iom_get( numror, 'rdttra1', zrdttra1 )
+         CALL iom_get( numror, 'rdttra1', zrdttra1, lrxios = lxios_read )
          IF( zrdttra1 /= rdttra(1) )   neuler = 0
       ENDIF
       ! 
       IF( iom_varid( numror, 'ub', ldstop = .FALSE. ) > 0 ) THEN
-         CALL iom_get( numror, jpdom_autoglo, 'ub'     , ub      )   ! before fields
-         CALL iom_get( numror, jpdom_autoglo, 'vb'     , vb      )
-         CALL iom_get( numror, jpdom_autoglo, 'tb'     , tsb(:,:,:,jp_tem) )
-         CALL iom_get( numror, jpdom_autoglo, 'sb'     , tsb(:,:,:,jp_sal) )
-         CALL iom_get( numror, jpdom_autoglo, 'rotb'   , rotb    )
-         CALL iom_get( numror, jpdom_autoglo, 'hdivb'  , hdivb   )
-         CALL iom_get( numror, jpdom_autoglo, 'sshb'   , sshb    )
+         CALL iom_get( numror, jpdom_autoglo, 'ub'     , ub, lrxios = lxios_read )   ! before fields
+         CALL iom_get( numror, jpdom_autoglo, 'vb'     , vb, lrxios = lxios_read )
+         CALL iom_get( numror, jpdom_autoglo, 'tb'     , tsb(:,:,:,jp_tem), lrxios = lxios_read )
+         CALL iom_get( numror, jpdom_autoglo, 'sb'     , tsb(:,:,:,jp_sal), lrxios = lxios_read )
+         CALL iom_get( numror, jpdom_autoglo, 'rotb'   , rotb, lrxios = lxios_read )
+         CALL iom_get( numror, jpdom_autoglo, 'hdivb'  , hdivb, lrxios = lxios_read )
+         CALL iom_get( numror, jpdom_autoglo, 'sshb'   , sshb, lrxios = lxios_read )
       ELSE
          neuler = 0
       ENDIF
       !
-      CALL iom_get( numror, jpdom_autoglo, 'un'     , un      )   ! now    fields
-      CALL iom_get( numror, jpdom_autoglo, 'vn'     , vn      )
-      CALL iom_get( numror, jpdom_autoglo, 'tn'     , tsn(:,:,:,jp_tem) )
-      CALL iom_get( numror, jpdom_autoglo, 'sn'     , tsn(:,:,:,jp_sal) )
-      CALL iom_get( numror, jpdom_autoglo, 'sshn'   , sshn    )
+      CALL iom_get( numror, jpdom_autoglo, 'un'     , un, lrxios = lxios_read )   ! now    fields
+      CALL iom_get( numror, jpdom_autoglo, 'vn'     , vn, lrxios = lxios_read )
+      CALL iom_get( numror, jpdom_autoglo, 'tn'     , tsn(:,:,:,jp_tem), lrxios = lxios_read )
+      CALL iom_get( numror, jpdom_autoglo, 'sn'     , tsn(:,:,:,jp_sal), lrxios = lxios_read )
+      CALL iom_get( numror, jpdom_autoglo, 'sshn'   , sshn, lrxios = lxios_read )
       IF( iom_varid( numror, 'rotn', ldstop = .FALSE. ) > 0 ) THEN
-         CALL iom_get( numror, jpdom_autoglo, 'rotn'   , rotn    )
-         CALL iom_get( numror, jpdom_autoglo, 'hdivn'  , hdivn   )
+         CALL iom_get( numror, jpdom_autoglo, 'rotn'   , rotn, lrxios = lxios_read )
+         CALL iom_get( numror, jpdom_autoglo, 'hdivn'  , hdivn, lrxios = lxios_read )
       ELSE
          CALL div_cur( 0 )                              ! Horizontal divergence & Relative vorticity
       ENDIF
       IF( iom_varid( numror, 'rhop', ldstop = .FALSE. ) > 0 ) THEN
-         CALL iom_get( numror, jpdom_autoglo, 'rhop'   , rhop    )   ! now    potential density
+         CALL iom_get( numror, jpdom_autoglo, 'rhop'   , rhop, lrxios = lxios_read )   ! now    potential density
       ELSE
          CALL eos    ( tsn, rhd, rhop, fsdept_n(:,:,:) )   
@@ -276,5 +296,5 @@
 #if defined key_zdfkpp
       IF( iom_varid( numror, 'rhd', ldstop = .FALSE. ) > 0 ) THEN
-         CALL iom_get( numror, jpdom_autoglo, 'rhd'    , rhd     )   ! now    in situ density anomaly
+         CALL iom_get( numror, jpdom_autoglo, 'rhd'    , rhd, lrxios = lxios_read )   ! now    in situ density anomaly
       ELSE
          CALL eos( tsn, rhd, fsdept_n(:,:,:) )   ! compute rhd
@@ -283,7 +303,7 @@
       !
       IF( iom_varid( numror, 'greenland_icesheet_mass', ldstop = .FALSE. ) > 0 )   THEN
-         CALL iom_get( numror, 'greenland_icesheet_mass', greenland_icesheet_mass )
-         CALL iom_get( numror, 'greenland_icesheet_timelapsed', greenland_icesheet_timelapsed )
-         CALL iom_get( numror, 'greenland_icesheet_mass_roc', greenland_icesheet_mass_rate_of_change )
+         CALL iom_get( numror, 'greenland_icesheet_mass', greenland_icesheet_mass, lrxios = lxios_read )
+         CALL iom_get( numror, 'greenland_icesheet_timelapsed', greenland_icesheet_timelapsed, lrxios = lxios_read )
+         CALL iom_get( numror, 'greenland_icesheet_mass_roc', greenland_icesheet_mass_rate_of_change, lrxios = lxios_read )
       ELSE
          greenland_icesheet_mass = 0.0 
@@ -292,7 +312,7 @@
       ENDIF
       IF( iom_varid( numror, 'antarctica_icesheet_mass', ldstop = .FALSE. ) > 0 )   THEN
-         CALL iom_get( numror, 'antarctica_icesheet_mass', antarctica_icesheet_mass )
-         CALL iom_get( numror, 'antarctica_icesheet_timelapsed', antarctica_icesheet_timelapsed )
-         CALL iom_get( numror, 'antarctica_icesheet_mass_roc', antarctica_icesheet_mass_rate_of_change )
+         CALL iom_get( numror, 'antarctica_icesheet_mass', antarctica_icesheet_mass, lrxios = lxios_read )
+         CALL iom_get( numror, 'antarctica_icesheet_timelapsed', antarctica_icesheet_timelapsed, lrxios = lxios_read )
+         CALL iom_get( numror, 'antarctica_icesheet_mass_roc', antarctica_icesheet_mass_rate_of_change, lrxios = lxios_read )
       ELSE
          antarctica_icesheet_mass = 0.0 
@@ -300,4 +320,5 @@
          antarctica_icesheet_timelapsed = 0.0
       ENDIF
+!     IF( nn_timing == 1 )  CALL timing_stop('iom_read')
 
       IF( neuler == 0 ) THEN                                  ! Euler restart (neuler=0)
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/SBC/sbcapr.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/SBC/sbcapr.F90	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/SBC/sbcapr.F90	(revision 8195)
@@ -68,4 +68,5 @@
       CHARACTER(len=100) ::  cn_dir   ! Root directory for location of ssr files
       TYPE(FLD_N)        ::  sn_apr   ! informations about the fields to be read
+      LOGICAL            ::  lxios_read ! read restart using XIOS?
       !!
       NAMELIST/namsbc_apr/ cn_dir, sn_apr, ln_ref_apr, rn_pref, ln_apr_obc
@@ -143,5 +144,5 @@
          IF( ln_rstart .AND. iom_varid( numror, 'ssh_ibb', ldstop = .FALSE. ) > 0 ) THEN 
             IF(lwp) WRITE(numout,*) 'sbc_apr:   ssh_ibb read in the restart file'
-            CALL iom_get( numror, jpdom_autoglo, 'ssh_ibb', ssh_ibb )   ! before inv. barometer ssh
+            CALL iom_get( numror, jpdom_autoglo, 'ssh_ibb', ssh_ibb, lrxios = lxios_read )   ! before inv. barometer ssh
             !
          ELSE                                         !* no restart: set from nit000 values
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/SBC/sbcisf.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/SBC/sbcisf.F90	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/SBC/sbcisf.F90	(revision 8195)
@@ -27,4 +27,5 @@
    USE fldread         ! read input field at current time step
    USE lib_fortran, ONLY: glob_sum
+   USE iom_def, ONLY : lxios_read
 
    IMPLICIT NONE
@@ -409,7 +410,7 @@
                  & iom_varid( numror, 'fwf_isf_b', ldstop = .FALSE. ) > 0 ) THEN
                IF(lwp) WRITE(numout,*) '          nit000-1 isf tracer content forcing fields read in the restart file'
-               CALL iom_get( numror, jpdom_autoglo, 'fwf_isf_b', fwfisf_b(:,:) )   ! before salt content isf_tsc trend
-               CALL iom_get( numror, jpdom_autoglo, 'isf_sc_b', risf_tsc_b(:,:,jp_sal) )   ! before salt content isf_tsc trend
-               CALL iom_get( numror, jpdom_autoglo, 'isf_hc_b', risf_tsc_b(:,:,jp_tem) )   ! before salt content isf_tsc trend
+               CALL iom_get( numror, jpdom_autoglo, 'fwf_isf_b', fwfisf_b(:,:), lrxios = lxios_read )   ! before salt content isf_tsc trend
+               CALL iom_get( numror, jpdom_autoglo, 'isf_sc_b', risf_tsc_b(:,:,jp_sal), lrxios = lxios_read )   ! before salt content isf_tsc trend
+               CALL iom_get( numror, jpdom_autoglo, 'isf_hc_b', risf_tsc_b(:,:,jp_tem), lrxios = lxios_read )   ! before salt content isf_tsc trend
             ELSE
                fwfisf_b(:,:)    = fwfisf(:,:)
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 8195)
@@ -54,4 +54,5 @@
    USE sbcwave          ! Wave module
    USE bdy_par          ! Require lk_bdy
+   USE iom_def, ONLY : lxios_read
 
    IMPLICIT NONE
@@ -420,13 +421,13 @@
             & iom_varid( numror, 'utau_b', ldstop = .FALSE. ) > 0 ) THEN 
             IF(lwp) WRITE(numout,*) '          nit000-1 surface forcing fields red in the restart file'
-            CALL iom_get( numror, jpdom_autoglo, 'utau_b', utau_b )   ! before i-stress  (U-point)
-            CALL iom_get( numror, jpdom_autoglo, 'vtau_b', vtau_b )   ! before j-stress  (V-point)
-            CALL iom_get( numror, jpdom_autoglo, 'qns_b' , qns_b  )   ! before non solar heat flux (T-point)
+            CALL iom_get( numror, jpdom_autoglo, 'utau_b', utau_b, lrxios = lxios_read )   ! before i-stress  (U-point)
+            CALL iom_get( numror, jpdom_autoglo, 'vtau_b', vtau_b, lrxios = lxios_read )   ! before j-stress  (V-point)
+            CALL iom_get( numror, jpdom_autoglo, 'qns_b' , qns_b, lrxios = lxios_read  )   ! before non solar heat flux (T-point)
             ! The 3D heat content due to qsr forcing is treated in traqsr
-            ! CALL iom_get( numror, jpdom_autoglo, 'qsr_b' , qsr_b  ) ! before     solar heat flux (T-point)
-            CALL iom_get( numror, jpdom_autoglo, 'emp_b', emp_b  )    ! before     freshwater flux (T-point)
+            ! CALL iom_get( numror, jpdom_autoglo, 'qsr_b' , qsr_b, lrxios = lxios_read  ) ! before     solar heat flux (T-point)
+            CALL iom_get( numror, jpdom_autoglo, 'emp_b', emp_b, lrxios = lxios_read  )    ! before     freshwater flux (T-point)
             ! To ensure restart capability with 3.3x/3.4 restart files    !! to be removed in v3.6
             IF( iom_varid( numror, 'sfx_b', ldstop = .FALSE. ) > 0 ) THEN
-               CALL iom_get( numror, jpdom_autoglo, 'sfx_b', sfx_b )  ! before salt flux (T-point)
+               CALL iom_get( numror, jpdom_autoglo, 'sfx_b', sfx_b, lrxios = lxios_read )  ! before salt flux (T-point)
             ELSE
                sfx_b (:,:) = sfx(:,:)
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/SBC/sbcrnf.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/SBC/sbcrnf.F90	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/SBC/sbcrnf.F90	(revision 8195)
@@ -27,4 +27,5 @@
    USE eosbn2
    USE wrk_nemo        ! Memory allocation
+   USE iom_def, ONLY : lxios_read
 
    IMPLICIT NONE
@@ -147,7 +148,7 @@
             & iom_varid( numror, 'rnf_b', ldstop = .FALSE. ) > 0 ) THEN
             IF(lwp) WRITE(numout,*) '          nit000-1 runoff forcing fields red in the restart file'
-            CALL iom_get( numror, jpdom_autoglo, 'rnf_b', rnf_b )     ! before runoff
-            CALL iom_get( numror, jpdom_autoglo, 'rnf_hc_b', rnf_tsc_b(:,:,jp_tem) )   ! before heat content of runoff
-            CALL iom_get( numror, jpdom_autoglo, 'rnf_sc_b', rnf_tsc_b(:,:,jp_sal) )   ! before salinity content of runoff
+            CALL iom_get( numror, jpdom_autoglo, 'rnf_b', rnf_b, lrxios = lxios_read )     ! before runoff
+            CALL iom_get( numror, jpdom_autoglo, 'rnf_hc_b', rnf_tsc_b(:,:,jp_tem), lrxios = lxios_read )   ! before heat content of runoff
+            CALL iom_get( numror, jpdom_autoglo, 'rnf_sc_b', rnf_tsc_b(:,:,jp_sal), lrxios = lxios_read )   ! before salinity content of runoff
          ELSE                                                   !* no restart: set from nit000 values
             IF(lwp) WRITE(numout,*) '          nit000-1 runoff forcing fields set to nit000'
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/SBC/sbcssm.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/SBC/sbcssm.F90	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/SBC/sbcssm.F90	(revision 8195)
@@ -21,4 +21,5 @@
    USE prtctl          ! Print control
    USE iom             ! IOM library
+   USE iom_def, ONLY : lxios_read
 
    IMPLICIT NONE
@@ -206,14 +207,14 @@
          IF( ln_rstart .AND. iom_varid( numror, 'nn_fsbc', ldstop = .FALSE. ) > 0 ) THEN
             l_ssm_mean = .TRUE.
-            CALL iom_get( numror               , 'nn_fsbc', zf_sbc )   ! sbc frequency of previous run
-            CALL iom_get( numror, jpdom_autoglo, 'ssu_m'  , ssu_m  )   ! sea surface mean velocity    (T-point)
-            CALL iom_get( numror, jpdom_autoglo, 'ssv_m'  , ssv_m  )   !   "         "    velocity    (V-point)
-            CALL iom_get( numror, jpdom_autoglo, 'sst_m'  , sst_m  )   !   "         "    temperature (T-point)
-            CALL iom_get( numror, jpdom_autoglo, 'sss_m'  , sss_m  )   !   "         "    salinity    (T-point)
-            CALL iom_get( numror, jpdom_autoglo, 'ssh_m'  , ssh_m  )   !   "         "    height      (T-point)
-            IF( lk_vvl ) CALL iom_get( numror, jpdom_autoglo, 'e3t_m', e3t_m )
+            CALL iom_get( numror               , 'nn_fsbc', zf_sbc, lrxios = lxios_read )   ! sbc frequency of previous run
+            CALL iom_get( numror, jpdom_autoglo, 'ssu_m'  , ssu_m, lrxios = lxios_read  )   ! sea surface mean velocity    (T-point)
+            CALL iom_get( numror, jpdom_autoglo, 'ssv_m'  , ssv_m, lrxios = lxios_read  )   !   "         "    velocity    (V-point)
+            CALL iom_get( numror, jpdom_autoglo, 'sst_m'  , sst_m, lrxios = lxios_read  )   !   "         "    temperature (T-point)
+            CALL iom_get( numror, jpdom_autoglo, 'sss_m'  , sss_m, lrxios = lxios_read  )   !   "         "    salinity    (T-point)
+            CALL iom_get( numror, jpdom_autoglo, 'ssh_m'  , ssh_m, lrxios = lxios_read  )   !   "         "    height      (T-point)
+            IF( lk_vvl ) CALL iom_get( numror, jpdom_autoglo, 'e3t_m', e3t_m, lrxios = lxios_read )
             ! fraction of solar net radiation absorbed in 1st T level
             IF( iom_varid( numror, 'frq_m', ldstop = .FALSE. ) > 0 ) THEN
-               CALL iom_get( numror, jpdom_autoglo, 'frq_m'  , frq_m  )
+               CALL iom_get( numror, jpdom_autoglo, 'frq_m'  , frq_m, lrxios = lxios_read  )
             ELSE
                frq_m(:,:) = 1._wp   ! default definition
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_iso.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_iso.F90	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_iso.F90	(revision 8195)
@@ -355,4 +355,6 @@
          CALL trd_tra( kt, cdtype, jp_sal, jptra_iso_z1, ztraz )    !
       ENDIF
+      DEALLOCATE( ztrax, ztray, ztraz ) 
+      IF( l_trdtra  .and. cdtype == 'TRA' ) DEALLOCATE( ztrax_T, ztray_T, ztraz_T ) 
       !
       DEALLOCATE( z2d ) 
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/TRA/traqsr.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/TRA/traqsr.F90	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/TRA/traqsr.F90	(revision 8195)
@@ -33,5 +33,5 @@
    USE wrk_nemo       ! Memory Allocation
    USE timing         ! Timing
-
+   USE iom_def, ONLY : lxios_read
    IMPLICIT NONE
    PRIVATE
@@ -137,5 +137,5 @@
             IF(lwp) WRITE(numout,*) '          nit000-1 qsr tracer content forcing field red in the restart file'
             zfact = 0.5e0
-            CALL iom_get( numror, jpdom_autoglo, 'qsr_hc_b', qsr_hc_b )   ! before heat content trend due to Qsr flux
+            CALL iom_get( numror, jpdom_autoglo, 'qsr_hc_b', qsr_hc_b, lrxios = lxios_read )   ! before heat content trend due to Qsr flux
          ELSE                                           ! No restart or restart not found: Euler forward time stepping
             zfact = 1.e0
@@ -607,5 +607,5 @@
       ! initialisation of fraqsr_1lev used in sbcssm
       IF( iom_varid( numror, 'fraqsr_1lev', ldstop = .FALSE. ) > 0 ) THEN
-         CALL iom_get( numror, jpdom_autoglo, 'fraqsr_1lev'  , fraqsr_1lev  )
+         CALL iom_get( numror, jpdom_autoglo, 'fraqsr_1lev'  , fraqsr_1lev, lrxios = lxios_read  )
       ELSE
          fraqsr_1lev(:,:) = 1._wp   ! default definition
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/TRA/trasbc.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/TRA/trasbc.F90	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/TRA/trasbc.F90	(revision 8195)
@@ -33,4 +33,5 @@
    USE timing          ! Timing
    USE eosbn2
+   USE iom_def, ONLY : lxios_read
 
    IMPLICIT NONE
@@ -154,6 +155,6 @@
             IF(lwp) WRITE(numout,*) '          nit000-1 surface tracer content forcing fields red in the restart file'
             zfact = 0.5_wp
-            CALL iom_get( numror, jpdom_autoglo, 'sbc_hc_b', sbc_tsc_b(:,:,jp_tem) )   ! before heat content sbc trend
-            CALL iom_get( numror, jpdom_autoglo, 'sbc_sc_b', sbc_tsc_b(:,:,jp_sal) )   ! before salt content sbc trend
+            CALL iom_get( numror, jpdom_autoglo, 'sbc_hc_b', sbc_tsc_b(:,:,jp_tem), lrxios = lxios_read )   ! before heat content sbc trend
+            CALL iom_get( numror, jpdom_autoglo, 'sbc_sc_b', sbc_tsc_b(:,:,jp_sal), lrxios = lxios_read )   ! before salt content sbc trend
          ELSE                                         ! No restart or restart not found: Euler forward time stepping
             zfact = 1._wp
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/TRD/trdmxl_rst.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/TRD/trdmxl_rst.F90	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/TRD/trdmxl_rst.F90	(revision 8195)
@@ -161,18 +161,18 @@
       IF( ln_trdmxl_instant ) THEN 
          !-- Temperature
-         CALL iom_get( inum, jpdom_autoglo, 'tmlbb'           , tmlbb          )
-         CALL iom_get( inum, jpdom_autoglo, 'tmlbn'           , tmlbn          )
-         CALL iom_get( inum, jpdom_autoglo, 'tmlatfb'         , tmlatfb        )
-         !
-         !-- Salinity
-         CALL iom_get( inum, jpdom_autoglo, 'smlbb'           , smlbb          )
-         CALL iom_get( inum, jpdom_autoglo, 'smlbn'           , smlbn          )
-         CALL iom_get( inum, jpdom_autoglo, 'smlatfb'         , smlatfb        )
+         CALL iom_get( inum, jpdom_autoglo, 'tmlbb'           , tmlbb )
+         CALL iom_get( inum, jpdom_autoglo, 'tmlbn'           , tmlbn )
+         CALL iom_get( inum, jpdom_autoglo, 'tmlatfb'         , tmlatfb )
+         !
+         !-- Salinity
+         CALL iom_get( inum, jpdom_autoglo, 'smlbb'           , smlbb )
+         CALL iom_get( inum, jpdom_autoglo, 'smlbn'           , smlbn )
+         CALL iom_get( inum, jpdom_autoglo, 'smlatfb'         , smlatfb )
       ELSE
-         CALL iom_get( inum, jpdom_autoglo, 'hmxlbn'          , hmxlbn         ) ! needed for hmxl_sum
-         !
-         !-- Temperature
-         CALL iom_get( inum, jpdom_autoglo, 'tmlbn'           , tmlbn          ) ! needed for tml_sum
-         CALL iom_get( inum, jpdom_autoglo, 'tml_sumb'        , tml_sumb       )
+         CALL iom_get( inum, jpdom_autoglo, 'hmxlbn'          , hmxlbn ) ! needed for hmxl_sum
+         !
+         !-- Temperature
+         CALL iom_get( inum, jpdom_autoglo, 'tmlbn'           , tmlbn ) ! needed for tml_sum
+         CALL iom_get( inum, jpdom_autoglo, 'tml_sumb'        , tml_sumb )
          DO jk = 1, jpltrd
             IF( jk < 10 ) THEN   ;   WRITE(charout,FMT="('tmltrd_csum_ub_', I1)")   jk
@@ -184,6 +184,6 @@
          !
          !-- Salinity
-         CALL iom_get( inum, jpdom_autoglo, 'smlbn'           , smlbn          ) ! needed for sml_sum
-         CALL iom_get( inum, jpdom_autoglo, 'sml_sumb'        , sml_sumb       )
+         CALL iom_get( inum, jpdom_autoglo, 'smlbn'           , smlbn ) ! needed for sml_sum
+         CALL iom_get( inum, jpdom_autoglo, 'sml_sumb'        , sml_sumb )
          DO jk = 1, jpltrd
             IF( jk < 10 ) THEN   ;   WRITE(charout,FMT="('smltrd_csum_ub_', I1)")   jk
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfgls.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfgls.F90	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfgls.F90	(revision 8195)
@@ -32,4 +32,5 @@
    USE timing         ! Timing
    USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)  
+   USE iom_def, ONLY : lxios_read
 
    IMPLICIT NONE
@@ -1184,10 +1185,10 @@
             !
             IF( MIN( id1, id2, id3, id4, id5, id6 ) > 0 ) THEN        ! all required arrays exist
-               CALL iom_get( numror, jpdom_autoglo, 'en'    , en     )
-               CALL iom_get( numror, jpdom_autoglo, 'avt'   , avt    )
-               CALL iom_get( numror, jpdom_autoglo, 'avm'   , avm    )
-               CALL iom_get( numror, jpdom_autoglo, 'avmu'  , avmu   )
-               CALL iom_get( numror, jpdom_autoglo, 'avmv'  , avmv   )
-               CALL iom_get( numror, jpdom_autoglo, 'mxln'  , mxln   )
+               CALL iom_get( numror, jpdom_autoglo, 'en'    , en, lrxios = lxios_read     )
+               CALL iom_get( numror, jpdom_autoglo, 'avt'   , avt, lrxios = lxios_read    )
+               CALL iom_get( numror, jpdom_autoglo, 'avm'   , avm, lrxios = lxios_read    )
+               CALL iom_get( numror, jpdom_autoglo, 'avmu'  , avmu, lrxios = lxios_read   )
+               CALL iom_get( numror, jpdom_autoglo, 'avmv'  , avmv, lrxios = lxios_read   )
+               CALL iom_get( numror, jpdom_autoglo, 'mxln'  , mxln, lrxios = lxios_read   )
             ELSE                        
                IF(lwp) WRITE(numout,*) ' ===>>>> : previous run without gls scheme, en and mxln computed by iterative loop'
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfini.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfini.F90	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfini.F90	(revision 8195)
@@ -29,4 +29,5 @@
    USE in_out_manager  ! I/O manager
    USE iom             ! IOM library
+   USE iom_def, ONLY : lxios_read
 
    IMPLICIT NONE
@@ -170,6 +171,6 @@
          ! file in traadv_cen2 end read here. 
          IF( iom_varid( numror, 'avmb', ldstop = .FALSE. ) > 0 ) THEN
-            CALL iom_get( numror, jpdom_unknown, 'avmb', avmb )
-            CALL iom_get( numror, jpdom_unknown, 'avtb', avtb )
+            CALL iom_get( numror, jpdom_unknown, 'avmb', avmb, lrxios = lxios_read )
+            CALL iom_get( numror, jpdom_unknown, 'avtb', avtb, lrxios = lxios_read )
          ENDIF
       ENDIF
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftke.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftke.F90	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftke.F90	(revision 8195)
@@ -57,4 +57,5 @@
    USE agrif_opa_update
 #endif
+   USE iom_def, ONLY : lxios_read
 
 
@@ -935,11 +936,11 @@
            !
            IF( id1 > 0 ) THEN                       ! 'en' exists
-              CALL iom_get( numror, jpdom_autoglo, 'en', en )
+              CALL iom_get( numror, jpdom_autoglo, 'en', en, lrxios = lxios_read )
               IF( MIN( id2, id3, id4, id5, id6 ) > 0 ) THEN        ! all required arrays exist
-                 CALL iom_get( numror, jpdom_autoglo, 'avt'  , avt   )
-                 CALL iom_get( numror, jpdom_autoglo, 'avm'  , avm   )
-                 CALL iom_get( numror, jpdom_autoglo, 'avmu' , avmu  )
-                 CALL iom_get( numror, jpdom_autoglo, 'avmv' , avmv  )
-                 CALL iom_get( numror, jpdom_autoglo, 'dissl', dissl )
+                 CALL iom_get( numror, jpdom_autoglo, 'avt'  , avt, lrxios = lxios_read   )
+                 CALL iom_get( numror, jpdom_autoglo, 'avm'  , avm, lrxios = lxios_read   )
+                 CALL iom_get( numror, jpdom_autoglo, 'avmu' , avmu, lrxios = lxios_read  )
+                 CALL iom_get( numror, jpdom_autoglo, 'avmv' , avmv, lrxios = lxios_read  )
+                 CALL iom_get( numror, jpdom_autoglo, 'dissl', dissl, lrxios = lxios_read )
               ELSE                                                 ! one at least array is missing
                  CALL tke_avn                                          ! compute avt, avm, avmu, avmv and dissl (approximation)
Index: branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/step.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/step.F90	(revision 8194)
+++ branches/UKMO/dev_r5518_GO6_package_fix_rnf_MOCI_TEST_SUITE/NEMOGCM/NEMO/OPA_SRC/step.F90	(revision 8195)
@@ -385,4 +385,5 @@
       IF( kstp == nitend .OR. indic < 0 ) THEN 
                       CALL iom_context_finalize(      cxios_context          ) ! needed for XIOS+AGRIF
+                      CALL iom_context_finalize(      rxios_context          )
          IF( ln_crs ) CALL iom_context_finalize( trim(cxios_context)//"_crs" ) ! 
       ENDIF
