Index: /XIOS/dev/dev_olga/src/buffer_client.cpp
===================================================================
--- /XIOS/dev/dev_olga/src/buffer_client.cpp	(revision 1076)
+++ /XIOS/dev/dev_olga/src/buffer_client.cpp	(revision 1077)
@@ -80,5 +80,12 @@
     {
       traceOff();
-      MPI_Test(&request, &flag, &status);
+      MPI_Errhandler_set(interComm,MPI_ERRORS_RETURN);
+      error=MPI_Test(&request, &flag, &status);
+      if (error != MPI_SUCCESS)
+      {
+        MPI_Error_class(error, &errclass);
+        MPI_Error_string(error, errstring, &len);
+        ERROR("MPI error class: ", <<errclass<<" MPI error "<<errstring );
+      }
       traceOn();
       if (flag == true) pending = false;
Index: /XIOS/dev/dev_olga/src/context_client.cpp
===================================================================
--- /XIOS/dev/dev_olga/src/context_client.cpp	(revision 1076)
+++ /XIOS/dev/dev_olga/src/context_client.cpp	(revision 1077)
@@ -264,6 +264,7 @@
    {
       map<int,CClientBuffer*>::iterator itBuff;
-      for (itBuff = buffers.begin(); itBuff != buffers.end(); itBuff++) delete itBuff->second;
-//        buffersReleased_ = true;
+      for (itBuff = buffers.begin(); itBuff != buffers.end(); itBuff++)
+          delete itBuff->second;
+      buffers.clear();
    }
 
Index: /XIOS/dev/dev_olga/src/context_client.hpp
===================================================================
--- /XIOS/dev/dev_olga/src/context_client.hpp	(revision 1076)
+++ /XIOS/dev/dev_olga/src/context_client.hpp	(revision 1077)
@@ -79,6 +79,4 @@
       StdSize maxBufferedEvents;
 
-//      bool buffersReleased_;
-
       struct {
         std::list<int> ranks, sizes;
Index: /XIOS/dev/dev_olga/src/cxios.hpp
===================================================================
--- /XIOS/dev/dev_olga/src/cxios.hpp	(revision 1076)
+++ /XIOS/dev/dev_olga/src/cxios.hpp	(revision 1077)
@@ -29,6 +29,4 @@
      static string rootFile ; //!< Configuration filename
      static string xiosCodeId ; //!< Identity for XIOS
-//     static string xiosCodeIdPrm ; //!< Identity for XIOS primary server
-//     static string xiosCodeIdSnd ; //!< Identity for XIOS secondary server
      static string clientFile;        //!< Filename template for client
      static string serverFile;        //!< Filename template for server
Index: /XIOS/dev/dev_olga/src/node/context.cpp
===================================================================
--- /XIOS/dev/dev_olga/src/node/context.cpp	(revision 1076)
+++ /XIOS/dev/dev_olga/src/node/context.cpp	(revision 1077)
@@ -460,11 +460,7 @@
          if (server->intraCommRank==0) CXios::globalRegistry->mergeRegistry(*registryOut) ;
        }
-
-//       for (std::list<MPI_Comm>::iterator it = comms.begin(); it != comms.end(); ++it)
-//         MPI_Comm_free(&(*it));
-//       comms.clear();
-
       }
    }
+
    //! Free internally allocated communicators
    void CContext::freeComms(void)
@@ -562,44 +558,4 @@
    void CContext::closeDefinition(void)
    {
-     // There is nothing client need to send to server
-//      if (hasClient)
-//     if (hasClient && !hasServer)
-//      if (hasClient)
-//      {
-//        // After xml is parsed, there are some more works with post processing
-//        postProcessing();
-//      }
-
-//      setClientServerBuffer();
-
-// //     if (hasClient && !hasServer)
-//      if (hasClient)
-//      {
-//       // Send all attributes of current context to server
-//       this->sendAllAttributesToServer();
-
-//       // Send all attributes of current calendar
-//       CCalendarWrapper::get(CCalendarWrapper::GetDefName())->sendAllAttributesToServer();
-
-//       // We have enough information to send to server
-//       // First of all, send all enabled files
-//        sendEnabledFiles();
-
-//       // Then, send all enabled fields
-//        sendEnabledFields();
-
-//       // At last, we have all info of domain and axis, then send them
-//        sendRefDomainsAxis();
-
-//       // After that, send all grid (if any)
-//        sendRefGrid();
-
-//        // // We have a xml tree on the server side and now, it should be also processed
-//        sendPostProcessing();
-//      }
-
-
-     // Now tell server that it can process all messages from client
-     // if (hasClient) this->sendCloseDefinition();
     postProcessingGlobalAttributes();
 
@@ -611,7 +567,5 @@
      if (hasClient && !hasServer)
     {
-      // this->buildFilterGraphOfEnabledFields();  // references are resolved here (access xml file)
       buildFilterGraphOfFieldsWithReadAccess();
-      // this->solveAllRefOfEnabledFields(true);
     }
 
@@ -619,12 +573,7 @@
     this->processGridEnabledFields();
     if (hasClient) this->sendProcessingGridOfEnabledFields();
-    // if (hasClient)        // We have a xml tree on the server side and now, it should be also processed
-    //    sendPostProcessing();
-//    // Now tell server that it can process all messages from client
-////    if (hasClient && !hasServer) this->sendCloseDefinition();
-   if (hasClient) this->sendCloseDefinition();
+    if (hasClient) this->sendCloseDefinition();
 
     // Nettoyage de l'arborescence
-//    if (hasClient && !hasServer) CleanTree(); // Only on client side??
     if (hasClient) CleanTree(); // Only on client side??
 
Index: /XIOS/dev/dev_olga/src/node/grid.cpp
===================================================================
--- /XIOS/dev/dev_olga/src/node/grid.cpp	(revision 1076)
+++ /XIOS/dev/dev_olga/src/node/grid.cpp	(revision 1077)
@@ -1949,6 +1949,6 @@
     {
       CDomain* pDom = CDomain::get(*it);
-      // if (context->hasClient && !context->hasServer)
-     if (context->hasClient)
+      if (context->hasClient && !context->hasServer)
+      //if (context->hasClient)
       {
         pDom->solveRefInheritance(apply);
@@ -1962,6 +1962,6 @@
     {
       CAxis* pAxis = CAxis::get(*it);
-      // if (context->hasClient && !context->hasServer)
-     if (context->hasClient)
+      if (context->hasClient && !context->hasServer)
+//     if (context->hasClient)
       {
         pAxis->solveRefInheritance(apply);
@@ -1975,6 +1975,6 @@
     {
       CScalar* pScalar = CScalar::get(*it);
-      // if (context->hasClient && !context->hasServer)
-     if (context->hasClient)
+      if (context->hasClient && !context->hasServer)
+//     if (context->hasClient)
       {
         pScalar->solveRefInheritance(apply);
Index: /XIOS/dev/dev_olga/src/server.cpp
===================================================================
--- /XIOS/dev/dev_olga/src/server.cpp	(revision 1076)
+++ /XIOS/dev/dev_olga/src/server.cpp	(revision 1077)
@@ -30,5 +30,5 @@
     int CServer::nbContexts_ = 0;
     bool CServer::isRoot = false ;
-    int CServer::rank = INVALID_RANK;
+    int CServer::rank_ = INVALID_RANK;
     StdOFStream CServer::m_infoStream;
     StdOFStream CServer::m_errorStream;
@@ -81,5 +81,5 @@
 
         MPI_Comm_size(CXios::globalComm, &size) ;
-        MPI_Comm_rank(CXios::globalComm, &rank);
+        MPI_Comm_rank(CXios::globalComm, &rank_);
 
         hashAll=new unsigned long[size] ;
@@ -104,5 +104,5 @@
         if (CXios::usingServer2)
         {
-          int serverRank = rank - leaders[hashServer]; // server proc rank starting 0
+          int serverRank = rank_ - leaders[hashServer]; // server proc rank starting 0
           serverSize_ = size - leaders[hashServer];
           nbPools = serverSize_ * CXios::ratioServer2 / 100;
@@ -115,9 +115,9 @@
             serverLevel = 2;
             poolId = serverRank - serverSize_ + nbPools;
-            myColor = rank;
+            myColor = rank_;
           }
         }
 
-        MPI_Comm_split(CXios::globalComm, myColor, rank, &intraComm) ;
+        MPI_Comm_split(CXios::globalComm, myColor, rank_, &intraComm) ;
 
         if (serverLevel == 0)
@@ -132,5 +132,5 @@
               MPI_Comm_size(intraComm,&intraCommSize) ;
               MPI_Comm_rank(intraComm,&intraCommRank) ;
-              info(50)<<"intercommCreate::server "<<rank<<" intraCommSize : "<<intraCommSize
+              info(50)<<"intercommCreate::server "<<rank_<<" intraCommSize : "<<intraCommSize
                        <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< clientLeader<<endl ;
 
@@ -152,5 +152,5 @@
               MPI_Comm_size(intraComm, &intraCommSize) ;
               MPI_Comm_rank(intraComm, &intraCommRank) ;
-              info(50)<<"intercommCreate::server "<<rank<<" intraCommSize : "<<intraCommSize
+              info(50)<<"intercommCreate::server "<<rank_<<" intraCommSize : "<<intraCommSize
                        <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< clientLeader<<endl ;
               MPI_Intercomm_create(intraComm, 0, CXios::globalComm, clientLeader, 0, &newComm) ;
@@ -167,5 +167,5 @@
             MPI_Comm_size(intraComm, &intraCommSize) ;
             MPI_Comm_rank(intraComm, &intraCommRank) ;
-            info(50)<<"intercommCreate::client "<<rank<<" intraCommSize : "<<intraCommSize
+            info(50)<<"intercommCreate::client "<<rank_<<" intraCommSize : "<<intraCommSize
                 <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< srvSndLeader<<endl ;
             MPI_Intercomm_create(intraComm, 0, CXios::globalComm, srvSndLeader, 0, &newComm) ;
@@ -180,5 +180,5 @@
           MPI_Comm_size(intraComm, &intraCommSize) ;
           MPI_Comm_rank(intraComm, &intraCommRank) ;
-          info(50)<<"intercommCreate::server "<<rank<<" intraCommSize : "<<intraCommSize
+          info(50)<<"intercommCreate::server "<<rank_<<" intraCommSize : "<<intraCommSize
                    <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< clientLeader<<endl ;
 
@@ -202,5 +202,5 @@
         MPI_Comm_dup(localComm, &intraComm);
 
-        MPI_Comm_rank(intraComm,&rank) ;
+        MPI_Comm_rank(intraComm,&rank_) ;
         MPI_Comm_size(intraComm,&size) ;
         string codesId=CXios::getin<string>("oasis_codes_id") ;
@@ -217,5 +217,5 @@
         {
           oasis_get_intercomm(newComm,*it) ;
-          if (rank==0) MPI_Send(&globalRank,1,MPI_INT,0,0,newComm) ;
+          if (rank_==0) MPI_Send(&globalRank,1,MPI_INT,0,0,newComm) ;
           MPI_Comm_remote_size(newComm,&size);
 //          interComm.push_back(newComm) ;
@@ -225,7 +225,6 @@
       }
 
-      int rankServer;
-      MPI_Comm_rank(intraComm, &rankServer) ;
-      if (rankServer==0) isRoot=true;
+      MPI_Comm_rank(intraComm, &rank_) ;
+      if (rank_==0) isRoot=true;
       else isRoot=false;
       
@@ -249,6 +248,6 @@
 //        MPI_Comm_free(&(*it));
 
-        for (std::list<MPI_Comm>::iterator it = interCommLeft.begin(); it != interCommLeft.end(); it++)
-          MPI_Comm_free(&(*it));
+//        for (std::list<MPI_Comm>::iterator it = interCommLeft.begin(); it != interCommLeft.end(); it++)
+//          MPI_Comm_free(&(*it));
 
         for (std::list<MPI_Comm>::iterator it = interCommRight.begin(); it != interCommRight.end(); it++)
@@ -524,5 +523,5 @@
          {
            StdString str = contextId +"_server_" + boost::lexical_cast<string>(i);
-           msg<<str<<size<<rank ;
+           msg<<str<<size<<rank_ ;
            messageSize = msg.size() ;
            buff = new char[messageSize] ;
@@ -555,12 +554,10 @@
          if (finished)
          {
-//           it->second->freeComms();  // deallocate internally allcoated context communicators
+           it->second->freeComms();  // deallocate internally allocated context communicators
            contextList.erase(it) ;
            break ;
          }
          else
-         {
            finished=it->second->checkBuffersAndListen();
-         }
        }
      }
@@ -569,5 +566,5 @@
      int CServer::getRank()
      {
-       return rank;
+       return rank_;
      }
 
@@ -598,5 +595,5 @@
       {
         if (serverLevel == 1)
-          id = rank-serverLeader_;
+          id = rank_;
         else
           id = poolId;
Index: /XIOS/dev/dev_olga/src/server.hpp
===================================================================
--- /XIOS/dev/dev_olga/src/server.hpp	(revision 1076)
+++ /XIOS/dev/dev_olga/src/server.hpp	(revision 1077)
@@ -64,5 +64,5 @@
 
       private:
-        static int rank;
+        static int rank_;
         static int serverLeader_;  //!< Leader of the classical or primary server (needed in case of secondary servers)
         static int serverSize_;    //!< Number of procs dedicated to servers (primary and seconday (if any) combined)
