Index: branches/UKMO/test_moci_test_suite/NEMOGCM/NEMO/OPA_SRC/IOM/in_out_manager.F90
===================================================================
--- branches/UKMO/test_moci_test_suite/NEMOGCM/NEMO/OPA_SRC/IOM/in_out_manager.F90	(revision 8221)
+++ branches/UKMO/test_moci_test_suite/NEMOGCM/NEMO/OPA_SRC/IOM/in_out_manager.F90	(revision 8243)
@@ -50,4 +50,5 @@
    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
+   INTEGER       ::   nn_wxios         !: write resart using xios 0 - no, 1 - single, 2 - multiple file output
 #if defined key_netcdf4
    !!----------------------------------------------------------------------
@@ -153,5 +154,6 @@
    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
+   CHARACTER(lc) ::   rxios_context = "nemo_rst"  !: context name used in xios to read restart
+   CHARACTER(lc) ::   wxios_context = "nemo_rstw" !: context name used in xios to write restart file
 
    !!----------------------------------------------------------------------
Index: branches/UKMO/test_moci_test_suite/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90
===================================================================
--- branches/UKMO/test_moci_test_suite/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 8221)
+++ branches/UKMO/test_moci_test_suite/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 8243)
@@ -41,13 +41,16 @@
    USE dianam          ! build name of file
    USE xios
-   USE iom_def, ONLY : max_rst_fields, rst_fields
+   USE iom_def, ONLY : max_rst_fields, rst_fields, wxioso
 # endif
    USE ioipsl, ONLY :  ju2ymds    ! for calendar
    USE crs             ! Grid coarsening
-   USE lib_fortran 
+   USE sbc_oce, ONLY : lk_oasis, ln_coupled_iceshelf_fluxes, ln_apr_dyn, ln_rnf, nn_components, jp_iam_sas
+   USE diadct, ONLY : lk_diadct
 
    IMPLICIT NONE
+   !  values needed to set correctlyfiles in reast file when using XIOS for writing
+   LOGICAL, PUBLIC :: lr_vvl_ztilde, lr_vvl_layer, lr_traadv_cen2
+
    PUBLIC   !   must be public to be able to access iom_def through iom
-   
 #if defined key_iomput
    LOGICAL, PUBLIC, PARAMETER ::   lk_iomput = .TRUE.        !: iom_put flag
@@ -55,4 +58,5 @@
    LOGICAL, PUBLIC, PARAMETER ::   lk_iomput = .FALSE.       !: iom_put flag
 #endif
+
    PUBLIC iom_init, iom_swap, iom_open, iom_close, iom_setkt, iom_varid, iom_get, iom_gettime, iom_rstput, iom_put
    PUBLIC iom_getatt, iom_use, iom_context_finalize
@@ -64,5 +68,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
+   PRIVATE set_rst_vars, set_rstr_active, set_rstw_active
 # endif
 
@@ -88,5 +92,5 @@
 CONTAINS
 
-   SUBROUTINE iom_init( cdname ) 
+   SUBROUTINE iom_init( cdname, filename, it ) 
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE   ***
@@ -108,4 +112,7 @@
       !
       REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: z_bnds
+      CHARACTER(len=*), OPTIONAL, INTENT(in)  :: filename 
+      LOGICAL :: lrst_context              ! is context related to restart
+      INTEGER, OPTIONAL :: it              ! timestep when subroutine was called
       !!----------------------------------------------------------------------
 #if ! defined key_xios2
@@ -119,4 +126,5 @@
       CALL xios_context_initialize(TRIM(clname), mpi_comm_opa)
       CALL iom_swap( cdname )
+      lrst_context =  (TRIM(cdname) == TRIM(wxios_context)).OR.(TRIM(cdname) == TRIM(rxios_context))
 
       ! calendar parameters
@@ -145,5 +153,5 @@
       CALL set_scalar
 
-      IF( TRIM(cdname) == TRIM(cxios_context) .OR. TRIM(cdname) == TRIM(rxios_context)) THEN  
+      IF( TRIM(cdname) == TRIM(cxios_context) ) THEN  
          CALL set_grid( "T", glamt, gphit, ln_mskland ) 
          CALL set_grid( "U", glamu, gphiu, ln_mskland )
@@ -151,7 +159,6 @@
          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 .AND. TRIM(cdname) .NE. TRIM(rxios_context)) THEN   ! Add additional grid metadata
+         IF( ln_cfmeta ) 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))
@@ -164,4 +171,6 @@
          ENDIF
       ENDIF
+
+     IF( lrst_context )  CALL set_grid("N",glamt, gphit, .FALSE.)        ! not masked values
 
       IF( TRIM(cdname) == TRIM(cxios_context)//"_crs" ) THEN  
@@ -176,5 +185,5 @@
          CALL dom_grid_glo   ! Return to parent grid domain
          !
-         IF( ln_cfmeta .AND. TRIM(cdname) .NE. TRIM(rxios_context)) THEN   ! Add additional grid metadata
+         IF( ln_cfmeta .AND. .NOT.lrst_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))
@@ -188,36 +197,37 @@
       ENDIF
 
-      ! vertical grid definition
-      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 )
-
+          ! vertical grid definition
+          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 )
+
+      IF(.NOT.lrst_context) THEN
       ! Add vertical grid bounds
 #if ! defined key_xios2
-      z_bnds(:      ,1) = gdepw_1d(:)
-      z_bnds(1:jpkm1,2) = gdepw_1d(2:jpk)
-      z_bnds(jpk:   ,2) = gdepw_1d(jpk) + e3t_1d(jpk)
-#else
-      z_bnds(1      ,:) = gdepw_1d(:)
-      z_bnds(2,1:jpkm1) = gdepw_1d(2:jpk)
-      z_bnds(2,jpk:   ) = gdepw_1d(jpk) + e3t_1d(jpk)
-#endif
-
-      CALL iom_set_axis_attr( "deptht", bounds=z_bnds )
-      CALL iom_set_axis_attr( "depthu", bounds=z_bnds )
-      CALL iom_set_axis_attr( "depthv", bounds=z_bnds )
+          z_bnds(:      ,1) = gdepw_1d(:)
+          z_bnds(1:jpkm1,2) = gdepw_1d(2:jpk)
+          z_bnds(jpk:   ,2) = gdepw_1d(jpk) + e3t_1d(jpk)
+#else
+          z_bnds(1      ,:) = gdepw_1d(:)
+          z_bnds(2,1:jpkm1) = gdepw_1d(2:jpk)
+          z_bnds(2,jpk:   ) = gdepw_1d(jpk) + e3t_1d(jpk)
+#endif
+
+          CALL iom_set_axis_attr( "deptht", bounds=z_bnds )
+          CALL iom_set_axis_attr( "depthu", bounds=z_bnds )
+          CALL iom_set_axis_attr( "depthv", bounds=z_bnds )
 
 #if ! defined key_xios2
-      z_bnds(:    ,2)  = gdept_1d(:)
-      z_bnds(2:jpk,1)  = gdept_1d(1:jpkm1)
-      z_bnds(1    ,1)  = gdept_1d(1) - e3w_1d(1)
-#else
-      z_bnds(2,:    )  = gdept_1d(:)
-      z_bnds(1,2:jpk)  = gdept_1d(1:jpkm1)
-      z_bnds(1,1    )  = gdept_1d(1) - e3w_1d(1)
-#endif
-      CALL iom_set_axis_attr( "depthw", bounds=z_bnds )
-
+          z_bnds(:    ,2)  = gdept_1d(:)
+          z_bnds(2:jpk,1)  = gdept_1d(1:jpkm1)
+          z_bnds(1    ,1)  = gdept_1d(1) - e3w_1d(1)
+#else
+          z_bnds(2,:    )  = gdept_1d(:)
+          z_bnds(1,2:jpk)  = gdept_1d(1:jpkm1)
+          z_bnds(1,1    )  = gdept_1d(1) - e3w_1d(1)
+#endif
+          CALL iom_set_axis_attr( "depthw", bounds=z_bnds )
+      ENDIF
 
 # if defined key_floats
@@ -237,4 +247,9 @@
 !set which fields are to be read from restart file
        CALL set_rstr_active()
+      ELSE IF ( TRIM(cdname) == TRIM(wxios_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_rstw_active(filename, it)
       ELSE
        CALL set_xmlatt
@@ -255,5 +270,4 @@
 
    END SUBROUTINE iom_init
-
    
    SUBROUTINE set_rst_vars()
@@ -370,7 +384,7 @@
         IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
         IF( TRIM(Agrif_CFixed()) == '0' ) THEN
-           rst_file = TRIM(cn_ocerst_indir)//TRIM(cn_ocerst_in)
+           rst_file = TRIM(clpath)//TRIM(cn_ocerst_in)
         ELSE
-           rst_file = TRIM(cn_ocerst_indir)//'1_'//TRIM(cn_ocerst_in)
+           rst_file = TRIM(clpath)//'1_'//TRIM(cn_ocerst_in)
         ENDIF
 !set name of the restart file and enable available fields
@@ -394,4 +408,261 @@
 #endif
    END SUBROUTINE set_rstr_active
+
+   SUBROUTINE set_rstw_active(rst_file, it)
+!sets enabled = .TRUE. for each field in restart file
+#if defined key_xios2
+   CHARACTER(len=*) :: rst_file
+   INTEGER, INTENT(in) :: it ! timestep when iom_init was called
+   TYPE(xios_field) :: field_hdl
+   TYPE(xios_file) :: file_hdl
+   TYPE(xios_filegroup) :: filegroup_hdl
+   INTEGER :: i
+
+!set then name of the restart file (OUTPUT!) and enable available fields
+        if(lwp) WRITE(numout,*) 'Setting (output) restart filename (for XIOS) to: ',TRIM(rst_file)
+        CALL xios_get_handle("file_definition", filegroup_hdl )
+        CALL xios_add_child(filegroup_hdl, file_hdl, 'wrestart')
+        IF(wxioso.eq.1) THEN
+            CALL xios_set_file_attr( "wrestart", type="one_file", name = TRIM(rst_file), &
+               enabled=.TRUE., mode="write", output_freq=xios_timestep)
+            if(lwp) write(numout,*) 'OPEN ', trim(rst_file), ' in one_file mode'
+        ELSE 
+            CALL xios_set_file_attr( "wrestart", type="multiple_file", name = TRIM(rst_file),&
+               enabled=.TRUE., mode="write", output_freq=xios_timestep)
+          if(lwp) write(numout,*) 'OPEN ', trim(rst_file), ' in multiple_file mode'
+        ENDIF
+
+        CALL xios_set_file_attr( "wrestart", name=trim(rst_file))
+        call flush(numout) 
+!      CALL xios_update_calendar(it+1)       ! + one because we open restart file 
+                                              ! 1 timestep before write
+
+!define fields for restart write context
+!in restart.F90
+        DO i= 1, 17
+           CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+           CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+           if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+        ENDDO
+!in daymod.F90
+        DO i= 18, 20
+                      CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+           CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+           if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+        ENDDO
+!end daymod.F90
+!sbcmod.F90
+        DO i= 21, 25
+           CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+           CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+           if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+        ENDDO
+!end sbcmod.F90
+!ALL FIELDS ABOUVE ALWAYS
+!zdftke.F90
+#if defined key_zdftke   ||   defined key_esopa
+        DO i= 26, 31
+           CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+           CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+           if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+        ENDDO
+#endif
+!end zdftke.F90
+!traqsr.F90
+       i = 34
+       CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+       CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")        
+       if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+       i = 37
+       CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+       CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")        
+       if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+!END traqsr.F90
+#if defined key_dynspg_flt   ||   defined key_esopa 
+!dynspg_flt.F90
+        DO i= 35, 36
+           CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+           CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+           if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+        ENDDO
+!end dynspg_flt.F90
+#endif
+!trasbc.F90 START
+        DO i= 32, 33
+           CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+           CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+           if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+        ENDDO
+        DO i= 69, 71
+           CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+           CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+           if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+        ENDDO
+!trasbc.F90 END
+        IF( lk_oasis) THEN
+        ! ln_coupled_iceshelf_fluxes uninitialised unless lk_oasis=true
+          IF( ln_coupled_iceshelf_fluxes ) THEN
+             DO i= 38, 43
+                CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+                CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+                if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+             ENDDO
+          ENDIF
+        ENDIF
+#if defined key_zdfkpp
+        i = 44
+        CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+        CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+             grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+        if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+#endif
+!dia_hsb_rst
+#if defined key_diadct
+        IF( lk_diadct     ) THEN
+             DO i= 45, 47
+                CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+                CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+                if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+             ENDDO
+
+             DO i= 50, 53
+                CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+                CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+                if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+             ENDDO
+             IF( .NOT. lk_vvl ) THEN
+             DO i= 48, 48
+                CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+                CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+                if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+             ENDDO
+             DO i= 54, 55
+                CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+                CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+                if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+             ENDDO
+             ENDIF
+        ENDIF
+#endif
+!end dia_hsb_rst
+!domvvl.F90
+        IF( lk_vvl ) THEN
+             DO i= 56, 57
+                CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+                CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+                if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+             ENDDO
+           IF( lr_vvl_ztilde .OR. lr_vvl_layer ) THEN  ! z_tilde and layer cases !
+             DO i= 58, 59
+                CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+                CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+                if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+             ENDDO
+            END IF
+            IF( lr_vvl_ztilde ) THEN                    ! z_tilde case !
+            i=60
+            CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+            CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+            if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+            ENDIF
+         ENDIF
+!end domvvl.F90
+!dynspg_ts.F90
+#if defined key_dynspg_ts   ||   defined key_esopa
+         DO i= 61, 62
+            CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+            CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                 grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+            if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+         ENDDO
+         IF (.NOT.ln_bt_av) THEN
+            DO i= 63, 68
+               CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+               CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                    grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+               if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+            ENDDO
+         ENDIF
+#if defined key_agrif
+         ! Save time integrated fluxes
+         IF ( .NOT.Agrif_Root() ) THEN
+            DO i= 84, 85
+               CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+               CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                    grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+               if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+            ENDDO
+         ENDIF
+#endif
+#endif
+!end dynspg_ts.F90
+!sbcapr.F90
+          IF( ln_apr_dyn) THEN
+             i = 72
+             CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+             if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+          ENDIF
+!end sbcapr.F90
+!sbcrnf.F90
+        IF( ln_rnf      ) THEN
+             DO i= 73, 75
+                CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+                CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+                if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+             ENDDO
+        ENDIF 
+!end sbcrnf.F90
+!sbcssm.F90
+        IF( nn_components /= jp_iam_sas .AND. nn_fsbc .NE. 1) THEN
+             DO i= 76, 81
+                CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+                CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+                if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+             ENDDO
+             i = 83
+             CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+             CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+             if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+             IF( lk_vvl )  THEN
+                i = 82
+                CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+                CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+                if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+             ENDIF 
+        ENDIF
+!end sbcssm.F90
+       IF( lr_traadv_cen2   ) THEN
+            DO i= 84, 85
+                CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname))
+                CALL xios_set_attr (field_hdl, enabled = .TRUE., prec = 8,           &
+                     grid_ref = TRIM(rst_fields(i)%grid ), operation = "instant")
+                if(lwp) write(numout,*) 'id= ',i,' set ', TRIM(rst_fields(i)%vname), ' enabled'
+             ENDDO
+       ENDIF
+#endif
+   END SUBROUTINE set_rstw_active
 
    SUBROUTINE iom_swap( cdname )
@@ -510,5 +781,7 @@
       ! try to find if the file to be opened already exist
       ! =============
-      INQUIRE( FILE = clname, EXIST = llok )
+      lxios_sini = .TRUE.
+      if(lwm) INQUIRE( FILE = clname, EXIST = llok )
+      IF(lk_mpp) CALL mpp_bcast(llok)
       IF( .NOT.llok ) THEN
          ! we try to add the cpu number to the name
@@ -528,6 +801,5 @@
             icnt = icnt + 1
          END DO
-      ELSE
-         lxios_sini = .TRUE.
+         lxios_sini = .FALSE.
       ENDIF
       IF( llwrt ) THEN
@@ -1263,5 +1535,5 @@
    !!                   INTERFACE iom_rstput
    !!----------------------------------------------------------------------
-   SUBROUTINE iom_rp0d( kt, kwrite, kiomid, cdvar, pvar, ktype )
+   SUBROUTINE iom_rp0d( kt, kwrite, kiomid, cdvar, pvar, ktype, lxios )
       INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
       INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
@@ -1270,20 +1542,34 @@
       REAL(wp)        , INTENT(in)                         ::   pvar     ! written field
       INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
+      LOGICAL, OPTIONAL :: lxios   ! xios write flag
+      LOGICAL :: lx                ! local xios write flag
       INTEGER :: ivid   ! variable id
-      IF( kiomid > 0 ) THEN
-         IF( iom_file(kiomid)%nfid > 0 ) THEN
-            ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
-            SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpioipsl )   ;   CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r0d = pvar )
-            CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r0d = pvar )
-            CASE (jprstdimg)   ;   IF( kt == kwrite )    CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pvar )
-            CASE DEFAULT     
-               CALL ctl_stop( 'iom_rp0d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
-            END SELECT
+
+      lx = .FALSE.
+      IF(PRESENT(lxios)) lx = lxios
+      IF( lx ) THEN
+#ifdef key_iomput
+       IF( kt == kwrite ) THEN
+          IF(lwp) write(numout,*) 'RESTART: write (XIOS 0D) ',trim(cdvar)
+          CALL xios_send_field(trim(cdvar), pvar)
+       ENDIF
+#endif
+      ELSE
+         IF( kiomid > 0 ) THEN
+            IF( iom_file(kiomid)%nfid > 0 ) THEN
+               ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
+               SELECT CASE (iom_file(kiomid)%iolib)
+               CASE (jpioipsl )   ;   CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r0d = pvar )
+               CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r0d = pvar )
+               CASE (jprstdimg)   ;   IF( kt == kwrite )    CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pvar )
+               CASE DEFAULT     
+                  CALL ctl_stop( 'iom_rp0d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+               END SELECT
+            ENDIF
          ENDIF
       ENDIF
    END SUBROUTINE iom_rp0d
 
-   SUBROUTINE iom_rp1d( kt, kwrite, kiomid, cdvar, pvar, ktype )
+   SUBROUTINE iom_rp1d( kt, kwrite, kiomid, cdvar, pvar, ktype, lxios )
       INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
       INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
@@ -1292,20 +1578,34 @@
       REAL(wp)        , INTENT(in), DIMENSION(          :) ::   pvar     ! written field
       INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
+      LOGICAL, OPTIONAL :: lxios   ! xios write flag
+      LOGICAL :: lx                ! local xios write flag
       INTEGER :: ivid   ! variable id
-      IF( kiomid > 0 ) THEN
-         IF( iom_file(kiomid)%nfid > 0 ) THEN
-            ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
-            SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpioipsl )   ;   CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r1d = pvar )
-            CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r1d = pvar )
-            CASE (jprstdimg)   ;   IF( kt == kwrite )    CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pv_r1d = pvar )
-            CASE DEFAULT     
-               CALL ctl_stop( 'iom_rp1d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
-            END SELECT
+
+      lx = .FALSE.
+      IF(PRESENT(lxios)) lx = lxios
+      IF( lx ) THEN
+#ifdef key_iomput
+       IF( kt == kwrite ) THEN
+          IF(lwp) write(numout,*) 'RESTART: write (XIOS 1D) ',trim(cdvar)
+          CALL xios_send_field(trim(cdvar), pvar)
+       ENDIF
+#endif
+      ELSE
+         IF( kiomid > 0 ) THEN
+            IF( iom_file(kiomid)%nfid > 0 ) THEN
+               ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
+               SELECT CASE (iom_file(kiomid)%iolib)
+               CASE (jpioipsl )   ;   CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r1d = pvar )
+               CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r1d = pvar )
+               CASE (jprstdimg)   ;   IF( kt == kwrite )    CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pv_r1d = pvar )
+               CASE DEFAULT     
+                  CALL ctl_stop( 'iom_rp1d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+               END SELECT
+            ENDIF
          ENDIF
       ENDIF
    END SUBROUTINE iom_rp1d
 
-   SUBROUTINE iom_rp2d( kt, kwrite, kiomid, cdvar, pvar, ktype )
+   SUBROUTINE iom_rp2d( kt, kwrite, kiomid, cdvar, pvar, ktype, lxios )
       INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
       INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
@@ -1314,20 +1614,34 @@
       REAL(wp)        , INTENT(in), DIMENSION(:,    :    ) ::   pvar     ! written field
       INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
+      LOGICAL, OPTIONAL :: lxios   ! xios write flag
+      LOGICAL :: lx                ! local xios write flag
       INTEGER :: ivid   ! variable id
-      IF( kiomid > 0 ) THEN
-         IF( iom_file(kiomid)%nfid > 0 ) THEN
-            ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
-            SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpioipsl )   ;   CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r2d = pvar )
-            CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r2d = pvar )
-            CASE (jprstdimg)   ;   IF( kt == kwrite )   CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pv_r2d = pvar ) 
-            CASE DEFAULT     
-               CALL ctl_stop( 'iom_rp2d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
-            END SELECT
+
+      lx = .FALSE.
+      IF(PRESENT(lxios)) lx = lxios
+      IF( lx ) THEN
+#ifdef key_iomput
+       IF( kt == kwrite ) THEN
+          IF(lwp) write(numout,*) 'RESTART: write (XIOS 2D) ',trim(cdvar)
+          CALL xios_send_field(trim(cdvar), pvar)
+       ENDIF
+#endif
+      ELSE
+         IF( kiomid > 0 ) THEN
+            IF( iom_file(kiomid)%nfid > 0 ) THEN
+               ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
+               SELECT CASE (iom_file(kiomid)%iolib)
+               CASE (jpioipsl )   ;   CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r2d = pvar )
+               CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r2d = pvar )
+               CASE (jprstdimg)   ;   IF( kt == kwrite )   CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pv_r2d = pvar ) 
+               CASE DEFAULT     
+                  CALL ctl_stop( 'iom_rp2d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+               END SELECT
+            ENDIF
          ENDIF
       ENDIF
    END SUBROUTINE iom_rp2d
 
-   SUBROUTINE iom_rp3d( kt, kwrite, kiomid, cdvar, pvar, ktype )
+   SUBROUTINE iom_rp3d( kt, kwrite, kiomid, cdvar, pvar, ktype, lxios )
       INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
       INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
@@ -1336,15 +1650,29 @@
       REAL(wp)        , INTENT(in),       DIMENSION(:,:,:) ::   pvar     ! written field
       INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
+      LOGICAL, OPTIONAL :: lxios   ! xios write flag
+      LOGICAL :: lx                 ! local xios write flag
       INTEGER :: ivid   ! variable id
-      IF( kiomid > 0 ) THEN
-         IF( iom_file(kiomid)%nfid > 0 ) THEN
-            ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
-            SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpioipsl )   ;   CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r3d = pvar )
-            CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r3d = pvar )
-            CASE (jprstdimg)   ;   IF( kt == kwrite )   CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pv_r3d = pvar )
-            CASE DEFAULT     
-               CALL ctl_stop( 'iom_rp3d: accepted IO library are only jpioipsl and jprstdimg' )
-            END SELECT
+
+      lx = .FALSE.
+      IF(PRESENT(lxios)) lx = lxios
+      IF( lx ) THEN
+#ifdef key_iomput
+      IF( kt == kwrite ) THEN
+          IF(lwp) write(numout,*) 'RESTART: write (XIOS 3D) ',trim(cdvar)
+          CALL xios_send_field(trim(cdvar), pvar)
+      ENDIF
+#endif
+      ELSE
+         IF( kiomid > 0 ) THEN
+            IF( iom_file(kiomid)%nfid > 0 ) THEN
+               ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
+               SELECT CASE (iom_file(kiomid)%iolib)
+               CASE (jpioipsl )   ;   CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r3d = pvar )
+               CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r3d = pvar )
+               CASE (jprstdimg)   ;   IF( kt == kwrite )   CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pv_r3d = pvar )
+               CASE DEFAULT     
+                  CALL ctl_stop( 'iom_rp3d: accepted IO library are only jpioipsl and jprstdimg' )
+               END SELECT
+            ENDIF
          ENDIF
       ENDIF
@@ -1598,8 +1926,8 @@
 #endif     
       CALL iom_set_domain_attr("grid_"//cdgrd, data_dim=2, data_ibegin = 1-nldi, data_ni = jpi, data_jbegin = 1-nldj, data_nj = jpj)
-      CALL iom_set_domain_attr("grid_"//cdgrd, lonvalue = RESHAPE(plon(nldi:nlei, nldj:nlej),(/ ni*nj /)),   &
-         &                                     latvalue = RESHAPE(plat(nldi:nlei, nldj:nlej),(/ ni*nj /)))  
 
       IF ( lmask ) THEN
+          CALL iom_set_domain_attr("grid_"//cdgrd, lonvalue = RESHAPE(plon(nldi:nlei,nldj:nlej),(/ ni*nj /)),   &
+         &                                     latvalue = RESHAPE(plat(nldi:nlei, nldj:nlej),(/ ni*nj /)))
          ! mask land points, keep values on coast line -> specific mask for U, V and W points
          SELECT CASE ( cdgrd )
Index: branches/UKMO/test_moci_test_suite/NEMOGCM/NEMO/OPA_SRC/IOM/iom_def.F90
===================================================================
--- branches/UKMO/test_moci_test_suite/NEMOGCM/NEMO/OPA_SRC/IOM/iom_def.F90	(revision 8221)
+++ branches/UKMO/test_moci_test_suite/NEMOGCM/NEMO/OPA_SRC/IOM/iom_def.F90	(revision 8243)
@@ -55,4 +55,9 @@
    LOGICAL, PUBLIC            ::   lxios_sini = .FALSE. ! is restart in a single file
    LOGICAL, PUBLIC            ::   lxios_set  = .FALSE. 
+!XIOS read restart   
+   LOGICAL, PUBLIC            ::   lwxios          !: read single file restart using XIOS
+   INTEGER, PUBLIC            ::   wxioso          !: type of restart file when writing using XIOS 1 - single, 2 - multiple
+   LOGICAL, PUBLIC            ::   lspr            !: single processor read data flag
+
 
    TYPE, PUBLIC ::   file_descriptor
@@ -72,4 +77,5 @@
       REAL(kind=wp), DIMENSION(jpmax_vars)      ::   scf      !: scale_factor of the variables
       REAL(kind=wp), DIMENSION(jpmax_vars)      ::   ofs      !: add_offset of the variables
+      LOGICAL                                   ::   lsngl = .FALSE.    !: one file flag
    END TYPE file_descriptor
    TYPE(file_descriptor), DIMENSION(jpmax_files), PUBLIC ::   iom_file !: array containing the info for all opened files
Index: branches/UKMO/test_moci_test_suite/NEMOGCM/NEMO/OPA_SRC/IOM/iom_nf90.F90
===================================================================
--- branches/UKMO/test_moci_test_suite/NEMOGCM/NEMO/OPA_SRC/IOM/iom_nf90.F90	(revision 8221)
+++ branches/UKMO/test_moci_test_suite/NEMOGCM/NEMO/OPA_SRC/IOM/iom_nf90.F90	(revision 8243)
@@ -72,4 +72,5 @@
       INTEGER            ::   ihdf5            ! local variable for retrieval of value for NF90_HDF5
       LOGICAL            ::   llclobber        ! local definition of ln_clobber
+      INTEGER            ::   lng              ! length of the string - unlimited dimension
       !---------------------------------------------------------------------
 
@@ -92,6 +93,12 @@
             CALL iom_nf90_check(NF90_SET_FILL( if90id, NF90_NOFILL, idmy                          ), clinfo)
          ELSE              ! ... in read mode
-            IF(lwp) WRITE(numout,*) TRIM(clinfo)//' open existing file: '//TRIM(cdname)//' in READ mode'
-            CALL iom_nf90_check(NF90_OPEN( TRIM(cdname), NF90_NOWRITE, if90id, chunksize = ichunk ), clinfo)
+            IF(lwp) WRITE(numout,*) &
+               TRIM(clinfo)//' open existing file: '//TRIM(cdname)//' in READ mode (Single PE read ',lspr,')'
+            IF(lspr) THEN
+              IF(lwm) CALL iom_nf90_check(NF90_OPEN( TRIM(cdname), NF90_NOWRITE, if90id, chunksize = ichunk ), clinfo)
+              IF(lk_mpp) call mpp_bcast(if90id)
+            ELSE
+              CALL iom_nf90_check(NF90_OPEN( TRIM(cdname), NF90_NOWRITE, if90id, chunksize = ichunk ), clinfo)
+            ENDIF
          ENDIF
       ELSE                                       ! the file does not exist (or we overwrite it)
@@ -152,11 +159,18 @@
          iom_file(kiomid)%nvars  = 0
          iom_file(kiomid)%irec   = -1   ! useless for NetCDF files, used to know if the file is in define mode 
-         CALL iom_nf90_check(NF90_Inquire(if90id, unlimitedDimId = iom_file(kiomid)%iduld), clinfo)
+         IF(lwm) CALL iom_nf90_check(NF90_Inquire(if90id, unlimitedDimId = iom_file(kiomid)%iduld), clinfo)
+         IF(lk_mpp) CALL mpp_bcast(iom_file(kiomid)%iduld)
          IF ( iom_file(kiomid)%iduld .GE. 0 ) THEN
-           CALL iom_nf90_check(NF90_Inquire_Dimension(if90id, iom_file(kiomid)%iduld,     & 
+           IF(lwm) CALL iom_nf90_check(NF90_Inquire_Dimension(if90id, iom_file(kiomid)%iduld,     & 
         &                                               name = iom_file(kiomid)%uldname,  &
         &                                               len  = iom_file(kiomid)%lenuld ), clinfo )
-         ENDIF
-         IF(lwp) WRITE(numout,*) '                   ---> '//TRIM(cdname)//' OK'
+           IF(lk_mpp) THEN
+             lng = 32                                    ! from iom_file definition
+             CALL mpp_bcast(iom_file(kiomid)%uldname, lng)
+             CALL mpp_bcast(iom_file(kiomid)%lenuld)
+           ENDIF
+         ENDIF
+         iom_file(kiomid)%lsngl = lxios_sini.and.lspr
+         IF(lwp) WRITE(numout,*) '                   ---> '//TRIM(cdname)//' OK. Is one file?:', lxios_sini, '1PE read:',iom_file(kiomid)%lsngl
       ELSE
          kiomid = 0               ! return error flag
@@ -177,5 +191,5 @@
       !
       clinfo = '      iom_nf90_close    , file: '//TRIM(iom_file(kiomid)%name)
-      CALL iom_nf90_check(NF90_CLOSE(iom_file(kiomid)%nfid), clinfo)
+      IF(lwp.OR.(.NOT.lwp.AND..NOT.iom_file(kiomid)%lsngl)) CALL iom_nf90_check(NF90_CLOSE(iom_file(kiomid)%nfid), clinfo)
       !    
    END SUBROUTINE iom_nf90_close
@@ -202,4 +216,5 @@
       LOGICAL                        ::   llok             ! ok  test
       CHARACTER(LEN=100)             ::   clinfo           ! info character
+      REAL(wp)                       ::   rwp              ! real scratch variable
       !!-----------------------------------------------------------------------
       clinfo = '          iom_nf90_varid, file: '//TRIM(iom_file(kiomid)%name)//', var: '//TRIM(cdvar)
@@ -208,33 +223,56 @@
       if90id = iom_file(kiomid)%nfid        ! get back NetCDF file id
       !
-      llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr   ! does the variable exist in the file
+      IF(lwm) llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr   ! does the variable exist in the file
+      IF(lk_mpp) CALL mpp_bcast(llok) 
       IF( llok ) THEN
          iom_nf90_varid = kiv
          iom_file(kiomid)%nvars       = kiv
+         IF(lk_mpp) CALL mpp_bcast(ivarid)
          iom_file(kiomid)%nvid(kiv)   = ivarid
          iom_file(kiomid)%cn_var(kiv) = TRIM(cdvar)
-         CALL iom_nf90_check(NF90_Inquire_Variable(if90id, ivarid, ndims = i_nvd), clinfo)   ! number of dimensions
+         IF(lwm) CALL iom_nf90_check(NF90_Inquire_Variable(if90id, ivarid, ndims = i_nvd), clinfo)   ! number of dimensions
+         IF(lk_mpp) CALL mpp_bcast(i_nvd)
          iom_file(kiomid)%ndims(kiv)  = i_nvd
-         CALL iom_nf90_check(NF90_Inquire_Variable(if90id, ivarid, dimids = idimid(1:i_nvd)), clinfo)   ! dimensions ids
+         IF(lwm) CALL iom_nf90_check(NF90_Inquire_Variable(if90id, ivarid, dimids = idimid(1:i_nvd)), clinfo)   ! dimensions ids
+         IF(lk_mpp) CALL mpp_bcast(idimid(1:i_nvd), i_nvd)
          iom_file(kiomid)%luld(kiv) = .FALSE.   ! default value
          iom_file(kiomid)%dimsz(:,kiv) = 0      ! reset dimsz in case previously used
          DO ji = 1, i_nvd                       ! dimensions size
-            CALL iom_nf90_check(NF90_Inquire_Dimension(if90id, idimid(ji), len = iom_file(kiomid)%dimsz(ji,kiv)), clinfo)   
+            IF(iom_file(kiomid)%lsngl) THEN                  ! if single file 
+               IF(lwm) CALL iom_nf90_check(NF90_Inquire_Dimension(if90id, idimid(ji), len = iom_file(kiomid)%dimsz(ji,kiv)), clinfo)   
+               IF(lk_mpp) CALL mpp_bcast(iom_file(kiomid)%dimsz(ji,kiv))
+            ELSE
+               CALL iom_nf90_check(NF90_Inquire_Dimension(if90id, idimid(ji), len = iom_file(kiomid)%dimsz(ji,kiv)), clinfo)
+            ENDIF
             IF( idimid(ji) == iom_file(kiomid)%iduld ) iom_file(kiomid)%luld(kiv) = .TRUE.   ! unlimited dimension? 
          END DO
          !---------- Deal with scale_factor and add_offset
-         llok = NF90_Inquire_attribute(if90id, ivarid, 'scale_factor') == nf90_noerr
+         IF(lwm) llok = NF90_Inquire_attribute(if90id, ivarid, 'scale_factor') == nf90_noerr
+         IF(lk_mpp) CALL mpp_bcast(llok)
          IF( llok) THEN
-            CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, 'scale_factor', iom_file(kiomid)%scf(kiv)), clinfo)
+            IF(iom_file(kiomid)%lsngl) THEN                  ! if single file
+               IF(lwm) CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, 'scale_factor', rwp), clinfo)
+               IF(lk_mpp) CALL mpp_bcast(rwp)
+            ELSE
+               CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, 'scale_factor', rwp), clinfo)
+            ENDIF
+            iom_file(kiomid)%scf(kiv) = rwp 
          ELSE
             iom_file(kiomid)%scf(kiv) = 1.
          END IF
-         llok = NF90_Inquire_attribute(if90id, ivarid, 'add_offset') == nf90_noerr
+         IF(lwm) llok = NF90_Inquire_attribute(if90id, ivarid, 'add_offset') == nf90_noerr
+         IF(lk_mpp) CALL mpp_bcast(llok)
          IF( llok ) THEN
-            CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, 'add_offset', iom_file(kiomid)%ofs(kiv)), clinfo)
+            IF(iom_file(kiomid)%lsngl) THEN                  ! if single file
+               IF(lwm) CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, 'add_offset', rwp), clinfo)
+               IF(lk_mpp) CALL mpp_bcast(rwp)
+            ELSE
+               CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, 'add_offset', rwp), clinfo)
+            ENDIF
+            iom_file(kiomid)%ofs(kiv) = rwp
          ELSE
             iom_file(kiomid)%ofs(kiv) = 0.
          END IF
-         ! return the simension size
+         ! return the dimension size
          IF( PRESENT(kdimsz) ) THEN 
             IF( i_nvd == SIZE(kdimsz) ) THEN
@@ -267,5 +305,7 @@
       !---------------------------------------------------------------------
       clinfo = 'iom_nf90_g0d , file: '//TRIM(iom_file(kiomid)%name)//', var: '//TRIM(iom_file(kiomid)%cn_var(kvid))
-      CALL iom_nf90_check(NF90_GET_VAR(iom_file(kiomid)%nfid, iom_file(kiomid)%nvid(kvid), pvar, start = kstart), clinfo )
+      IF(lwm.OR.(.NOT.iom_file(kiomid)%lsngl)) &
+      & CALL iom_nf90_check(NF90_GET_VAR(iom_file(kiomid)%nfid, iom_file(kiomid)%nvid(kvid), pvar, start = kstart), clinfo )
+      IF(lk_mpp.AND.iom_file(kiomid)%lsngl) call mpp_bcast(pvar)
       ! 
    END SUBROUTINE iom_nf90_g0d
@@ -290,8 +330,15 @@
       REAL(wp), DIMENSION(:,:)   , INTENT(  out), OPTIONAL ::   pv_r2d    ! read field (2D case)
       REAL(wp), DIMENSION(:,:,:) , INTENT(  out), OPTIONAL ::   pv_r3d    ! read field (3D case)
+      ! Temporary arrays
+      ! 
+      REAL(wp), ALLOCATABLE, DIMENSION(:)   ::   t_r1d
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:)   ::   t_r2d    ! read field (2D case)
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   t_r3d    ! read field (3D case)
       !
       CHARACTER(LEN=100) ::   clinfo               ! info character
       INTEGER            ::   if90id               ! nf90 identifier of the opened file
       INTEGER            ::   ivid                 ! nf90 variable id
+      INTEGER            ::   klev                 ! vertical level
+      REAL(wp)           ::   astart , mpi_wtime
       !---------------------------------------------------------------------
       clinfo = 'iom_nf90_g123d , file: '//TRIM(iom_file(kiomid)%name)//', var: '//TRIM(iom_file(kiomid)%cn_var(kvid))
@@ -299,14 +346,70 @@
       ivid   = iom_file(kiomid)%nvid(kvid)   ! get back NetCDF var id
       !
+      if(lwm) astart =  mpi_wtime()
       IF(     PRESENT(pv_r1d) ) THEN
+        IF(iom_file(kiomid)%lsngl) THEN
+            allocate(t_r1d(iom_file(kiomid)%dimsz(1,kvid)))
+            IF(lwm) THEN
+               if(lwp) write(numout,*) 'READ 1D SINGLE PROCESSOR: ',TRIM(iom_file(kiomid)%cn_var(kvid))
+               IF(knbdim.EQ.2) THEN
+                  CALL iom_nf90_check( NF90_GET_VAR(if90id, ivid, t_r1d, start = (/ 1, kstart(knbdim) /), &
+     &                 count = (/ iom_file(kiomid)%dimsz(1,kvid), 1 /)), clinfo)
+               ELSE
+                  CALL iom_nf90_check( NF90_GET_VAR(if90id, ivid, t_r1d), clinfo)
+               ENDIF
+            ENDIF
+            if(lk_mpp) CALL mpp_bcast(t_r1d, iom_file(kiomid)%dimsz(1,kvid))
+            pv_r1d(:) = t_r1d(kstart(1):kstart(1)+kcount(1)-1)
+            deallocate(t_r1d)
+        ELSE
          CALL iom_nf90_check( NF90_GET_VAR(if90id, ivid, pv_r1d(:                ), start = kstart(1:knbdim),   &
             &                                                                       count = kcount(1:knbdim)), clinfo )
+        ENDIF
       ELSEIF( PRESENT(pv_r2d) ) THEN
-         CALL iom_nf90_check( NF90_GET_VAR(if90id, ivid, pv_r2d(kx1:kx2,ky1:ky2  ), start = kstart(1:knbdim),   &
+         IF(iom_file(kiomid)%lsngl) THEN
+            allocate(t_r2d(iom_file(kiomid)%dimsz(1,kvid), iom_file(kiomid)%dimsz(2,kvid)))
+            IF(lwm) THEN
+               if(lwp) write(numout,*) 'READ 2D SINGLE PROCESSOR: ',TRIM(iom_file(kiomid)%cn_var(kvid))
+               IF(knbdim.EQ.3) THEN
+                  CALL iom_nf90_check( NF90_GET_VAR(if90id, ivid, t_r2d, start = (/ 1, 1, kstart(knbdim) /), &
+     &                 count = (/ iom_file(kiomid)%dimsz(1,kvid), iom_file(kiomid)%dimsz(2,kvid), 1 /)), clinfo)
+               ELSE
+                  CALL iom_nf90_check( NF90_GET_VAR(if90id, ivid, t_r2d), clinfo)
+               ENDIF
+            ENDIF
+            if(lk_mpp) CALL mpp_bcast(t_r2d, iom_file(kiomid)%dimsz(1,kvid), iom_file(kiomid)%dimsz(2,kvid))
+            pv_r2d(kx1:kx2,ky1:ky2  ) = t_r2d(kstart(1):kstart(1)+kcount(1)-1, kstart(2):kstart(2)+kcount(2)-1)
+            deallocate(t_r2d)
+         ELSE
+            CALL iom_nf90_check( NF90_GET_VAR(if90id, ivid, pv_r2d(kx1:kx2,ky1:ky2  ), start = kstart(1:knbdim),   &
             &                                                                       count = kcount(1:knbdim)), clinfo )
+         ENDIF
       ELSEIF( PRESENT(pv_r3d) ) THEN
+        IF(iom_file(kiomid)%lsngl) THEN
+            allocate(t_r3d(iom_file(kiomid)%dimsz(1,kvid), iom_file(kiomid)%dimsz(2,kvid), iom_file(kiomid)%dimsz(3,kvid)))
+            if(lwp) write(numout,*) 'READ 3D SINGLE PROCESSOR: ',TRIM(iom_file(kiomid)%cn_var(kvid))
+            IF(lwm) THEN
+                IF(knbdim.EQ.4) THEN
+                     CALL iom_nf90_check( NF90_GET_VAR(if90id, ivid, t_r3d, start = (/ 1, 1, 1, kstart(knbdim) /), &
+      &                  count = (/ iom_file(kiomid)%dimsz(1,kvid), iom_file(kiomid)%dimsz(2,kvid), &
+                                                                  iom_file(kiomid)%dimsz(3,kvid), 1 /)), clinfo)
+!                 do klev = 1, iom_file(kiomid)%dimsz(3,kvid)
+!                    CALL iom_nf90_check( NF90_GET_VAR(if90id, ivid, t_r3d(:,:,klev), start = (/ 1, 1, klev, kstart(knbdim) /), &
+!    &                  count = (/ iom_file(kiomid)%dimsz(1,kvid), iom_file(kiomid)%dimsz(2,kvid), 1, 1 /)), clinfo)
+!                 enddo
+               ELSE
+                  CALL iom_nf90_check( NF90_GET_VAR(if90id, ivid, t_r3d), clinfo)
+               ENDIF
+            ENDIF
+            if(lk_mpp) CALL mpp_bcast(t_r3d, iom_file(kiomid)%dimsz(1,kvid), iom_file(kiomid)%dimsz(2,kvid), iom_file(kiomid)%dimsz(3,kvid))
+            pv_r3d(kx1:kx2,ky1:ky2, :) = &
+               t_r3d(kstart(1):kstart(1)+kcount(1)-1, kstart(2):kstart(2)+kcount(2)-1, kstart(3):kstart(3)+kcount(3)-1)
+            deallocate(t_r3d)
+        ELSE
          CALL iom_nf90_check( NF90_GET_VAR(if90id, ivid, pv_r3d(kx1:kx2,ky1:ky2,:), start = kstart(1:knbdim),   &
             &                                                                       count = kcount(1:knbdim)), clinfo )
-      ENDIF
+        ENDIF
+      ENDIF 
+      if(lwm) write(*,*) 'IT took ', mpi_wtime() - astart ,' [s] to read ',TRIM(iom_file(kiomid)%cn_var(kvid))
       !
    END SUBROUTINE iom_nf90_g123d
@@ -327,14 +430,20 @@
       CHARACTER(LEN=100)              ::   clinfo   ! info character
       !---------------------------------------------------------------------
-      ! 
-      if90id = iom_file(kiomid)%nfid
-      llok = NF90_Inquire_attribute(if90id, NF90_GLOBAL, cdatt) == nf90_noerr
-      IF( llok) THEN
-         clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', att: '//TRIM(cdatt)
-         CALL iom_nf90_check(NF90_GET_ATT(if90id, NF90_GLOBAL, cdatt, values=pvar), clinfo)
-      ELSE
-         CALL ctl_warn('iom_nf90_getatt: no attribute '//cdatt//' found')
-         pvar = -999
-      ENDIF
+      !
+      clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', att: '//TRIM(cdatt)
+      IF(lwm) THEN 
+         if90id = iom_file(kiomid)%nfid
+         llok = NF90_Inquire_attribute(if90id, NF90_GLOBAL, cdatt) == nf90_noerr
+         IF( llok) THEN
+            clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', att: '//TRIM(cdatt)
+            CALL iom_nf90_check(NF90_GET_ATT(if90id, NF90_GLOBAL, cdatt, values=pvar), clinfo)
+         ELSE
+            pvar = -999
+         ENDIF
+      ENDIF
+
+      IF( lk_mpp ) call mpp_bcast(pvar)
+
+      IF( pvar .EQ. -999 ) CALL ctl_warn('iom_nf90_getatt: no attribute '//cdatt//' found')
       ! 
    END SUBROUTINE iom_nf90_intatt
@@ -356,13 +465,22 @@
       !---------------------------------------------------------------------
       clinfo = 'iom_nf90_gettime, file: '//TRIM(iom_file(kiomid)%name)//', var: '//TRIM(iom_file(kiomid)%cn_var(kvid))
-      CALL iom_nf90_check(NF90_GET_VAR(iom_file(kiomid)%nfid, iom_file(kiomid)%nvid(kvid), ptime(:),   &
-            &                           start=(/ 1 /), count=(/ iom_file(kiomid)%dimsz(1, kvid) /)), clinfo)
-      IF ( PRESENT(cdunits) ) THEN 
-         CALL iom_nf90_check(NF90_GET_ATT(iom_file(kiomid)%nfid, iom_file(kiomid)%nvid(kvid), "units", &
-            &                           values=cdunits), clinfo)
-      ENDIF
-      IF ( PRESENT(cdcalendar) ) THEN 
-         CALL iom_nf90_check(NF90_GET_ATT(iom_file(kiomid)%nfid, iom_file(kiomid)%nvid(kvid), "calendar", &
-            &                           values=cdcalendar), clinfo)
+      IF(lwm) THEN
+         CALL iom_nf90_check(NF90_GET_VAR(iom_file(kiomid)%nfid, iom_file(kiomid)%nvid(kvid), ptime(:),   &
+               &                           start=(/ 1 /), count=(/ iom_file(kiomid)%dimsz(1, kvid) /)), clinfo)
+         IF( lk_mpp ) CALL mpp_bcast(ptime, SIZE(ptime))
+         IF ( PRESENT(cdunits) ) THEN 
+            CALL iom_nf90_check(NF90_GET_ATT(iom_file(kiomid)%nfid, iom_file(kiomid)%nvid(kvid), "units", &
+               &                           values=cdunits), clinfo)
+            IF( lk_mpp ) CALL mpp_bcast(cdunits, LEN(cdunits))
+         ENDIF
+         IF ( PRESENT(cdcalendar) ) THEN 
+            CALL iom_nf90_check(NF90_GET_ATT(iom_file(kiomid)%nfid, iom_file(kiomid)%nvid(kvid), "calendar", &
+               &                           values=cdcalendar), clinfo)
+            IF( lk_mpp ) CALL mpp_bcast(cdcalendar, LEN(cdcalendar))
+         ENDIF
+      ELSE
+         IF( lk_mpp ) CALL mpp_bcast(ptime, SIZE(ptime))
+         IF ( PRESENT(cdunits) .AND. lk_mpp ) CALL mpp_bcast(cdunits, LEN(cdunits))
+         IF ( PRESENT(cdcalendar)  .AND. lk_mpp ) CALL mpp_bcast(cdcalendar, LEN(cdcalendar))
       ENDIF
       !
@@ -576,5 +694,7 @@
       CHARACTER(LEN=*), INTENT(in) :: cdinfo
       !---------------------------------------------------------------------
-      IF(kstatus /= nf90_noerr)   CALL ctl_stop( 'iom_nf90_check : '//TRIM(nf90_strerror(kstatus)), TRIM(cdinfo) )
+      IF(kstatus /= nf90_noerr)   then
+        CALL ctl_stop( 'iom_nf90_check : '//TRIM(nf90_strerror(kstatus)), TRIM(cdinfo) )
+      ENDIF
    END SUBROUTINE iom_nf90_check
 
Index: branches/UKMO/test_moci_test_suite/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90
===================================================================
--- branches/UKMO/test_moci_test_suite/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90	(revision 8221)
+++ branches/UKMO/test_moci_test_suite/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90	(revision 8243)
@@ -26,5 +26,5 @@
    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 iom_def, ONLY : lxios_read, lxios_set, lxios_sini, lwxios
    USE timing
 
@@ -67,4 +67,5 @@
       !!----------------------------------------------------------------------
       !
+
       IF( kt == nit000 ) THEN   ! default definitions
          lrst_oce = .FALSE.   
@@ -105,17 +106,28 @@
             IF(lwp) THEN
                WRITE(numout,*)
-               SELECT CASE ( jprstlib )
-               CASE ( jprstdimg )   ;   WRITE(numout,*)                            &
-                   '             open ocean restart binary file: ',TRIM(clpath)//clname
-               CASE DEFAULT         ;   WRITE(numout,*)                            &
-                   '             open ocean restart NetCDF file: ',TRIM(clpath)//clname
-               END SELECT
-               IF ( snc4set%luse )      WRITE(numout,*) '             opened for NetCDF4 chunking and compression'
-               IF( kt == nitrst - 1 ) THEN   ;   WRITE(numout,*) '             kt = nitrst - 1 = ', kt
-               ELSE                          ;   WRITE(numout,*) '             kt = '             , kt
+               IF(lwxios) THEN
+                  WRITE(numout,*)                                                     &
+                      '        XIOS open ocean restart NetCDF file: ',TRIM(clpath)//TRIM(clname)
+               ELSE
+                  SELECT CASE ( jprstlib )
+                  CASE ( jprstdimg )   ;   WRITE(numout,*)                            &
+                      '             open ocean restart binary file: ',TRIM(clpath)//TRIM(clname)
+                  CASE DEFAULT         ;   WRITE(numout,*)                            &
+                      '             open ocean restart NetCDF file: ',TRIM(clpath)//TRIM(clname)
+                  END SELECT
+                  IF ( snc4set%luse )      WRITE(numout,*) '             opened for NetCDF4 chunking and compression'
+                  IF( kt == nitrst - 1 ) THEN   ;   WRITE(numout,*) '             kt = nitrst - 1 = ', kt
+                  ELSE                          ;   WRITE(numout,*) '             kt = '             , kt
+                  ENDIF
                ENDIF
             ENDIF
             !
-            CALL iom_open( TRIM(clpath)//TRIM(clname), numrow, ldwrt = .TRUE., kiolib = jprstlib )
+            IF(.NOT.lwxios) THEN
+               CALL iom_open( TRIM(clpath)//TRIM(clname), numrow, ldwrt = .TRUE., kiolib = jprstlib )
+            ELSE
+               CALL iom_init( wxios_context, TRIM(clpath)//TRIM(clname) )
+               CALL xios_update_calendar(nitrst)
+               CALL iom_swap(      cxios_context          )
+            ENDIF
             lrst_oce = .TRUE.
          ENDIF
@@ -136,41 +148,52 @@
       INTEGER, INTENT(in) ::   kt   ! ocean time-step
       !!----------------------------------------------------------------------
-
-                     CALL iom_rstput( kt, nitrst, numrow, 'rdt'    , rdt       )   ! dynamics time step
-                     CALL iom_rstput( kt, nitrst, numrow, 'rdttra1', rdttra(1) )   ! surface tracer time step
-
-                     CALL iom_rstput( kt, nitrst, numrow, 'ub'     , ub        )     ! before fields
-                     CALL iom_rstput( kt, nitrst, numrow, 'vb'     , vb        )
-                     CALL iom_rstput( kt, nitrst, numrow, 'tb'     , tsb(:,:,:,jp_tem) )
-                     CALL iom_rstput( kt, nitrst, numrow, 'sb'     , tsb(:,:,:,jp_sal) )
-                     CALL iom_rstput( kt, nitrst, numrow, 'rotb'   , rotb      )
-                     CALL iom_rstput( kt, nitrst, numrow, 'hdivb'  , hdivb     )
-                     CALL iom_rstput( kt, nitrst, numrow, 'sshb'   , sshb      )
+                     IF(lwxios) CALL iom_swap(      wxios_context          )
+                     CALL iom_rstput( kt, nitrst, numrow, 'rdt'    , rdt       , lxios = lwxios)   ! dynamics time step
+                     CALL iom_rstput( kt, nitrst, numrow, 'rdttra1', rdttra(1) , lxios = lwxios)   ! surface tracer time step
+
+                     CALL iom_rstput( kt, nitrst, numrow, 'ub'     , ub        , lxios = lwxios)     ! before fields
+                     CALL iom_rstput( kt, nitrst, numrow, 'vb'     , vb        , lxios = lwxios)
+                     CALL iom_rstput( kt, nitrst, numrow, 'tb'     , tsb(:,:,:,jp_tem) , lxios = lwxios)
+                     CALL iom_rstput( kt, nitrst, numrow, 'sb'     , tsb(:,:,:,jp_sal) , lxios = lwxios)
+                     CALL iom_rstput( kt, nitrst, numrow, 'rotb'   , rotb      , lxios = lwxios)
+                     CALL iom_rstput( kt, nitrst, numrow, 'hdivb'  , hdivb     , lxios = lwxios)
+                     CALL iom_rstput( kt, nitrst, numrow, 'sshb'   , sshb      , lxios = lwxios)
                      !
-                     CALL iom_rstput( kt, nitrst, numrow, 'un'     , un        )     ! now fields
-                     CALL iom_rstput( kt, nitrst, numrow, 'vn'     , vn        )
-                     CALL iom_rstput( kt, nitrst, numrow, 'tn'     , tsn(:,:,:,jp_tem) )
-                     CALL iom_rstput( kt, nitrst, numrow, 'sn'     , tsn(:,:,:,jp_sal) )
-                     CALL iom_rstput( kt, nitrst, numrow, 'rotn'   , rotn      )
-                     CALL iom_rstput( kt, nitrst, numrow, 'hdivn'  , hdivn     )
-                     CALL iom_rstput( kt, nitrst, numrow, 'sshn'   , sshn      )
-                     CALL iom_rstput( kt, nitrst, numrow, 'rhop'   , rhop      )
+                     CALL iom_rstput( kt, nitrst, numrow, 'un'     , un        , lxios = lwxios)     ! now fields
+                     CALL iom_rstput( kt, nitrst, numrow, 'vn'     , vn        , lxios = lwxios)
+                     CALL iom_rstput( kt, nitrst, numrow, 'tn'     , tsn(:,:,:,jp_tem) , lxios = lwxios)
+                     CALL iom_rstput( kt, nitrst, numrow, 'sn'     , tsn(:,:,:,jp_sal) , lxios = lwxios)
+                     CALL iom_rstput( kt, nitrst, numrow, 'rotn'   , rotn      , lxios = lwxios)
+                     CALL iom_rstput( kt, nitrst, numrow, 'hdivn'  , hdivn     , lxios = lwxios)
+                     CALL iom_rstput( kt, nitrst, numrow, 'sshn'   , sshn      , lxios = lwxios)
+                     CALL iom_rstput( kt, nitrst, numrow, 'rhop'   , rhop      , lxios = lwxios)
 #if defined key_zdfkpp
-                     CALL iom_rstput( kt, nitrst, numrow, 'rhd'    , rhd       )
+                     CALL iom_rstput( kt, nitrst, numrow, 'rhd'    , rhd       , lxios = lwxios)
 #endif
                      IF( lk_oasis) THEN
                      ! ln_coupled_iceshelf_fluxes uninitialised unless lk_oasis=true
                      IF( ln_coupled_iceshelf_fluxes ) THEN
-                        CALL iom_rstput( kt, nitrst, numrow, 'greenland_icesheet_mass', greenland_icesheet_mass )
-                        CALL iom_rstput( kt, nitrst, numrow, 'greenland_icesheet_timelapsed', greenland_icesheet_timelapsed )
-                        CALL iom_rstput( kt, nitrst, numrow, 'greenland_icesheet_mass_roc', greenland_icesheet_mass_rate_of_change )
-                        CALL iom_rstput( kt, nitrst, numrow, 'antarctica_icesheet_mass', antarctica_icesheet_mass )
-                        CALL iom_rstput( kt, nitrst, numrow, 'antarctica_icesheet_timelapsed', antarctica_icesheet_timelapsed )
-                        CALL iom_rstput( kt, nitrst, numrow, 'antarctica_icesheet_mass_roc', antarctica_icesheet_mass_rate_of_change )
+                        CALL iom_rstput( kt, nitrst, numrow, 'greenland_icesheet_mass', greenland_icesheet_mass ,&
+      &                                   lxios = lwxios)
+                        CALL iom_rstput( kt, nitrst, numrow, 'greenland_icesheet_timelapsed', greenland_icesheet_timelapsed ,&
+      &                                   lxios = lwxios)
+                        CALL iom_rstput( kt, nitrst, numrow, 'greenland_icesheet_mass_roc', greenland_icesheet_mass_rate_of_change ,&
+      &                                   lxios = lwxios)
+                        CALL iom_rstput( kt, nitrst, numrow, 'antarctica_icesheet_mass', antarctica_icesheet_mass , &
+      &                                  lxios = lwxios)
+                        CALL iom_rstput( kt, nitrst, numrow, 'antarctica_icesheet_timelapsed', antarctica_icesheet_timelapsed ,&
+      &                                   lxios = lwxios)
+                        CALL iom_rstput( kt, nitrst, numrow, 'antarctica_icesheet_mass_roc', &
+      &                                  antarctica_icesheet_mass_rate_of_change , lxios = lwxios)
                      ENDIF
                      ENDIF
 
       IF( kt == nitrst ) THEN
-         CALL iom_close( numrow )     ! close the restart file (only at last time step)
+         IF(.NOT.lwxios) THEN
+            CALL iom_close( numrow )     ! close the restart file (only at last time step)
+         ELSE
+            CALL iom_context_finalize(      wxios_context          )
+            CALL iom_swap(      cxios_context          )
+         ENDIF
 !!gm         IF( .NOT. lk_trdmld )   lrst_oce = .FALSE.
 !!gm  not sure what to do here   ===>>>  ask to Sebastian
@@ -180,5 +203,4 @@
                nitrst = nstocklist( nrst_lst )
             ENDIF
-            lrst_oce = .FALSE.
       ENDIF
       !
@@ -219,4 +241,5 @@
            IF ( llok ) THEN ; jlibalt = jpnf90  ; ELSE ; jlibalt = jprstlib ; ENDIF
          ENDIF
+         lspr = .FALSE.                       ! do not read restart using single processor
          CALL iom_open( TRIM(clpath)//cn_ocerst_in, numror, kiolib = jlibalt )
 ! are we using XIOS to read the data? Part above will have to modified once XIOS
@@ -226,5 +249,4 @@
          IF( lxios_read) THEN
          if(.NOT.lxios_set) then
-             rxios_context = 'nemo_rst'
              call iom_init( rxios_context )
              lxios_set = .TRUE.
@@ -232,5 +254,4 @@
          ENDIF
          IF( TRIM(Agrif_CFixed()) /= '0' .AND. lxios_read) THEN
-            rxios_context = 'nemo_rst'
             call iom_init( rxios_context )
          ENDIF 
@@ -339,5 +360,4 @@
       !
    END SUBROUTINE rst_read
-
    !!=====================================================================
 END MODULE restart
