Index: /XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.cpp
===================================================================
--- /XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.cpp	(revision 1344)
+++ /XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.cpp	(revision 1345)
@@ -26,4 +26,5 @@
       , transformationMap_(), hasValue(false), hasLabel(false)
       , computedWrittenIndex_(false)
+	  , clients()
    {
    }
@@ -37,4 +38,5 @@
       , transformationMap_(), hasValue(false), hasLabel(false)
       , computedWrittenIndex_(false)
+	  , clients()
    {
    }
@@ -839,12 +841,9 @@
                                         CServerDistributionDescription::ServerDistributionType distType)
   {
-    CContext* context = CContext::getCurrent();
-
-    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1;
-    for (int i = 0; i < nbSrvPools; ++i)
-    {
-      CContextClient* contextClientTmp = (context->hasServer) ? context->clientPrimServer[i]
-                                                                         : context->client;
-      int nbServer = contextClientTmp->serverSize;
+    std::set<CContextClient*>::iterator it;
+    for (it=clients.begin(); it!=clients.end(); ++it)
+    {
+      CContextClient* client = *it;
+      int nbServer = client->serverSize;
 
       CServerDistributionDescription serverDescription(globalDim, nbServer);
@@ -855,9 +854,9 @@
 
       CEventClient event(getType(),EVENT_ID_DISTRIBUTION_ATTRIBUTE);
-      if (contextClientTmp->isServerLeader())
+      if (client->isServerLeader())
       {
         std::list<CMessage> msgs;
 
-        const std::list<int>& ranks = contextClientTmp->getRanksServerLeader();
+        const std::list<int>& ranks = client->getRanksServerLeader();
         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
         {
@@ -875,7 +874,7 @@
           event.push(*itRank,1,msg);
         }
-        contextClientTmp->sendEvent(event);
-      }
-      else contextClientTmp->sendEvent(event);
+        client->sendEvent(event);
+      }
+      else client->sendEvent(event);
     }
   }
@@ -960,10 +959,8 @@
   void CAxis::sendNonDistributedAttributes()
   {
-    CContext* context = CContext::getCurrent();
-
-    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1;
-    for (int p = 0; p < nbSrvPools; ++p)
-    {
-      CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[p] : context->client;
+    std::set<CContextClient*>::iterator it;
+    for (it=clients.begin(); it!=clients.end(); ++it)
+	{
+	  CContextClient* client = *it;
 
       CEventClient event(getType(), EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES);
@@ -1086,10 +1083,9 @@
   {
     int ns, n, i, j, ind, nv, idx;
-    CContext* context = CContext::getCurrent();
-    
-    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1;
-    for (int p = 0; p < nbSrvPools; ++p)
-    {
-      CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[p] : context->client;
+    std::set<CContextClient*>::iterator it;
+
+    for (it=clients.begin(); it!=clients.end(); ++it)
+    {
+      CContextClient* client = *it;
       int nbServer = client->serverSize;
 
@@ -1442,4 +1438,9 @@
   }
 
+  void CAxis::setContextClient(CContextClient* contextClient)
+  {
+    clients.insert(contextClient);
+  }
+
   void CAxis::parse(xml::CXMLNode & node)
   {
Index: /XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.hpp
===================================================================
--- /XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.hpp	(revision 1344)
+++ /XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.hpp	(revision 1345)
@@ -94,4 +94,6 @@
          virtual void parse(xml::CXMLNode & node);
 
+         void setContextClient(CContextClient* contextClient);
+
          /// Accesseurs statiques ///
          static StdString GetName(void);
@@ -150,4 +152,8 @@
 
       private:
+
+/** Clients that have to send a domain. There can be multiple clients in case of secondary server, otherwise only one client. */
+         std::set<CContextClient*> clients;
+
          bool isChecked;
          bool areClientAttributesChecked_;
Index: /XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.cpp
===================================================================
--- /XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.cpp	(revision 1344)
+++ /XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.cpp	(revision 1345)
@@ -33,4 +33,5 @@
       , lonvalue(), latvalue(), bounds_lonvalue(), bounds_latvalue()
       , globalLocalIndexMap_(), computedWrittenIndex_(false)
+	  , clients()
    {
    }
@@ -44,4 +45,5 @@
       , lonvalue(), latvalue(), bounds_lonvalue(), bounds_latvalue()
       , globalLocalIndexMap_(), computedWrittenIndex_(false)
+	  , clients()
    {
     }
@@ -2065,11 +2067,9 @@
   {
     int ns, n, i, j, ind, nv, idx;
-    CContext* context = CContext::getCurrent();
-
-    // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
-    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1;
-    for (int p = 0; p < nbSrvPools; ++p)
+    std::set<CContextClient*>::iterator it;
+    for (it=clients.begin(); it!=clients.end(); ++it)
     {
-      CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[p] : context->client;
+      CContextClient* client = *it;
+
       int serverSize = client->serverSize;
       CEventClient eventIndex(getType(), EVENT_ID_INDEX);
@@ -2115,13 +2115,9 @@
   void CDomain::sendDistributionAttributes(void)
   {
-    CContext* context = CContext::getCurrent();
-     // Use correct context client to send message
-    // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
-    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1;
-    for (int i = 0; i < nbSrvPools; ++i)
+    std::set<CContextClient*>::iterator it;
+    for (it=clients.begin(); it!=clients.end(); ++it)
     {
-      CContextClient* contextClientTmp = (context->hasServer) ? context->clientPrimServer[i]
-                                                                         : context->client;    
-      int nbServer = contextClientTmp->serverSize;
+      CContextClient* client = *it;
+      int nbServer = client->serverSize;
       std::vector<int> nGlobDomain(2);
       nGlobDomain[0] = this->ni_glo;
@@ -2136,9 +2132,9 @@
 
       CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT);
-      if (contextClientTmp->isServerLeader())
+      if (client->isServerLeader())
       {
         std::list<CMessage> msgs;
 
-        const std::list<int>& ranks = contextClientTmp->getRanksServerLeader();
+        const std::list<int>& ranks = client->getRanksServerLeader();
         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
         {
@@ -2158,7 +2154,7 @@
           event.push(*itRank,1,msg);
         }
-        contextClientTmp->sendEvent(event);
-      }
-      else contextClientTmp->sendEvent(event);
+        client->sendEvent(event);
+      }
+      else client->sendEvent(event);
     }
   }
@@ -2170,11 +2166,8 @@
   {
     int ns, n, i, j, ind, nv, idx;
-    CContext* context = CContext::getCurrent();
-
-    // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
-    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1;
-    for (int p = 0; p < nbSrvPools; ++p)
+    std::set<CContextClient*>::iterator it;
+    for (it=clients.begin(); it!=clients.end(); ++it)
     {
-      CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[p] : context->client;
+      CContextClient* client = *it;
       int serverSize = client->serverSize;
 
@@ -2219,11 +2212,9 @@
 
     int ns, n, i, j, ind, nv, idx;
-    CContext* context = CContext::getCurrent();
-
-    // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
-    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1;
-    for (int p = 0; p < nbSrvPools; ++p)
+    std::set<CContextClient*>::iterator it;
+
+    for (it=clients.begin(); it!=clients.end(); ++it)
     {
-      CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[p] : context->client;
+      CContextClient* client = *it;
       int serverSize = client->serverSize;
 
@@ -2271,11 +2262,8 @@
 
     int ns, n, i, j, ind, nv, idx;
-    CContext* context = CContext::getCurrent();
-
-    // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
-    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1;
-    for (int p = 0; p < nbSrvPools; ++p)
+    std::set<CContextClient*>::iterator it;
+    for (it=clients.begin(); it!=clients.end(); ++it)
     {
-      CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[p] : context->client;
+      CContextClient* client = *it;
       int serverSize = client->serverSize;
 
@@ -2368,11 +2356,9 @@
   {
     int ns, n, i, j, ind, nv, idx;
-    CContext* context = CContext::getCurrent();
-
-    // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
-    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1;
-    for (int p = 0; p < nbSrvPools; ++p)
+    std::set<CContextClient*>::iterator it;
+    for (it=clients.begin(); it!=clients.end(); ++it)
     {
-      CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[p] : context->client;
+      CContextClient* client = *it;
+
       int serverSize = client->serverSize;
 
@@ -3128,4 +3114,9 @@
   }
 
+  void CDomain::setContextClient(CContextClient* contextClient)
+  {
+    clients.insert(contextClient);
+  }
+
   /*!
     Parse children nodes of a domain in xml file.
Index: /XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.hpp
===================================================================
--- /XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.hpp	(revision 1344)
+++ /XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.hpp	(revision 1345)
@@ -71,4 +71,6 @@
         
          virtual void parse(xml::CXMLNode & node);
+
+         void setContextClient(CContextClient* contextClient);
 
          /// VÃ©rifications ///
@@ -199,4 +201,8 @@
 
        private:         
+
+/** Clients that have to send a domain. There can be multiple clients in case of secondary server, otherwise only one client. */
+         std::set<CContextClient*> clients;
+
          bool doZoomByIndex_;
          bool isChecked, computedWrittenIndex_;
Index: /XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.cpp
===================================================================
--- /XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.cpp	(revision 1344)
+++ /XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.cpp	(revision 1345)
@@ -2509,4 +2509,8 @@
   {
     clients.insert(contextClient);
+    for (int i=0; i<this->getDomains().size(); i++)
+    	this->getDomains()[i]->setContextClient(contextClient);
+    for (int i=0; i<this->getAxis().size(); i++)
+    	this->getAxis()[i]->setContextClient(contextClient);
   }
 
