Index: XIOS/dev/dev_oa/bld.cfg
===================================================================
--- XIOS/dev/dev_oa/bld.cfg	(revision 1967)
+++ XIOS/dev/dev_oa/bld.cfg	(revision 1968)
@@ -46,13 +46,14 @@
 #bld::target test_remap.exe
 bld::target xios_server.exe 
-bld::target generic_testcase.exe 
+#bld::target generic_testcase.exe 
 #bld::target test_regular.exe
 #bld::target test_xios2_cmip6.exe
 #bld::target test_new_features.exe test_unstruct_complete.exe 
-bld::target test_remap.exe
-bld::target test_complete.exe
-bld::target test_client.exe
+#bld::target test_remap.exe
+#bld::target test_complete.exe
+#bld::target test_client.exe
 #bld::target test_unstruct_complete.exe
 #bld::target test_unstructured.exe
+#bld::target test_tiled_domain
 bld::exe_dep
 
Index: XIOS/dev/dev_oa/inputs/test_tiled_domain/iodef.xml
===================================================================
--- XIOS/dev/dev_oa/inputs/test_tiled_domain/iodef.xml	(revision 1968)
+++ XIOS/dev/dev_oa/inputs/test_tiled_domain/iodef.xml	(revision 1968)
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<simulation>
+
+ <context id="test">
+   <calendar type="Gregorian" start_date="2012-03-01 15:00:00" time_origin="2012-02-28 15:00:00 + 1d" />
+
+
+   <field_definition level="1" enabled=".TRUE.">
+     <field id="field_3d"  operation="average" freq_op="3600s" grid_ref="grid"/>
+     <field id="field_2d"  operation="average" freq_op="3600s" domain_ref="domain"/>
+   </field_definition>
+
+
+   <file_definition type="one_file" par_access="collective" output_freq="1h" output_level="10" enabled=".FALSE.">
+      <file id="output" name="output" enabled=".TRUE.">
+         <field field_ref="field_3d" name="field_3d" />
+     </file>
+   </file_definition>
+
+   <axis_definition>
+     <axis id="axis"/>
+   </axis_definition>
+
+   <domain_definition>
+     <domain id="domain" />
+
+   </domain_definition>
+
+   <grid_definition>
+     <grid id="grid">
+       <domain domain_ref="domain" />
+       <axis axis_ref="axis" />
+     </grid>
+   </grid_definition>
+  </context>
+
+  <context id="xios">
+      <variable_definition>
+         <variable_group id="server">
+            <variable id="using_server2" type="bool">false</variable>
+            <variable id="ratio_server2" type="int">50</variable>
+         </variable_group>
+
+        <variable_group id="buffer">
+            <variable id="optimal_buffer_size" type="string">performance</variable>
+            <variable id="buffer_size_factor" type="double">10.0</variable>
+         </variable_group>
+
+        <variable_group id="parameters" >
+          <variable id="using_server" type="bool">false</variable>
+          <variable id="info_level" type="int">50</variable>
+          <variable id="print_file" type="bool">true</variable>
+        </variable_group>
+      </variable_definition>
+  </context>
+
+</simulation>
+
Index: XIOS/dev/dev_oa/inputs/test_tiled_domain/tile_data_def.nml
===================================================================
--- XIOS/dev/dev_oa/inputs/test_tiled_domain/tile_data_def.nml	(revision 1968)
+++ XIOS/dev/dev_oa/inputs/test_tiled_domain/tile_data_def.nml	(revision 1968)
@@ -0,0 +1,5 @@
+&TILE_DATA_DEF
+! both offsets should be of the same sign or equal to zero simulteneously
+ioffset=-2
+joffset=-2
+/
Index: XIOS/dev/dev_oa/src/test/test_tiled_domain.f90
===================================================================
--- XIOS/dev/dev_oa/src/test/test_tiled_domain.f90	(revision 1968)
+++ XIOS/dev/dev_oa/src/test/test_tiled_domain.f90	(revision 1968)
@@ -0,0 +1,197 @@
+PROGRAM test_tiled_domain
+
+  USE xios
+  USE mod_wait
+  IMPLICIT NONE
+  INCLUDE "mpif.h"
+  INTEGER :: rank
+  INTEGER :: size
+  INTEGER :: ierr
+
+  CHARACTER(len=*),PARAMETER :: id="client"
+  INTEGER :: comm
+  TYPE(xios_duration) :: dtime
+  CHARACTER(len=20) :: dtime_str
+  TYPE(xios_date) :: date
+  CHARACTER(len=20) :: date_str
+  CHARACTER(len=15) :: calendar_type
+  TYPE(xios_context) :: ctx_hdl
+  INTEGER,PARAMETER :: ni_glo=10!100
+  INTEGER,PARAMETER :: nj_glo=10!100
+  INTEGER,PARAMETER :: llm=5
+  DOUBLE PRECISION  :: lval(llm)=1, scalar = 5
+
+  integer, parameter :: ntiles=2
+  integer, dimension (ntiles) :: tile_ni, tile_nj, tile_ibegin, tile_jbegin
+  integer, dimension (ntiles) :: tile_data_ni, tile_data_nj, tile_data_ibegin, tile_data_jbegin  
+
+  TYPE(xios_field) :: field_hdl
+  TYPE(xios_fieldgroup) :: fieldgroup_hdl
+  TYPE(xios_file) :: file_hdl
+  LOGICAL :: ok
+
+  DOUBLE PRECISION,DIMENSION(ni_glo,nj_glo) :: lon_glo,lat_glo
+  DOUBLE PRECISION :: field_3d_glo(ni_glo,nj_glo,llm)
+  DOUBLE PRECISION,ALLOCATABLE :: field_3d(:,:,:)
+  DOUBLE PRECISION,ALLOCATABLE :: field_3d_tile(:,:,:)
+  INTEGER :: ni,ibegin,iend,nj,jbegin,jend
+  INTEGER :: i,j,l,ts,n
+  INTEGER :: ioffset, joffset
+
+  namelist /tile_data_def/ ioffset, joffset
+
+!!! MPI Initialization
+
+  CALL MPI_INIT(ierr)
+
+  CALL init_wait
+
+!!! XIOS Initialization (get the local communicator)
+
+  CALL xios_initialize(id,return_comm=comm)
+
+  CALL MPI_COMM_RANK(comm,rank,ierr)
+  CALL MPI_COMM_SIZE(comm,size,ierr)
+
+!!! Fill in global data array
+
+  DO l=1,llm
+    DO j=1,nj_glo
+      DO i=1,ni_glo
+        field_3d_glo(i,j,l)=(l-1)*ni_glo*nj_glo+(j-1)*ni_glo+(i-1)
+      ENDDO
+    ENDDO
+  ENDDO
+  ni=ni_glo ; ibegin=0
+
+!!! MPI domain decomposition
+
+  jbegin=0
+  DO n=0,size-1
+    nj=nj_glo/size
+    IF (n<MOD(nj_glo,size)) nj=nj+1
+    IF (n==rank) exit
+    jbegin=jbegin+nj
+  ENDDO
+
+  iend=ibegin+ni-1 ; jend=jbegin+nj-1
+
+!!! Fill in local data array
+
+  ALLOCATE(field_3d(ni,nj,llm))
+  field_3d(1:ni,1:nj,:)=field_3d_glo(ibegin+1:iend+1,jbegin+1:jend+1,:)
+
+!!! Tile domain decomposition
+  tile_ni(:)=ni
+  tile_ibegin(:)=0
+  tile_jbegin(1)=0
+  do n=0,ntiles-1
+    tile_nj(n+1)=nj/ntiles
+    if (n<MOD(nj,ntiles)) tile_nj(n+1)=tile_nj(n+1)+1
+  enddo
+
+  do n=2,ntiles
+    tile_jbegin(n)=tile_jbegin(n-1)+tile_nj(n-1)
+  enddo
+
+!!! Define tile data size
+
+  open(10,file='tile_data_def.nml')
+  read(10,nml=tile_data_def)
+  close(10)
+
+  ! Option 1: data correspond in size to a tile
+  if (ioffset == 0) then
+    tile_data_ni(:)=tile_ni(:)
+    tile_data_nj(:)=tile_nj(:)
+    tile_data_ibegin(:)=0
+    tile_data_jbegin(:)=0
+  
+  ! Option 2: masked data
+  else if (ioffset > 0) then
+    do n=1,ntiles
+      tile_data_ni(n)=tile_ni(n)-ioffset*2
+      tile_data_nj(n)=tile_nj(n)-joffset*2
+    enddo
+    tile_data_ibegin(:)=ioffset
+    tile_data_jbegin(:)=joffset
+
+  ! Option 3: data contain ghost zones
+  else
+    do n=1,ntiles
+      tile_data_ni(n)=tile_ni(n)+abs(ioffset)*2
+      tile_data_nj(n)=tile_nj(n)+abs(joffset)*2
+    enddo
+    tile_data_ibegin(:)=ioffset
+    tile_data_jbegin(:)=joffset
+  endif
+
+  CALL xios_context_initialize("test",comm)
+  CALL xios_get_handle("test",ctx_hdl)
+  CALL xios_set_current_context(ctx_hdl)
+
+  CALL xios_set_axis_attr("axis",n_glo=llm ,value=lval) ;
+  CALL xios_set_domain_attr("domain",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj,type='curvilinear')
+  CALL xios_set_domain_attr("domain",ntiles=ntiles, tile_ni=tile_ni, tile_nj=tile_nj, tile_ibegin=tile_ibegin, tile_jbegin=tile_jbegin)
+  CALL xios_set_domain_attr("domain",tile_data_ni=tile_data_ni,tile_data_nj=tile_data_nj)
+  CALL xios_set_domain_attr("domain",tile_data_ibegin=tile_data_ibegin,tile_data_jbegin=tile_data_jbegin)
+
+  dtime%second = 3600
+  CALL xios_set_timestep(dtime)
+
+  ! The calendar is created as soon as the calendar type is defined. This way
+  ! calendar operations can be used before the context definition is closed
+  dtime%timestep = 1
+  dtime = 0.5 * dtime
+  
+  CALL xios_close_context_definition()
+  PRINT *,"close context definition: ok "
+
+  DO ts=1,10
+    CALL xios_update_calendar(ts)
+
+    do n=1,ntiles
+      ALLOCATE(field_3d_tile(tile_data_ibegin(n):tile_data_ibegin(n)+tile_data_ni(n)-1,&
+                             tile_data_jbegin(n):tile_data_jbegin(n)+tile_data_nj(n)-1,llm))
+      
+      if (ioffset == 0) then
+      ! Option 1: data correspond in size to a tile 
+      field_3d_tile(:,:,:)=field_3d(tile_ibegin(n)+1:tile_ibegin(n)+1+tile_ni(n),&
+                                  tile_jbegin(n)+1:tile_jbegin(n)+1+tile_nj(n),:)
+      
+      else if (ioffset > 0) then
+      ! Option 2: masked data
+      field_3d_tile(:,:,:)=field_3d(tile_ibegin(n)+1:tile_ibegin(n)+1+tile_ni(n),&
+                                  tile_jbegin(n)+1:tile_jbegin(n)+1+tile_nj(n),:)
+
+      else
+      ! Option 3: data contain ghost zones
+      field_3d_tile(:,:,:)=2.0
+      field_3d_tile(0:tile_ni(n)-1, 0:tile_nj(n)-1,:)=&
+                    field_3d(tile_ibegin(n)+1:tile_ibegin(n)+tile_ni(n),&
+                             tile_jbegin(n)+1:tile_jbegin(n)+tile_nj(n),:)
+      end if
+
+      CALL xios_send_field("field_3d",field_3d_tile,n-1)
+      DEALLOCATE(field_3d_tile)
+    enddo
+
+    CALL wait_us(5000) ;
+  ENDDO
+
+  CALL xios_context_finalize()
+
+  DEALLOCATE(field_3d)
+
+  CALL MPI_COMM_FREE(comm, ierr)
+
+  CALL xios_finalize()
+
+  CALL MPI_FINALIZE(ierr)
+
+END PROGRAM test_tiled_domain
+
+
+
+
+
