Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/io/nc4_data_output.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/io/nc4_data_output.cpp	(revision 1794)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/io/nc4_data_output.cpp	(revision 1847)
@@ -1639,5 +1639,5 @@
 
            CArray<int, 1> indexes(grid->getNumberWrittenIndexes());
-           indexes = grid->localIndexToWriteOnServer;
+           indexes = grid->localIndexToWriteOnServer_;
 
            switch (SuperClass::type)
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/node/axis.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/node/axis.hpp	(revision 1794)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/node/axis.hpp	(revision 1847)
@@ -169,5 +169,4 @@
          // std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server
          std::unordered_map<size_t,size_t> globalLocalIndexMap_;
-         std::vector<int> indexesToWrite;
          std::map<int,int> numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;
          std::map<int, CArray<int, 1> > compressedIndexToWriteOnServer;
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/node/domain.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/node/domain.hpp	(revision 1794)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/node/domain.hpp	(revision 1847)
@@ -209,15 +209,38 @@
          bool isClientChecked; // Verify whether all attributes of domain on the client side are good
          bool isClientAfterTransformationChecked;
+
+/** global index of the domain on server side, sent by the clients. This is global index for lon, lat, mask elements (ie non masked elements)
+    indGlobs_[rank] -> array of global index received from the client of rank "rank"
+    indGlobs[rank](ind) -> global indices of the "ind" element sent.
+    Defined only on server side
+*/
          std::map<int, CArray<int,1> > indGlob_;
-         std::map<int, map<int,int> > nbSenders; // Mapping of number of communicating client to a server
-
-/** Global index of each client sent to server: map<serverSize, map<serverRank, indexes>> */
+
+/** only on client sided : defined the number of clients which participate to a message sent to a server for longitude, lat, area, etc. attributes 
+    nbSender[nbServers] --> first map is related to the server distribution (ie associated with the contextClient)
+    nbSenders[nbServers][server_rank]-> return the number of participants of a message sent to the server of rank "server_rank"
+*/
+         std::map<int, map<int,int> > nbSenders; 
+
+/** only on client side : Global index of each client sent to server: map<serverSize, map<serverRank, indexes>> 
+    indSrv_[nbServers] -->  first map is related to the server distribution (ie associated with the contextClient)
+    indSrv_[nbServers][server_rank] -> array of global index sent to the server of rank "server_rank"
+    indSrv_[nbServers][server_rank](ind) --> global index on server of the local element "ind" sent (for lon, lat, mask, etc...) 
+*/
          std::map<int, std::unordered_map<int, vector<size_t> > > indSrv_;
-         // std::map<CContextClient*, std::map<int, vector<int> > > indWrittenSrv_; // Global written index of each client sent to server
-         std::vector<int> indexesToWrite;
+         
+ /** make the mapping between the global index (the key) and the local index
+     globalLocalIndexMap_[global_index] --> get the local index
+ */        
+         std::unordered_map<size_t,size_t> globalLocalIndexMap_;
+
+
+/** only on server side : get the rank of each clients which participate to a received message
+*   recvClientRanks_[num_receiver] : client rank of the receiver "num_receiver" 
+*/
          std::vector<int> recvClientRanks_;
+
          std::map<int,int> numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;
          std::map<int, CArray<int, 1> > compressedIndexToWriteOnServer;     
-         std::map<int, std::map<int,size_t> > connectedDataSize_;
          std::map<int, std::vector<int> > connectedServerRank_;
 
@@ -227,5 +250,5 @@
          TransMapTypes transformationMap_;         
          bool isUnstructed_;
-         std::unordered_map<size_t,size_t> globalLocalIndexMap_;
+
        
        private:
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.cpp	(revision 1794)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.cpp	(revision 1847)
@@ -1627,6 +1627,6 @@
    TRY
    { 
-      CArray<size_t,1>& outIndexClient = grid->localIndexToWriteOnClient;
-      CArray<size_t,1>& outIndexServer = grid->localIndexToWriteOnServer;
+      CArray<size_t,1>& outIndexClient = grid->localIndexToWriteOnClient_;
+      CArray<size_t,1>& outIndexServer = grid->localIndexToWriteOnServer_;
       for (size_t idx = 0; idx < outIndexServer.numElements(); ++idx)
       {
@@ -1639,6 +1639,6 @@
    TRY
    {
-      CArray<size_t,1>& outIndexClient = grid->localIndexToWriteOnClient;
-      CArray<size_t,1>& outIndexServer = grid->localIndexToWriteOnServer;
+      CArray<size_t,1>& outIndexClient = grid->localIndexToWriteOnClient_;
+      CArray<size_t,1>& outIndexServer = grid->localIndexToWriteOnServer_;
       for (size_t idx = 0; idx < outIndexServer.numElements(); ++idx)
       {
@@ -1651,6 +1651,6 @@
    TRY
    {
-      CArray<size_t,1>& outIndexClient = grid->localIndexToWriteOnClient;
-      CArray<size_t,1>& outIndexServer = grid->localIndexToWriteOnServer;
+      CArray<size_t,1>& outIndexClient = grid->localIndexToWriteOnClient_;
+      CArray<size_t,1>& outIndexServer = grid->localIndexToWriteOnServer_;
       for (size_t idx = 0; idx < outIndexServer.numElements(); ++idx)
       {
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp	(revision 1794)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp	(revision 1847)
@@ -622,8 +622,8 @@
         int writtenIndex = 0;
 
-        localIndexToWriteOnClient.resize(nbWritten);  
-        localIndexToWriteOnServer.resize(nbWritten);
-        localIndexToWriteOnServer(0) = writtenIndex;
-        localIndexToWriteOnClient(0) = writtenIndex;
+        localIndexToWriteOnClient_.resize(nbWritten);  
+        localIndexToWriteOnServer_.resize(nbWritten);
+        localIndexToWriteOnServer_(0) = writtenIndex;
+        localIndexToWriteOnClient_(0) = writtenIndex;
         
         return;
@@ -643,6 +643,6 @@
       }
 
-      localIndexToWriteOnClient.resize(nbWritten);  
-      localIndexToWriteOnServer.resize(nbWritten);
+      localIndexToWriteOnClient_.resize(nbWritten);  
+      localIndexToWriteOnServer_.resize(nbWritten);
       
       {
@@ -650,7 +650,7 @@
         if (isDataDistributed_)
         {
-          CContextServer* server = CContext::getCurrent()->server;      
-          MPI_Allreduce(&numberWrittenIndexes_, &totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm);
-          MPI_Scan(&numberWrittenIndexes_, &offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm);
+          CContext* context = CContext::getCurrent();      
+          MPI_Allreduce(&numberWrittenIndexes_, &totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, context->intraComm_);
+          MPI_Scan(&numberWrittenIndexes_, &offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, context->intraComm_);
           offsetWrittenIndexes_ -= numberWrittenIndexes_;
         }
@@ -666,6 +666,6 @@
         if (itSrve != itSrv)
         {
-          localIndexToWriteOnServer(nbWritten) = itSrv->second;
-          localIndexToWriteOnClient(nbWritten) = it->second;
+          localIndexToWriteOnServer_(nbWritten) = itSrv->second;
+          localIndexToWriteOnClient_(nbWritten) = it->second;
           ++nbWritten;                
         } 
@@ -1743,5 +1743,5 @@
         for (int i = 0; i < nSize.size(); ++i)
         dataSize *= nSize[i];
-        serverDistribution_ = new CDistributionServer(server->intraCommRank, 
+        serverDistribution_ = new CDistributionServer(context->intraCommRank_, 
                                                       globalIndex, axis_domain_order,
                                                       nBegin, nSize, nBeginGlobal, nGlob);
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.hpp	(revision 1794)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.hpp	(revision 1847)
@@ -315,11 +315,11 @@
 // Maybe we need a flag to determine whether a client wants to write. TODO "
 
-/** Map storing received data on server side. This map is the equivalent of storeIndex_client, but for data not received from model
-  * instead that for client. This map is used to concatenate data received from several clients into a single array on server side
+/** Map storing received data on server side. This map is the equivalent to the storeIndex_client, but for data received from client
+  * instead that from model. This map is used to concatenate data received from several clients into a single array on server side
   * which match the local workflow grid.
   * outLocalIndexStoreOnClient_[client_rank] -> Array of index from client of rank "client_rank"
   * outLocalIndexStoreOnClient_[client_rank](index of buffer from client) -> local index of the workflow grid
   * The map is created in CGrid::computeClientIndex and filled upon receiving data in CField::recvUpdateData().
-  * Symetrically it is also used to send data from a server to sevral client for reading case. */
+  * Symetrically it is also used to send data from a server to several client for reading case. */
          map<int, CArray<size_t, 1> > outLocalIndexStoreOnClient_; 
 
@@ -327,14 +327,15 @@
 /** Indexes calculated based on server-like distribution.
  *  They are used for writing/reading data and only calculated for server level that does the writing/reading.
- *  Along with localIndexToWriteOnClient, these indexes are used to correctly place incoming data. */
-         CArray<size_t,1> localIndexToWriteOnServer;
+ *  Along with localIndexToWriteOnClient, these indexes are used to correctly place incoming data. 
+ *  size of the array : numberWrittenIndexes_ : number of index written in a compressed way
+ *  localIndexToWriteOnServer_(compressed_written_index) : -> local uncompressed index that will be written in the file */
+         CArray<size_t,1> localIndexToWriteOnServer_;
 
 /** Indexes calculated based on client-like distribution.
   * They are used for writing/reading data and only calculated for server level that does the writing/reading.
-  * Along with localIndexToWriteOnServer, these indexes are used to correctly place incoming data. */
-         CArray<size_t,1> localIndexToWriteOnClient;
-
-         CArray<size_t,1> indexFromClients;
-
+  * Along with localIndexToWriteOnServer, these indexes are used to correctly place incoming data. 
+  * size of the array : numberWrittenIndexes_
+  * localIndexToWriteOnClient_(compressed_written_index) -> local index of the workflow grid*/
+         CArray<size_t,1> localIndexToWriteOnClient_;
 
       private:
@@ -344,6 +345,10 @@
         std::set<CContextClient*> clientsSet;
 
-/** Map storing received indexes. Key = sender rank, value = index array. */
-         map<int, CArray<size_t, 1> > outGlobalIndexFromClient_;
+/** Map storing received indexes on server side sent by clients. Key = sender rank, value = global index array. 
+    Later, the global indexes received will be mapped onto local index computed with the local distribution.
+    outGlobalIndexFromClient_[rank] -> array of global index send by client of rank "rank"
+    outGlobalIndexFromClient_[rank](n) -> global index of datav n sent by client
+*/
+        map<int, CArray<size_t, 1> > outGlobalIndexFromClient_;
 
         bool isChecked;
@@ -394,6 +399,11 @@
         bool hasTransform_;
 
-/** Map storing global indexes of server-like (band-wise) distribution for sending to receivers.
-  * Key = size of receiver's intracomm.
+/** Map storing global indexes of server-like (band-wise) distribution for sending to receivers (client side).
+  * Key = size of receiver's intracomm (i.e. number of servers)
+  * ~ map<int, umap<int, std::vector<size_t> >> globalIndexOnServer_
+  * globalIndexOnServer_[servers_size] -> map for a distribution of size "servers_size" (number of servers)
+  * globalIndexOnServer_[servers_size][server_rank] -> array of global index managed by server of rank "server_rank"
+  * globalIndexOnServer_[servers_size][server_rank][n] -> global index of data to be send to the server by client based on sub element of the grid.
+  * -> grid masking is not included.
   */
 //        std::map<CContextClient*, CClientServerMapping::GlobalIndexMap> globalIndexOnServer_;
