Index: /XIOS/dev/dev_ym/XIOS_COUPLING/src/node/axis.cpp
===================================================================
--- /XIOS/dev/dev_ym/XIOS_COUPLING/src/node/axis.cpp	(revision 1974)
+++ /XIOS/dev/dev_ym/XIOS_COUPLING/src/node/axis.cpp	(revision 1975)
@@ -20,11 +20,8 @@
    CAxis::CAxis(void)
       : CObjectTemplate<CAxis>()
-      , CAxisAttributes(), isChecked(false), relFiles(), areClientAttributesChecked_(false)
-      , isClientAfterTransformationChecked(false)
+      , CAxisAttributes(), isChecked(false), relFiles()
       , hasBounds(false), isCompressible_(false)
-      , numberWrittenIndexes_(), totalNumberWrittenIndexes_(), offsetWrittenIndexes_()
       , transformationMap_(), hasValue(false), hasLabel(false)
-      , computedWrittenIndex_(false)
-	  , clients()
+      , clients()
    {
    }
@@ -32,11 +29,8 @@
    CAxis::CAxis(const StdString & id)
       : CObjectTemplate<CAxis>(id)
-      , CAxisAttributes(), isChecked(false), relFiles(), areClientAttributesChecked_(false)
-      , isClientAfterTransformationChecked(false)
+      , CAxisAttributes(), isChecked(false), relFiles()
       , hasBounds(false), isCompressible_(false)
-      , numberWrittenIndexes_(), totalNumberWrittenIndexes_(), offsetWrittenIndexes_()
       , transformationMap_(), hasValue(false), hasLabel(false)
-      , computedWrittenIndex_(false)
-	  , clients()
+      , clients()
    {
    }
@@ -131,55 +125,5 @@
    CATCH_DUMP_ATTR
 
-   //----------------------------------------------------------------
-
-   /*!
-     Returns the number of indexes written by each server.
-     \return the number of indexes written by each server
-   */
-   int CAxis::getNumberWrittenIndexes(MPI_Comm writtenCom)
-   TRY
-   {
-     int writtenSize;
-     MPI_Comm_size(writtenCom, &writtenSize);
-     return numberWrittenIndexes_[writtenSize];
-   }
-   CATCH_DUMP_ATTR
-
-   /*!
-     Returns the total number of indexes written by the servers.
-     \return the total number of indexes written by the servers
-   */
-   int CAxis::getTotalNumberWrittenIndexes(MPI_Comm writtenCom)
-   TRY
-   {
-     int writtenSize;
-     MPI_Comm_size(writtenCom, &writtenSize);
-     return totalNumberWrittenIndexes_[writtenSize];
-   }
-   CATCH_DUMP_ATTR
-
-   /*!
-     Returns the offset of indexes written by each server.
-     \return the offset of indexes written by each server
-   */
-   int CAxis::getOffsetWrittenIndexes(MPI_Comm writtenCom)
-   TRY
-   {
-     int writtenSize;
-     MPI_Comm_size(writtenCom, &writtenSize);
-     return offsetWrittenIndexes_[writtenSize];
-   }
-   CATCH_DUMP_ATTR
-
-   CArray<int, 1>& CAxis::getCompressedIndexToWriteOnServer(MPI_Comm writtenCom)
-   TRY
-   {
-     int writtenSize;
-     MPI_Comm_size(writtenCom, &writtenSize);
-     return compressedIndexToWriteOnServer[writtenSize];
-   }
-   CATCH_DUMP_ATTR
-
-   //----------------------------------------------------------------
+    //----------------------------------------------------------------
 
    /*!
@@ -481,16 +425,4 @@
        switch(event.type)
        {
-          case EVENT_ID_DISTRIBUTION_ATTRIBUTE :
-            recvDistributionAttribute(event);
-            return true;
-            break;
-         case EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES:
-           recvNonDistributedAttributes(event);
-           return true;
-           break;
-         case EVENT_ID_DISTRIBUTED_ATTRIBUTES:
-           recvDistributedAttributes_old(event);
-           return true;
-           break;
          case EVENT_ID_AXIS_DISTRIBUTION:
            recvAxisDistribution(event);
@@ -510,98 +442,13 @@
   CATCH
 
-   /*!
-     Check attributes on client side (This name is still adequate???)
-   */
-   void CAxis::checkAttributesOnClient()
-   TRY
-   {
-     if (this->areClientAttributesChecked_) return;
-
-     CContext* context=CContext::getCurrent();
-     if (context->getServiceType()==CServicesManager::CLIENT) this->checkAttributes();
-
-     this->areClientAttributesChecked_ = true;
-   }
-   CATCH_DUMP_ATTR
-
-   /*
-     The (spatial) transformation sometimes can change attributes of an axis (e.g zoom can change mask or generate can change whole attributes)
-     Therefore, we should recheck them.
-   */
-   // ym : obsolete to be removed
-   void CAxis::checkAttributesOnClientAfterTransformation(const std::vector<int>& globalDim, int orderPositionInGrid,
-                                                          CServerDistributionDescription::ServerDistributionType distType)
-   TRY
-   {
-     CContext* context=CContext::getCurrent() ;
-
-     if (this->isClientAfterTransformationChecked) return;
-     if (context->getServiceType()==CServicesManager::CLIENT || context->getServiceType()==CServicesManager::GATHERER)
-     {        
-       /* suppressed because of interface changed
-       if (orderPositionInGrid == CServerDistributionDescription::defaultDistributedDimension(globalDim.size(), distType))
-         computeConnectedClients(globalDim, orderPositionInGrid, distType);
-       else if (index.numElements() != n_glo) computeConnectedClients(globalDim, orderPositionInGrid,  CServerDistributionDescription::ROOT_DISTRIBUTION);
-       */
-     }
-
-     this->isClientAfterTransformationChecked = true;
-   }
-   CATCH_DUMP_ATTR
-
-   /*
-     Send all checked attributes to server? (We dont have notion of server any more so client==server)
-     \param [in] globalDim global dimension of grid containing this axis
-     \param [in] orderPositionInGrid the relative order of this axis in the grid (e.g grid composed of domain+axis -> orderPositionInGrid is 2)
-     \param [in] distType distribution type of the server. For now, we only have band distribution.
-
-   */
-   //ym obsolete : to be removed
-   void CAxis::sendCheckedAttributes(const std::vector<int>& globalDim, int orderPositionInGrid,
-                                     CServerDistributionDescription::ServerDistributionType distType)
-   TRY
-   {
-     if (!this->areClientAttributesChecked_) checkAttributesOnClient();
-     if (!this->isClientAfterTransformationChecked) checkAttributesOnClientAfterTransformation(globalDim, orderPositionInGrid, distType);
-     CContext* context = CContext::getCurrent();
-
-     if (this->isChecked) return;
-     if (context->getServiceType()==CServicesManager::CLIENT || context->getServiceType()==CServicesManager::GATHERER) /*sendAttributes(globalDim, orderPositionInGrid, distType)*/;    
-
-     this->isChecked = true;
-   }
-   CATCH_DUMP_ATTR
-
-  
-   void CAxis::sendAxisToFileServer(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid)
-   {
-     if (sendAxisToFileServer_done_.count(client)!=0) return ;
-     else sendAxisToFileServer_done_.insert(client) ;
-     
-     StdString axisDefRoot("axis_definition");
-     CAxisGroup* axisPtr = CAxisGroup::get(axisDefRoot);
-     axisPtr->sendCreateChild(this->getId(),client);
-     this->sendAllAttributesToServer(client)  ; 
-     this->sendAttributes(client, globalDim, orderPositionInGrid, CServerDistributionDescription::BAND_DISTRIBUTION) ;
-   }
-
+   /* to remove later when reimplementing coupling */
    void CAxis::sendAxisToCouplerOut(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, const string& fieldId, int posInGrid)
    {
-     if (sendAxisToFileServer_done_.count(client)!=0) return ;
-     else sendAxisToFileServer_done_.insert(client) ;
+     if (sendAxisToCouplerOut_done_.count(client)!=0) return ;
+     else sendAxisToCouplerOut_done_.insert(client) ;
      
      string axisId="_axis["+std::to_string(posInGrid)+"]_of_"+fieldId ;
 
-     if (!axis_ref.isEmpty())
-    {
-      auto axis_ref_tmp=axis_ref.getValue() ;
-      axis_ref.reset() ; // remove the reference, find an other way to do that more cleanly
-      this->sendAllAttributesToServer(client, axisId)  ; 
-      axis_ref = axis_ref_tmp ;
-    }
-    else this->sendAllAttributesToServer(client, axisId)  ; 
-  
-    this->sendAttributes(client, globalDim, orderPositionInGrid, CServerDistributionDescription::BAND_DISTRIBUTION, axisId) ;
-   }
+    }
 
   void CAxis::makeAliasForCoupling(const string& fieldId, int posInGrid)
@@ -611,772 +458,5 @@
   }
 
-  /*!
-    Send attributes from one client to other clients
-    \param[in] globalDim global dimension of grid which contains this axis
-    \param[in] order
-  */
-  void CAxis::sendAttributes(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid,
-                             CServerDistributionDescription::ServerDistributionType distType, const string& axisId)
-  TRY
-  {
-     sendDistributionAttribute(client, globalDim, orderPositionInGrid, distType, axisId);
-
-     // if (index.numElements() == n_glo.getValue())
-     if ((orderPositionInGrid == CServerDistributionDescription::defaultDistributedDimension(globalDim.size(), distType))
-         || (index.numElements() != n_glo))
-     {
-       sendDistributedAttributes_old(client, axisId);       
-     }
-     else
-     {
-       sendNonDistributedAttributes(client, axisId);    
-     }     
-  }
-  CATCH_DUMP_ATTR
-
-  /*
-    Compute the connection between group of clients (or clients/servers).
-    (E.g: Suppose we have 2 group of clients in two model: A (client role) connect to B (server role),
-    this function calculate number of clients B connect to one client of A)
-     \param [in] globalDim global dimension of grid containing this axis
-     \param [in] orderPositionInGrid the relative order of this axis in the grid (e.g grid composed of domain+axis -> orderPositionInGrid is 2)
-     \param [in] distType distribution type of the server. For now, we only have band distribution.
-  */
-  void CAxis::computeConnectedClients(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid)
-  TRY
-  {
-    if (computeConnectedClients_done_.count(client)!=0) return ;
-    else computeConnectedClients_done_.insert(client) ;
-
-    CContext* context = CContext::getCurrent();
-    CServerDistributionDescription::ServerDistributionType distType ;
-    int defaultDistributedPos = CServerDistributionDescription::defaultDistributedDimension(globalDim.size(), CServerDistributionDescription::BAND_DISTRIBUTION) ;
-    
-    if (orderPositionInGrid == defaultDistributedPos) distType =  CServerDistributionDescription::BAND_DISTRIBUTION ;
-    else if (index.numElements() != n_glo) distType =  CServerDistributionDescription::ROOT_DISTRIBUTION ;
-    else return ;
-
-    int nbServer = client->serverSize;
-    int range, clientSize = client->clientSize;
-    int rank = client->clientRank;
-
-    if (listNbServer_.count(nbServer) == 0)
-    {
-      listNbServer_.insert(nbServer) ;
-
-      if (connectedServerRank_.find(nbServer) != connectedServerRank_.end())
-      {
-        nbSenders.erase(nbServer);
-        connectedServerRank_.erase(nbServer);
-      }
-
-      size_t ni = this->n.getValue();
-      size_t ibegin = this->begin.getValue();
-      size_t nbIndex = index.numElements();
-
-      // First of all, we should compute the mapping of the global index and local index of the current client
-      if (globalLocalIndexMap_.empty())
-      {
-        for (size_t idx = 0; idx < nbIndex; ++idx)
-        {
-          globalLocalIndexMap_[index(idx)] = idx;
-        }
-      }
-
-      // Calculate the compressed index if any
-      //        std::set<int> writtenInd;
-      //        if (isCompressible_)
-      //        {
-      //          for (int idx = 0; idx < data_index.numElements(); ++idx)
-      //          {
-      //            int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni); 
-      //
-      //            if (ind >= 0 && ind < ni && mask(ind))
-      //            {
-      //              ind += ibegin;
-      //              writtenInd.insert(ind);
-      //            }
-      //          }
-      //        }
-
-      // Compute the global index of the current client (process) hold
-      std::vector<int> nGlobAxis(1);
-      nGlobAxis[0] = n_glo.getValue();
-
-      size_t globalSizeIndex = 1, indexBegin, indexEnd;
-      for (int i = 0; i < nGlobAxis.size(); ++i) globalSizeIndex *= nGlobAxis[i];
-      indexBegin = 0;
-      if (globalSizeIndex <= clientSize)
-      {
-        indexBegin = rank%globalSizeIndex;
-        indexEnd = indexBegin;
-      }
-      else
-      {
-        for (int i = 0; i < clientSize; ++i)
-        {
-          range = globalSizeIndex / clientSize;
-          if (i < (globalSizeIndex%clientSize)) ++range;
-          if (i == client->clientRank) break;
-          indexBegin += range;
-        }
-        indexEnd = indexBegin + range - 1;
-      }
-
-      CArray<size_t,1> globalIndex(index.numElements());
-      for (size_t idx = 0; idx < globalIndex.numElements(); ++idx)
-        globalIndex(idx) = index(idx);
-
-      // Describe the distribution of server side
-
-      CServerDistributionDescription serverDescription(nGlobAxis, nbServer, distType);
-    
-      std::vector<int> serverZeroIndex;
-      serverZeroIndex = serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t&,size_t&>(indexBegin, indexEnd), 0);
-
-      std::list<int> serverZeroIndexLeader;
-      std::list<int> serverZeroIndexNotLeader; 
-      CContextClient::computeLeader(client->clientRank, client->clientSize, serverZeroIndex.size(), serverZeroIndexLeader, serverZeroIndexNotLeader);
-      for (std::list<int>::iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it)
-        *it = serverZeroIndex[*it];
-
-      // Find out the connection between client and server side
-      CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), client->intraComm);
-      clientServerMap->computeServerIndexMapping(globalIndex, nbServer);
-      CClientServerMapping::GlobalIndexMap& globalIndexAxisOnServer = clientServerMap->getGlobalIndexOnServer();      
-
-      indSrv_[nbServer].swap(globalIndexAxisOnServer);
-
-      if (distType==CServerDistributionDescription::ROOT_DISTRIBUTION)
-      {
-        for(int i=1; i<nbServer; ++i) indSrv_[nbServer].insert(pair<int, vector<size_t> >(i,indSrv_[nbServer][0]) ) ;
-        serverZeroIndexLeader.clear() ;
-      }
-       
-      CClientServerMapping::GlobalIndexMap::const_iterator it  = indSrv_[nbServer].begin(),
-                                                           ite = indSrv_[nbServer].end();
-
-      for (it = indSrv_[nbServer].begin(); it != ite; ++it) connectedServerRank_[nbServer].push_back(it->first);
-
-      for (std::list<int>::const_iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it)
-        connectedServerRank_[nbServer].push_back(*it);
-
-       // Even if a client has no index, it must connect to at least one server and 
-       // send an "empty" data to this server
-       if (connectedServerRank_[nbServer].empty())
-        connectedServerRank_[nbServer].push_back(client->clientRank % client->serverSize);
-
-      nbSenders[nbServer] = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[nbServer]);
-
-      delete clientServerMap;
-    }
-  }
-  CATCH_DUMP_ATTR
-
-  /*
-    Compute the index of data to write into file
-    (Different from the previous version, this version of XIOS allows data be written into file (classical role),
-    or transfered to another clients)
-  */
-  void CAxis::computeWrittenIndex()
-  TRY
-  {  
-    if (computedWrittenIndex_) return;
-    computedWrittenIndex_ = true;
-
-    CContext* context=CContext::getCurrent();      
-
-    // We describe the distribution of client (server) on which data are written
-    std::vector<int> nBegin(1), nSize(1), nBeginGlobal(1), nGlob(1);
-    nBegin[0]       = begin;
-    nSize[0]        = n;
-    nBeginGlobal[0] = 0; 
-    nGlob[0]        = n_glo;
-    CDistributionServer srvDist(context->intraCommSize_, nBegin, nSize, nBeginGlobal, nGlob); 
-    const CArray<size_t,1>& writtenGlobalIndex  = srvDist.getGlobalIndex();
-
-    // Because all written data are local on a client, 
-    // we need to compute the local index on the server from its corresponding global index
-    size_t nbWritten = 0, indGlo;      
-    std::unordered_map<size_t,size_t>::const_iterator itb = globalLocalIndexMap_.begin(),
-                                                        ite = globalLocalIndexMap_.end(), it;          
-    CArray<size_t,1>::const_iterator itSrvb = writtenGlobalIndex.begin(),
-                                     itSrve = writtenGlobalIndex.end(), itSrv;  
-
-    localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements());
-    nbWritten = 0;
-    for (itSrv = itSrvb; itSrv != itSrve; ++itSrv)
-    {
-      indGlo = *itSrv;
-      if (ite != globalLocalIndexMap_.find(indGlo))
-      {
-        localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo];
-      }
-      else
-      {
-        localIndexToWriteOnServer(nbWritten) = -1;
-      }
-      ++nbWritten;
-    }
-
-  }
-  CATCH_DUMP_ATTR
-
-  void CAxis::computeWrittenCompressedIndex(MPI_Comm writtenComm)
-  TRY
-  {
-    int writtenCommSize;
-    MPI_Comm_size(writtenComm, &writtenCommSize);
-    if (compressedIndexToWriteOnServer.find(writtenCommSize) != compressedIndexToWriteOnServer.end())
-      return;
-
-    if (isCompressible())
-    {
-      size_t nbWritten = 0, indGlo;
-      CContext* context=CContext::getCurrent();      
- 
-      // We describe the distribution of client (server) on which data are written
-      std::vector<int> nBegin(1), nSize(1), nBeginGlobal(1), nGlob(1);
-      nBegin[0]       = 0;
-      nSize[0]        = n;
-      nBeginGlobal[0] = 0; 
-      nGlob[0]        = n_glo;
-      CDistributionServer srvDist(context->intraCommSize_, nBegin, nSize, nBeginGlobal, nGlob); 
-      const CArray<size_t,1>& writtenGlobalIndex  = srvDist.getGlobalIndex();
-      std::unordered_map<size_t,size_t>::const_iterator itb = globalLocalIndexMap_.begin(),
-                                                          ite = globalLocalIndexMap_.end(), it;   
-
-      CArray<size_t,1>::const_iterator itSrvb = writtenGlobalIndex.begin(),
-                                       itSrve = writtenGlobalIndex.end(), itSrv;
-      std::unordered_map<size_t,size_t> localGlobalIndexMap;
-      for (itSrv = itSrvb; itSrv != itSrve; ++itSrv)
-      {
-        indGlo = *itSrv;
-        if (ite != globalLocalIndexMap_.find(indGlo))
-        {
-          localGlobalIndexMap[localIndexToWriteOnServer(nbWritten)] = indGlo;
-          ++nbWritten;
-        }                 
-      }
-//
-//      nbWritten = 0;
-//      for (int idx = 0; idx < data_index.numElements(); ++idx)
-//      {
-//        if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_index(idx)))
-//        {
-//          ++nbWritten;
-//        }
-//      }
-//
-//      compressedIndexToWriteOnServer[writtenCommSize].resize(nbWritten);
-//      nbWritten = 0;
-//      for (int idx = 0; idx < data_index.numElements(); ++idx)
-//      {
-//        if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_index(idx)))
-//        {
-//          compressedIndexToWriteOnServer[writtenCommSize](nbWritten) = localGlobalIndexMap[data_index(idx)];
-//          ++nbWritten;
-//        }
-//      }
-
-      nbWritten = 0;
-      for (int idx = 0; idx < data_index.numElements(); ++idx)
-      {
-        if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_index(idx)))
-        {
-          ++nbWritten;
-        }
-      }
-
-      compressedIndexToWriteOnServer[writtenCommSize].resize(nbWritten);
-      nbWritten = 0;
-      for (int idx = 0; idx < data_index.numElements(); ++idx)
-      {
-        if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_index(idx)))
-        {
-          compressedIndexToWriteOnServer[writtenCommSize](nbWritten) = localGlobalIndexMap[data_index(idx)];
-          ++nbWritten;
-        }
-      }
-
-      numberWrittenIndexes_[writtenCommSize] = nbWritten;
-
-      bool distributed_glo, distributed=isDistributed() ;
-      MPI_Allreduce(&distributed,&distributed_glo, 1, MPI_INT, MPI_LOR, writtenComm) ;
-      if (distributed_glo)
-      {
-             
-        MPI_Allreduce(&numberWrittenIndexes_[writtenCommSize], &totalNumberWrittenIndexes_[writtenCommSize], 1, MPI_INT, MPI_SUM, writtenComm);
-        MPI_Scan(&numberWrittenIndexes_[writtenCommSize], &offsetWrittenIndexes_[writtenCommSize], 1, MPI_INT, MPI_SUM, writtenComm);
-        offsetWrittenIndexes_[writtenCommSize] -= numberWrittenIndexes_[writtenCommSize];
-      }
-      else
-        totalNumberWrittenIndexes_[writtenCommSize] = numberWrittenIndexes_[writtenCommSize];
-    }
-  }
-  CATCH_DUMP_ATTR
-
-  /*!
-    Send distribution information from a group of client (client role) to another group of client (server role)
-    The distribution of a group of client (server role) is imposed by the group of client (client role)
-    \param [in] globalDim global dimension of grid containing this axis
-    \param [in] orderPositionInGrid the relative order of this axis in the grid (e.g grid composed of domain+axis -> orderPositionInGrid is 2)
-    \param [in] distType distribution type of the server. For now, we only have band distribution.
-  */
-  void CAxis::sendDistributionAttribute(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid,
-                                        CServerDistributionDescription::ServerDistributionType distType, const string& axisId)
-  TRY
-  {
-    string serverAxisId = axisId.empty() ? this->getId() : axisId ; 
-    int nbServer = client->serverSize;
-
-    CServerDistributionDescription serverDescription(globalDim, nbServer);
-    serverDescription.computeServerDistribution();
-
-    std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin();
-    std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes();
-
-    CEventClient event(getType(),EVENT_ID_DISTRIBUTION_ATTRIBUTE);
-    if (client->isServerLeader())
-    {
-      std::list<CMessage> msgs;
-
-      const std::list<int>& ranks = client->getRanksServerLeader();
-      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-      {
-        // Use const int to ensure CMessage holds a copy of the value instead of just a reference
-        const int begin = serverIndexBegin[*itRank][orderPositionInGrid];
-        const int ni    = serverDimensionSizes[*itRank][orderPositionInGrid];
-
-        msgs.push_back(CMessage());
-        CMessage& msg = msgs.back();
-        msg << serverAxisId;
-        msg << ni << begin;
-        msg << isCompressible_;                    
-
-        event.push(*itRank,1,msg);
-      }
-      client->sendEvent(event);
-    }
-    else client->sendEvent(event);
-  }
-  CATCH_DUMP_ATTR
-
-  /*
-    Receive distribution attribute from another client
-    \param [in] event event containing data of these attributes
-  */
-  void CAxis::recvDistributionAttribute(CEventServer& event)
-  TRY
-  {
-    CBufferIn* buffer = event.subEvents.begin()->buffer;
-    string axisId;
-    *buffer >> axisId;
-    get(axisId)->recvDistributionAttribute(*buffer);
-  }
-  CATCH
-
-  /*
-    Receive distribution attribute from another client
-    \param [in] buffer buffer containing data of these attributes
-  */
-  void CAxis::recvDistributionAttribute(CBufferIn& buffer)
-  TRY
-  {
-    int ni_srv, begin_srv;
-    buffer >> ni_srv >> begin_srv;
-    buffer >> isCompressible_;            
-
-    // Set up new local size of axis on the receiving clients
-    n.setValue(ni_srv);
-    begin.setValue(begin_srv);
-  }
-  CATCH_DUMP_ATTR
-
-  /*
-    Send attributes of axis from a group of client to other group of clients/servers 
-    on supposing that these attributes are not distributed among the sending group
-    In the future, if new attributes are added, they should also be processed in this function
-  */
-  void CAxis::sendNonDistributedAttributes(CContextClient* client, const string& axisId)
-  TRY
-  {
-    string serverAxisId = axisId.empty() ? this->getId() : axisId ; 
-
-    CEventClient event(getType(), EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES);
-    size_t nbIndex = index.numElements();
-    size_t nbDataIndex = 0;
-
-    for (int idx = 0; idx < data_index.numElements(); ++idx)
-    {
-      int ind = data_index(idx);
-      if (ind >= 0 && ind < nbIndex) ++nbDataIndex;
-    }
-
-    CArray<int,1> dataIndex(nbDataIndex);
-    nbDataIndex = 0;
-    for (int idx = 0; idx < data_index.numElements(); ++idx)
-    {
-      int ind = data_index(idx);
-      if (ind >= 0 && ind < nbIndex)
-      {
-        dataIndex(nbDataIndex) = ind;
-        ++nbDataIndex;
-      }
-    }
-
-    if (client->isServerLeader())
-    {
-      std::list<CMessage> msgs;
-
-      const std::list<int>& ranks = client->getRanksServerLeader();
-      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-      {
-        msgs.push_back(CMessage());
-        CMessage& msg = msgs.back();
-        msg << serverAxisId;
-        msg << index.getValue() << dataIndex << mask.getValue();
-        msg << hasValue;
-        if (hasValue) msg << value.getValue();
-        msg << hasBounds;
-        if (hasBounds) msg << bounds.getValue();
-        msg << hasLabel;
-        if (hasLabel) msg << label.getValue();
-
-        event.push(*itRank, 1, msg);
-      }
-      client->sendEvent(event);
-    }
-    else client->sendEvent(event);
-  }
-  CATCH_DUMP_ATTR
-
-  /*
-    Receive the non-distributed attributes from another group of clients
-    \param [in] event event containing data of these attributes
-  */
-  void CAxis::recvNonDistributedAttributes(CEventServer& event)
-  TRY
-  {
-    list<CEventServer::SSubEvent>::iterator it;
-    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it)
-    {
-      CBufferIn* buffer = it->buffer;
-      string axisId;
-      *buffer >> axisId;
-      get(axisId)->recvNonDistributedAttributes(it->rank, *buffer);
-    }
-  }
-  CATCH
-
-  /*
-    Receive the non-distributed attributes from another group of clients
-    \param [in] rank rank of the sender
-    \param [in] buffer buffer containing data sent from the sender
-  */
-  void CAxis::recvNonDistributedAttributes(int rank, CBufferIn& buffer)
-  TRY
-  { 
-    CArray<int,1> tmp_index, tmp_data_index;
-    CArray<bool,1> tmp_mask;
-    CArray<double,1> tmp_val;
-    CArray<double,2> tmp_bnds;
-    CArray<string,1> tmp_label;
-
-    buffer >> tmp_index;
-    index.reference(tmp_index);
-    buffer >> tmp_data_index;
-    data_index.reference(tmp_data_index);
-    buffer >> tmp_mask;
-    mask.reference(tmp_mask);
-
-    buffer >> hasValue;
-    if (hasValue)
-    {
-      buffer >> tmp_val;
-      value.reference(tmp_val);
-    }
-
-    buffer >> hasBounds;
-    if (hasBounds)
-    {
-      buffer >> tmp_bnds;
-      bounds.reference(tmp_bnds);
-    }
-
-    buffer >> hasLabel;
-    if (hasLabel)
-    {
-      buffer >> tmp_label;
-      label.reference(tmp_label);
-    }
-
-    // Some value should be reset here
-    data_begin.setValue(0);
-    data_n.setValue(data_index.numElements());
-    globalLocalIndexMap_.rehash(std::ceil(index.numElements()/globalLocalIndexMap_.max_load_factor()));
-//    for (int idx = 0; idx < index.numElements(); ++idx) globalLocalIndexMap_[idx] = index(idx);
-    for (int idx = 0; idx < index.numElements(); ++idx) globalLocalIndexMap_[index(idx)] = idx;
-  }
-  CATCH_DUMP_ATTR
-
-  /*
-    Send axis attributes from a group of clients to another group of clients/servers
-    supposing that these attributes are distributed among the clients of the sending group
-    In future, if new attributes are added, they should also be processed in this function
-  */
-  void CAxis::sendDistributedAttributes_old(CContextClient* client, const string& axisId)
-  TRY
-  {
-    string serverAxisId = axisId.empty() ? this->getId() : axisId ; 
-    
-    int ind, idx;
-    int nbServer = client->serverSize;
-
-    CEventClient eventData(getType(), EVENT_ID_DISTRIBUTED_ATTRIBUTES);
-
-    list<CMessage> listData;
-    list<CArray<int,1> > list_indi, list_dataInd;
-    list<CArray<double,1> > list_val;
-    list<CArray<double,2> > list_bounds;
-    list<CArray<string,1> > list_label;
-
-    // Cut off the ghost points
-    int nbIndex = index.numElements();
-    CArray<int,1> dataIndex(nbIndex);
-    dataIndex = -1;
-    for (idx = 0; idx < data_index.numElements(); ++idx)
-    {
-      if (0 <= data_index(idx) && data_index(idx) < nbIndex)
-        dataIndex(data_index(idx)) = 1;
-    }
-
-    std::unordered_map<int, std::vector<size_t> >::const_iterator it, iteMap;
-    iteMap = indSrv_[nbServer].end();
-    for (int k = 0; k < connectedServerRank_[nbServer].size(); ++k)
-    {
-      int nbData = 0, nbDataCount = 0;
-      int rank = connectedServerRank_[nbServer][k];
-      it = indSrv_[nbServer].find(rank);
-      if (iteMap != it)
-        nbData = it->second.size();
-
-      list_indi.push_back(CArray<int,1>(nbData));
-      list_dataInd.push_back(CArray<int,1>(nbData));
-
-      if (hasValue)
-        list_val.push_back(CArray<double,1>(nbData));
-
-      if (hasBounds)        
-        list_bounds.push_back(CArray<double,2>(2,nbData));
-
-      if (hasLabel)
-        list_label.push_back(CArray<string,1>(nbData));
-
-      CArray<int,1>& indi = list_indi.back();
-      CArray<int,1>& dataIndi = list_dataInd.back();
-      dataIndi = -1;
-
-      for (int n = 0; n < nbData; ++n)
-      {
-        idx = static_cast<int>(it->second[n]);
-        indi(n) = idx;
-
-        ind = globalLocalIndexMap_[idx];
-        dataIndi(n) = dataIndex(ind);
-
-        if (hasValue)
-        {
-          CArray<double,1>& val = list_val.back();
-          val(n) = value(ind);
-        }
-
-        if (hasBounds)
-        {
-          CArray<double,2>& boundsVal = list_bounds.back();
-          boundsVal(0, n) = bounds(0,ind);
-          boundsVal(1, n) = bounds(1,ind);
-        }
-
-        if (hasLabel)
-        {
-          CArray<string,1>& labelVal = list_label.back();
-          labelVal(n) = label(ind); 
-        }
-      }
-
-      listData.push_back(CMessage());
-      listData.back() << serverAxisId
-                      << list_indi.back() << list_dataInd.back();
-
-      listData.back() << hasValue;
-      if (hasValue)
-        listData.back() << list_val.back();
-
-      listData.back() << hasBounds;
-      if (hasBounds)
-        listData.back() << list_bounds.back();
-
-      listData.back() << hasLabel;
-      if (hasLabel)
-        listData.back() << list_label.back();
-
-      eventData.push(rank, nbSenders[nbServer][rank], listData.back());
-    }
-
-    client->sendEvent(eventData);
-  }
-  CATCH_DUMP_ATTR
-
-  /*
-    Receive the distributed attributes from another group of clients
-    \param [in] event event containing data of these attributes
-  */
-  void CAxis::recvDistributedAttributes_old(CEventServer& event)
-  TRY
-  {
-    string axisId;
-    vector<int> ranks;
-    vector<CBufferIn*> buffers;
-
-    list<CEventServer::SSubEvent>::iterator it;
-    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it)
-    {
-      ranks.push_back(it->rank);
-      CBufferIn* buffer = it->buffer;
-      *buffer >> axisId;
-      buffers.push_back(buffer);
-    }
-    get(axisId)->recvDistributedAttributes_old(ranks, buffers);
-  }
-  CATCH
-
-  /*
-    Receive the non-distributed attributes from another group of clients
-    \param [in] ranks rank of the sender
-    \param [in] buffers buffer containing data sent from the sender
-  */
-  void CAxis::recvDistributedAttributes_old(vector<int>& ranks, vector<CBufferIn*> buffers)
-  TRY
-  {
-    int nbReceived = ranks.size(), idx, ind, gloInd, locInd;
-    vector<CArray<int,1> > vec_indi(nbReceived), vec_dataInd(nbReceived);
-    vector<CArray<double,1> > vec_val(nbReceived);
-    vector<CArray<double,2> > vec_bounds(nbReceived);
-    vector<CArray<string,1> > vec_label(nbReceived);
-    
-    for (idx = 0; idx < nbReceived; ++idx)
-    {      
-      CBufferIn& buffer = *buffers[idx];
-      buffer >> vec_indi[idx];
-      buffer >> vec_dataInd[idx];      
-
-      buffer >> hasValue;
-      if (hasValue)
-        buffer >> vec_val[idx];
-
-      buffer >> hasBounds;
-      if (hasBounds)
-        buffer >> vec_bounds[idx];
-
-      buffer >> hasLabel;
-      if (hasLabel)
-        buffer >> vec_label[idx]; 
-    }
-
-    // Estimate size of index array
-    int nbIndexGlob = 0;
-    for (idx = 0; idx < nbReceived; ++idx)
-    {
-      nbIndexGlob += vec_indi[idx].numElements();
-    }
-
-    // Recompute global index
-    // Take account of the overlapped index 
-    index.resize(nbIndexGlob);
-    globalLocalIndexMap_.rehash(std::ceil(index.numElements()/globalLocalIndexMap_.max_load_factor()));
-    nbIndexGlob = 0;
-    int nbIndLoc = 0;
-    for (idx = 0; idx < nbReceived; ++idx)
-    {
-      CArray<int,1>& tmp = vec_indi[idx];
-      for (ind = 0; ind < tmp.numElements(); ++ind)
-      {
-         gloInd = tmp(ind);
-         nbIndLoc = (gloInd % n_glo)-begin;
-         if (0 == globalLocalIndexMap_.count(gloInd))
-         {
-           index(nbIndexGlob) = gloInd % n_glo;
-           globalLocalIndexMap_[gloInd] = nbIndexGlob;
-           ++nbIndexGlob;
-         } 
-      } 
-    }
-
-    // Resize index to its real size
-    if (nbIndexGlob==0) index.resize(nbIndexGlob) ;
-    else index.resizeAndPreserve(nbIndexGlob);
-
-    int nbData = nbIndexGlob;
-    CArray<int,1> nonCompressedData(nbData);
-    nonCompressedData = -1;   
-    // Mask is incorporated into data_index and is not sent/received anymore
-    mask.reset();
-    if (hasValue)
-      value.resize(nbData);
-    if (hasBounds)
-      bounds.resize(2,nbData);
-    if (hasLabel)
-      label.resize(nbData);
-
-    nbData = 0;
-    for (idx = 0; idx < nbReceived; ++idx)
-    {
-      CArray<int,1>& indi = vec_indi[idx];
-      CArray<int,1>& dataIndi = vec_dataInd[idx];
-      int nb = indi.numElements();
-      for (int n = 0; n < nb; ++n)
-      { 
-        locInd = globalLocalIndexMap_[size_t(indi(n))];
-
-        nonCompressedData(locInd) = (-1 == nonCompressedData(locInd)) ? dataIndi(n) : nonCompressedData(locInd);
-
-        if (hasValue)
-          value(locInd) = vec_val[idx](n);
-
-        if (hasBounds)
-        {
-          bounds(0,locInd) = vec_bounds[idx](0,n);
-          bounds(1,locInd) = vec_bounds[idx](1,n);
-        }
-
-        if (hasLabel)
-          label(locInd) = vec_label[idx](n);
-      }
-    }
-    
-    int nbCompressedData = 0;
-    for (idx = 0; idx < nonCompressedData.numElements(); ++idx)
-    {
-      if (0 <= nonCompressedData(idx))
-        ++nbCompressedData;
-    }
-
-    data_index.resize(nbCompressedData);
-    nbCompressedData = 0;
-    for (idx = 0; idx < nonCompressedData.numElements(); ++idx)
-    {
-      if (0 <= nonCompressedData(idx))
-      {
-        data_index(nbCompressedData) = idx % n;
-        ++nbCompressedData;
-      }
-    }
-
-    data_begin.setValue(0);
-    data_n.setValue(data_index.numElements());
-  }
-  CATCH_DUMP_ATTR
-
+  
   /*!
     Compare two axis objects. 
Index: /XIOS/dev/dev_ym/XIOS_COUPLING/src/node/axis.hpp
===================================================================
--- /XIOS/dev/dev_ym/XIOS_COUPLING/src/node/axis.hpp	(revision 1974)
+++ /XIOS/dev/dev_ym/XIOS_COUPLING/src/node/axis.hpp	(revision 1975)
@@ -50,9 +50,4 @@
          enum EEventId
          {
-           EVENT_ID_DISTRIBUTION_ATTRIBUTE,           
-           EVENT_ID_DISTRIBUTED_VALUE,
-           EVENT_ID_NON_DISTRIBUTED_VALUE,
-           EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES,
-           EVENT_ID_DISTRIBUTED_ATTRIBUTES,
            EVENT_ID_AXIS_DISTRIBUTION,
            EVENT_ID_SEND_DISTRIBUTED_ATTRIBUTE
@@ -75,10 +70,5 @@
          /// Accesseurs ///
          const std::set<StdString> & getRelFiles(void) const;
-
-         int getNumberWrittenIndexes(MPI_Comm writtenCom);
-         int getTotalNumberWrittenIndexes(MPI_Comm writtenCom);
-         int getOffsetWrittenIndexes(MPI_Comm writtenCom);
-         CArray<int, 1>& getCompressedIndexToWriteOnServer(MPI_Comm writtenCom);
-
+ 
          std::map<int, StdSize> getAttributesBufferSize(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid,
                                                         CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION);
@@ -126,15 +116,7 @@
          void checkAttributes(void);
          bool checkAttributes_done_ = false ;
-         
-         void checkAttributesOnClient();
-         void checkAttributesOnClientAfterTransformation(const std::vector<int>& globalDim, int orderPositionInGrid,
-                                                         CServerDistributionDescription::ServerDistributionType distType = CServerDistributionDescription::BAND_DISTRIBUTION);
-         void sendCheckedAttributes(const std::vector<int>& globalDim, int orderPositionInGrid,
-                                    CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION);
 
          size_t getGlobalWrittenSize(void) ;
 
-         void computeWrittenIndex();
-         void computeWrittenCompressedIndex(MPI_Comm);
          bool hasTransformation();
          void solveInheritanceTransformation();
@@ -149,20 +131,9 @@
         bool hasLabel;
 
-        CArray<int,1> localIndexToWriteOnServer;
-         
-         void computeConnectedClients(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid);
-         private: std::set<CContextClient*> computeConnectedClients_done_ ; public :
-         /** The number of server of a context client. Avoid to re-compute indice computed in a previous computeConnectedClient */
-         private: std::set<int> listNbServer_ ; public:
-
-      private:
+       private:
          void checkData();
          void checkMask();
          void checkBounds();
          void checkLabel();
-      public:
-         void sendAxisToFileServer(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid) ;
-      private:
-         std::set<CContextClient*> sendAxisToFileServer_done_ ;
       
       public:
@@ -175,20 +146,4 @@
 
       private:
-         void sendAttributes(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid,
-                             CServerDistributionDescription::ServerDistributionType distType, const string& axisId="");
-         void sendDistributionAttribute(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid,
-                                        CServerDistributionDescription::ServerDistributionType distType, const string& axisId="");
-         
-
-         void sendNonDistributedAttributes(CContextClient* client, const string& axisId="");
-         void sendDistributedAttributes_old(CContextClient* client, const string& axisId="");
-
-         static void recvNonDistributedAttributes(CEventServer& event);
-         static void recvDistributedAttributes_old(CEventServer& event);
-         static void recvDistributionAttribute(CEventServer& event);
-         void recvNonDistributedAttributes(int rank, CBufferIn& buffer);
-         void recvDistributedAttributes_old(vector<int>& rank, vector<CBufferIn*> buffers);
-         void recvDistributionAttribute(CBufferIn& buffer);
-
          void setTransformations(const TransMapTypes&);
 
@@ -221,17 +176,9 @@
       private:
          bool isChecked;
-         bool areClientAttributesChecked_;
-         bool isClientAfterTransformationChecked;
          std::set<StdString> relFiles, relFilesCompressed;
          TransMapTypes transformationMap_;         
 
-         std::map<int, map<int,int> > nbSenders; // Mapping of number of communicating client to a server
          std::map<int, std::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server
-         // std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server
-         std::unordered_map<size_t,size_t> globalLocalIndexMap_;
-         std::map<int,int> numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;
-         std::map<int, CArray<int, 1> > compressedIndexToWriteOnServer;
          std::map<int, std::vector<int> > connectedServerRank_;
-         bool computedWrittenIndex_;                  
 
        private:
Index: /XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.cpp
===================================================================
--- /XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.cpp	(revision 1974)
+++ /XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.cpp	(revision 1975)
@@ -70,9 +70,4 @@
     addWorkflowView() ;
     addModelView() ;
-  }
-
-  void CScalar::checkAttributesOnClient()
-  {
-
   }
 
@@ -158,13 +153,5 @@
   }
  
-  void CScalar::sendScalarToFileServer(CContextClient* client)
-  {
-    if (sendScalarToFileServer_done_.count(client)!=0) return ;
-    else sendScalarToFileServer_done_.insert(client) ;
-    StdString scalarDefRoot("scalar_definition");
-    CScalarGroup* scalarPtr = CScalarGroup::get(scalarDefRoot);
-    this->sendAllAttributesToServer(client);
-  }
-
+  /* obsolete, to remove after reimplementing coupling */
   void CScalar::sendScalarToCouplerOut(CContextClient* client, const string& fieldId, int posInGrid)
   {
@@ -173,14 +160,4 @@
 
     string scalarId="_scalar["+std::to_string(posInGrid)+"]_of_"+fieldId ;
-   
-    if (!scalar_ref.isEmpty())
-    {
-      auto scalar_ref_tmp=scalar_ref.getValue() ;
-      scalar_ref.reset() ; // remove the reference, find an other way to do that more cleanly
-      this->sendAllAttributesToServer(client, scalarId)  ;
-      scalar_ref = scalar_ref_tmp ;
-    }
-    else this->sendAllAttributesToServer(client, scalarId)  ;
-
 
     this->sendAllAttributesToServer(client, scalarId);
Index: /XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.hpp
===================================================================
--- /XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.hpp	(revision 1974)
+++ /XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.hpp	(revision 1975)
@@ -86,12 +86,6 @@
             void addRelFile(const StdString& filename);
             bool IsWritten(const StdString& filename) const;
-            void checkAttributesOnClient();
-            virtual void parse(xml::CXMLNode & node);
+             virtual void parse(xml::CXMLNode & node);
         
-         public:
-            void sendScalarToFileServer(CContextClient* client) ;
-         private:
-            std::set<CContextClient*> sendScalarToFileServer_done_ ;
-
          public:
             void sendScalarToCouplerOut(CContextClient* client, const string& fieldId, int posInGrid) ;
