Index: /XIOS/trunk/inputs/REMAP/iodef.xml
===================================================================
--- /XIOS/trunk/inputs/REMAP/iodef.xml	(revision 714)
+++ /XIOS/trunk/inputs/REMAP/iodef.xml	(revision 715)
@@ -8,18 +8,25 @@
    <field_definition level="1" >
      <field id="src_field"  operation="instant" grid_ref="src_grid"/>
-     <field id="dst_field"  operation="instant" field_ref="src_field" grid_ref="dst_grid"/>
-     <field id="dst_field_regular"  operation="instant" field_ref="src_field" grid_ref="dst_grid_regular"/>
+     <field id="dst_field_regular"  operation="instant" field_ref="tmp_field" grid_ref="dst_grid_regular"/>
+     <field id="tmp_field"  operation="instant" grid_ref="src_grid_regular"/>
    </field_definition>
 
 
-   <file_definition type="one_file" par_access="collective" output_freq="1ts" output_level="10" enabled=".TRUE.">
+   <file_definition type="multiple_file" par_access="collective" output_freq="1ts" output_level="10" enabled=".TRUE.">
      <file id="output" name="output">
-        <field field_ref="src_field" name="field" />
+<!--        <field field_ref="src_field" name="field" />-->
      </file>
      <file id="output_dst" name="output_dst">
-        <field field_ref="dst_field" name="field" />
+<!--        <field id="test" field_ref="dst_field" name="field" />-->
      </file>
-     <file id="output_dst_regular" name="output_dst_regular">
+     <file id="output_dst_regular" name="output_dst_regular" type="one_file">
         <field field_ref="dst_field_regular" name="field" />
+     </file>
+
+     <file id="output_src_regular" name="output_src_regular" mode="read" type="multiple_file">
+        <field id="src_field_regular" name="field" grid_ref="src_grid_regular" operation="instant"/>
+     </file>
+     <file id="output_regular" name="output_regular" mode="write">
+<!--        <field field_ref="field_regular" name="field" />-->
      </file>
    </file_definition>
@@ -35,7 +42,10 @@
        <interpolate_domain/>
      </domain>
-     <domain id="dst_domain_regular" domain_src="src_domain" ni_glo="180" nj_glo="90">
+     <domain id="dst_domain_regular" domain_src="src_domain_regular" ni_glo="90" nj_glo="60" type="rectilinear">
        <generate_rectilinear_domain />
        <interpolate_domain/>
+     </domain>
+     <domain id="src_domain_regular" ni_glo="180" nj_glo="90" type="rectilinear">
+       <generate_rectilinear_domain />
      </domain>
    </domain_definition>
@@ -50,4 +60,7 @@
      <grid id="src_grid">
        <domain domain_ref="src_domain" />
+     </grid>
+     <grid id="src_grid_regular">
+       <domain domain_ref="src_domain_regular" />
      </grid>
    </grid_definition>
Index: /XIOS/trunk/src/node/domain.cpp
===================================================================
--- /XIOS/trunk/src/node/domain.cpp	(revision 714)
+++ /XIOS/trunk/src/node/domain.cpp	(revision 715)
@@ -35,5 +35,5 @@
       , isClientAfterTransformationChecked(false), hasLonLat(false)
       , lonvalue_client(), latvalue_client(), bounds_lon_client(), bounds_lat_client()
-      , srcObject_(0)
+      , srcObject_(0), isRedistributed_(false)
    { /* Ne rien faire de plus */ }
 
@@ -45,5 +45,5 @@
       , isClientAfterTransformationChecked(false), hasLonLat(false)
       , lonvalue_client(), latvalue_client(), bounds_lon_client(), bounds_lat_client()
-      , srcObject_(0)
+      , srcObject_(0), isRedistributed_(false)
    { /* Ne rien faire de plus */ }
 
@@ -171,4 +171,5 @@
    void CDomain::redistribute(int nbLocalDomain)
    {
+     if (this->isRedistributed_) return;
      if (type_attr::rectilinear == type)
      {
@@ -270,5 +271,7 @@
         // Now fill other attributes
         fillInRectilinearLonLat();
-//        fillInRectilinearBoundLonLat();
+        this->isRedistributed_ = true;
+        info <<"now, we are here " << std::endl;
+        info << "domain " << this->getId() << " ni " << ni.getValue() << " nj " << nj.getValue() << std::endl;
      }
    }
@@ -327,4 +330,29 @@
        }
    }
+
+   /*!
+     Temporary function to verify whether a rectilinear domain is created automatically.
+   The domain is distributed into number of parts which are equal to number of clients (intracomm)
+   */
+   void CDomain::checkGenerate()
+   {
+     TransMapTypes trans = this->getAllTransformations();
+     TransMapTypes::const_iterator it = trans.begin(), ite = trans.end();
+     int transOrder = 0;
+     for (; it != ite; ++it, ++transOrder)
+     {
+       ETranformationType transType = it->first;
+       if ((TRANS_GENERATE_RECTILINEAR_DOMAIN == transType) && (0 == transOrder))
+       {
+         CContext* context = CContext::getCurrent();
+         CContextClient* client = context->client;
+         int nbClient;
+         MPI_Comm_size(client->intraComm,&nbClient);
+         this->redistribute(nbClient);
+         break;
+       }
+     }
+   }
+
 
    void CDomain::checkDomain(void)
@@ -942,4 +970,5 @@
      CContext* context=CContext::getCurrent();
 
+      this->checkGenerate();
       this->checkDomain();
       this->checkBounds();
Index: /XIOS/trunk/src/node/domain.hpp
===================================================================
--- /XIOS/trunk/src/node/domain.hpp	(revision 714)
+++ /XIOS/trunk/src/node/domain.hpp	(revision 715)
@@ -164,4 +164,5 @@
          void checkArea(void);
          void checkLonLat();
+         void checkGenerate();
 
          void checkTransformations();
@@ -189,4 +190,5 @@
          //! True if and only if the data defined on the domain can be outputted in a compressed way
          bool isCompressible_;
+         bool isRedistributed_;
          TransMapTypes transformationMap_;
          std::vector<int> nGlobDomain_;
Index: /XIOS/trunk/src/test/test_remap.f90
===================================================================
--- /XIOS/trunk/src/test/test_remap.f90	(revision 714)
+++ /XIOS/trunk/src/test/test_remap.f90	(revision 715)
@@ -20,5 +20,5 @@
   DOUBLE PRECISION,ALLOCATABLE :: src_boundslon(:,:), dst_boundslon(:,:)
   DOUBLE PRECISION,ALLOCATABLE :: src_boundslat(:,:), dst_boundslat(:,:)
-  DOUBLE PRECISION,ALLOCATABLE :: src_field(:)
+  DOUBLE PRECISION,ALLOCATABLE :: src_field(:), tmp_field(:)
   INTEGER :: src_ni_glo, dst_ni_glo;
   INTEGER :: src_nvertex, dst_nvertex;
@@ -119,6 +119,8 @@
                             bounds_lon_1D=dst_boundslon, bounds_lat_1D=dst_boundslat, nvertex=dst_nvertex)
 
-  CALL xios_set_domain_attr("dst_domain_regular", type="rectilinear")
+!  CALL xios_set_domain_attr("dst_domain_regular", type="rectilinear")
 
+
+  ALLOCATE(tmp_field(180*90/2))
   dtime%second = 3600
   CALL xios_set_timestep(dtime)
@@ -127,6 +129,8 @@
 
   DO ts=1,1
+    CALL xios_recv_field("src_field_regular", tmp_field)
     CALL xios_update_calendar(ts)
-    CALL xios_send_field("src_field",src_field)
+!    CALL xios_send_field("src_field",src_field)
+    CALL xios_send_field("tmp_field",tmp_field)
     CALL wait_us(5000) ;
   ENDDO
