Index: /branches/UKMO/dev_r7573_xios_write/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90
===================================================================
--- /branches/UKMO/dev_r7573_xios_write/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90	(revision 8309)
+++ /branches/UKMO/dev_r7573_xios_write/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90	(revision 8310)
@@ -195,5 +195,6 @@
          WRITE(numout,*) '      overwrite an existing file      ln_clobber = ', ln_clobber
          WRITE(numout,*) '      NetCDF chunksize (bytes)        nn_chunksz = ', nn_chunksz
-         WRITE(numout,*) '      Write restart using XIOS        nn_wxios   = ', nn_wxios
+         IF( TRIM(Agrif_CFixed()) == '0' ) &
+     &      WRITE(numout,*) '      Write restart using XIOS        nn_wxios   = ', nn_wxios
       ENDIF
 
@@ -308,6 +309,16 @@
       rdtmax    = rn_rdtmin
       rdth      = rn_rdth
-      if (nn_wxios > 0) lwxios = .TRUE. 
-      wxioso = nn_wxios
+
+      IF( TRIM(Agrif_CFixed()) == '0' ) THEN
+!set output file type for XIOS based on NEMO namelist 
+         if (nn_wxios > 0) lwxios = .TRUE. 
+         wxioso = nn_wxios
+      ELSE
+         IF(lwp) THEN
+            write(numout,*)
+            write(numout,*) "AGRIF: nn_wxios will be ingored. See setting for NEMO" 
+            write(numout,*)
+         ENDIF
+      ENDIF
 
       REWIND( numnam_ref )              ! Namelist namcla in reference namelist : Cross land advection
Index: /branches/UKMO/dev_r7573_xios_write/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90
===================================================================
--- /branches/UKMO/dev_r7573_xios_write/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 8309)
+++ /branches/UKMO/dev_r7573_xios_write/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 8310)
@@ -251,5 +251,5 @@
    END SUBROUTINE iom_init
 
-   SUBROUTINE iom_rstw_init( cdname, filename, it ) 
+   SUBROUTINE iom_rstw_init( cdname, filename ) 
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE   ***
@@ -274,9 +274,7 @@
       !
       CHARACTER(len=*), OPTIONAL, INTENT(in)  :: filename 
-      INTEGER, OPTIONAL :: it              ! timestep when subroutine was called
       !!----------------------------------------------------------------------
 
       clname = cdname 
-      if(lwp) write(numout,*) 'initialize CONTEXT:', TRIM(cdname)
       IF( TRIM(Agrif_CFixed()) /= '0' )   clname = TRIM(Agrif_CFixed())//"_"//TRIM(cdname)
       CALL xios_context_initialize(TRIM(clname), mpi_comm_opa)
@@ -298,12 +296,13 @@
       CALL xios_add_child(domaingroup_hdl, domain_hdl, "grid_N")
       CALL set_grid("N", glamt, gphit, .FALSE.)
-
+ 
       CALL xios_get_handle("axis_definition",axisgroup_hdl)
       CALL xios_add_child(axisgroup_hdl, axis_hdl, "deptht")
-      CALL xios_set_axis_attr( "deptht", long_name="Vertical levels",  unit="m", positive="down")
+!if unit="m" is present AGRIF configuration fails to compile
+      CALL xios_set_axis_attr( "deptht", long_name="Vertical levels in meters", positive="down")
       ! vertical grid definition
       CALL iom_set_axis_attr( "deptht", paxis = gdept_1d )
 
-      CALL XIOS_GET_HANDLE("scalar_definition",scalargroup_hdl)
+      CALL xios_get_handle("scalar_definition",scalargroup_hdl)
       CALL xios_add_child(scalargroup_hdl, scalar_hdl, "grid_scalar")
 
@@ -311,5 +310,5 @@
       IF( TRIM(cdname) == TRIM(wxios_context)) THEN
 !set which fields are to be read from restart file
-       CALL set_rstw_active(filename, it)
+       CALL set_rstw_active(filename)
       ENDIF
 
@@ -318,13 +317,11 @@
       CALL xios_set_timestep(dtime)
       CALL xios_close_context_definition()
-      
 #endif
 
    END SUBROUTINE iom_rstw_init
 
-   SUBROUTINE set_rstw_active(rst_file, it)
+   SUBROUTINE set_rstw_active(rst_file)
 !sets enabled = .TRUE. for each field in restart file
    CHARACTER(len=*) :: rst_file
-   INTEGER, INTENT(in) :: it ! timestep when iom_init was called
    TYPE(xios_file) :: file_hdl
    TYPE(xios_filegroup) :: filegroup_hdl
@@ -346,5 +343,5 @@
         CALL xios_set_file_attr( "wrestart", name=trim(rst_file))
         CALL set_numro_active(file_hdl)
-
+ 
     END SUBROUTINE set_rstw_active
 
@@ -768,5 +765,4 @@
       TYPE(xios_context) :: nemo_hdl
 
-      if(lwp) write(numout,*) 'iom_swap to: ',trim(cdname)
       IF( TRIM(Agrif_CFixed()) == '0' ) THEN
         CALL xios_get_handle(TRIM(cdname),nemo_hdl)
@@ -1927,6 +1923,10 @@
    SUBROUTINE iom_context_finalize( cdname )
       CHARACTER(LEN=*), INTENT(in) :: cdname
-      !
-      IF( xios_is_valid_context(cdname) ) THEN
+      CHARACTER(LEN=120)           :: clname
+      !
+      clname = cdname
+      IF( TRIM(Agrif_CFixed()) .NE. '0' ) clname = TRIM(Agrif_CFixed())//"_"//clname 
+
+      IF( xios_is_valid_context(clname) ) THEN
          CALL iom_swap( cdname )   ! swap to cdname context
          CALL xios_context_finalize() ! finalize the context
Index: /branches/UKMO/dev_r7573_xios_write/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90
===================================================================
--- /branches/UKMO/dev_r7573_xios_write/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90	(revision 8309)
+++ /branches/UKMO/dev_r7573_xios_write/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90	(revision 8310)
@@ -63,4 +63,5 @@
       CHARACTER(LEN=20)   ::   clkt     ! ocean time-step deine as a character
       CHARACTER(LEN=50)   ::   clname   ! ocean output restart file name
+      CHARACTER(LEN=52)   ::   dlname   ! ocean output restart file name includinf prefix for AGRIF
       CHARACTER(LEN=150)  ::   clpath   ! full path to ocean output restart file
       !!----------------------------------------------------------------------
@@ -106,8 +107,5 @@
             IF(lwp) THEN
                WRITE(numout,*)
-               IF(lwxios) THEN
-                  WRITE(numout,*)                                                     &
-                      '        XIOS open ocean restart NetCDF file: ',TRIM(clpath)//TRIM(clname)
-               ELSE
+               IF(.NOT.lwxios) THEN
                   SELECT CASE ( jprstlib )
                   CASE ( jprstdimg )   ;   WRITE(numout,*)                            &
@@ -127,5 +125,10 @@
             ELSE
                wxios_context = "rstw_"//TRIM(ADJUSTL(clkt))
-               CALL iom_rstw_init( wxios_context, TRIM(clpath)//TRIM(clname) )
+               IF( TRIM(Agrif_CFixed()) == '0' ) THEN
+                  dlname = clname
+               ELSE
+                  dlname = TRIM(Agrif_CFixed())//"_"//clname   
+               ENDIF
+               CALL iom_rstw_init( wxios_context, TRIM(clpath)//TRIM(dlname))
                CALL xios_update_calendar(nitrst)
                CALL iom_swap(      cxios_context          )
@@ -196,5 +199,4 @@
          ELSE
             CALL iom_context_finalize(      wxios_context          )
-            CALL iom_swap(      cxios_context          )
          ENDIF
 !!gm         IF( .NOT. lk_trdmld )   lrst_oce = .FALSE.
Index: /branches/UKMO/dev_r7573_xios_write/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90
===================================================================
--- /branches/UKMO/dev_r7573_xios_write/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90	(revision 8309)
+++ /branches/UKMO/dev_r7573_xios_write/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90	(revision 8310)
@@ -941,5 +941,4 @@
                &                          ' data type: '      ,       sdf(jf)%cltype      ,   &
                &                          ' land/sea mask:'   , TRIM( sdf(jf)%lsmname    )
-            call flush(numout)
          END DO
       ENDIF
