Index: /XIOS/trunk/inputs/REMAP/iodef.xml
===================================================================
--- /XIOS/trunk/inputs/REMAP/iodef.xml	(revision 872)
+++ /XIOS/trunk/inputs/REMAP/iodef.xml	(revision 873)
@@ -5,5 +5,5 @@
    <calendar type="Gregorian" start_date="2012-03-01 15:00:00" time_origin="2012-02-28 15:00:00 + 1d" />
    <field_definition level="1" >
-     <field id="src_field" operation="instant" domain_ref="src_domain"/>
+     <field id="src_field" operation="instant" domain_ref="src_domain_clone"/>
      <field id="src_field_3D" operation="instant" domain_ref="src_domain" axis_ref="src_axis"/>
      <field id="src_field_3D_interp" operation="instant" field_ref="src_field_3D" axis_ref="dst_axis"/>
@@ -24,8 +24,8 @@
    <file_definition type="one_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_3D" name="output_3D">
-        <field field_ref="src_field_3D" name="field" />
+     <file id="output_2D" name="output_2D">
+        <field field_ref="src_field" name="field"  domain_ref="dst_domain_regular_pole" default_value="10.e+5"/>
      </file>
     <file id="output_3D_pression" name="output_3D_pression">
Index: /XIOS/trunk/src/filter/spatial_transform_filter.cpp
===================================================================
--- /XIOS/trunk/src/filter/spatial_transform_filter.cpp	(revision 872)
+++ /XIOS/trunk/src/filter/spatial_transform_filter.cpp	(revision 873)
@@ -6,10 +6,10 @@
 namespace xios
 {
-  CSpatialTransformFilter::CSpatialTransformFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, size_t inputSlotsCount)
-    : CFilter(gc, inputSlotsCount, engine)
+  CSpatialTransformFilter::CSpatialTransformFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, double outputValue, size_t inputSlotsCount)
+    : CFilter(gc, inputSlotsCount, engine), outputDefaultValue(outputValue)
   { /* Nothing to do */ }
 
   std::pair<boost::shared_ptr<CSpatialTransformFilter>, boost::shared_ptr<CSpatialTransformFilter> >
-  CSpatialTransformFilter::buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid)
+  CSpatialTransformFilter::buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid, double defaultValue)
   {
     if (!srcGrid || !destGrid)
@@ -26,5 +26,5 @@
       const std::vector<StdString>& auxInputs = gridTransformation->getAuxInputs();
       size_t inputCount = 1 + (auxInputs.empty() ? 0 : auxInputs.size());
-      boost::shared_ptr<CSpatialTransformFilter> filter(new CSpatialTransformFilter(gc, engine, inputCount));
+      boost::shared_ptr<CSpatialTransformFilter> filter(new CSpatialTransformFilter(gc, engine, defaultValue, inputCount));
 
       if (!lastFilter)
@@ -48,4 +48,12 @@
   }
 
+  void CSpatialTransformFilter::onInputReady(std::vector<CDataPacketPtr> data)
+  {
+    CSpatialTransformFilterEngine* spaceFilter = static_cast<CSpatialTransformFilterEngine*>(engine);
+    CDataPacketPtr outputPacket = spaceFilter->applyFilter(data, outputDefaultValue);
+    if (outputPacket)
+      deliverOuput(outputPacket);
+  }
+
   CSpatialTransformFilterEngine::CSpatialTransformFilterEngine(CGridTransformation* gridTransformation)
     : gridTransformation(gridTransformation)
@@ -75,4 +83,9 @@
 
   CDataPacketPtr CSpatialTransformFilterEngine::apply(std::vector<CDataPacketPtr> data)
+  {
+    /* Nothing to do */
+  }
+
+  CDataPacketPtr CSpatialTransformFilterEngine::applyFilter(std::vector<CDataPacketPtr> data, double defaultValue)
   {
     CDataPacketPtr packet(new CDataPacket);
@@ -90,4 +103,5 @@
       }
       packet->data.resize(gridTransformation->getGridDestination()->storeIndex_client.numElements());
+      packet->data = defaultValue;
       apply(data[0]->data, packet->data);
     }
@@ -99,8 +113,13 @@
   {
     CContextClient* client = CContext::getCurrent()->client;
+
+    // Get default value for output data
+    double defaultValue = 0.0;
+    if (0 != dataDest.numElements()) defaultValue = dataDest(0);
 
     const std::list<CGridTransformation::SendingIndexGridSourceMap>& listLocalIndexSend = gridTransformation->getLocalIndexToSendFromGridSource();
     const std::list<CGridTransformation::RecvIndexGridDestinationMap>& listLocalIndexToReceive = gridTransformation->getLocalIndexToReceiveOnGridDest();
     const std::list<size_t>& listNbLocalIndexToReceive = gridTransformation->getNbLocalIndexToReceiveOnGridDest();
+    const std::list<std::vector<bool> >& listLocalIndexMaskOnDest = gridTransformation->getLocalMaskIndexOnGridDest();
 
     CArray<double,1> dataCurrentDest(dataSrc.copy());
@@ -110,6 +129,7 @@
     std::list<CGridTransformation::RecvIndexGridDestinationMap>::const_iterator itListRecv = listLocalIndexToReceive.begin();
     std::list<size_t>::const_iterator itNbListRecv = listNbLocalIndexToReceive.begin();
-
-    for (; itListSend != iteListSend; ++itListSend, ++itListRecv, ++itNbListRecv)
+    std::list<std::vector<bool> >::const_iterator itLocalMaskIndexOnDest = listLocalIndexMaskOnDest.begin();
+
+    for (; itListSend != iteListSend; ++itListSend, ++itListRecv, ++itNbListRecv, ++itLocalMaskIndexOnDest)
     {
       CArray<double,1> dataCurrentSrc(dataCurrentDest);
@@ -164,5 +184,9 @@
 
       dataCurrentDest.resize(*itNbListRecv);
-      dataCurrentDest = 0.0;
+      const std::vector<bool>& localMaskDest = *itLocalMaskIndexOnDest;
+      for (int i = 0; i < localMaskDest.size(); ++i)
+        if (localMaskDest[i]) dataCurrentDest(i) = 0.0;
+        else dataCurrentDest(i) = defaultValue;
+
       currentBuff = 0;
       for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv)
Index: /XIOS/trunk/src/filter/spatial_transform_filter.hpp
===================================================================
--- /XIOS/trunk/src/filter/spatial_transform_filter.hpp	(revision 872)
+++ /XIOS/trunk/src/filter/spatial_transform_filter.hpp	(revision 873)
@@ -21,7 +21,8 @@
        * \param gc the associated garbage collector
        * \param engine the engine defining the spatial transformation
+       * \param outputValue default value of output pin
        * \param [in] inputSlotsCount number of input, by default there is only one for field src
        */
-      CSpatialTransformFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, size_t inputSlotsCount = 1);
+      CSpatialTransformFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, double outputValue, size_t inputSlotsCount = 1);
 
       /*!
@@ -34,5 +35,15 @@
        */
       static std::pair<boost::shared_ptr<CSpatialTransformFilter>, boost::shared_ptr<CSpatialTransformFilter> >
-      buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid);
+      buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid, double defaultValue);
+
+    protected:
+      /*!
+        Overriding this function to process transformations with auxillary inputs
+      */
+      void virtual onInputReady(std::vector<CDataPacketPtr> data);
+
+    protected:
+      //! Default value of output pin
+      double outputDefaultValue;
   }; // class CSpatialTransformFilter
 
@@ -56,7 +67,18 @@
        *
        * \param data a vector of packets corresponding to each slot (one in this case)
+       * \param [in] defaultValue default value of output data
+       * \return the result of the grid transformation
+       */
+      CDataPacketPtr applyFilter(std::vector<CDataPacketPtr> data, double defaultValue = 0);
+
+       /*!
+       * Applies the grid transformation to the input data and returns the result.
+       *
+       * \param data a vector of packets corresponding to each slot (one in this case)
        * \return the result of the grid transformation
        */
       CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data);
+
+
 
     protected:
Index: /XIOS/trunk/src/node/field.cpp
===================================================================
--- /XIOS/trunk/src/node/field.cpp	(revision 872)
+++ /XIOS/trunk/src/node/field.cpp	(revision 873)
@@ -289,5 +289,5 @@
       cout<<"file->output_freq.getValue() : "<<file->output_freq.getValue()<<endl ;
       cout<<"lastDataRequestedFromServer + file->output_freq.getValue() : "<<lastDataRequestedFromServer + file->output_freq.getValue()<<endl ;
-     
+
       sendReadDataRequest();
     }
@@ -346,5 +346,5 @@
           nstepMax = getRelFile()->getDataInput()->getFieldNbRecords(CField::get(this));
         }
-        
+
         this->incrementNStep();
 
@@ -780,5 +780,10 @@
      // Check if a spatial transformation is needed
      if (grid && grid != fieldRef->grid && grid->hasTransform())
-       filters = CSpatialTransformFilter::buildFilterGraph(gc, fieldRef->grid, grid);
+     {
+       double defaultValue = 0.0;
+       if (!default_value.isEmpty()) defaultValue = this->default_value;
+       filters = CSpatialTransformFilter::buildFilterGraph(gc, fieldRef->grid, grid, defaultValue);
+     }
+
      else
        filters.first = filters.second = boost::shared_ptr<CFilter>(new CPassThroughFilter(gc));
Index: /XIOS/trunk/src/test/test_remap.f90
===================================================================
--- /XIOS/trunk/src/test/test_remap.f90	(revision 872)
+++ /XIOS/trunk/src/test/test_remap.f90	(revision 873)
@@ -21,4 +21,5 @@
   DOUBLE PRECISION,ALLOCATABLE :: src_boundslat(:,:), dst_boundslat(:,:)
   DOUBLE PRECISION,ALLOCATABLE :: src_field(:), tmp_field(:), tmp_field_1(:), tmp_field_2(:), src_field_3D(:,:), lval(:), lval1(:), src_field_pression(:,:)
+  LOGICAL,ALLOCATABLE :: src_mask_2D(:)
   INTEGER :: src_ni_glo, dst_ni_glo;
   INTEGER :: src_nvertex, dst_nvertex;
@@ -67,4 +68,5 @@
   ALLOCATE(src_field(src_ni))
   ALLOCATE(src_field_3D(src_ni,llm))
+  ALLOCATE(src_mask_2D(src_ni))
   ALLOCATE(src_field_pression(src_ni,llm))
   ALLOCATE(lval(llm))
@@ -83,4 +85,9 @@
   DO i=1,src_ni
     src_field_3D(i,:) = src_field(i)
+    IF (MOD(i,10)==0) THEN
+      src_mask_2D(i)=.FALSE.
+    ELSE
+      src_mask_2D(i)=.TRUE.
+    ENDIF
   ENDDO
 
@@ -136,5 +143,6 @@
   CALL xios_set_domain_attr("src_domain_clone", ni_glo=src_ni_glo, ibegin=src_ibegin, ni=src_ni, type="unstructured")
   CALL xios_set_domain_attr("src_domain_clone", lonvalue_1D=src_lon, latvalue_1D=src_lat, &
-                            bounds_lon_1D=src_boundslon, bounds_lat_1D=src_boundslat, nvertex=src_nvertex)
+                            bounds_lon_1D=src_boundslon, bounds_lat_1D=src_boundslat, nvertex=src_nvertex, &
+                            mask_1d=src_mask_2D)
 
   CALL xios_set_axis_attr("src_axis", n_glo=llm, value=lval)
Index: /XIOS/trunk/src/transformation/grid_transformation.cpp
===================================================================
--- /XIOS/trunk/src/transformation/grid_transformation.cpp	(revision 872)
+++ /XIOS/trunk/src/transformation/grid_transformation.cpp	(revision 873)
@@ -438,4 +438,5 @@
       std::list<RecvIndexGridDestinationMap>().swap(localIndexToReceiveOnGridDest_);
       std::list<size_t>().swap(nbLocalIndexOnGridDest_);
+      std::list<std::vector<bool> >().swap(localMaskOnGridDest_);
     }
     else
@@ -458,10 +459,6 @@
     SourceDestinationIndexMap globaIndexWeightFromSrcToDst;
 
-//    if (1 < nbAlgos_)
-//    {
-//      // Create a temporary grid destination which contains transformed element of grid destination and
-//      // non-transformed elements fo grid source
-////      if (nbAgloTransformation != (nbAlgos_-1)) setUpGridDestination(elementPositionInGrid, transType, nbAgloTransformation);
-//    }
+    // Create a temporary grid destination which contains transformed element of grid destination and
+    // non-transformed elements fo grid source
     setUpGridDestination(elementPositionInGrid, transType, nbAgloTransformation);
 
@@ -512,7 +509,5 @@
   // Recalculate the distribution of grid destination
   CDistributionClient distributionClientDest(client->clientRank, tmpGridDestination_);
-//  CDistributionClient distributionClientDest(client->clientRank, gridDestination_);
   CDistributionClient::GlobalLocalDataMap& globalLocalIndexGridDestSendToServer = distributionClientDest.getGlobalLocalDataSendToServer();
-  const std::vector<int>& localMask = distributionClientDest.getLocalMaskIndexOnClient();
 
   // Update number of local index on each transformation
@@ -522,8 +517,4 @@
   std::vector<bool>& tmpMask = localMaskOnGridDest_.back();
   tmpMask.resize(nbLocalIndex,false);
-//  for (int idx = 0; idx < nbLocalIndex; ++idx)
-//  {
-//    tmpMask[localMask[idx]] = true;
-//  }
 
   // Find out number of index sent from grid source and number of index received on grid destination
@@ -708,4 +699,5 @@
         recvTmp[recvRank][realRecvSize].first = globalLocalIndexGridDestSendToServer[recvIndexDst(idx)];
         recvTmp[recvRank][realRecvSize].second = recvWeightDst(idx);
+        tmpMask[globalLocalIndexGridDestSendToServer[recvIndexDst(idx)]] = true;
          ++realRecvSize;
       }
