Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/config/scalar_attribute.conf
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/config/scalar_attribute.conf	(revision 1939)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/config/scalar_attribute.conf	(revision 1940)
@@ -8,7 +8,9 @@
 
 /* LOCAL and GLOBAL*/
+DECLARE_ATTRIBUTE(bool, mask, false)
 DECLARE_ATTRIBUTE(double, value)
 DECLARE_ATTRIBUTE(StdString, bounds_name)
 DECLARE_ARRAY(double, 1 , bounds)
+
 
 DECLARE_ATTRIBUTE(StdString, scalar_ref)
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp	(revision 1939)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp	(revision 1940)
@@ -3266,6 +3266,8 @@
     std::vector<CDomain*> domainList = this->getDomains();
     std::vector<CAxis*> axisList = this->getAxis();
+    std::vector<CScalar*> scalarList = this->getScalars();
     auto domain=domainList.begin() ;
     auto axis=axisList.begin() ;
+    auto scalar=scalarList.begin() ;
     vector<CLocalElement*> elements;
     for(auto order : order_)
@@ -3283,4 +3285,6 @@
       else if (order==0)
       { 
+        elements.push_back((*scalar)->getLocalElement());
+        scalar++ ;
       }
     }
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.cpp	(revision 1939)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.cpp	(revision 1940)
@@ -9,59 +9,66 @@
 #include "context.hpp"
 
-namespace xios {
-
-   /// ////////////////////// DÃ©finitions ////////////////////// ///
-
-   CScalar::CScalar(void)
-      : CObjectTemplate<CScalar>()
-      , CScalarAttributes()
-      , relFiles()
-   { /* Ne rien faire de plus */ }
-
-   CScalar::CScalar(const StdString & id)
-      : CObjectTemplate<CScalar>(id)
-      , CScalarAttributes()
-      , relFiles()
-   { /* Ne rien faire de plus */ }
-
-   CScalar::~CScalar(void)
-   { /* Ne rien faire de plus */ }
-
-   std::map<StdString, ETranformationType> CScalar::transformationMapList_ = std::map<StdString, ETranformationType>();
-   bool CScalar::dummyTransformationMapList_ = CScalar::initializeTransformationMap(CScalar::transformationMapList_);
-   bool CScalar::initializeTransformationMap(std::map<StdString, ETranformationType>& m)
-   {
-     m["reduce_axis"]   = TRANS_REDUCE_AXIS_TO_SCALAR;
-     m["extract_axis"]  = TRANS_EXTRACT_AXIS_TO_SCALAR;
-     m["reduce_domain"] = TRANS_REDUCE_DOMAIN_TO_SCALAR;
-     m["reduce_scalar"] = TRANS_REDUCE_SCALAR_TO_SCALAR;
-   }
-
-   StdString CScalar::GetName(void)   { return (StdString("scalar")); }
-   StdString CScalar::GetDefName(void){ return (CScalar::GetName()); }
-   ENodeType CScalar::GetType(void)   { return (eScalar); }
-
-   CScalar* CScalar::createScalar()
-   {
-     CScalar* scalar = CScalarGroup::get("scalar_definition")->createChild();
-     return scalar;
-   }
-
-   bool CScalar::IsWritten(const StdString & filename) const
-   {
-      return (this->relFiles.find(filename) != this->relFiles.end());
-   }
-
-   void CScalar::addRelFile(const StdString& filename)
-   {
+namespace xios 
+{
+
+  /// ////////////////////// DÃ©finitions ////////////////////// ///
+
+  CScalar::CScalar(void)
+     : CObjectTemplate<CScalar>()
+     , CScalarAttributes()
+     , relFiles()
+  { /* Ne rien faire de plus */ }
+
+  CScalar::CScalar(const StdString & id)
+     : CObjectTemplate<CScalar>(id)
+     , CScalarAttributes()
+     , relFiles()
+  { /* Ne rien faire de plus */ }
+
+  CScalar::~CScalar(void)
+  { /* Ne rien faire de plus */ }
+
+  std::map<StdString, ETranformationType> CScalar::transformationMapList_ = std::map<StdString, ETranformationType>();
+  bool CScalar::dummyTransformationMapList_ = CScalar::initializeTransformationMap(CScalar::transformationMapList_);
+  bool CScalar::initializeTransformationMap(std::map<StdString, ETranformationType>& m)
+  {
+    m["reduce_axis"]   = TRANS_REDUCE_AXIS_TO_SCALAR;
+    m["extract_axis"]  = TRANS_EXTRACT_AXIS_TO_SCALAR;
+    m["reduce_domain"] = TRANS_REDUCE_DOMAIN_TO_SCALAR;
+    m["reduce_scalar"] = TRANS_REDUCE_SCALAR_TO_SCALAR;
+  }
+
+  StdString CScalar::GetName(void)   { return (StdString("scalar")); }
+  StdString CScalar::GetDefName(void){ return (CScalar::GetName()); }
+  ENodeType CScalar::GetType(void)   { return (eScalar); }
+
+  CScalar* CScalar::createScalar()
+  {
+    CScalar* scalar = CScalarGroup::get("scalar_definition")->createChild();
+    return scalar;
+  }
+
+  bool CScalar::IsWritten(const StdString & filename) const
+  {
+    return (this->relFiles.find(filename) != this->relFiles.end());
+  }
+
+  void CScalar::addRelFile(const StdString& filename)
+  {
       this->relFiles.insert(filename);
-   }
-
-   void CScalar::checkAttributes(void)
-   {
-      if (checkAttributes_done_) return ;
-
-      checkAttributes_done_ = true ; 
-   }
+  }
+
+  void CScalar::checkAttributes(void)
+  {
+    if (checkAttributes_done_) return ;
+    checkAttributes_done_ = true ; 
+
+    if (mask.isEmpty()) mask=true ;
+
+    initializeLocalElement() ;
+    addFullView() ;
+    addWorkflowView() ;
+    addModelView() ;
+  }
 
   void CScalar::checkAttributesOnClient()
@@ -243,5 +250,4 @@
       CArray<size_t,1> ind(1) ;
       ind(0)=0 ;
-
       localElement_ = new CLocalElement(rank, 1, ind) ;
    }
@@ -256,7 +262,12 @@
    void CScalar::addWorkflowView(void)
    {
-     CArray<int,1> index(1) ;
-     for(int i=0; i<1 ; i++) index(0)=0 ;
-     localElement_ -> addView(CElementView::WORKFLOW, index) ;
+      CArray<int,1> index ;
+      if (mask) 
+      {
+        index.resize(1) ;
+        index(0)=0 ;
+      }
+      else index.resize(0) ;
+      localElement_ -> addView(CElementView::WORKFLOW, index) ;
    }
 
@@ -277,5 +288,5 @@
 
 
-   void CScalar::computeRemoteElement(CContextClient* client, EDistributionType type)
+  void CScalar::computeRemoteElement(CContextClient* client, EDistributionType type)
   {
     CContext* context = CContext::getCurrent();
@@ -284,7 +295,7 @@
     int nbServer = client->serverSize;
     size_t nglo=1 ;
-    CArray<size_t,1> indGlo ;
+    CArray<size_t,1> indGlo(nglo) ;
     for(size_t i=0;i<nglo;i++) indGlo(i) = i ;
-    for (auto& rankServer : client->getRanksServerLeader()) globalIndex[rankServer] = indGlo ; 
+    for (auto& rankServer : client->getRanksServerLeader()) globalIndex[rankServer].reference(indGlo.copy()) ; 
 
     remoteElement_[client] = new CDistributedElement(nglo, globalIndex) ;
@@ -292,15 +303,175 @@
   }
  
-  void CScalar::distributeToServer(CContextClient* client, std::map<int, CArray<size_t,1>>& globalIndex)
-  {
+  void CScalar::distributeToServer(CContextClient* client, std::map<int, CArray<size_t,1>>& globalIndex,  const string& scalarId)
+  {
+   
+    string serverScalarId = scalarId.empty() ? this->getId() : scalarId ;
     CContext* context = CContext::getCurrent();
+
+    this->sendAllAttributesToServer(client, serverScalarId)  ;
+
     CDistributedElement scatteredElement(1,globalIndex) ;
-    clientToServerConnector_[client] = new CScattererConnector(localElement_->getView(CElementView::FULL), scatteredElement.getView(CElementView::FULL), 
-                                                               context->getIntraComm()) ;
-    clientToServerConnector_[client] ->computeConnector() ;
-
-// need to be completed    
-
-  }
+    scatteredElement.addFullView() ;
+    CScattererConnector scattererConnector(localElement_->getView(CElementView::FULL), scatteredElement.getView(CElementView::FULL), context->getIntraComm()) ;
+    scattererConnector.computeConnector() ;
+    
+    // phase 0
+    // send remote element to construct the full view on server, ie without hole 
+    CEventClient event0(getType(), EVENT_ID_SCALAR_DISTRIBUTION);
+    CMessage message0 ;
+    message0<<serverScalarId<<0 ; 
+    remoteElement_[client]->sendToServer(client,event0,message0) ; 
+    
+    // phase 1
+    // send the full view of element to construct the connector which connect distributed data coming from client to the full local view
+    CEventClient event1(getType(), EVENT_ID_SCALAR_DISTRIBUTION);
+    CMessage message1 ;
+    message1<<serverScalarId<<1<<localElement_->getView(CElementView::FULL)->getGlobalSize() ; 
+    scattererConnector.transfer(localElement_->getView(CElementView::FULL)->getGlobalIndex(),client,event1,message1) ;
+
+    sendDistributedAttributes(client, scattererConnector, scalarId) ;
+  
+    // phase 2 send the mask : data index + mask2D
+    CArray<bool,1> maskIn(localElement_->getView(CElementView::WORKFLOW)->getSize());
+    CArray<bool,1> maskOut ;
+    CLocalConnector workflowToFull(localElement_->getView(CElementView::WORKFLOW), localElement_->getView(CElementView::FULL)) ;
+    workflowToFull.computeConnector() ;
+    maskIn=true ;
+    workflowToFull.transfer(maskIn,maskOut,false) ;
+
+    // phase 3 : prepare grid scatterer connector to send data from client to server
+    map<int,CArray<size_t,1>> workflowGlobalIndex ;
+    map<int,CArray<bool,1>> maskOut2 ; 
+    scattererConnector.transfer(maskOut, maskOut2) ;
+    scatteredElement.addView(CElementView::WORKFLOW, maskOut2) ;
+    scatteredElement.getView(CElementView::WORKFLOW)->getGlobalIndexView(workflowGlobalIndex) ;
+    // create new workflow view for scattered element
+    CDistributedElement clientToServerElement(scatteredElement.getGlobalSize(), workflowGlobalIndex) ;
+    clientToServerElement.addFullView() ;
+    CEventClient event2(getType(), EVENT_ID_SCALAR_DISTRIBUTION);
+    CMessage message2 ;
+    message2<<serverScalarId<<2 ; 
+    clientToServerElement.sendToServer(client, event2, message2) ; 
+    clientToServerConnector_[client] = new CScattererConnector(localElement_->getView(CElementView::WORKFLOW),
+                                                              clientToServerElement.getView(CElementView::FULL), context->getIntraComm()) ;
+    clientToServerConnector_[client]->computeConnector() ;
+
+
+    CEventClient event3(getType(), EVENT_ID_SCALAR_DISTRIBUTION);
+    CMessage message3 ;
+    message3<<serverScalarId<<3 ; 
+    clientToServerConnector_[client]->transfer(maskIn,client,event3,message3) ; 
+
+    clientFromServerConnector_[client] = new CGathererConnector(clientToServerElement.getView(CElementView::FULL), localElement_->getView(CElementView::WORKFLOW));
+    clientFromServerConnector_[client]->computeConnector() ;
+
+  }
+  
+  void CScalar::recvScalarDistribution(CEventServer& event)
+  TRY
+  {
+    string scalarId;
+    int phasis ;
+    for (auto& subEvent : event.subEvents) (*subEvent.buffer) >> scalarId >> phasis ;
+    get(scalarId)->receivedScalarDistribution(event, phasis);
+  }
+  CATCH
+  
+  void CScalar::receivedScalarDistribution(CEventServer& event, int phasis)
+  TRY
+  {
+    CContext* context = CContext::getCurrent();
+    if (phasis==0) // receive the remote element to construct the full view
+    {
+      localElement_ = new  CLocalElement(context->getIntraCommRank(),event) ;
+      localElement_->addFullView() ;
+      // construct the local dimension and indexes
+      auto& globalIndex=localElement_->getGlobalIndex() ;
+      int nk=globalIndex.numElements() ;
+      // no distribution for scalar => nk ==1 or maybe 0 ?
+    }
+    else if (phasis==1) // receive the sent view from client to construct the full distributed full view on server
+    {
+      CContext* context = CContext::getCurrent();
+      CDistributedElement* elementFrom = new  CDistributedElement(event) ;
+      elementFrom->addFullView() ;
+      gathererConnector_ = new CGathererConnector(elementFrom->getView(CElementView::FULL), localElement_->getView(CElementView::FULL)) ;
+      gathererConnector_->computeConnector() ; 
+    }
+    else if (phasis==2)
+    {
+      delete gathererConnector_ ;
+      elementFrom_ = new  CDistributedElement(event) ;
+      elementFrom_->addFullView() ;
+      gathererConnector_ =  new CGathererConnector(elementFrom_->getView(CElementView::FULL), localElement_->getView(CElementView::FULL)) ;
+      gathererConnector_ -> computeConnector() ;
+    }
+    else if (phasis==3)
+    {
+      CArray<bool,1> localMask ;
+      gathererConnector_->transfer(event,localMask,false) ;
+      localElement_->addView(CElementView::WORKFLOW, localMask) ;
+      mask = localMask(0) ;
+       
+      serverFromClientConnector_ = new CGathererConnector(elementFrom_->getView(CElementView::FULL), localElement_->getView(CElementView::WORKFLOW)) ;
+      serverFromClientConnector_->computeConnector() ;
+
+      serverToClientConnector_ = new CScattererConnector(localElement_->getView(CElementView::WORKFLOW), elementFrom_->getView(CElementView::FULL),
+                                                         context->getIntraComm()) ;
+      serverToClientConnector_->computeConnector() ;
+
+    }
+  }
+  CATCH
+
+  void CScalar::sendDistributedAttributes(CContextClient* client, CScattererConnector& scattererConnector, const string& scalarId)
+  {
+    string serverScalarId = scalarId.empty() ? this->getId() : scalarId ;
+    CContext* context = CContext::getCurrent();
+
+    // nothing for now
+  }
+
+  void CScalar::recvDistributedAttributes(CEventServer& event)
+  TRY
+  {
+    string scalarId;
+    string type ;
+    for (auto& subEvent : event.subEvents) (*subEvent.buffer) >> scalarId >> type ;
+    get(scalarId)->recvDistributedAttributes(event, type);
+  }
+  CATCH
+
+  void CScalar::recvDistributedAttributes(CEventServer& event, const string& type)
+  TRY
+  {
+    // nothing for now
+  }
+  CATCH  
+
+  bool CScalar::dispatchEvent(CEventServer& event)
+  TRY
+  {
+     if (SuperClass::dispatchEvent(event)) return true;
+     else
+     {
+       switch(event.type)
+       {
+          case EVENT_ID_SCALAR_DISTRIBUTION:
+            recvScalarDistribution(event);
+            return true;
+            break;
+          case EVENT_ID_SEND_DISTRIBUTED_ATTRIBUTE:
+            recvDistributedAttributes(event);
+            return true;
+            break;
+          default :
+            ERROR("bool CScalar::dispatchEvent(CEventServer& event)",
+                   << "Unknown Event");
+          return false;
+        }
+     }
+  }
+  CATCH
 
 
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.hpp	(revision 1939)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.hpp	(revision 1940)
@@ -41,9 +41,18 @@
          , public CScalarAttributes
       {
+           friend class CScalarGroup;
+
             /// typedef ///
             typedef CObjectTemplate<CScalar>   SuperClass;
             typedef CScalarAttributes SuperClassAttribute;
 
-            friend class CScalarGroup;
+         public:
+           enum EEventId
+           {
+             EVENT_ID_SCALAR_DISTRIBUTION,
+             EVENT_ID_SEND_DISTRIBUTED_ATTRIBUTE,
+           } ;
+           static bool dispatchEvent(CEventServer& event);      
+           
 
          public :
@@ -166,5 +175,11 @@
        public:
          void computeRemoteElement(CContextClient* client, EDistributionType) ;
-         void distributeToServer(CContextClient* client, std::map<int, CArray<size_t,1>>& globalIndex) ;
+         void distributeToServer(CContextClient* client, std::map<int, CArray<size_t,1>>& globalIndex, const string& scalarId="") ;
+         static void recvScalarDistribution(CEventServer& event) ;
+         void receivedScalarDistribution(CEventServer& event, int phasis) ;
+         void sendDistributedAttributes(CContextClient* client, CScattererConnector& scattererConnector, const string& scalarId) ;
+         static void recvDistributedAttributes(CEventServer& event) ;
+         void recvDistributedAttributes(CEventServer& event, const string& type) ;
+
        private:
          map<CContextClient*, CDistributedElement*> remoteElement_ ;
@@ -179,4 +194,5 @@
          CGathererConnector*  gathererConnector_ ;
          CGathererConnector* serverFromClientConnector_ ;
+         CDistributedElement* elementFrom_ ;
        public:
         CGathererConnector* getServerFromClientConnector(void) { return serverFromClientConnector_ ;}
