Index: NEMO/branches/UKMO/dev_r9950_GO8_package/src/OCE/IOM/iom.F90
===================================================================
--- NEMO/branches/UKMO/dev_r9950_GO8_package/src/OCE/IOM/iom.F90	(revision 9953)
+++ NEMO/branches/UKMO/dev_r9950_GO8_package/src/OCE/IOM/iom.F90	(revision 10012)
@@ -150,8 +150,8 @@
       !
       IF( TRIM(cdname) == TRIM(cxios_context) ) THEN  
-         CALL set_grid( "T", glamt, gphit, .FALSE. ) 
-         CALL set_grid( "U", glamu, gphiu, .FALSE. )
-         CALL set_grid( "V", glamv, gphiv, .FALSE. )
-         CALL set_grid( "W", glamt, gphit, .FALSE. )
+         CALL set_grid( "T", glamt, gphit, .FALSE., .FALSE. ) 
+         CALL set_grid( "U", glamu, gphiu, .FALSE., .FALSE. )
+         CALL set_grid( "V", glamv, gphiv, .FALSE., .FALSE. )
+         CALL set_grid( "W", glamt, gphit, .FALSE., .FALSE. )
          CALL set_grid_znl( gphit )
          !
@@ -171,8 +171,8 @@
          CALL dom_grid_crs   ! Save the parent grid information  & Switch to coarse grid domain
          !
-         CALL set_grid( "T", glamt_crs, gphit_crs, .FALSE. ) 
-         CALL set_grid( "U", glamu_crs, gphiu_crs, .FALSE. ) 
-         CALL set_grid( "V", glamv_crs, gphiv_crs, .FALSE. ) 
-         CALL set_grid( "W", glamt_crs, gphit_crs, .FALSE. ) 
+         CALL set_grid( "T", glamt_crs, gphit_crs, .FALSE., .FALSE. ) 
+         CALL set_grid( "U", glamu_crs, gphiu_crs, .FALSE., .FALSE. ) 
+         CALL set_grid( "V", glamv_crs, gphiv_crs, .FALSE., .FALSE. ) 
+         CALL set_grid( "W", glamt_crs, gphit_crs, .FALSE., .FALSE. ) 
          CALL set_grid_znl( gphit_crs )
           !
@@ -227,5 +227,5 @@
       IF( TRIM(cdname) == TRIM(crxios_context) ) THEN
 !set names of the fields in restart file IF using XIOS to read data
-          CALL iom_set_rst_context()
+          CALL iom_set_rst_context(.TRUE.)
           CALL iom_set_rst_vars(rst_rfields)
 !set which fields are to be read from restart file
@@ -233,5 +233,5 @@
       ELSE IF( TRIM(cdname) == TRIM(cwxios_context) ) THEN
 !set names of the fields in restart file IF using XIOS to write data
-          CALL iom_set_rst_context()
+          CALL iom_set_rst_context(.FALSE.)
           CALL iom_set_rst_vars(rst_wfields)
 !set which fields are to be written to a restart file
@@ -571,5 +571,5 @@
    END SUBROUTINE iom_set_rstw_active
 
-   SUBROUTINE iom_set_rst_context( ) 
+   SUBROUTINE iom_set_rst_context(ld_rstr) 
      !!---------------------------------------------------------------------
       !!                   ***  SUBROUTINE  iom_set_rst_context  ***
@@ -579,4 +579,7 @@
       !!               
       !!---------------------------------------------------------------------
+   LOGICAL, INTENT(IN)               :: ld_rstr
+!ld_rstr is true for restart context. There is no need to define grid for 
+!restart read, because it's read from file
 #if defined key_iomput
    TYPE(xios_domaingroup)            :: domaingroup_hdl 
@@ -589,5 +592,5 @@
      CALL xios_get_handle("domain_definition",domaingroup_hdl) 
      CALL xios_add_child(domaingroup_hdl, domain_hdl, "grid_N") 
-     CALL set_grid("N", glamt, gphit, .TRUE.) 
+     CALL set_grid("N", glamt, gphit, .TRUE., ld_rstr) 
  
      CALL xios_get_handle("axis_definition",axisgroup_hdl) 
@@ -1935,5 +1938,5 @@
 
 
-   SUBROUTINE set_grid( cdgrd, plon, plat, ldxios )
+   SUBROUTINE set_grid( cdgrd, plon, plat, ldxios, ldrxios )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE set_grid  ***
@@ -1947,5 +1950,5 @@
       INTEGER  :: ni, nj
       REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zmask
-      LOGICAL, INTENT(IN) :: ldxios
+      LOGICAL, INTENT(IN) :: ldxios, ldrxios
       !!----------------------------------------------------------------------
       !
@@ -1955,5 +1958,7 @@
       CALL iom_set_domain_attr("grid_"//cdgrd, ni_glo=jpiglo, nj_glo=jpjglo, ibegin=nimpp+nldi-2, jbegin=njmpp+nldj-2, ni=ni, nj=nj)
       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 /)),   &
+!don't define lon and lat for restart reading context. 
+      IF ( .NOT.ldrxios ) &
+         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 /)))  
       !
