Index: XIOS/dev/dev_trunk_omp/src/filter/spatial_transform_filter.cpp
===================================================================
--- XIOS/dev/dev_trunk_omp/src/filter/spatial_transform_filter.cpp	(revision 1601)
+++ XIOS/dev/dev_trunk_omp/src/filter/spatial_transform_filter.cpp	(revision 1646)
@@ -5,5 +5,7 @@
 #include "context_client.hpp"
 #include "timer.hpp"
+#ifdef _usingEP
 using namespace ep_lib;
+#endif
 
 namespace xios
@@ -197,4 +199,6 @@
     
     CContextClient* client = CContext::getCurrent()->client;
+    int rank;
+    MPI_Comm_rank (client->intraComm, &rank);
 
     // Get default value for output data
@@ -206,5 +210,4 @@
     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();
     const std::vector<CGenericAlgorithmTransformation*>& listAlgos = gridTransformation->getAlgos();
 
@@ -215,8 +218,7 @@
     std::list<CGridTransformation::RecvIndexGridDestinationMap>::const_iterator itListRecv = listLocalIndexToReceive.begin();
     std::list<size_t>::const_iterator itNbListRecv = listNbLocalIndexToReceive.begin();
-    std::list<std::vector<bool> >::const_iterator itLocalMaskIndexOnDest = listLocalIndexMaskOnDest.begin();
     std::vector<CGenericAlgorithmTransformation*>::const_iterator itAlgo = listAlgos.begin();
 
-    for (; itListSend != iteListSend; ++itListSend, ++itListRecv, ++itNbListRecv, ++itLocalMaskIndexOnDest, ++itAlgo)
+    for (; itListSend != iteListSend; ++itListSend, ++itListRecv, ++itNbListRecv, ++itAlgo)
     {
       CArray<double,1> dataCurrentSrc(dataCurrentDest);
@@ -228,8 +230,15 @@
       int idxSendBuff = 0;
       std::vector<double*> sendBuff(localIndexToSend.size());
+      double* sendBuffRank;
       for (itSend = itbSend; itSend != iteSend; ++itSend, ++idxSendBuff)
       {
+        int destRank = itSend->first;
         if (0 != itSend->second.numElements())
-          sendBuff[idxSendBuff] = new double[itSend->second.numElements()];
+        {
+          if (rank != itSend->first)
+            sendBuff[idxSendBuff] = new double[itSend->second.numElements()];
+          else
+            sendBuffRank = new double[itSend->second.numElements()];
+        }
       }
 
@@ -242,9 +251,20 @@
         const CArray<int,1>& localIndex_p = itSend->second;
         int countSize = localIndex_p.numElements();
-        for (int idx = 0; idx < countSize; ++idx)
-        {
-          sendBuff[idxSendBuff][idx] = dataCurrentSrc(localIndex_p(idx));
-        }
-        MPI_Isend(sendBuff[idxSendBuff], countSize, MPI_DOUBLE, destRank, 12, client->intraComm, &sendRecvRequest[position++]);
+        if (destRank != rank)
+        {
+          for (int idx = 0; idx < countSize; ++idx)
+          {
+            sendBuff[idxSendBuff][idx] = dataCurrentSrc(localIndex_p(idx));
+          }  
+          MPI_Isend(sendBuff[idxSendBuff], countSize, MPI_DOUBLE, destRank, 12, client->intraComm, &sendRecvRequest[position++]);
+          
+        }
+        else
+        {
+          for (int idx = 0; idx < countSize; ++idx)
+          {
+            sendBuffRank[idx] = dataCurrentSrc(localIndex_p(idx));
+          }
+        }
       }
 
@@ -254,7 +274,12 @@
                                                                        iteRecv = localIndexToReceive.end();
       int recvBuffSize = 0;
-      for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) recvBuffSize += itRecv->second.size(); //(recvBuffSize < itRecv->second.size())
-                                                                       //? itRecv->second.size() : recvBuffSize;
+      for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv)
+      {
+        if (itRecv->first != rank )
+          recvBuffSize += itRecv->second.size();
+      }
+      //(recvBuffSize < itRecv->second.size()) ? itRecv->second.size() : recvBuffSize;
       double* recvBuff;
+
       if (0 != recvBuffSize) recvBuff = new double[recvBuffSize];
       int currentBuff = 0;
@@ -262,16 +287,18 @@
       {
         int srcRank = itRecv->first;
-        int countSize = itRecv->second.size();
-        MPI_Irecv(recvBuff + currentBuff, countSize, MPI_DOUBLE, srcRank, 12, client->intraComm, &sendRecvRequest[position++]);
-        currentBuff += countSize;
+        if (srcRank != rank)
+        {
+          int countSize = itRecv->second.size();
+          MPI_Irecv(recvBuff + currentBuff, countSize, MPI_DOUBLE, srcRank, 12, client->intraComm, &sendRecvRequest[position++]);
+          currentBuff += countSize;
+        }
       }
       std::vector<MPI_Status> status(sendRecvRequest.size());
-      MPI_Waitall(sendRecvRequest.size(), &sendRecvRequest[0], &status[0]);
+      MPI_Waitall(position, &sendRecvRequest[0], &status[0]);
+
+
 
       dataCurrentDest.resize(*itNbListRecv);
-      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;
+      dataCurrentDest = 0.0;
 
       std::vector<bool> localInitFlag(dataCurrentDest.numElements(), true);
@@ -280,13 +307,25 @@
       for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv)
       {
-        int countSize = itRecv->second.size();
         const std::vector<std::pair<int,double> >& localIndex_p = itRecv->second;
-        (*itAlgo)->apply(localIndex_p,
-                         recvBuff+currentBuff,
-                         dataCurrentDest,
-                         localInitFlag,
-                         ignoreMissingValue,firstPass);
-
-        currentBuff += countSize;
+        int srcRank = itRecv->first;
+        if (srcRank != rank)
+        {
+          int countSize = itRecv->second.size();
+          (*itAlgo)->apply(localIndex_p,
+                           recvBuff+currentBuff,
+                           dataCurrentDest,
+                           localInitFlag,
+                           ignoreMissingValue,firstPass);
+          currentBuff += countSize;
+        }
+        else
+        {
+          (*itAlgo)->apply(localIndex_p,
+                           sendBuffRank,
+                           dataCurrentDest,
+                           localInitFlag,
+                           ignoreMissingValue,firstPass);
+        }
+
         firstPass=false ;
       }
@@ -298,5 +337,10 @@
       {
         if (0 != itSend->second.numElements())
-          delete [] sendBuff[idxSendBuff];
+        {
+          if (rank != itSend->first)
+            delete [] sendBuff[idxSendBuff];
+          else
+            delete [] sendBuffRank;
+        }
       }
       if (0 != recvBuffSize) delete [] recvBuff;
