Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.cpp	(revision 1962)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.cpp	(revision 1973)
@@ -898,131 +898,5 @@
    CATCH_DUMP_ATTR
 
-   void CContext::postProcessingGlobalAttributes()
-   TRY
-   {
-     if (allProcessed) return;  
-     
-    // create intercommunicator with servers. 
-    // not sure it is the good place to be called here 
-    createServerInterComm() ;
-
-
-     // After xml is parsed, there are some more works with post processing
-     postProcessing();
-
-     // Distribute files between secondary servers according to the data size
-     distributeFiles(this->enabledWriteModeFiles);
-
-     // Check grid and calculate its distribution
-     checkGridEnabledFields();
-
-     setClientServerBuffer(client, (serviceType_==CServicesManager::CLIENT) ) ;
-     for (int i = 0; i < clientPrimServer.size(); ++i)
-         setClientServerBuffer(clientPrimServer[i], true);
-
-    
-     if (serviceType_==CServicesManager::CLIENT || serviceType_==CServicesManager::GATHERER)
-     { 
-       if (serviceType_==CServicesManager::GATHERER)
-       { 
-         for (auto it=clientPrimServer.begin(); it!=clientPrimServer.end();++it) 
-         {
-           this->sendAllAttributesToServer(*it); // Send all attributes of current context to server
-           CCalendarWrapper::get(CCalendarWrapper::GetDefName())->sendAllAttributesToServer(*it); // Send all attributes of current calendar
-         }
-       }
-       else 
-       {
-         this->sendAllAttributesToServer(client);   // Send all attributes of current context to server
-         CCalendarWrapper::get(CCalendarWrapper::GetDefName())->sendAllAttributesToServer(client); // Send all attributes of current calendar
-       }
-
-
-      // We have enough information to send to server
-      // First of all, send all enabled files
-      sendEnabledFiles(this->enabledWriteModeFiles);
-      // We only use server-level 1 (for now) to read data
-      if (serviceType_==CServicesManager::CLIENT)  sendEnabledFiles(this->enabledReadModeFiles);
-
-      // Then, send all enabled fields      
-      sendEnabledFieldsInFiles(this->enabledWriteModeFiles);
-      
-      if (serviceType_==CServicesManager::CLIENT) sendEnabledFieldsInFiles(this->enabledReadModeFiles);
-
-      // Then, check whether we have domain_ref, axis_ref or scalar_ref attached to the enabled fields
-      // If any, so send them to server
-       sendRefDomainsAxisScalars(this->enabledWriteModeFiles); 
-     
-      if (serviceType_==CServicesManager::CLIENT) sendRefDomainsAxisScalars(this->enabledReadModeFiles);        
-
-       // Check whether enabled fields have grid_ref, if any, send this info to server
-      sendRefGrid(this->enabledFiles);
-      // This code may be useful in the future when we want to seperate completely read and write
-      // sendRefGrid(this->enabledWriteModeFiles);
-      // if (!hasServer)
-      //   sendRefGrid(this->enabledReadModeFiles);
-      
-      // A grid of enabled fields composed of several components which must be checked then their
-      // checked attributes should be sent to server
-      sendGridComponentEnabledFieldsInFiles(this->enabledFiles); // This code can be seperated in two (one for reading, another for writing)
-
-       // We have a xml tree on the server side and now, it should be also processed
-      sendPostProcessing();
-       
-      // Finally, we send information of grid itself to server 
-      sendGridEnabledFieldsInFiles(this->enabledWriteModeFiles);       
-     
-      if (serviceType_==CServicesManager::CLIENT) sendGridEnabledFieldsInFiles(this->enabledReadModeFiles);       
-     
-     }
-     allProcessed = true;
-   }
-   CATCH_DUMP_ATTR
-
-   void CContext::sendPostProcessingGlobalAttributes()
-   TRY
-   {
-
-    int nbSrvPools ;
-    if (serviceType_==CServicesManager::CLIENT) nbSrvPools = 1 ;
-    else if (serviceType_==CServicesManager::GATHERER) nbSrvPools = this->clientPrimServer.size() ;
-    else nbSrvPools = 0 ;
-    CContextClient* contextClientTmp ;
-
-    for (int i = 0; i < nbSrvPools; ++i)
-     {
-       if (serviceType_==CServicesManager::CLIENT) contextClientTmp = client ;
-       else if (serviceType_==CServicesManager::GATHERER ) contextClientTmp = clientPrimServer[i] ;
-      
-       CEventClient event(getType(),EVENT_ID_POST_PROCESS_GLOBAL_ATTRIBUTES);
-
-       if (contextClientTmp->isServerLeader())
-       {
-         CMessage msg;
-         const std::list<int>& ranks = contextClientTmp->getRanksServerLeader();
-         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-           event.push(*itRank,1,msg);
-         contextClientTmp->sendEvent(event);
-       }
-       else contextClientTmp->sendEvent(event);
-     }
-   }
-   CATCH_DUMP_ATTR
-
-   void CContext::recvPostProcessingGlobalAttributes(CEventServer& event)
-   TRY
-   {
-      CBufferIn* buffer=event.subEvents.begin()->buffer;
-      getCurrent()->recvPostProcessingGlobalAttributes(*buffer);
-   }
-   CATCH
-
-   void CContext::recvPostProcessingGlobalAttributes(CBufferIn& buffer)
-   TRY
-   {      
-      postProcessingGlobalAttributes();
-   }
-   CATCH_DUMP_ATTR
-
+   
    /*!
    \brief Close all the context defintion and do processing data
@@ -1136,8 +1010,8 @@
       for(auto field : couplerOutField) 
       {
-        field->computeGridIndexToFileServer() ; // same kind of index than for file server -> in future distribution may change
-      }
-      if (first) setClientServerBuffer(couplerOutField, true) ; // set buffer context
-
+        // connect to couplerOut -> to do
+      }
+      if (first) setClientServerBuffer(couplerOutField, true) ; // set buffer context --> to check
+   
       bool couplersReady ;
       do 
@@ -1179,7 +1053,6 @@
       {
         field->connectToFileServer(garbageCollector) ; // connect the field to server filter
-        field->computeGridIndexToFileServer() ; // compute grid index for transfer to the server context
-      }
-      setClientServerBuffer(fileOutField, true) ; // set buffer context
+      }
+      setClientServerBuffer(fileOutField, true) ; // set buffer context --> to review
       for(auto field : fileOutField) field->sendFieldToFileServer() ;
     }
@@ -1247,5 +1120,4 @@
       {
         field->connectToServerInput(garbageCollector) ; // connect the field to server filter
-    // obsolete    field->computeGridIndexToFileServer() ; // compute grid index for transfer to the server context
         field->sendFieldToInputFileServer() ;
         fileInFields_.push_back(field) ;
@@ -1291,139 +1163,64 @@
     } while (!ok) ;
 
-    return ;
-
-
-
-
-
-
-
-
-
-
-    // For now, only read files with client and only one level server
-    // if (hasClient && !hasServer) findEnabledReadModeFiles();      
-
-    // Find all enabled fields of each file      
-    findAllEnabledFieldsInFiles(this->enabledWriteModeFiles);
-    findAllEnabledFieldsInFiles(this->enabledReadModeFiles);
-
-    // For now, only read files with client and only one level server
-    // if (hasClient && !hasServer) 
-    //   findAllEnabledFieldsInFiles(this->enabledReadModeFiles);      
-
-    if (serviceType_==CServicesManager::CLIENT)
-    {
-      initReadFiles();
-      // Try to read attributes of fields in file then fill in corresponding grid (or domain, axis)
-      this->readAttributesOfEnabledFieldsInReadModeFiles();
-    }
-
-    // Only search and rebuild all reference objects of enable fields, don't transform
-    this->solveOnlyRefOfEnabledFields();
-
-    // Search and rebuild all reference object of enabled fields, and transform
-    this->solveAllRefOfEnabledFieldsAndTransform();
-
-    // Find all fields with read access from the public API
-    if (serviceType_==CServicesManager::CLIENT) findFieldsWithReadAccess();
-    // and solve the all reference for them
-    if (serviceType_==CServicesManager::CLIENT) solveAllRefOfFieldsWithReadAccess();
-
-    isPostProcessed = true;
-
-
-
-    // Distribute files between secondary servers according to the data size
-    distributeFiles(this->enabledWriteModeFiles);
-
-    // Check grid and calculate its distribution
-    checkGridEnabledFields();
-
-    setClientServerBuffer(client, (serviceType_==CServicesManager::CLIENT) ) ;
-    for (int i = 0; i < clientPrimServer.size(); ++i)
-         setClientServerBuffer(clientPrimServer[i], true);
-
-    
-    if (serviceType_==CServicesManager::CLIENT || serviceType_==CServicesManager::GATHERER)
-    { 
-      if (serviceType_==CServicesManager::GATHERER)
-      { 
-        for (auto it=clientPrimServer.begin(); it!=clientPrimServer.end();++it) 
-        {
-          this->sendAllAttributesToServer(*it); // Send all attributes of current context to server
-          CCalendarWrapper::get(CCalendarWrapper::GetDefName())->sendAllAttributesToServer(*it); // Send all attributes of current calendar
-        }
-      }
-      else 
-      {
-        this->sendAllAttributesToServer(client);   // Send all attributes of current context to server
-        CCalendarWrapper::get(CCalendarWrapper::GetDefName())->sendAllAttributesToServer(client); // Send all attributes of current calendar
-      }
-
-      // We have enough information to send to server
-      // First of all, send all enabled files
-      sendEnabledFiles(this->enabledWriteModeFiles);
-      // We only use server-level 1 (for now) to read data
-      if (serviceType_==CServicesManager::CLIENT)  sendEnabledFiles(this->enabledReadModeFiles);
-
-      // Then, send all enabled fields      
-      sendEnabledFieldsInFiles(this->enabledWriteModeFiles);
-      
-      if (serviceType_==CServicesManager::CLIENT) sendEnabledFieldsInFiles(this->enabledReadModeFiles);
-
-      // Then, check whether we have domain_ref, axis_ref or scalar_ref attached to the enabled fields
-      // If any, so send them to server
-      sendRefDomainsAxisScalars(this->enabledWriteModeFiles); 
-     
-      if (serviceType_==CServicesManager::CLIENT) sendRefDomainsAxisScalars(this->enabledReadModeFiles);        
-
-      // Check whether enabled fields have grid_ref, if any, send this info to server
-      sendRefGrid(this->enabledFiles);
-      // This code may be useful in the future when we want to seperate completely read and write
-      // sendRefGrid(this->enabledWriteModeFiles);
-      // if (!hasServer)
-      //   sendRefGrid(this->enabledReadModeFiles);
-      
-      // A grid of enabled fields composed of several components which must be checked then their
-      // checked attributes should be sent to server
-      sendGridComponentEnabledFieldsInFiles(this->enabledFiles); // This code can be seperated in two (one for reading, another for writing)
-
-      // We have a xml tree on the server side and now, it should be also processed
-      sendPostProcessing();
-       
-      // Finally, we send information of grid itself to server 
-      sendGridEnabledFieldsInFiles(this->enabledWriteModeFiles);       
-     
-      if (serviceType_==CServicesManager::CLIENT) sendGridEnabledFieldsInFiles(this->enabledReadModeFiles);       
-    }
-    allProcessed = true;
-
-
-    if (serviceType_==CServicesManager::CLIENT || serviceType_==CServicesManager::GATHERER) sendPostProcessingGlobalAttributes();
-
-    // There are some processings that should be done after all of above. For example: check mask or index
-    this->buildFilterGraphOfEnabledFields();
-    
-     if (serviceType_==CServicesManager::CLIENT)
-    {
-      buildFilterGraphOfFieldsWithReadAccess();
-      postProcessFilterGraph(); // For coupling in, modify this later
-    }
-    
-    checkGridEnabledFields();   
-
-    if (serviceType_==CServicesManager::CLIENT || serviceType_==CServicesManager::GATHERER) this->sendProcessingGridOfEnabledFields();
-    if (serviceType_==CServicesManager::CLIENT || serviceType_==CServicesManager::GATHERER) this->sendCloseDefinition();
-
-    // Nettoyage de l'arborescence
-    if (serviceType_==CServicesManager::CLIENT || serviceType_==CServicesManager::GATHERER) CleanTree(); // Only on client side??
-
-    if (serviceType_==CServicesManager::CLIENT || serviceType_==CServicesManager::GATHERER) sendCreateFileHeader();
-    if (serviceType_==CServicesManager::CLIENT) startPrefetchingOfEnabledReadModeFiles();
-    
-    CTimer::get("Context : close definition").suspend() ;
+     CTimer::get("Context : close definition").suspend() ;
   }
   CATCH_DUMP_ATTR
+
+
+  vector<CField*> CContext::findAllEnabledFieldsInFileOut(const std::vector<CFile*>& activeFiles)
+   TRY
+   {
+     vector<CField*> fields ;
+     for(auto file : activeFiles)
+     {
+        const vector<CField*>&& fieldList=file->getEnabledFields() ;
+        for(auto field : fieldList) field->setFileOut(file) ;
+        fields.insert(fields.end(),fieldList.begin(),fieldList.end());
+     }
+     return fields ;
+   }
+   CATCH_DUMP_ATTR
+
+   vector<CField*> CContext::findAllEnabledFieldsInFileIn(const std::vector<CFile*>& activeFiles)
+   TRY
+   {
+     vector<CField*> fields ;
+     for(auto file : activeFiles)
+     {
+        const vector<CField*>&& fieldList=file->getEnabledFields() ;
+        for(auto field : fieldList) field->setFileIn(file) ;
+        fields.insert(fields.end(),fieldList.begin(),fieldList.end());
+     }
+     return fields ;
+   }
+   CATCH_DUMP_ATTR
+
+   vector<CField*> CContext::findAllEnabledFieldsCouplerOut(const std::vector<CCouplerOut*>& activeCouplerOut)
+   TRY
+   {
+     vector<CField*> fields ;
+     for (auto couplerOut :activeCouplerOut)
+     {
+        const vector<CField*>&& fieldList=couplerOut->getEnabledFields() ;
+        for(auto field : fieldList) field->setCouplerOut(couplerOut) ;
+        fields.insert(fields.end(),fieldList.begin(),fieldList.end());
+     }
+     return fields ;
+   }
+   CATCH_DUMP_ATTR
+
+   vector<CField*> CContext::findAllEnabledFieldsCouplerIn(const std::vector<CCouplerIn*>& activeCouplerIn)
+   TRY
+   {
+     vector<CField*> fields ;
+     for (auto couplerIn :activeCouplerIn)
+     {
+        const vector<CField*>&& fieldList=couplerIn->getEnabledFields() ;
+        for(auto field : fieldList) field->setCouplerIn(couplerIn) ;
+        fields.insert(fields.end(),fieldList.begin(),fieldList.end());
+     }
+     return fields ;
+   }
+   CATCH_DUMP_ATTR
 
  /*!
@@ -1440,110 +1237,5 @@
   }
 
-  // ym obsolete now to be removed
-   void CContext::closeDefinition_old(void)
-   TRY
-   {
-     CTimer::get("Context : close definition").resume() ;
-    
-    //
-    postProcessingGlobalAttributes();
-
-    if (serviceType_==CServicesManager::CLIENT || serviceType_==CServicesManager::GATHERER) sendPostProcessingGlobalAttributes();
-
-    // There are some processings that should be done after all of above. For example: check mask or index
-    this->buildFilterGraphOfEnabledFields();
-    
-     if (serviceType_==CServicesManager::CLIENT)
-    {
-      buildFilterGraphOfFieldsWithReadAccess();
-      postProcessFilterGraph(); // For coupling in, modify this later
-    }
-    
-    checkGridEnabledFields();   
-
-    if (serviceType_==CServicesManager::CLIENT || serviceType_==CServicesManager::GATHERER) this->sendProcessingGridOfEnabledFields();
-    if (serviceType_==CServicesManager::CLIENT || serviceType_==CServicesManager::GATHERER) this->sendCloseDefinition();
-
-    // Nettoyage de l'arborescence
-    if (serviceType_==CServicesManager::CLIENT || serviceType_==CServicesManager::GATHERER) CleanTree(); // Only on client side??
-
-    if (serviceType_==CServicesManager::CLIENT || serviceType_==CServicesManager::GATHERER) sendCreateFileHeader();
-    if (serviceType_==CServicesManager::CLIENT) startPrefetchingOfEnabledReadModeFiles();
-    
-    CTimer::get("Context : close definition").suspend() ;
-   }
-   CATCH_DUMP_ATTR
-
-   vector<CField*> CContext::findAllEnabledFieldsInFiles(const std::vector<CFile*>& activeFiles)
-   TRY
-   {
-     vector<CField*> fields ;
-     for (unsigned int i = 0; i < activeFiles.size(); i++)
-     {
-        const vector<CField*>&& field=activeFiles[i]->getEnabledFields() ;
-        fields.insert(fields.end(),field.begin(),field.end());
-     }
-     return fields ;
-   }
-   CATCH_DUMP_ATTR
-
-   vector<CField*> CContext::findAllEnabledFieldsInFileOut(const std::vector<CFile*>& activeFiles)
-   TRY
-   {
-     vector<CField*> fields ;
-     for(auto file : activeFiles)
-     {
-        const vector<CField*>&& fieldList=file->getEnabledFields() ;
-        for(auto field : fieldList) field->setFileOut(file) ;
-        fields.insert(fields.end(),fieldList.begin(),fieldList.end());
-     }
-     return fields ;
-   }
-   CATCH_DUMP_ATTR
-
-   vector<CField*> CContext::findAllEnabledFieldsInFileIn(const std::vector<CFile*>& activeFiles)
-   TRY
-   {
-     vector<CField*> fields ;
-     for(auto file : activeFiles)
-     {
-        const vector<CField*>&& fieldList=file->getEnabledFields() ;
-        for(auto field : fieldList) field->setFileIn(file) ;
-        fields.insert(fields.end(),fieldList.begin(),fieldList.end());
-     }
-     return fields ;
-   }
-   CATCH_DUMP_ATTR
-
-   vector<CField*> CContext::findAllEnabledFieldsCouplerOut(const std::vector<CCouplerOut*>& activeCouplerOut)
-   TRY
-   {
-     vector<CField*> fields ;
-     for (auto couplerOut :activeCouplerOut)
-     {
-        const vector<CField*>&& fieldList=couplerOut->getEnabledFields() ;
-        for(auto field : fieldList) field->setCouplerOut(couplerOut) ;
-        fields.insert(fields.end(),fieldList.begin(),fieldList.end());
-     }
-     return fields ;
-   }
-   CATCH_DUMP_ATTR
-
-   vector<CField*> CContext::findAllEnabledFieldsCouplerIn(const std::vector<CCouplerIn*>& activeCouplerIn)
-   TRY
-   {
-     vector<CField*> fields ;
-     for (auto couplerIn :activeCouplerIn)
-     {
-        const vector<CField*>&& fieldList=couplerIn->getEnabledFields() ;
-        for(auto field : fieldList) field->setCouplerIn(couplerIn) ;
-        fields.insert(fields.end(),fieldList.begin(),fieldList.end());
-     }
-     return fields ;
-   }
-   CATCH_DUMP_ATTR
-
-
-
+ 
    void CContext::readAttributesOfEnabledFieldsInReadModeFiles()
    TRY
@@ -2110,17 +1802,6 @@
              return true;
              break;
-           case EVENT_ID_POST_PROCESS:
-             recvPostProcessing(event);
-             return true;
            case EVENT_ID_SEND_REGISTRY:
              recvRegistry(event);
-             return true;
-             break;
-           case EVENT_ID_POST_PROCESS_GLOBAL_ATTRIBUTES:
-             recvPostProcessingGlobalAttributes(event);
-             return true;
-             break;
-           case EVENT_ID_PROCESS_GRID_ENABLED_FIELDS:
-             recvProcessingGridOfEnabledFields(event);
              return true;
              break;
@@ -2288,168 +1969,4 @@
       if (serviceType_==CServicesManager::IO_SERVER || serviceType_==CServicesManager::OUT_SERVER) 
         createFileHeader();
-   }
-   CATCH_DUMP_ATTR
-
-   //! Client side: Send a message to do some post processing on server
-   void CContext::sendProcessingGridOfEnabledFields()
-   TRY
-   {
-     int nbSrvPools ;
-     if (serviceType_==CServicesManager::CLIENT) nbSrvPools = 1 ;
-     else if (serviceType_==CServicesManager::GATHERER) nbSrvPools = this->clientPrimServer.size() ;
-     else nbSrvPools = 0 ;
-     CContextClient* contextClientTmp ;
-
-     for (int i = 0; i < nbSrvPools; ++i)
-     {
-       if (serviceType_==CServicesManager::CLIENT) contextClientTmp = client ;
-       else if (serviceType_==CServicesManager::GATHERER ) contextClientTmp = clientPrimServer[i] ;
-
-       CEventClient event(getType(),EVENT_ID_PROCESS_GRID_ENABLED_FIELDS);
-
-       if (contextClientTmp->isServerLeader())
-       {
-         CMessage msg;
-         const std::list<int>& ranks = contextClientTmp->getRanksServerLeader();
-         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-           event.push(*itRank,1,msg);
-         contextClientTmp->sendEvent(event);
-       }
-       else contextClientTmp->sendEvent(event);
-     }
-   }
-   CATCH_DUMP_ATTR
-
-   //! Server side: Receive a message to do some post processing
-   void CContext::recvProcessingGridOfEnabledFields(CEventServer& event)
-   TRY
-   {
-      CBufferIn* buffer=event.subEvents.begin()->buffer;
-      // nothing to do, no call ??!!    
-   }
-   CATCH
-
-   //! Client side: Send a message to do some post processing on server
-   void CContext::sendPostProcessing()
-   TRY
-   {
-     int nbSrvPools ;
-     if (serviceType_==CServicesManager::CLIENT) nbSrvPools = 1 ;
-     else if (serviceType_==CServicesManager::GATHERER) nbSrvPools = this->clientPrimServer.size() ;
-     else nbSrvPools = 0 ;
-     CContextClient* contextClientTmp ;
-
-     for (int i = 0; i < nbSrvPools; ++i)
-     {
-       if (serviceType_==CServicesManager::CLIENT) contextClientTmp = client ;
-       else if (serviceType_==CServicesManager::GATHERER ) contextClientTmp = clientPrimServer[i] ;
-       CEventClient event(getType(),EVENT_ID_POST_PROCESS);
-       if (contextClientTmp->isServerLeader())
-       {
-         CMessage msg;
-         const std::list<int>& ranks = contextClientTmp->getRanksServerLeader();
-         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-         event.push(*itRank,1,msg);
-         contextClientTmp->sendEvent(event);
-       }
-       else contextClientTmp->sendEvent(event);
-     }
-   }
-   CATCH_DUMP_ATTR
-
-   //! Server side: Receive a message to do some post processing
-   void CContext::recvPostProcessing(CEventServer& event)
-   TRY
-   {
-      CBufferIn* buffer=event.subEvents.begin()->buffer;
-      getCurrent()->recvPostProcessing(*buffer);
-   }
-   CATCH
-
-   //! Server side: Receive a message to do some post processing
-   void CContext::recvPostProcessing(CBufferIn& buffer)
-   TRY
-   {
-      CCalendarWrapper::get(CCalendarWrapper::GetDefName())->createCalendar();
-      postProcessing();
-   }
-   CATCH_DUMP_ATTR
-
- 
-   /*!
-   \brief Do some simple post processings after parsing xml file
-      After the xml file (iodef.xml) is parsed, it is necessary to build all relations among
-   created object, e.g: inhertance among fields, domain, axis. After that, all fiels as well as their parents (reference fields),
-   which will be written out into netcdf files, are processed
-   */
-   void CContext::postProcessing()
-   TRY
-   {
-     if (isPostProcessed) return;
-
-      // Make sure the calendar was correctly created
-      if (!calendar)
-        ERROR("CContext::postProcessing()", << "A calendar must be defined for the context \"" << getId() << "!\"")
-      else if (calendar->getTimeStep() == NoneDu)
-        ERROR("CContext::postProcessing()", << "A timestep must be defined for the context \"" << getId() << "!\"")
-      // Calendar first update to set the current date equals to the start date
-      calendar->update(0);
-
-      // Find all inheritance in xml structure
-      this->solveAllInheritance();
-
-//      ShowTree(info(10));
-
-      // Check if some axis, domains or grids are eligible to for compressed indexed output.
-      // Warning: This must be done after solving the inheritance and before the rest of post-processing
-      //checkAxisDomainsGridsEligibilityForCompressedOutput();      // only for field written on IO_SERVER service ????
-
-      // Check if some automatic time series should be generated
-      // Warning: This must be done after solving the inheritance and before the rest of post-processing      
-      prepareTimeseries();
-
-      //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers Ã  sortir.
-      findEnabledFiles();
-      findEnabledWriteModeFiles();
-      findEnabledReadModeFiles();
-      findEnabledCouplerIn();
-      findEnabledCouplerOut();
-      createCouplerInterCommunicator() ;
-
-      // Find all enabled fields of each file      
-      const vector<CField*>&& fileOutField = findAllEnabledFieldsInFiles(this->enabledWriteModeFiles);
-      const vector<CField*>&& fileInField = findAllEnabledFieldsInFiles(this->enabledReadModeFiles);
-      const vector<CField*>&& CouplerOutField = findAllEnabledFieldsCouplerOut(this->enabledCouplerOut);
-      const vector<CField*>&& CouplerInField = findAllEnabledFieldsCouplerIn(this->enabledCouplerIn);
-
-
-
-      // For now, only read files with client and only one level server
-      // if (hasClient && !hasServer) findEnabledReadModeFiles();      
-
-
-      // For now, only read files with client and only one level server
-      // if (hasClient && !hasServer) 
-      //   findAllEnabledFieldsInFiles(this->enabledReadModeFiles);      
-
-      if (serviceType_==CServicesManager::CLIENT)
-      {
-        initReadFiles();
-        // Try to read attributes of fields in file then fill in corresponding grid (or domain, axis)
-        this->readAttributesOfEnabledFieldsInReadModeFiles();
-      }
-
-      // Only search and rebuild all reference objects of enable fields, don't transform
-      this->solveOnlyRefOfEnabledFields();
-
-      // Search and rebuild all reference object of enabled fields, and transform
-      this->solveAllRefOfEnabledFieldsAndTransform();
-
-      // Find all fields with read access from the public API
-      if (serviceType_==CServicesManager::CLIENT) findFieldsWithReadAccess();
-      // and solve the all reference for them
-      if (serviceType_==CServicesManager::CLIENT) solveAllRefOfFieldsWithReadAccess();
-
-      isPostProcessed = true;
    }
    CATCH_DUMP_ATTR
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.hpp	(revision 1962)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.hpp	(revision 1973)
@@ -53,7 +53,5 @@
            EVENT_ID_CLOSE_DEFINITION,EVENT_ID_UPDATE_CALENDAR,
            EVENT_ID_CREATE_FILE_HEADER,EVENT_ID_CONTEXT_FINALIZE,
-           EVENT_ID_POST_PROCESS, EVENT_ID_SEND_REGISTRY,
-           EVENT_ID_POST_PROCESS_GLOBAL_ATTRIBUTES,
-           EVENT_ID_PROCESS_GRID_ENABLED_FIELDS,
+           EVENT_ID_SEND_REGISTRY,
            EVENT_ID_CONTEXT_FINALIZE_CLIENT,
            EVENT_ID_COUPLER_IN_READY,
@@ -117,5 +115,4 @@
 
          void closeDefinition(void);
-         void closeDefinition_old(void);
 
          // to be removed     
@@ -140,5 +137,5 @@
          void createFileHeader(void);
          void initReadFiles(void);
-        void prepareTimeseries(void);
+         void prepareTimeseries(void);
          void solveOnlyRefOfEnabledFields(void);         
          void buildFilterGraphOfEnabledFields();
@@ -150,6 +147,4 @@
          void solveAllRefOfFieldsWithReadAccess();
          void buildFilterGraphOfFieldsWithReadAccess();
-         void postProcessing();
-         void postProcessingGlobalAttributes();         
          void triggerLateFields(void) ;
          void solveAllRefOfEnabledFieldsAndTransform(void);
@@ -183,7 +178,4 @@
          void sendRefDomainsAxisScalars(const std::vector<CFile*>& activeFiles);
          void sendRefGrid(const std::vector<CFile*>& activeFiles);
-         void sendPostProcessing();
-         void sendPostProcessingGlobalAttributes();
-         void sendProcessingGridOfEnabledFields();
          //!< after be gathered to the root process of the context, merged registry is sent to the root process of the servers
          void sendRegistry(void) ;
@@ -206,9 +198,4 @@
          static void recvSolveInheritanceContext(CEventServer& event);
          void recvSolveInheritanceContext(CBufferIn& buffer);
-         static void recvPostProcessing(CEventServer& event);
-         void recvPostProcessing(CBufferIn& buffer);
-         static void recvProcessingGridOfEnabledFields(CEventServer& event);
-         static void recvPostProcessingGlobalAttributes(CEventServer& event);
-         void recvPostProcessingGlobalAttributes(CBufferIn& buffer);
          static void recvRegistry(CEventServer& event) ;
          void recvRegistry(CBufferIn& buffer) ; //!< registry is received by the servers
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.cpp	(revision 1962)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.cpp	(revision 1973)
@@ -15,5 +15,4 @@
 #include <set>
 #include "garbage_collector.hpp"
-#include "source_filter.hpp"
 #include "pass_through_filter.hpp"
 #include "filter_expr_node.hpp"
@@ -624,5 +623,4 @@
     }
 
-    solveCheckMaskIndex(doSending2Server);
   }
   CATCH_DUMP_ATTR
@@ -865,12 +863,5 @@
   } 
 
-  /*!
-   * Compute grid index needed to send grid and data to server
-   */
-  void CField::computeGridIndexToFileServer(void)
-  {
-    grid_->computeGridIndexToFileServer(client) ;
-  }
-
+ 
   /*!
    * Connect field to a source filter to receive data from model.
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.hpp	(revision 1962)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.hpp	(revision 1973)
@@ -240,6 +240,4 @@
         void connectToServerToClient(CGarbageCollector& gc) ;
 
-        void computeGridIndexToFileServer(void) ;
-
         void setContextClientDataBufferSize(map<CContextClient*,map<int,size_t>>& bufferSize, 
                                         map<CContextClient*,map<int,size_t>>& maxEventSize, 
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field_impl.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field_impl.hpp	(revision 1962)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field_impl.hpp	(revision 1973)
@@ -9,5 +9,4 @@
 #include "timer.hpp"
 #include "array_new.hpp"
-#include "source_filter.hpp"
 
 
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp	(revision 1962)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp	(revision 1973)
@@ -36,12 +36,10 @@
       , vAxisGroup_(), axisList_(), isAxisListSet(false)
       , vScalarGroup_(), scalarList_(), isScalarListSet(false)
-      , clientDistribution_(0), isIndexSent(false) , serverDistribution_(0), clientServerMap_(0)
-      , numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0)
+      , clientDistribution_(0), isIndexSent(false)
       , connectedDataSize_(), connectedServerRank_(), connectedServerRankRead_(), connectedDataSizeRead_()
 	    , isCompressible_(false)
       , transformations_(0), isTransformed_(false)
       , axisPositionInGrid_(), hasDomainAxisBaseRef_(false)
-      , gridSrc_(), hasTransform_(false), isGenerated_(false), order_(), globalIndexOnServer_()
-      , computedWrittenIndex_(false)
+      , gridSrc_(), hasTransform_(false), isGenerated_(false), order_()
       , clients()
    {
@@ -57,12 +55,10 @@
       , vAxisGroup_(), axisList_(), isAxisListSet(false)
       , vScalarGroup_(), scalarList_(), isScalarListSet(false)
-      , clientDistribution_(0), isIndexSent(false) , serverDistribution_(0), clientServerMap_(0)
-      , numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0)
+      , clientDistribution_(0), isIndexSent(false)
       , connectedDataSize_(), connectedServerRank_(), connectedServerRankRead_(), connectedDataSizeRead_()
 	    , isCompressible_(false)
       , transformations_(0), isTransformed_(false)
       , axisPositionInGrid_(), hasDomainAxisBaseRef_(false)
-      , gridSrc_(), hasTransform_(false), isGenerated_(false), order_(), globalIndexOnServer_()
-      , computedWrittenIndex_(false)
+      , gridSrc_(), hasTransform_(false), isGenerated_(false), order_()
       , clients()
    {
@@ -75,6 +71,4 @@
    {
     if (0 != clientDistribution_) delete clientDistribution_;
-    if (0 != serverDistribution_) delete serverDistribution_;
-    if (0 != clientServerMap_) delete clientServerMap_;
     if (0 != transformations_) delete transformations_;
    }
@@ -859,8 +853,4 @@
      this->checkAttributesAfterTransformation();
 
-     // TODO: Transfer grid attributes
-     //if (!context->hasClient && context->hasServer) this->createMask();
-     this->computeIndex();
-
      if (!(this->hasTransform() && !this->isTransformed()))
       this->isChecked = true;
@@ -897,180 +887,6 @@
       return mask_ ;
    }
-   /*
-     Create mask of grid from mask of its components
-   */
-   void CGrid::createMask(void)
-   TRY
-   {
-      using namespace std;
-      std::vector<CDomain*> domainP = this->getDomains();
-      std::vector<CAxis*> axisP = this->getAxis();
-      int dim = domainP.size() * 2 + axisP.size();
-
-      std::vector<CArray<bool,1>* > domainMasks(domainP.size());
-      for (int i = 0; i < domainMasks.size(); ++i) domainMasks[i] = &(domainP[i]->domainMask);
-      std::vector<CArray<bool,1>* > axisMasks(axisP.size());
-      for (int i = 0; i < axisMasks.size(); ++i) axisMasks[i] = &(axisP[i]->mask);
-
-      switch (dim) {
-        case 1:
-          checkGridMask(mask_1d, domainMasks, axisMasks, axis_domain_order, true);
-          break;
-        case 2:
-          checkGridMask(mask_2d, domainMasks, axisMasks, axis_domain_order, true);
-          break;
-        case 3:
-          checkGridMask(mask_3d, domainMasks, axisMasks, axis_domain_order, true);
-          break;
-        case 4:
-          checkGridMask(mask_4d, domainMasks, axisMasks, axis_domain_order, true);
-          break;
-        case 5:
-          checkGridMask(mask_5d, domainMasks, axisMasks, axis_domain_order, true);
-          break;
-        case 6:
-          checkGridMask(mask_6d, domainMasks, axisMasks, axis_domain_order, true);
-          break;
-        case 7:
-          checkGridMask(mask_7d, domainMasks, axisMasks, axis_domain_order, true);
-          break;
-        default:
-          break;
-      }
-   }
-   CATCH_DUMP_ATTR
-
-   /*
-     Check validity of grid's mask by using the masks of its components
-   */
-   void CGrid::checkMask(void)
-   TRY
-   {
-      using namespace std;
-      std::vector<CDomain*> domainP = this->getDomains();
-      std::vector<CAxis*> axisP = this->getAxis();
-      int dim = domainP.size() * 2 + axisP.size();
-
-      std::vector<CArray<bool,1>* > domainMasks(domainP.size());
-      for (int i = 0; i < domainMasks.size(); ++i) domainMasks[i] = &(domainP[i]->domainMask);
-      std::vector<CArray<bool,1>* > axisMasks(axisP.size());
-      for (int i = 0; i < axisMasks.size(); ++i) axisMasks[i] = &(axisP[i]->mask);
-
-      switch (dim) {
-        case 1:
-          checkGridMask(mask_1d, domainMasks, axisMasks, axis_domain_order);
-          break;
-        case 2:
-          checkGridMask(mask_2d, domainMasks, axisMasks, axis_domain_order);
-          break;
-        case 3:
-          checkGridMask(mask_3d, domainMasks, axisMasks, axis_domain_order);
-          break;
-        case 4:
-          checkGridMask(mask_4d, domainMasks, axisMasks, axis_domain_order);
-          break;
-        case 5:
-          checkGridMask(mask_5d, domainMasks, axisMasks, axis_domain_order);
-          break;
-        case 6:
-          checkGridMask(mask_6d, domainMasks, axisMasks, axis_domain_order);
-          break;
-        case 7:
-          checkGridMask(mask_7d, domainMasks, axisMasks, axis_domain_order);
-          break;
-        default:
-          break;
-      }
-   }
-   CATCH_DUMP_ATTR
-
-   /*
-     Modify value of mask in a certain index
-     This function can be used to correct the mask of grid after being constructed with createMask
-     \param [in] indexToModify
-     \param [in] modifyValue
-   */
-   void CGrid::modifyMask(const CArray<int,1>& indexToModify, bool modifyValue)
-   TRY
-   {
-      using namespace std;
-      std::vector<CDomain*> domainP = this->getDomains();
-      std::vector<CAxis*> axisP = this->getAxis();
-      int dim = domainP.size() * 2 + axisP.size();
-
-      switch (dim) {
-        case 0:
-          modifyGridMask(mask_0d, indexToModify, modifyValue);
-          break;
-        case 1:
-          modifyGridMask(mask_1d, indexToModify, modifyValue);
-          break;
-        case 2:
-          modifyGridMask(mask_2d, indexToModify, modifyValue);
-          break;
-        case 3:
-          modifyGridMask(mask_3d, indexToModify, modifyValue);
-          break;
-        case 4:
-          modifyGridMask(mask_4d, indexToModify, modifyValue);
-          break;
-        case 5:
-          modifyGridMask(mask_5d, indexToModify, modifyValue);
-          break;
-        case 6:
-          modifyGridMask(mask_6d, indexToModify, modifyValue);
-          break;
-        case 7:
-          modifyGridMask(mask_7d, indexToModify, modifyValue);
-          break;
-        default:
-          break;
-      }
-   }
-   CATCH_DUMP_ATTR
-
-   /*
-     Change the mask size. This function is used on reconstructing mask in server side
-     \param [in] newDimensionSize
-     \param [in] newValue 
-   */
-   void CGrid::modifyMaskSize(const std::vector<int>& newDimensionSize, bool newValue)
-   TRY
-   {      
-      std::vector<CDomain*> domainP = this->getDomains();
-      std::vector<CAxis*> axisP = this->getAxis();            
-      int dim = domainP.size() * 2 + axisP.size();
-
-      switch (dim) {
-        case 0:
-          modifyGridMaskSize(mask_0d, newDimensionSize, newValue);
-          break;
-        case 1:
-          modifyGridMaskSize(mask_1d, newDimensionSize, newValue);
-          break;
-        case 2:
-          modifyGridMaskSize(mask_2d, newDimensionSize, newValue);
-          break;
-        case 3:
-          modifyGridMaskSize(mask_3d, newDimensionSize, newValue);
-          break;
-        case 4:
-          modifyGridMaskSize(mask_4d, newDimensionSize, newValue);
-          break;
-        case 5:
-          modifyGridMaskSize(mask_5d, newDimensionSize, newValue);
-          break;
-        case 6:
-          modifyGridMaskSize(mask_6d, newDimensionSize, newValue);
-          break;
-        case 7:
-          modifyGridMaskSize(mask_7d, newDimensionSize, newValue);
-          break;
-        default:
-          break;
-      }
-   }
-   CATCH_DUMP_ATTR
-
+
+  
    //---------------------------------------------------------------
 
@@ -1130,94 +946,13 @@
    CATCH_DUMP_ATTR
 
-   /*!
-      Compute the index to for write data into a file
-   */
-   void CGrid::computeWrittenIndex()
-   TRY
-   {      
-      if (computedWrittenIndex_) return;
-      computedWrittenIndex_ = true;
-
-      if (isScalarGrid())
-      {
-        size_t nbWritten = 1;
-        int writtenIndex = 0;
-
-        localIndexToWriteOnClient_.resize(nbWritten);  
-        localIndexToWriteOnServer_.resize(nbWritten);
-        localIndexToWriteOnServer_(0) = writtenIndex;
-        localIndexToWriteOnClient_(0) = writtenIndex;
-        
-        return;
-      }
-
-      size_t nbWritten = 0, indGlo;
-      CDistributionClient::GlobalLocalDataMap& globalDataIndex = getClientDistribution()->getGlobalDataIndexOnClient();
-      CDistributionClient::GlobalLocalDataMap::const_iterator itb = globalDataIndex.begin(),
-                                                              ite = globalDataIndex.end(), it;    
-      const CDistributionServer::GlobalLocalMap& globalLocalIndex = serverDistribution_->getGlobalLocalIndex();                                                              
-      CDistributionServer::GlobalLocalMap::const_iterator itSrvb = globalLocalIndex.begin(),
-                                                          itSrve = globalLocalIndex.end(), itSrv;
-      for (it = itb; it != ite; ++it)
-      {
-        indGlo = it->first;
-        if (globalLocalIndex.end() != globalLocalIndex.find(indGlo)) ++nbWritten;                
-      }
-
-      localIndexToWriteOnClient_.resize(nbWritten);  
-      localIndexToWriteOnServer_.resize(nbWritten);
-      
-      {
-        numberWrittenIndexes_ = nbWritten;
-        if (isDataDistributed())
-        {
-          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_;
-        }
-        else
-          totalNumberWrittenIndexes_ = numberWrittenIndexes_;
-      }
-
-      nbWritten = 0; 
-      for (it = itb; it != ite; ++it)
-      {
-        indGlo = it->first;
-        itSrv = globalLocalIndex.find(indGlo);
-        if (itSrve != itSrv)
-        {
-          localIndexToWriteOnServer_(nbWritten) = itSrv->second;
-          localIndexToWriteOnClient_(nbWritten) = it->second;
-          ++nbWritten;                
-        } 
-      }
-   }
-   CATCH_DUMP_ATTR
-
-   
-
-   /*!
-     Compute the global index of grid to send to server as well as the connected server of the current client.
-     First of all, from the local data on each element of grid, we can calculate their local index which also allows us to know
-     their global index. We can have a map of global index of grid and local index that each client holds
-     Then, each client holds a piece of information about the distribution of servers, which permits to compute the connected server(s)
-     of the current client.
-   */
-   void CGrid::computeGridIndexToFileServer(CContextClient* client)
-   {
-     if (isScalarGrid()) computeConnectedClientsScalarGrid(client);
-     else computeConnectedClients(client);
-    
-     // compute indices for client/server transfer for domain
-     for (const auto& domainId : domList_) CDomain::get(domainId)->computeConnectedClients(client);
-   
-   
-     // compute indices for client/server transfer for axis
-     std::vector<CAxis*> axisList = this->getAxis();
-     for(int i=0 ; i<axisList.size(); i++) axisList[i] -> computeConnectedClients(client, getGlobalDimension(),getAxisPositionInGrid()[i]) ;
-   }
-   //---------------------------------------------------------------
-
+
+    //---------------------------------------------------------------
+   CDistributionClient* CGrid::getClientDistribution()
+   TRY
+   {
+     if (!computeClientDistribution_done_) computeClientDistribution() ;
+     return clientDistribution_;
+   }
+   CATCH_DUMP_ATTR
    
    void CGrid::computeClientDistribution(void)
@@ -1231,100 +966,4 @@
    }
 
-   void CGrid::computeStoreIndex_client(void)
-   {
-     if (computeStoreIndex_client_done_) return ;
-     else computeStoreIndex_client_done_ = true ;
-     if (isScalarGrid())
-     {
-       storeIndex_client_.resize(1);
-       storeIndex_client_(0) = 0;
-     }
-     else
-     {
-       CDistributionClient* clientDistribution = getClientDistribution() ;
-       const std::vector<int>& localDataIndex = clientDistribution->getLocalDataIndexOnClient() ;
-       int nbStoreIndex = localDataIndex.size() ;
-       storeIndex_client_.resize(nbStoreIndex);
-       for (int idx = 0; idx < nbStoreIndex; ++idx) storeIndex_client_(idx) = localDataIndex[idx];
-     }
-   }
-
-   void CGrid::computeStoreMask_client(void)
-   {
-     if (computeStoreMask_client_done_) return ;
-     else computeStoreMask_client_done_ = true ;
-     if (isScalarGrid())
-     {
-       storeMask_client_.resize(1);
-       storeMask_client_(0) = true;
-     }
-     else
-     {
-       CDistributionClient* clientDistribution = getClientDistribution() ;
-       const std::vector<bool>& localMaskIndex = clientDistribution->getLocalMaskIndexOnClient() ;
-       int nbMaskIndex = localMaskIndex.size() ;
-       storeMask_client_.resize(nbMaskIndex);
-       for (int idx = 0; idx < nbMaskIndex; ++idx) storeMask_client_(idx) = localMaskIndex[idx];
-     }
-   }
-
-
-  void CGrid::computeOutLocalIndexStoreOnClient(void)
-  {
-    if (computeOutLocalIndexStoreOnClient_done_) return ;
-    else computeOutLocalIndexStoreOnClient_done_=true ;
-
-    if (isScalarGrid())
-    {
-        auto& outGlobalIndexFromClient  = getOutGlobalIndexFromClient();
-        auto itb = outGlobalIndexFromClient.begin(), ite = outGlobalIndexFromClient.end() ;
-        for (auto it = itb; it != ite; ++it)
-        {
-          int rank = it->first;
-          CArray<size_t,1>& globalIndex = outGlobalIndexFromClient[rank];
-          outLocalIndexStoreOnClient_.insert(make_pair(rank, CArray<size_t,1>(globalIndex.numElements())));
-          CArray<size_t,1>& localIndex = outLocalIndexStoreOnClient_[rank];
-          if (1 != globalIndex.numElements())
-            ERROR("void CGrid::computeClientIndexScalarGrid()",
-              << "Something wrong happened. "
-              << "Number of received global index on scalar grid should equal to 1" 
-              << "Number of received global index " << globalIndex.numElements() << ".");
-
-          localIndex(0) = globalIndex(0);
-        }
-    }
-    else
-    {
-      CDistributionClient::GlobalLocalDataMap& globalDataIndex = getClientDistribution()->getGlobalDataIndexOnClient();
-      CDistributionClient::GlobalLocalDataMap::const_iterator itGloe = globalDataIndex.end();
-      auto& outGlobalIndexFromClient  = getOutGlobalIndexFromClient();
-      auto itb = outGlobalIndexFromClient.begin(), ite = outGlobalIndexFromClient.end() ;
-    
-      for (auto it = itb; it != ite; ++it)
-      {
-         int rank = it->first;
-         CArray<size_t,1>& globalIndex = outGlobalIndexFromClient[rank];
-         outLocalIndexStoreOnClient_.insert(make_pair(rank, CArray<size_t,1>(globalIndex.numElements())));
-         CArray<size_t,1>& localIndex = outLocalIndexStoreOnClient_[rank];
-         size_t nbIndex = 0;
-
-        // Keep this code for this moment but it should be removed (or moved to DEBUG) to improve performance
-        for (size_t idx = 0; idx < globalIndex.numElements(); ++idx)
-          if (itGloe != globalDataIndex.find(globalIndex(idx))) ++nbIndex;
-
-        if (nbIndex != localIndex.numElements())
-             ERROR("void CGrid::computeClientIndex()",
-                 << "Number of local index on client is different from number of received global index"
-                 << "Rank of sent client " << rank <<"."
-                 << "Number of local index " << nbIndex << ". "
-                 << "Number of received global index " << localIndex.numElements() << ".");
-
-        nbIndex = 0;
-        for (size_t idx = 0; idx < globalIndex.numElements(); ++idx)
-          if (itGloe != globalDataIndex.find(globalIndex(idx)))
-            localIndex(idx) = globalDataIndex[globalIndex(idx)];
-      }
-    }
-  }
 
   bool CGrid::isDataDistributed(void) 
@@ -1333,126 +972,5 @@
   }
 
-   /*!
-     Compute connected receivers and indexes to be sent to these receivers.
-   */
-   void CGrid::computeConnectedClients(CContextClient* client)
-   TRY
-   {
-     if (computeConnectedClients_done_.count(client)!=0) return ;
-     else  computeConnectedClients_done_.insert(client) ;
-
-     CContext* context = CContext::getCurrent();
-     
-     set<int> listReceiverSize ;
-     int receiverSize = client->serverSize;
-      
-     if (listReceiverSize.find(receiverSize)==listReceiverSize.end())
-     {
-       listReceiverSize.insert(receiverSize) ;
-       if (connectedServerRank_.find(receiverSize) != connectedServerRank_.end())
-       {
-          // delete corresponding map in case of recompute, probably because a grid could has been modifiedd 
-          // by a transformation
-          connectedServerRank_.erase(receiverSize);
-          connectedDataSize_.erase(receiverSize);
-          globalIndexOnServer_.erase(receiverSize);
-          nbSenders_.erase(receiverSize);
-       }
-
-       if (!doGridHaveDataDistributed(client))
-       {
-          if (client->isServerLeader())
-          {
-            size_t ssize = getClientDistribution()->getLocalDataIndexOnClient().size();
-            const std::list<int>& ranks = client->getRanksServerLeader();
-            for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-            {
-              connectedServerRank_[receiverSize].push_back(*itRank);
-              connectedDataSize_[receiverSize][*itRank] = ssize;
-            }
-          }
-          return;
-       }
-
-       // Compute mapping between client and server
-       std::vector<std::unordered_map<size_t,std::vector<int> > > indexServerOnElement;
-       CServerDistributionDescription serverDistributionDescription(getGlobalDimension(), client->serverSize);
-       std::vector<int> serverZeroIndex = serverDistributionDescription.computeServerGlobalByElement(indexServerOnElement,
-                                                                                                    client->clientRank,
-                                                                                                    client->clientSize,
-                                                                                                    axis_domain_order,
-                                                                                                    getDistributedDimension());
-
-       // Even if servers have no index, they must received something from client
-       // We only use several client to send "empty" message to these servers
-       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];
-
-       if (globalIndexOnServer_.find(receiverSize) == globalIndexOnServer_.end())
-         computeIndexByElement(indexServerOnElement, client, globalIndexOnServer_[receiverSize]);
-
-       const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = getClientDistribution()->getGlobalLocalDataSendToServer();
-       CDistributionClient::GlobalLocalDataMap::const_iterator iteGlobalLocalIndexMap = globalLocalIndexSendToServer.end(), itGlobalLocalIndexMap;
-       CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itbGlobalMap, itGlobalMap;
-       itbGlobalMap = globalIndexOnServer_[receiverSize].begin();
-       iteGlobalMap = globalIndexOnServer_[receiverSize].end();
-
-       for (itGlobalMap  = itbGlobalMap; itGlobalMap != iteGlobalMap; ++itGlobalMap)
-       {
-         int serverRank = itGlobalMap->first;
-         int indexSize = itGlobalMap->second.size();
-         const std::vector<size_t>& indexVec = itGlobalMap->second;
-         for (int idx = 0; idx < indexSize; ++idx)
-         {
-            itGlobalLocalIndexMap = globalLocalIndexSendToServer.find(indexVec[idx]);
-            if (iteGlobalLocalIndexMap != itGlobalLocalIndexMap)
-            {
-              if (connectedDataSize_[receiverSize].end() == connectedDataSize_[receiverSize].find(serverRank))
-                connectedDataSize_[receiverSize][serverRank] = 1;
-              else
-                ++connectedDataSize_[receiverSize][serverRank];
-            }
-         }
-       }
-
-       // Connected servers which really have index
-       for (itGlobalMap = itbGlobalMap; itGlobalMap != iteGlobalMap; ++itGlobalMap) 
-         connectedServerRank_[receiverSize].push_back(itGlobalMap->first);
-     
-       // Connected servers which have no index at all
-       for (std::list<int>::iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it)
-         connectedServerRank_[receiverSize].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_[receiverSize].empty())
-         connectedServerRank_[receiverSize].push_back(client->clientRank % client->serverSize);
- 
-       // Now check if all servers have data to receive. If not, master client will send empty data.
-       // This ensures that all servers will participate in collective calls upon receiving even if they have no date to receive.
-       std::vector<int> counts (client->clientSize);
-       std::vector<int> displs (client->clientSize);
-       displs[0] = 0;
-       int localCount = connectedServerRank_[receiverSize].size() ;
-       MPI_Gather(&localCount, 1, MPI_INT, &counts[0], 1, MPI_INT, 0, client->intraComm) ;
-       for (int i = 0; i < client->clientSize-1; ++i) displs[i+1] = displs[i] + counts[i];
-       std::vector<int> allConnectedServers(displs[client->clientSize-1]+counts[client->clientSize-1]);
-       MPI_Gatherv(&(connectedServerRank_[receiverSize])[0], localCount, MPI_INT, &allConnectedServers[0], &counts[0], &displs[0], MPI_INT, 0, client->intraComm);
-
-       if ((allConnectedServers.size() != receiverSize) && (client->clientRank == 0))
-       {
-         std::vector<bool> isSrvConnected (receiverSize, false);
-         for (int i = 0; i < allConnectedServers.size(); ++i) isSrvConnected[allConnectedServers[i]] = true;
-         for (int i = 0; i < receiverSize; ++i) if (!isSrvConnected[i]) connectedServerRank_[receiverSize].push_back(i);
-       }
-
-       nbSenders_[receiverSize] = CClientServerMapping::computeConnectedClients(receiverSize, client->clientSize, client->intraComm, connectedServerRank_[receiverSize]);
-     }
-   }
-   CATCH_DUMP_ATTR
-
+  
    /*!
      Compute the global index of grid to send to server as well as the connected server of the current client.
@@ -1487,192 +1005,10 @@
      if (context->getServiceType()==CServicesManager::OUT_SERVER)
      {
-       computeWrittenIndex() ;
-       if (serverDistribution_!=0) serverDistribution_->partialClear() ;
        if (clientDistribution_!=0) clientDistribution_->partialClear() ;
-       outGlobalIndexFromClient_.clear() ;
      }
    }
    CATCH_DUMP_ATTR
 
-   /*!
-      Compute the global of (client) grid to send to server with the global index of each element of grid
-      Each element of grid has its own global index associated to a groups of server. We only search for the global index of each element whose
-      server is the same, then calculate the global index of grid. This way can reduce so much the time for executing DHT, which only needs to run
-      on each element whose size is much smaller than one of whole grid.
-      \param [in] indexServerOnElement global index of each element and the rank of server associated with these index
-      \param [in] client contextClient
-      \param [out] globalIndexOnServer global index of grid and its corresponding rank of server.
-   */
-   void CGrid::computeIndexByElement(const std::vector<std::unordered_map<size_t,std::vector<int> > >& indexServerOnElement,
-                                     const CContextClient* client,
-                                     CClientServerMapping::GlobalIndexMap& globalIndexOnServer)
-   TRY
-   {
-     int serverSize = client->serverSize;
-
-     std::vector<CDomain*> domList = getDomains();
-     std::vector<CAxis*> axisList = getAxis();
-
-     // Some pre-calculations of global index on each element of current grid.
-     int nbElement = axis_domain_order.numElements();
-     std::vector<CArray<size_t,1> > globalIndexElement(nbElement);
-     int domainIdx = 0, axisIdx = 0, scalarIdx = 0;
-     std::vector<size_t> elementNGlobal(nbElement);
-     elementNGlobal[0] = 1;
-     size_t globalSize = 1;
-     for (int idx = 0; idx < nbElement; ++idx)
-     {
-       elementNGlobal[idx] = globalSize;
-       size_t elementSize;
-       size_t elementGlobalSize = 1;
-       if (2 == axis_domain_order(idx)) // This is domain
-       {
-         elementSize = domList[domainIdx]->i_index.numElements();
-         globalIndexElement[idx].resize(elementSize);
-         for (int jdx = 0; jdx < elementSize; ++jdx)
-         {
-           globalIndexElement[idx](jdx) = (domList[domainIdx]->i_index)(jdx) + domList[domainIdx]->ni_glo * (domList[domainIdx]->j_index)(jdx);
-         }
-         elementGlobalSize = domList[domainIdx]->ni_glo.getValue() * domList[domainIdx]->nj_glo.getValue();
-         ++domainIdx;
-       }
-       else if (1 == axis_domain_order(idx))  // This is axis
-       {
-         elementSize = axisList[axisIdx]->index.numElements();
-         globalIndexElement[idx].resize(elementSize);
-         for (int jdx = 0; jdx < elementSize; ++jdx)
-         {
-           globalIndexElement[idx](jdx) = (axisList[axisIdx]->index)(jdx);
-         }
-         elementGlobalSize = axisList[axisIdx]->n_glo.getValue();
-         ++axisIdx;
-       }
-       else  // Of course, this is scalar
-       {
-         globalIndexElement[idx].resize(1);
-         globalIndexElement[idx](0) = 0;
-         elementGlobalSize = 1;
-       }
-       globalSize *= elementGlobalSize;
-     }
-
-     std::vector<std::vector<bool> > elementOnServer(nbElement, std::vector<bool>(serverSize, false));
-     std::vector<std::unordered_map<int,std::vector<size_t> > > globalElementIndexOnServer(nbElement);
-     CArray<int,1> nbIndexOnServer(serverSize); // Number of distributed global index held by each client for each server
-     // Number of temporary distributed global index held by each client for each server
-     // We have this variable for the case of non-distributed element (often axis) to check the duplicate server rank
-     CArray<int,1> nbIndexOnServerTmp(serverSize);
-     for (int idx = 0; idx < nbElement; ++idx)
-     {
-       nbIndexOnServer = 0;
-       const std::unordered_map<size_t,std::vector<int> >& indexServerElement = indexServerOnElement[idx];
-       const CArray<size_t,1>& globalIndexElementOnClient = globalIndexElement[idx];
-       CClientClientDHTInt clientClientDHT(indexServerElement, client->intraComm);
-       clientClientDHT.computeIndexInfoMapping(globalIndexElementOnClient);
-       const CClientClientDHTInt::Index2VectorInfoTypeMap& globalIndexElementOnServerMap = clientClientDHT.getInfoIndexMap();
-       CClientClientDHTInt::Index2VectorInfoTypeMap::const_iterator itb = globalIndexElementOnServerMap.begin(),
-                                                                    ite = globalIndexElementOnServerMap.end(), it;
-       for (it = itb; it != ite; ++it)
-       {
-         const std::vector<int>& tmp = it->second;
-         nbIndexOnServerTmp = 0;
-         for (int i = 0; i < tmp.size(); ++i)
-         {
-           if (0 == nbIndexOnServerTmp(tmp[i])) ++nbIndexOnServerTmp(tmp[i]);
-         }
-         nbIndexOnServer += nbIndexOnServerTmp;
-       }
-
-       for (int i = 0; i < serverSize; ++i)
-       {
-         if (0 != nbIndexOnServer(i))
-         {
-           globalElementIndexOnServer[idx][i].resize(nbIndexOnServer(i));
-           elementOnServer[idx][i] = true;
-         }
-       }
-
-     nbIndexOnServer = 0;
-     for (size_t j = 0; j < globalIndexElementOnServerMap.size(); ++j)
-     {
-       it = globalIndexElementOnServerMap.find(globalIndexElementOnClient(j));
-       if (it != ite)
-       {
-         const std::vector<int>& tmp = it->second;
-         nbIndexOnServerTmp = 0;
-         for (int i = 0; i < tmp.size(); ++i)
-         {
-           if (0 == nbIndexOnServerTmp(tmp[i]))
-           {
-             globalElementIndexOnServer[idx][tmp[i]][nbIndexOnServer(tmp[i])] = it->first;
-             ++nbIndexOnServerTmp(tmp[i]);
-           }
-         }
-         nbIndexOnServer += nbIndexOnServerTmp;
-       }
-     }
-   }
-
-    // Determine server which contain global source index
-    std::vector<bool> intersectedProc(serverSize, true);
-    for (int idx = 0; idx < nbElement; ++idx)
-    {
-      std::transform(elementOnServer[idx].begin(), elementOnServer[idx].end(),
-                     intersectedProc.begin(), intersectedProc.begin(),
-                     std::logical_and<bool>());
-    }
-
-    std::vector<int> srcRank;
-    for (int idx = 0; idx < serverSize; ++idx)
-    {
-      if (intersectedProc[idx]) srcRank.push_back(idx);
-    }
-
-    // Compute the global index of grid from global index of each element.
-    for (int i = 0; i < srcRank.size(); ++i)
-    {
-      size_t ssize = 1;
-      int rankSrc = srcRank[i];
-      std::vector<std::vector<size_t>* > globalIndexOfElementTmp(nbElement);
-      std::vector<size_t> currentIndex(nbElement,0);
-      for (int idx = 0; idx < nbElement; ++idx)
-      {
-        ssize *= (globalElementIndexOnServer[idx][rankSrc]).size();
-        globalIndexOfElementTmp[idx] = &(globalElementIndexOnServer[idx][rankSrc]);
-      }
-      globalIndexOnServer[rankSrc].resize(ssize);
-
-      std::vector<int> idxLoop(nbElement,0);
-      int innnerLoopSize = (globalIndexOfElementTmp[0])->size();
-      size_t idx = 0;
-      while (idx < ssize)
-      {
-        for (int ind = 0; ind < nbElement; ++ind)
-        {
-          if (idxLoop[ind] == (globalIndexOfElementTmp[ind])->size())
-          {
-            idxLoop[ind] = 0;
-            ++idxLoop[ind+1];
-          }
-
-          currentIndex[ind] = (*(globalIndexOfElementTmp[ind]))[idxLoop[ind]];
-        }
-
-        for (int ind = 0; ind < innnerLoopSize; ++ind)
-        {
-          currentIndex[0] = (*globalIndexOfElementTmp[0])[ind];
-          size_t globalSrcIndex = 0;
-          for (int idxElement = 0; idxElement < nbElement; ++idxElement)
-          {
-            globalSrcIndex += currentIndex[idxElement] * elementNGlobal[idxElement];
-          }
-          globalIndexOnServer[rankSrc][idx] = globalSrcIndex;
-          ++idx;
-          ++idxLoop[0];
-        }
-      }
-    }
-   }
-   CATCH_DUMP_ATTR
+   
 //----------------------------------------------------------------
 
@@ -1783,620 +1119,7 @@
    //----------------------------------------------------------------
 
-   void CGrid::storeField_arr(const double* const data, CArray<double, 1>& stored) 
-   TRY
-   {
-      auto& storeIndex_client = getStoreIndex_client() ;
-      const StdSize size = storeIndex_client.numElements();
-
-      stored.resize(size);
-      for(StdSize i = 0; i < size; i++) stored(i) = data[storeIndex_client(i)];
-   }
-   CATCH
-
-   void CGrid::restoreField_arr(const CArray<double, 1>& stored, double* const data) 
-   TRY
-   {
-      auto& storeIndex_client=getStoreIndex_client() ;
-      const StdSize size = storeIndex_client.numElements();
-
-      for(StdSize i = 0; i < size; i++) data[storeIndex_client(i)] = stored(i);
-   }
-   CATCH
-
-   void CGrid::maskField_arr(const double* const data, CArray<double, 1>& stored) 
-   {
-      auto& storeIndex_client=getStoreIndex_client() ;
-      auto& storeMask_client=getStoreMask_client() ;
-        
-      const StdSize size = storeIndex_client.numElements();
-      stored.resize(size);
-      const double nanValue = std::numeric_limits<double>::quiet_NaN();
-
-      if (storeMask_client.numElements() != 0)
-        for(StdSize i = 0; i < size; i++) stored(i) = (storeMask_client(i)) ? data[storeIndex_client(i)] : nanValue;
-      else
-        for(StdSize i = 0; i < size; i++) stored(i) = data[storeIndex_client(i)];
-   }
-
-   void CGrid::uncompressField_arr(const double* const data, CArray<double, 1>& out) 
-   TRY
-   {
-      const std::vector<int>& localMaskedDataIndex = getClientDistribution()->getLocalMaskedDataIndexOnClient();
-      const int size = localMaskedDataIndex.size();
-      for(int i = 0; i < size; ++i) out(localMaskedDataIndex[i]) = data[i];
-   }
-   CATCH
-
-  
-  void CGrid::computeConnectedClientsScalarGrid(CContextClient* client)
-  TRY
-  {
-    if (computeConnectedClientsScalarGrid_done_.count(client)!=0) return ;
-
-    CContext* context = CContext::getCurrent();
-     
-    set<int> listReceiverSize ;
-
-    int receiverSize = client->serverSize;
-      
-    if (listReceiverSize.find(receiverSize)==listReceiverSize.end())
-    {
-      listReceiverSize.insert(receiverSize) ;
-      if (connectedServerRank_.find(receiverSize) != connectedServerRank_.end())
-      {
-         // delete corresponding map in case of recompute, probably because a grid could has been modifiedd 
-         // by a transformation
-        connectedServerRank_.erase(receiverSize);
-        connectedDataSize_.erase(receiverSize);
-        globalIndexOnServer_.erase(receiverSize);
-        nbSenders_.erase(receiverSize);
-      }
-
-      if (client->isServerLeader())
-      {
-        const std::list<int>& ranks = client->getRanksServerLeader();
-        for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-        {
-          int rank = *itRank;
-          int nb = 1;
-          connectedServerRank_[receiverSize].push_back(rank);
-          connectedDataSize_[receiverSize][rank] = nb;
-          nbSenders_[receiverSize][rank] = nb;
-        }
-      }
-      else
-      {
-        const std::list<int>& ranks = client->getRanksServerNotLeader();
-        for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-        {
-          int rank = *itRank;
-          int nb = 1;
-          connectedServerRank_[receiverSize].push_back(rank);
-          connectedDataSize_[receiverSize][rank] = nb;
-          nbSenders_[receiverSize][rank] = nb;
-        }
-      }
-    }
-   
-    computeConnectedClientsScalarGrid_done_.insert(client) ;
-  }
-  CATCH_DUMP_ATTR
-
-  void CGrid::sendIndexScalarGrid(CContextClient* client, const string& gridId)
-  TRY
-  {
-    if (sendIndexScalarGrid_done_.count(client)!=0) return ;
-    else sendIndexScalarGrid_done_.insert(client) ;
-
-    CContext* context = CContext::getCurrent();
     
-    string serverGridId = gridId.empty() ? serverGridId=this->getId() : serverGridId=gridId ;
-
-    int receiverSize = client->serverSize;
-
-    CEventClient event(getType(), EVENT_ID_INDEX);
-    list<CMessage> listMsg;
-    list<CArray<size_t,1> > listOutIndex;
-
-    if (client->isServerLeader())
-    {
-      const std::list<int>& ranks = client->getRanksServerLeader();
-      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-      {
-        int rank = *itRank;
-        int nb = 1;
-        storeIndex_toSrv_[client].insert(std::make_pair(rank, CArray<int,1>(nb)));
-        listOutIndex.push_back(CArray<size_t,1>(nb));
-
-        CArray<int, 1>& outLocalIndexToServer = storeIndex_toSrv_[client][rank];
-        CArray<size_t, 1>& outGlobalIndexOnServer = listOutIndex.back();
-
-        for (int k = 0; k < nb; ++k)
-        {
-          outGlobalIndexOnServer(k) = 0;
-          outLocalIndexToServer(k)  = 0;
-        }
-
-        if (context->getServiceType()==CServicesManager::CLIENT)  // -> what about for coupling probably unusefull to be check
-          storeIndex_fromSrv_.insert(std::make_pair(rank, CArray<int,1>(outLocalIndexToServer)));
-
-        listMsg.push_back(CMessage());
-        listMsg.back() << serverGridId << isCompressible_ << listOutIndex.back();
-
-        event.push(rank, 1, listMsg.back());
-      }
-      client->sendEvent(event);
-    }
-    else
-    {
-      const std::list<int>& ranks = client->getRanksServerNotLeader();
-      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-      {
-        int rank = *itRank;
-        int nb = 1;          
-        CArray<int, 1> outLocalIndexToServer(nb);
-        for (int k = 0; k < nb; ++k)
-        {
-          outLocalIndexToServer(k)  = 0;
-        }
-
-        if (context->getServiceType()==CServicesManager::CLIENT)
-          storeIndex_fromSrv_.insert(std::make_pair(rank, CArray<int,1>(outLocalIndexToServer)));
-      }
-      client->sendEvent(event);
-    }
-  }
-  CATCH_DUMP_ATTR
-
-  void CGrid::sendIndex(CContextClient* client, const string& gridId)
-  TRY
-  {
-    if (sendIndex_done_.count(client)!=0) return ;
-    else sendIndex_done_.insert(client) ;
-    CContext* context = CContext::getCurrent();
-    string serverGridId = gridId.empty() ? this->getId() : gridId ;
-
-
-
-    int receiverSize = client->serverSize;
-
-    CEventClient event(getType(), EVENT_ID_INDEX);
-    int rank;
-    list<CMessage> listMsg;
-    list<CArray<size_t,1> > listOutIndex;
-    const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = getClientDistribution()->getGlobalLocalDataSendToServer();
-    CDistributionClient::GlobalLocalDataMap::const_iterator itbIndex = globalLocalIndexSendToServer.begin(), itIndex,
-                                                            iteIndex = globalLocalIndexSendToServer.end();
-    itIndex = itbIndex;                                                              
-
-    if (!doGridHaveDataDistributed(client))
-    {
-      if (client->isServerLeader())
-      {
-        int indexSize = globalLocalIndexSendToServer.size();
-        CArray<size_t,1> outGlobalIndexOnServer(indexSize);
-        CArray<int,1> outLocalIndexToServer(indexSize);
-        for (int idx = 0; itIndex != iteIndex; ++itIndex, ++idx)
-        {
-          outGlobalIndexOnServer(idx) = itIndex->first;
-          outLocalIndexToServer(idx) = itIndex->second;
-        }
-
-        const std::list<int>& ranks = client->getRanksServerLeader();
-        for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-        {
-          storeIndex_toSrv_[client].insert(std::make_pair(*itRank, CArray<int,1>(outLocalIndexToServer)));
-          if (context->getServiceType()==CServicesManager::CLIENT)  // -> what about for coupling probably unusefull to be check
-            storeIndex_fromSrv_.insert(std::make_pair(*itRank, CArray<int,1>(outLocalIndexToServer)));
-          
-          listOutIndex.push_back(CArray<size_t,1>(outGlobalIndexOnServer));
-
-          listMsg.push_back(CMessage());
-          listMsg.back() << serverGridId << isCompressible_ << listOutIndex.back();
-
-          event.push(*itRank, 1, listMsg.back());
-        }
-        client->sendEvent(event);
-      }
-      else
-      {
-         int indexSize = globalLocalIndexSendToServer.size();
-         CArray<int,1> outLocalIndexToServer(indexSize);
-         for (int idx = 0; itIndex != iteIndex; ++itIndex, ++idx)
-         {
-           outLocalIndexToServer(idx) = itIndex->second;
-         }
-
-         const std::list<int>& ranks = client->getRanksServerNotLeader();
-         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
-         {
-           storeIndex_fromSrv_.insert(std::make_pair(*itRank, CArray<int,1>(outLocalIndexToServer)));
-         }
-         client->sendEvent(event);
-       }
-    }
-    else
-    {
-      CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itGlobalMap;
-      itGlobalMap = globalIndexOnServer_[receiverSize].begin();
-      iteGlobalMap = globalIndexOnServer_[receiverSize].end();
-
-      std::map<int,std::vector<int> >localIndexTmp;
-      std::map<int,std::vector<size_t> > globalIndexTmp;
-      for (; itGlobalMap != iteGlobalMap; ++itGlobalMap)
-      {
-        int serverRank = itGlobalMap->first;
-        int indexSize = itGlobalMap->second.size();
-        const std::vector<size_t>& indexVec = itGlobalMap->second;
-        for (int idx = 0; idx < indexSize; ++idx)
-        {
-          itIndex = globalLocalIndexSendToServer.find(indexVec[idx]);
-          if (iteIndex != itIndex)
-          {
-            globalIndexTmp[serverRank].push_back(itIndex->first);
-            localIndexTmp[serverRank].push_back(itIndex->second);
-          }
-        }
-      }
-
-      for (int ns = 0; ns < connectedServerRank_[receiverSize].size(); ++ns)
-      {
-        rank = connectedServerRank_[receiverSize][ns];
-        int nb = 0;
-        if (globalIndexTmp.end() != globalIndexTmp.find(rank))
-          nb = globalIndexTmp[rank].size();
-
-        storeIndex_toSrv_[client].insert(make_pair(rank, CArray<int,1>(nb)));
-        listOutIndex.push_back(CArray<size_t,1>(nb));
-
-        CArray<int, 1>& outLocalIndexToServer = storeIndex_toSrv_[client][rank];
-        CArray<size_t, 1>& outGlobalIndexOnServer = listOutIndex.back();
-
-        for (int k = 0; k < nb; ++k)
-        {
-          outGlobalIndexOnServer(k) = globalIndexTmp[rank].at(k);
-          outLocalIndexToServer(k)  = localIndexTmp[rank].at(k);
-        }
-
-        storeIndex_fromSrv_.insert(make_pair(rank, CArray<int,1>(outLocalIndexToServer)));
-        listMsg.push_back(CMessage());
-        listMsg.back() << serverGridId  << isCompressible_ << listOutIndex.back();
-
-        event.push(rank, nbSenders_[receiverSize][rank], listMsg.back());
-      }
-      client->sendEvent(event);
-    }
-  }
-  CATCH_DUMP_ATTR
-
-  void CGrid::recvIndex(CEventServer& event)
-  TRY
-  {
-    string gridId;
-    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 >> gridId;
-      buffers.push_back(buffer);
-    }
-    get(gridId)->recvIndex(ranks, buffers, event.getContextServer());
-  }
-  CATCH
-
-  void CGrid::recvIndex(vector<int> ranks, vector<CBufferIn*> buffers, CContextServer* server)
-  TRY
-  {
-    CContextClient* client = server->getAssociatedClient();
-    connectedServerRankRead_ = ranks;
-    for (int n = 0; n < ranks.size(); n++)
-    {
-      int rank = ranks[n];
-      CBufferIn& buffer = *buffers[n];
-      buffer >>  isCompressible_; // probably to be removed later
-      CArray<size_t,1> outIndex;
-      buffer >> outIndex;
-      outGlobalIndexFromClient_.insert(std::make_pair(rank, outIndex));
-      connectedDataSizeRead_[rank] = outIndex.numElements();
-    }
-    // ym : displaced to avoid collective call at message reception
-/* 
-    nbReadSenders_[client] = CClientServerMappingDistributed::computeConnectedClients(client->serverSize, client->clientSize,
-                                                                                     client->intraComm, ranks);
-*/
-  }
-  CATCH_DUMP_ATTR
   
   
-  /*!
-   * Compute the number of connected client for a given contextClient and insert it in the nbReadSenders map.
-   * /param[in] client : the given contextClient
-   */
-  void CGrid::computeNbReadSenders(CContextClient* client) 
-  TRY
-  
-  { 
-    nbReadSenders_[client] = CClientServerMappingDistributed::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRankRead_);
-  }
-  CATCH_DUMP_ATTR
-  
-  void CGrid::computeServerDistribution(void)
-  TRY
-  {
-    if (computeServerDistribution_done_) return ;
-    else computeServerDistribution_done_=true ;
-
-    CContext* context = CContext::getCurrent();
-      
-    int idx = 0, numElement = axis_domain_order.numElements();
-    int ssize = numElement;
-    std::vector<int> indexMap(numElement);
-    for (int i = 0; i < numElement; ++i)
-    {
-      indexMap[i] = idx;
-      if (2 == axis_domain_order(i))
-      {
-        ++ssize;
-        idx += 2;
-      }
-      else
-        ++idx;
-    }
-
-    for (int n = 0; n < connectedServerRankRead_.size(); n++)
-    {
-      int rank = connectedServerRankRead_[n];
-      size_t dataSize = 0;
-
-      if (0 == serverDistribution_)
-      {
-        int axisId = 0, domainId = 0, scalarId = 0, globalSize = 1;
-        std::vector<CDomain*> domainList = getDomains();
-        std::vector<CAxis*> axisList = getAxis();
-        std::vector<int> nBegin(ssize), nSize(ssize), nGlob(ssize), nBeginGlobal(ssize), nGlobElement(numElement);
-        std::vector<CArray<int,1> > globalIndex(numElement);
-        for (int i = 0; i < numElement; ++i)
-        {
-          nGlobElement[i] = globalSize;
-          if (2 == axis_domain_order(i)) //domain
-          {
-            nBegin[indexMap[i]] = domainList[domainId]->ibegin;
-            nSize[indexMap[i]]  = domainList[domainId]->ni;
-            nBeginGlobal[indexMap[i]] = 0;
-            nGlob[indexMap[i]] = domainList[domainId]->ni_glo;
-
-            nBegin[indexMap[i] + 1] = domainList[domainId]->jbegin;
-            nSize[indexMap[i] + 1] = domainList[domainId]->nj;
-            nBeginGlobal[indexMap[i] + 1] = 0;
-            nGlob[indexMap[i] + 1] = domainList[domainId]->nj_glo;
-
-            {
-              int count = 0;
-              globalIndex[i].resize(nSize[indexMap[i]]*nSize[indexMap[i]+1]);
-              for (int jdx = 0; jdx < nSize[indexMap[i]+1]; ++jdx)
-                for (int idx = 0; idx < nSize[indexMap[i]]; ++idx)
-                {
-                  globalIndex[i](count) = (nBegin[indexMap[i]] + idx) + (nBegin[indexMap[i]+1] + jdx) * nGlob[indexMap[i]];
-                  ++count;
-                }
-            }
-
-            ++domainId;
-          }
-          else if (1 == axis_domain_order(i)) // axis
-          {
-            nBegin[indexMap[i]] = axisList[axisId]->begin;
-            nSize[indexMap[i]]  = axisList[axisId]->n;
-            nBeginGlobal[indexMap[i]] = 0;
-            nGlob[indexMap[i]] = axisList[axisId]->n_glo;     
-            globalIndex[i].resize(nSize[indexMap[i]]);
-            for (int idx = 0; idx < nSize[indexMap[i]]; ++idx)
-              globalIndex[i](idx) = nBegin[indexMap[i]] + idx;
-
-            ++axisId;
-          }
-          else // scalar
-          { 
-            nBegin[indexMap[i]] = 0;
-            nSize[indexMap[i]]  = 1;
-            nBeginGlobal[indexMap[i]] = 0;
-            nGlob[indexMap[i]] = 1;
-            globalIndex[i].resize(1);
-            globalIndex[i](0) = 0;
-            ++scalarId;
-          }
-        }
-        dataSize = 1;
-
-        for (int i = 0; i < nSize.size(); ++i)
-        dataSize *= nSize[i];
-        serverDistribution_ = new CDistributionServer(context->intraCommRank_, 
-                                                      globalIndex, axis_domain_order,
-                                                      nBegin, nSize, nBeginGlobal, nGlob);
-      }
-    }
-  }
-  CATCH_DUMP_ATTR
-
-
-
-
-
-
-/* old interface => transform into compute receivedIndex
-  void CGrid::recvIndex(vector<int> ranks, vector<CBufferIn*> buffers, CContextServer* server)
-  TRY
-  {
-    CContext* context = CContext::getCurrent();
-    connectedServerRankRead_ = ranks;
-
-    nbReadSenders_.clear();
-    CContextClient* client = server->getAssociatedClient();   
-      
-    int idx = 0, numElement = axis_domain_order.numElements();
-    int ssize = numElement;
-    std::vector<int> indexMap(numElement);
-    for (int i = 0; i < numElement; ++i)
-    {
-      indexMap[i] = idx;
-      if (2 == axis_domain_order(i))
-      {
-        ++ssize;
-        idx += 2;
-      }
-      else
-        ++idx;
-    }
-
-    for (int n = 0; n < ranks.size(); n++)
-    {
-      int rank = ranks[n];
-      CBufferIn& buffer = *buffers[n];
-
-      buffer >>  isCompressible_;
-      size_t dataSize = 0;
-
-      if (0 == serverDistribution_)
-      {
-        int axisId = 0, domainId = 0, scalarId = 0, globalSize = 1;
-        std::vector<CDomain*> domainList = getDomains();
-        std::vector<CAxis*> axisList = getAxis();
-        std::vector<int> nBegin(ssize), nSize(ssize), nGlob(ssize), nBeginGlobal(ssize), nGlobElement(numElement);
-        std::vector<CArray<int,1> > globalIndex(numElement);
-        for (int i = 0; i < numElement; ++i)
-        {
-          nGlobElement[i] = globalSize;
-          if (2 == axis_domain_order(i)) //domain
-          {
-            nBegin[indexMap[i]] = domainList[domainId]->ibegin;
-            nSize[indexMap[i]]  = domainList[domainId]->ni;
-            nBeginGlobal[indexMap[i]] = 0;
-            nGlob[indexMap[i]] = domainList[domainId]->ni_glo;
-
-            nBegin[indexMap[i] + 1] = domainList[domainId]->jbegin;
-            nSize[indexMap[i] + 1] = domainList[domainId]->nj;
-            nBeginGlobal[indexMap[i] + 1] = 0;
-            nGlob[indexMap[i] + 1] = domainList[domainId]->nj_glo;
-
-            {
-              int count = 0;
-              globalIndex[i].resize(nSize[indexMap[i]]*nSize[indexMap[i]+1]);
-              for (int jdx = 0; jdx < nSize[indexMap[i]+1]; ++jdx)
-                for (int idx = 0; idx < nSize[indexMap[i]]; ++idx)
-                {
-                  globalIndex[i](count) = (nBegin[indexMap[i]] + idx) + (nBegin[indexMap[i]+1] + jdx) * nGlob[indexMap[i]];
-                  ++count;
-                }
-            }
-
-            ++domainId;
-          }
-          else if (1 == axis_domain_order(i)) // axis
-          {
-            nBegin[indexMap[i]] = axisList[axisId]->begin;
-            nSize[indexMap[i]]  = axisList[axisId]->n;
-            nBeginGlobal[indexMap[i]] = 0;
-            nGlob[indexMap[i]] = axisList[axisId]->n_glo;     
-            globalIndex[i].resize(nSize[indexMap[i]]);
-            for (int idx = 0; idx < nSize[indexMap[i]]; ++idx)
-              globalIndex[i](idx) = nBegin[indexMap[i]] + idx;
-
-            ++axisId;
-          }
-          else // scalar
-          { 
-            nBegin[indexMap[i]] = 0;
-            nSize[indexMap[i]]  = 1;
-            nBeginGlobal[indexMap[i]] = 0;
-            nGlob[indexMap[i]] = 1;
-            globalIndex[i].resize(1);
-            globalIndex[i](0) = 0;
-            ++scalarId;
-          }
-        }
-        dataSize = 1;
-
-        for (int i = 0; i < nSize.size(); ++i)
-        dataSize *= nSize[i];
-        serverDistribution_ = new CDistributionServer(context->intraCommRank_, 
-                                                      globalIndex, axis_domain_order,
-                                                      nBegin, nSize, nBeginGlobal, nGlob);
-      }
-
-      CArray<size_t,1> outIndex;
-      buffer >> outIndex;
-      outGlobalIndexFromClient_.insert(std::make_pair(rank, outIndex));
-      connectedDataSizeRead_[rank] = outIndex.numElements();
-
-      if (doGridHaveDataDistributed(client))
-      {}
-      else
-      {
-        // THE PROBLEM HERE IS THAT DATA CAN BE NONDISTRIBUTED ON CLIENT AND DISTRIBUTED ON SERVER
-        // BELOW IS THE TEMPORARY FIX only for a single type of element (domain, asix, scalar)
-        dataSize = serverDistribution_->getGridSize();
-      }
-      writtenDataSize_ += dataSize;
-    }
-
-
-    // Compute mask of the current grid
-    {
-      int axisId = 0, domainId = 0, scalarId = 0, globalSize = 1;
-      std::vector<CDomain*> domainList = getDomains();
-      std::vector<CAxis*> axisList = getAxis();
-      int dimSize = 2 * domainList.size() + axisList.size();
-      std::vector<int> nBegin(dimSize), nSize(dimSize), nGlob(dimSize), nBeginGlobal(dimSize);        
-      for (int i = 0; i < numElement; ++i)
-      {          
-        if (2 == axis_domain_order(i)) //domain
-        {
-          nBegin[indexMap[i]] = domainList[domainId]->ibegin;
-          nSize[indexMap[i]]  = domainList[domainId]->ni;
-          nBeginGlobal[indexMap[i]] = 0;              
-          nGlob[indexMap[i]] = domainList[domainId]->ni_glo;
-
-          nBegin[indexMap[i] + 1] = domainList[domainId]->jbegin;
-          nSize[indexMap[i] + 1] = domainList[domainId]->nj;
-          nBeginGlobal[indexMap[i] + 1] = 0;              
-          nGlob[indexMap[i] + 1] = domainList[domainId]->nj_glo;
-          ++domainId;
-        }
-        else if (1 == axis_domain_order(i)) // axis
-        {
-          nBegin[indexMap[i]] = axisList[axisId]->begin;
-          nSize[indexMap[i]]  = axisList[axisId]->n;
-          nBeginGlobal[indexMap[i]] = 0;              
-          nGlob[indexMap[i]] = axisList[axisId]->n_glo;              
-          ++axisId;
-        }
-        else // scalar
-        {  
-        }
-      }
-     
-      if (nSize.empty()) // Scalar grid
-      {
-        nBegin.push_back(0);
-        nSize.push_back(1);
-        nBeginGlobal.push_back(0);              
-        nGlob.push_back(1);  
-      }
-    }
-
-    if (isScalarGrid()) return;
-
-    nbReadSenders_[client] = CClientServerMappingDistributed::computeConnectedClients(client->serverSize, client->clientSize,
-                                                                                      client->intraComm, ranks);
-
-  }
-  CATCH_DUMP_ATTR
-*/
-
-
   /*
      Compute on the fly the global dimension of a grid with its elements
@@ -2495,59 +1218,5 @@
   CATCH_DUMP_ATTR
 
-  /*!
-    Return size of data which is written on each server
-    Whatever dimension of a grid, data which are written on server must be presented as
-    an one dimension array.
-    \return size of data written on server
-  */
-  size_t CGrid::getWrittenDataSize() 
-  TRY
-  {
-    return getGridLocalElements()->getView(CElementView::FULL)->getSize() ;
-  }
-  CATCH
-
-  /*!
-    Returns the number of indexes written by each server.
-    \return the number of indexes written by each server
-  */
-  int CGrid::getNumberWrittenIndexes() const
-  TRY
-  {
-    return numberWrittenIndexes_;
-  }
-  CATCH
-
-  /*!
-    Returns the total number of indexes written by the servers.
-    \return the total number of indexes written by the servers
-  */
-  int CGrid::getTotalNumberWrittenIndexes() const
-  TRY
-  {
-    return totalNumberWrittenIndexes_;
-  }
-  CATCH
-
-  /*!
-    Returns the offset of indexes written by each server.
-    \return the offset of indexes written by each server
-  */
-  int CGrid::getOffsetWrittenIndexes() const
-  TRY
-  {
-    return offsetWrittenIndexes_;
-  }
-  CATCH
-
-  
-  CDistributionClient* CGrid::getClientDistribution()
-  TRY
-  {
-    if (!computeClientDistribution_done_) computeClientDistribution() ;
-    return clientDistribution_;
-  }
-  CATCH_DUMP_ATTR
-
+ 
   bool CGrid::doGridHaveDataDistributed(CContextClient* client)
   TRY
@@ -2582,9 +1251,4 @@
       switch(event.type)
       {
-        case EVENT_ID_INDEX :
-          recvIndex(event);
-          return true;
-          break;
-
          case EVENT_ID_ADD_DOMAIN :
            recvAddDomain(event);
@@ -2626,10 +1290,4 @@
     gridPtr->sendCreateChild(this->getId(),client);
     this->sendAllAttributesToServer(client);
-    //if (isScalarGrid())  sendIndexScalarGrid(client);
-    //else  sendIndex(client);
-    //this->sendAllDomains(client);
-    //this->sendAllAxis(client);
-    //this->sendAllScalars(client);
-
     distributeGridToFileServer(client) ;
   }
@@ -3209,7 +1867,5 @@
     if (0 < transformations_->getNbAlgo()) hasTransform_ = true;
 
-    // Ok, now need to compute index of grid source
-    transformGridSrc->checkMaskIndex(false);
-  }
+ }
   CATCH_DUMP_ATTR
 
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.hpp	(revision 1962)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.hpp	(revision 1973)
@@ -75,5 +75,5 @@
          enum EEventId
          {
-           EVENT_ID_INDEX, EVENT_ID_ADD_DOMAIN, EVENT_ID_ADD_AXIS, EVENT_ID_ADD_SCALAR,
+           EVENT_ID_ADD_DOMAIN, EVENT_ID_ADD_AXIS, EVENT_ID_ADD_SCALAR,
            EVENT_ID_SEND_MASK,
 
@@ -117,14 +117,5 @@
          StdSize  getLocalDataSize(void) ;
 
-         /// Entrees-sorties de champs
-         template <int n>
-         void inputField(const CArray<double,n>& field, CArray<double,1>& stored) ;
-         template <int n>
-         void maskField(const CArray<double,n>& field, CArray<double,1>& stored) ;
-         template <int n>
-         void outputField(const CArray<double,1>& stored, CArray<double,n>& field) ;  
-         template <int n>
-         void uncompressField(const CArray<double,n>& data, CArray<double,1>& outData) ; 
-
+ 
          virtual void parse(xml::CXMLNode& node);
 
@@ -155,8 +146,6 @@
 
       public:            
-         void computeIndexServer(void);
          void computeIndex(void);
          void computeIndexScalarGrid();
-         void computeWrittenIndex();
          void solveDomainAxisRef(bool areAttributesChecked);
          void checkElementsAttributes(void) ;
@@ -202,22 +191,8 @@
 
          static bool dispatchEvent(CEventServer& event);
-         static void recvIndex(CEventServer& event);
-         void recvIndex(vector<int> ranks, vector<CBufferIn*> buffers, CContextServer* server);
-       
-       public:  
-         void sendIndex(CContextClient* client, const string& gridId="");
-       private:
-          set<CContextClient*> sendIndex_done_ ;
        
        public:
-         void sendIndexScalarGrid(CContextClient* client, const string& gridId="");
-       private:
-          set<CContextClient*> sendIndexScalarGrid_done_ ;
-      
-       public:
          void setContextClient(CContextClient* contextClient);
 
-         void computeDomConServer();
-         std::map<int, int> getDomConServerSide();
          std::map<int, StdSize> getAttributesBufferSize(CContextClient* client, bool bufferForWriting = false);
          std::map<int, StdSize> getDataBufferSize(CContextClient* client, const std::string& id = "", bool bufferForWriting = false);
@@ -237,8 +212,4 @@
          bool doGridHaveDataToWrite();
          bool doGridHaveDataDistributed(CContextClient* client = 0);
-         size_t getWrittenDataSize() ;
-         int getNumberWrittenIndexes() const;
-         int getTotalNumberWrittenIndexes() const;
-         int getOffsetWrittenIndexes() const;
 
          CGridTransformation* getTransformations();
@@ -255,5 +226,4 @@
 
          void completeGrid(CGrid* transformGridSrc = 0);
-         void doAutoDistribution(CGrid* transformGridSrc);
          bool isTransformed();
          void setTransformed();
@@ -271,21 +241,9 @@
 
          bool hasMask(void) const;
-         void checkMask(void);
-         void createMask(void);
-         void modifyMask(const CArray<int,1>& indexToModify, bool valueToModify = false);
-         void modifyMaskSize(const std::vector<int>& newDimensionSize, bool newValue = false);
-        
         /** get mask pointer stored in mask_1d, or mask_2d, or..., or mask_7d */
          CArray<bool,1> mask_ ;
          CArray<bool,1>& getMask(void) ;
 
-         void computeGridGlobalDimension(const std::vector<CDomain*>& domains,
-                                         const std::vector<CAxis*>& axis,
-                                         const std::vector<CScalar*>& scalars,
-                                         const CArray<int,1>& axisDomainOrder);
-
-         void computeGridIndexToFileServer(CContextClient* client) ;
- 
-     private:
+      private:
         /** Client-like distribution calculated based on the knowledge of the entire grid */
        CDistributionClient* clientDistribution_;
@@ -298,31 +256,4 @@
 
      private:   
-       /** Server-like distribution calculated upon receiving indexes */
-       CDistributionServer* serverDistribution_;
-       void computeServerDistribution(void) ;
-       bool computeServerDistribution_done_=false ;
-     public: 
-       CDistributionServer* getServerDistribution(void) { if (!computeServerDistribution_done_) computeServerDistribution() ; return serverDistribution_ ;}
-
-
-     private:
-       template<int N>
-       void checkGridMask(CArray<bool,N>& gridMask,
-                          const std::vector<CArray<bool,1>* >& domainMasks,
-                          const std::vector<CArray<bool,1>* >& axisMasks,
-                          const CArray<int,1>& axisDomainOrder,
-                          bool createMask = false);
-
-        template<int N>
-        void modifyGridMask(CArray<bool,N>& gridMask, const CArray<int,1>& indexToModify, bool valueToModify);
-
-        template<int N>
-        void modifyGridMaskSize(CArray<bool,N>& gridMask, const std::vector<int>& eachDimSize, bool newValue);
-
-        void storeField_arr(const double* const data, CArray<double, 1>& stored) ;
-        void restoreField_arr(const CArray<double, 1>& stored, double* const data) ;
-        void uncompressField_arr(const double* const data, CArray<double, 1>& outData) ;
-        void maskField_arr(const double* const data, CArray<double, 1>& stored) ;
-
         void setVirtualDomainGroup(CDomainGroup* newVDomainGroup);
         void setVirtualAxisGroup(CAxisGroup* newVAxisGroup);
@@ -339,7 +270,4 @@
         void checkAttributesAfterTransformation();
         void setTransformationAlgorithms();
-        void computeIndexByElement(const std::vector<std::unordered_map<size_t,std::vector<int> > >& indexServerOnElement,
-                                   const CContextClient* client,
-                                   CClientServerMapping::GlobalIndexMap& globalIndexOnServer);
         int computeGridGlobalDimension(std::vector<int>& globalDim,
                                        const std::vector<CDomain*> domains,
@@ -348,105 +276,6 @@
                                        const CArray<int,1>& axisDomainOrder);
         int getDistributedDimension();
-
-        void computeConnectedClients(CContextClient* client);
-        set<CContextClient*> computeConnectedClients_done_ ;
-
-        void computeConnectedClientsScalarGrid(CContextClient* client); 
-        set<CContextClient*> computeConnectedClientsScalarGrid_done_ ;
-
-      public:
-/** Array containing the local index of the grid
- *  storeIndex_client[local_workflow_grid_index] -> local_model_grid_index. 
- *  Used to store field from model into the worklow, or to return field into models.  
- *  The size of the array is the number of local index of the workflow grid */        
-        CArray<int, 1> storeIndex_client_;
-        void computeStoreIndex_client(void) ;
-        bool computeStoreIndex_client_done_ = false ;
-        CArray<int, 1>& getStoreIndex_client(void) { if (!computeStoreIndex_client_done_) computeStoreIndex_client() ; return storeIndex_client_ ;}
-
-/** Array containing the grid mask masked defined by the mask_nd grid attribute.        
-  * The corresponding masked field value provided by the model will be replaced by a NaN value
-  * in the workflow.  */
-        CArray<bool, 1> storeMask_client_;
-        void computeStoreMask_client(void) ;
-        bool computeStoreMask_client_done_ = false ;
-        CArray<bool, 1>& getStoreMask_client(void) { if (!computeStoreMask_client_done_) computeStoreMask_client() ; return storeMask_client_ ;}
-
-/** Map containing the indexes on client side that will be sent to each connected server.
-  * storeIndex_toSrv[&contextClient] -> map concerning the contextClient for which the data will be sent (client side)
-  * storeIndex_toSrv[&contextClient][rank] -> array of indexes that will be sent to each "rank" of the connected servers 
-  * storeIndex_toSrv[&contextClient][rank](index_of_buffer_sent_to_server) -> local index of the field of the workflow 
-  * grid that will be sent to server */
-         std::map<CContextClient*, map<int, CArray<int, 1> > > storeIndex_toSrv_;
-
-
-/** Map containing the indexes on client side that will be received from each connected server.
-  * This map is used to agreggate field data received from server (for reading) into a single array, which will be an entry
-  * point of the worklow on client side.
-  * storeIndex_toSrv[rank] -> array of indexes that will be received from each "rank" of the connected servers 
-  * storeIndex_toSrv[rank](index_of_buffer_received_from_server) -> local index of the field in the "workflow grid"
-  * that has been received from server */
-         std::map<int, CArray<int, 1> > storeIndex_fromSrv_; // Support, for now, reading with level-1 server
-
-
-/** Maps storing the number of participating clients for data sent a specific server for a given contextClient, identified
-  * by the servers communicator size. In future must be direcly identified by context.
-  * nbSender_[context_server_size] -> map the number of client sender by connected rank of servers
-  * nbSender_[context_server_size] [rank_server] -> the number of client participating to a send message for a server of rank "rank_server" 
-  * Usefull to indicate in a message the number of participant needed by the transfer protocol */
-         std::map<int, std::map<int,int> > nbSenders_;
-
-      private:
-/** Maps storing the number of participating servers for data sent a specific client for a given contextClient.
-  * Symetric of nbSenders_, but for server side which want to send data to client.
-  * nbReadSender_[context_client_size] -> map the number of server sender by connected rank of clients
-  * nbReadSender_[context_client_size] [rank_client] -> the number of server participating to a send message for a client of rank "rank_client" 
-  * Usefull to indicate in a message the number of participant needed by the transfer protocol */
-         std::map<CContextClient*, std::map<int,int> > nbReadSenders_;
-      public:
-         std::map<int,int>& getNbReadSenders(CContextClient* client) 
-         { if (nbReadSenders_.count(client)==0) computeNbReadSenders(client) ; return nbReadSenders_[client] ;}
-      private:
-         void computeNbReadSenders(CContextClient* client) ;
-     
-
-// Manh Ha's comment: " A client receives global index from other clients (via recvIndex)
-// then does mapping these index into local index of STORE_CLIENTINDEX
-// In this way, store_clientIndex can be used as an input of a source filter
-// Maybe we need a flag to determine whether a client wants to write. TODO "
-
-      private:
-       /** 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 several client for reading case. */
-        map<int, CArray<size_t, 1>> outLocalIndexStoreOnClient_; 
-      public:
-         void computeOutLocalIndexStoreOnClient(void) ;
-      private:
-         bool computeOutLocalIndexStoreOnClient_done_ = false ;  
-      public:   
-         map<int, CArray<size_t, 1>>& getOutLocalIndexStoreOnClient(void) 
-         { if (!computeOutLocalIndexStoreOnClient_done_) computeOutLocalIndexStoreOnClient(); return outLocalIndexStoreOnClient_ ; }
-
-      public:
-/** 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. 
- *  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. 
-  * size of the array : numberWrittenIndexes_
-  * localIndexToWriteOnClient_(compressed_written_index) -> local index of the workflow grid*/
-         CArray<size_t,1> localIndexToWriteOnClient_;
-
-      public: 
+      public:
+
         bool isDataDistributed(void) ; 
       private:
@@ -455,14 +284,4 @@
         std::list<CContextClient*> clients;
         std::set<CContextClient*> clientsSet;
-
-      private:  
-        /** 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_;
-      public:  
-        map<int, CArray<size_t, 1> >& getOutGlobalIndexFromClient() { return outGlobalIndexFromClient_ ;}
 
       private:
@@ -476,7 +295,4 @@
         std::vector<std::string> axisList_, domList_, scalarList_;
         bool isAxisListSet, isDomListSet, isScalarListSet;
-
-        CClientServerMapping* clientServerMap_;
-        int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;
 
 /** Map storing local ranks of connected receivers. Key = size of receiver's intracomm.
@@ -499,5 +315,4 @@
 
         bool isTransformed_, isGenerated_;
-        bool computedWrittenIndex_;
         
         std::vector<int> axisPositionInGrid_;
@@ -511,16 +326,4 @@
         bool hasTransform_;
 
-/** 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_;
-      std::map<int, CClientServerMapping::GlobalIndexMap> globalIndexOnServer_;
-     
-
      //////////////////////////////////////////////////////////////////////////////////////
      //  this part is related to distribution, element definition, views and connectors  //
@@ -602,231 +405,4 @@
    }; // class CGrid
 
-   ///--------------------------------------------------------------
-
-   template <int n>
-   void CGrid::inputField(const CArray<double,n>& field, CArray<double,1>& stored)
-   TRY
-   {
-//#ifdef __XIOS_DEBUG
-      if (this->getDataSize() != field.numElements())
-         ERROR("void CGrid::inputField(const  CArray<double,n>& field, CArray<double,1>& stored) const",
-                << "[ Awaiting data of size = " << this->getDataSize() << ", "
-                << "Received data size = "      << field.numElements() << " ] "
-                << "The data array does not have the right size! "
-                << "Grid = " << this->getId())
-//#endif
-      this->storeField_arr(field.dataFirst(), stored);
-   }
-   CATCH
-
-/* obsolete
-   template <int n>
-   void CGrid::maskField(const CArray<double,n>& field, CArray<double,1>& stored)
-   {
-//#ifdef __XIOS_DEBUG
-      if (this->getDataSize() != field.numElements())
-         ERROR("void CGrid::inputField(const  CArray<double,n>& field, CArray<double,1>& stored) const",
-                << "[ Awaiting data of size = " << this->getDataSize() << ", "
-                << "Received data size = "      << field.numElements() << " ] "
-                << "The data array does not have the right size! "
-                << "Grid = " << this->getId())
-//#endif
-      this->maskField_arr(field.dataFirst(), stored);
-   }
-*/
-   template <int n>
-   void CGrid::maskField(const CArray<double,n>& field, CArray<double,1>& stored)
-   {
-      auto connector = getModelToWorkflowConnector() ;
-
-      if (connector->getSrcSize() != field.numElements())
-         ERROR("void CGrid::inputField(const  CArray<double,n>& field, CArray<double,1>& stored) const",
-                << "[ Awaiting data of size = " << this->getDataSize() << ", "
-                << "Received data size = "      << field.numElements() << " ] "
-                << "The data array does not have the right size! "
-                << "Grid = " << this->getId())
-      const double nanValue = std::numeric_limits<double>::quiet_NaN();
-      connector->transfer(field, stored, nanValue) ;
-   }
-
-
-
-   template <int n>
-   void CGrid::outputField(const CArray<double,1>& stored, CArray<double,n>& field)
-   TRY
-   {
-//#ifdef __XIOS_DEBUG
-      if (this->getDataSize() != field.numElements())
-         ERROR("void CGrid::outputField(const CArray<double,1>& stored, CArray<double,n>& field) const",
-                << "[ Size of the data = " << this->getDataSize() << ", "
-                << "Output data size = "   << field.numElements() << " ] "
-                << "The ouput array does not have the right size! "
-                << "Grid = " << this->getId())
-//#endif
-      this->restoreField_arr(stored, field.dataFirst());
-   }
-   CATCH
-
-   /*!
-     This function removes the effect of mask on received data on the server.
-     This function only serve for the checking purpose. TODO: Something must be done to seperate mask and data_index from each other in received data
-     \data data received data with masking effect on the server
-     \outData data without masking effect
-   */
-   template <int N>
-   void CGrid::uncompressField(const CArray<double,N>& data, CArray<double,1>& outData)
-   TRY
-   {      
-     uncompressField_arr(data.dataFirst(), outData);
-   }
-   CATCH
-
-   template<int N>
-   void CGrid::checkGridMask(CArray<bool,N>& gridMask,
-                             const std::vector<CArray<bool,1>* >& domainMasks,
-                             const std::vector<CArray<bool,1>* >& axisMasks,
-                             const CArray<int,1>& axisDomainOrder,
-                             bool createMask)
-   TRY
-   {
-     int idx = 0;
-     int numElement = axisDomainOrder.numElements();
-     int dim = domainMasks.size() * 2 + axisMasks.size();
-     std::vector<CDomain*> domainP = this->getDomains();
-     std::vector<CAxis*> axisP = this->getAxis();
-
-     std::vector<int> idxLoop(dim,0), indexMap(numElement), eachDimSize(dim);
-     std::vector<int> currentIndex(dim);
-     int idxDomain = 0, idxAxis = 0;
-    for (int i = 0; i < numElement; ++i)
-    {
-      indexMap[i] = idx;
-      if (2 == axisDomainOrder(i)) {
-          eachDimSize[indexMap[i]]   = domainP[idxDomain]->ni;
-          eachDimSize[indexMap[i]+1] = domainP[idxDomain]->nj;
-          idx += 2; ++idxDomain;
-      }
-      else if (1 == axisDomainOrder(i)) {
-//        eachDimSize[indexMap[i]] = axisMasks[idxAxis]->numElements();
-        eachDimSize[indexMap[i]] = axisP[idxAxis]->n;
-        ++idx; ++idxAxis;
-      }
-      else {};
-    }
-
-    if (!gridMask.isEmpty() && !createMask)
-    {
-      for (int i = 0; i < dim; ++i)
-      {
-        if (gridMask.extent(i) != eachDimSize[i])
-          ERROR("CGrid::checkMask(void)",
-                << "The mask has one dimension whose size is different from the one of the local grid." << std::endl
-                << "Local size of dimension " << i << " is " << eachDimSize[i] << "." << std::endl
-                << "Mask size for dimension " << i << " is " << gridMask.extent(i) << "." << std::endl
-                << "Grid = " << this->getId())
-      }
-    }
-    else {
-        CArrayBoolTraits<CArray<bool,N> >::resizeArray(gridMask,eachDimSize);
-        gridMask = true;
-    }
-
-    int ssize = gridMask.numElements();
-    idx = 0;
-    while (idx < ssize)
-    {
-      for (int i = 0; i < dim-1; ++i)
-      {
-        if (idxLoop[i] == eachDimSize[i])
-        {
-          idxLoop[i] = 0;
-          ++idxLoop[i+1];
-        }
-      }
-
-      // Find out outer index
-      idxDomain = idxAxis = 0;
-      bool maskValue = true;
-      for (int i = 0; i < numElement; ++i)
-      {
-        if (2 == axisDomainOrder(i))
-        {
-          int idxTmp = idxLoop[indexMap[i]] + idxLoop[indexMap[i]+1] * eachDimSize[indexMap[i]];
-          if (idxTmp < (*domainMasks[idxDomain]).numElements())
-            maskValue = maskValue && (*domainMasks[idxDomain])(idxTmp);
-          else
-            maskValue = false;
-          ++idxDomain;
-        }
-        else if (1 == axisDomainOrder(i))
-        {
-          int idxTmp = idxLoop[indexMap[i]];
-          if (idxTmp < (*axisMasks[idxAxis]).numElements())
-            maskValue = maskValue && (*axisMasks[idxAxis])(idxTmp);
-          else
-            maskValue = false;
-
-          ++idxAxis;
-        }
-      }
-
-      int maskIndex = idxLoop[0];
-      int mulDim = 1;
-      for (int k = 1; k < dim; ++k)
-      {
-        mulDim *= eachDimSize[k-1];
-        maskIndex += idxLoop[k]*mulDim;
-      }
-      *(gridMask.dataFirst()+maskIndex) &= maskValue;
-
-      ++idxLoop[0];
-      ++idx;
-    }
-   }
-   CATCH_DUMP_ATTR
-
-   template<int N>
-   void CGrid::modifyGridMaskSize(CArray<bool,N>& gridMask,
-                                  const std::vector<int>& eachDimSize,
-                                  bool newValue)
-   TRY
-   {
-      if (N != eachDimSize.size())
-      {
-        // ERROR("CGrid::modifyGridMaskSize(CArray<bool,N>& gridMask,
-        //                                  const std::vector<int>& eachDimSize,
-        //                                  bool newValue)",
-        //       << "Dimension size of the mask is different from input dimension size." << std::endl
-        //       << "Mask dimension is " << N << "." << std::endl
-        //       << "Input dimension is " << eachDimSize.size() << "." << std::endl
-        //       << "Grid = " << this->getId())
-      }
-      CArrayBoolTraits<CArray<bool,N> >::resizeArray(gridMask,eachDimSize);
-      gridMask = newValue;
-   }
-   CATCH_DUMP_ATTR
-                                 
-
-   /*!
-     Modify the current mask of grid, the local index to be modified will take value false
-     \param [in/out] gridMask current mask of grid
-     \param [in] indexToModify local index to modify
-   */
-   template<int N>
-   void CGrid::modifyGridMask(CArray<bool,N>& gridMask, const CArray<int,1>& indexToModify, bool valueToModify)
-   TRY
-   {     
-     int num = indexToModify.numElements();
-     for (int idx = 0; idx < num; ++idx)
-     {
-       *(gridMask.dataFirst()+indexToModify(idx)) = valueToModify;
-     }
-   }
-   CATCH_DUMP_ATTR
-
-   ///--------------------------------------------------------------
-
-
-
    // Declare/Define CGridGroup and CGridDefinition
    DECLARE_GROUP(CGrid);
