Index: XIOS/dev/dev_olga/src/client.cpp
===================================================================
--- XIOS/dev/dev_olga/src/client.cpp	(revision 1589)
+++ XIOS/dev/dev_olga/src/client.cpp	(revision 1590)
@@ -11,4 +11,5 @@
 #include "timer.hpp"
 #include "buffer_client.hpp"
+#include "string_tools.hpp"
 
 namespace xios
@@ -23,7 +24,6 @@
     StdOFStream CClient::m_infoStream;
     StdOFStream CClient::m_errorStream;
-
     MPI_Comm& CClient::getInterComm(void)   { return (interComm); }
-
+     
 ///---------------------------------------------------------------
 /*!
@@ -230,4 +230,34 @@
       }
     }
+
+/*!
+ * \fn void CClient::callOasisEnddef(void)
+ * \brief Send the order to the servers to call "oasis_enddef". It must be done by each compound of models before calling oasis_enddef on client side
+ * Function is only called by client.
+ */
+    void CClient::callOasisEnddef(void)
+    {
+      bool oasisEnddef=CXios::getin<bool>("call_oasis_enddef",true) ;
+      if (!oasisEnddef) ERROR("void CClient::callOasisEnddef(void)", <<"Function xios_oasis_enddef called but variable <call_oasis_enddef> is set to false."<<endl
+                                                                     <<"Variable <call_oasis_enddef> must be set to true"<<endl) ;
+      if (CXios::isServer)
+      // Attached mode
+      {
+        // nothing to do   
+      }
+      else
+      {
+        int rank ;
+        int msg=0 ;
+
+        MPI_Comm_rank(intraComm,&rank) ;
+        if (rank==0) 
+        {
+          MPI_Send(&msg,1,MPI_INT,0,5,interComm) ; // tags oasis_endded = 5
+        }
+
+      }
+    }
+
 
     void CClient::finalize(void)
Index: XIOS/dev/dev_olga/src/client.hpp
===================================================================
--- XIOS/dev/dev_olga/src/client.hpp	(revision 1589)
+++ XIOS/dev/dev_olga/src/client.hpp	(revision 1590)
@@ -13,4 +13,5 @@
         static void finalize(void);
         static void registerContext(const string& id, MPI_Comm contextComm);
+        static void callOasisEnddef(void) ;
 
         static MPI_Comm intraComm;
Index: XIOS/dev/dev_olga/src/interface/c/icdata.cpp
===================================================================
--- XIOS/dev/dev_olga/src/interface/c/icdata.cpp	(revision 1589)
+++ XIOS/dev/dev_olga/src/interface/c/icdata.cpp	(revision 1590)
@@ -81,4 +81,11 @@
      CClient::registerContext(str, comm);
      CTimer::get("XIOS init context").suspend();
+     CTimer::get("XIOS").suspend();
+   }
+
+   void cxios_oasis_enddef()
+   {
+     CTimer::get("XIOS").resume();
+     CClient::callOasisEnddef();
      CTimer::get("XIOS").suspend();
    }
Index: XIOS/dev/dev_olga/src/interface/fortran/idata.F90
===================================================================
--- XIOS/dev/dev_olga/src/interface/fortran/idata.F90	(revision 1589)
+++ XIOS/dev/dev_olga/src/interface/fortran/idata.F90	(revision 1590)
@@ -42,5 +42,8 @@
       END SUBROUTINE cxios_context_finalize
 
-
+      SUBROUTINE  cxios_oasis_enddef() BIND(C)
+         USE ISO_C_BINDING
+      END SUBROUTINE cxios_oasis_enddef
+      
       SUBROUTINE  cxios_finalize() BIND(C)
       END SUBROUTINE cxios_finalize
@@ -507,4 +510,10 @@
     END SUBROUTINE  xios(finalize)
 
+   SUBROUTINE  xios(oasis_enddef)
+   IMPLICIT NONE
+
+      CALL cxios_oasis_enddef
+
+    END SUBROUTINE  xios(oasis_enddef)
 
    SUBROUTINE xios(close_context_definition)()
Index: XIOS/dev/dev_olga/src/interface/fortran/ixios.F90
===================================================================
--- XIOS/dev/dev_olga/src/interface/fortran/ixios.F90	(revision 1589)
+++ XIOS/dev/dev_olga/src/interface/fortran/ixios.F90	(revision 1590)
@@ -13,5 +13,5 @@
 
 USE idata, ONLY : xios(initialize), xios(init_server), xios(finalize), xios(context_initialize), xios(context_is_initialized), &
-                  xios(close_context_definition), xios(context_finalize), xios(solve_inheritance)
+                  xios(close_context_definition), xios(context_finalize), xios(solve_inheritance), xios(oasis_enddef)
 
 USE idomain, ONLY : txios(domain), txios(domaingroup), xios(is_valid_domain), xios(is_valid_domaingroup)
Index: XIOS/dev/dev_olga/src/io/nc4_data_output.cpp
===================================================================
--- XIOS/dev/dev_olga/src/io/nc4_data_output.cpp	(revision 1589)
+++ XIOS/dev/dev_olga/src/io/nc4_data_output.cpp	(revision 1590)
@@ -56,5 +56,5 @@
       {
         StdString lonName,latName ;
-
+         
         domain->computeWrittenIndex();
         domain->computeWrittenCompressedIndex(comm_file);
Index: XIOS/dev/dev_olga/src/server.cpp
===================================================================
--- XIOS/dev/dev_olga/src/server.cpp	(revision 1589)
+++ XIOS/dev/dev_olga/src/server.cpp	(revision 1590)
@@ -14,4 +14,5 @@
 #include "timer.hpp"
 #include "event_scheduler.hpp"
+#include "string_tools.hpp"
 
 namespace xios
@@ -343,6 +344,6 @@
 
         string codesId=CXios::getin<string>("oasis_codes_id") ;
-        vector<string> splitted ;
-        boost::split( splitted, codesId, boost::is_any_of(","), boost::token_compress_on ) ;
+        vector<string> oasisCodeId=splitRegex(codesId,"\\s*,\\s*") ;
+ 
         vector<string>::iterator it ;
 
@@ -352,5 +353,5 @@
 
 //      (2) Create interComms with models
-        for(it=splitted.begin();it!=splitted.end();it++)
+        for(it=oasisCodeId.begin();it!=oasisCodeId.end();it++)
         {
           oasis_get_intercomm(newComm,*it) ;
@@ -386,5 +387,7 @@
         }
         if (CXios::usingServer2) delete [] srvGlobalRanks ;
-        oasis_enddef() ;
+
+        bool oasisEnddef=CXios::getin<bool>("call_oasis_enddef",true) ;
+        if (!oasisEnddef) oasis_enddef() ;
       }
 
@@ -442,4 +445,6 @@
            listenContext();
            listenRootContext();
+           listenOasisEnddef() ;
+           listenRootOasisEnddef() ;
            if (!finished) listenFinalize() ;
          }
@@ -447,4 +452,5 @@
          {
            listenRootContext();
+           listenRootOasisEnddef() ;
            if (!finished) listenRootFinalize() ;
          }
@@ -516,4 +522,104 @@
         }
       }
+
+
+   /*!
+    * Root process is listening for an order sent by client to call "oasis_enddef".
+    * The root client of a compound send the order (tag 5). It is probed and received.
+    * When the order has been received from each coumpound, the server root process ping the order to the root processes of the secondary levels of servers (if any).
+    * After, it also inform (asynchronous call) other processes of the communicator that the oasis_enddef call must be done
+    */
+    
+     void CServer::listenOasisEnddef(void)
+     {
+        int flag ;
+        MPI_Status status ;
+        list<MPI_Comm>::iterator it;
+        int msg ;
+        static int nbCompound=0 ;
+        int size ;
+        static bool sent=false ;
+        static MPI_Request* allRequests ;
+        static MPI_Status* allStatus ;
+
+
+        if (sent)
+        {
+          MPI_Comm_size(intraComm,&size) ;
+          MPI_Testall(size,allRequests, &flag, allStatus) ;
+          if (flag==true)
+          {
+            delete [] allRequests ;
+            delete [] allStatus ;
+            sent=false ;
+          }
+        }
+        
+
+        for(it=interCommLeft.begin();it!=interCommLeft.end();it++)
+        {
+           MPI_Status status ;
+           traceOff() ;
+           MPI_Iprobe(0,5,*it,&flag,&status) ;  // tags oasis_endded = 5
+           traceOn() ;
+           if (flag==true)
+           {
+              MPI_Recv(&msg,1,MPI_INT,0,5,*it,&status) ; // tags oasis_endded = 5
+              nbCompound++ ;
+              if (nbCompound==interCommLeft.size())
+              {
+                for (std::list<MPI_Comm>::iterator it = interCommRight.begin(); it != interCommRight.end(); it++)
+                {
+                   MPI_Send(&msg,1,MPI_INT,0,5,*it) ; // tags oasis_endded = 5
+                }
+                MPI_Comm_size(intraComm,&size) ;
+                allRequests= new MPI_Request[size] ;
+                allStatus= new MPI_Status[size] ;
+                for(int i=0;i<size;i++) MPI_Isend(&msg,1,MPI_INT,i,5,intraComm,&allRequests[i]) ; // tags oasis_endded = 5
+                sent=true ;
+              }
+           }
+        }
+     }
+     
+   /*!
+    * Processes probes message from root process if oasis_enddef call must be done.
+    * When the order is received it is scheduled to be treated in a synchronized way by all server processes of the communicator
+    */
+     void CServer::listenRootOasisEnddef(void)
+     {
+       int flag ;
+       MPI_Status status ;
+       const int root=0 ;
+       int msg ;
+       static bool eventSent=false ;
+
+       if (eventSent)
+       {
+         boost::hash<string> hashString;
+         size_t hashId = hashString("oasis_enddef");
+         if (eventScheduler->queryEvent(0,hashId))
+         {
+           oasis_enddef() ;
+           eventSent=false ;
+         }
+       }
+         
+       traceOff() ;
+       MPI_Iprobe(root,5,intraComm, &flag, &status) ;
+       traceOn() ;
+       if (flag==true)
+       {
+         MPI_Recv(&msg,1,MPI_INT,root,5,intraComm,&status) ; // tags oasis_endded = 5
+         boost::hash<string> hashString;
+         size_t hashId = hashString("oasis_enddef");
+         eventScheduler->registerEvent(0,hashId);
+         eventSent=true ;
+       }
+     }
+
+
+
+     
 
      void CServer::listenContext(void)
Index: XIOS/dev/dev_olga/src/server.hpp
===================================================================
--- XIOS/dev/dev_olga/src/server.hpp	(revision 1589)
+++ XIOS/dev/dev_olga/src/server.hpp	(revision 1590)
@@ -22,4 +22,6 @@
         static void listenRootContext(void);
         static void listenRootFinalize(void);
+        static void listenRootOasisEnddef(void);
+        static void listenOasisEnddef(void);
         static void registerContext(void* buff,int count, int leaderRank=0);
 
@@ -72,5 +74,4 @@
         static StdOFStream m_infoStream;
         static StdOFStream m_errorStream;
-
         static void openStream(const StdString& fileName, const StdString& ext, std::filebuf* fb);
     };
Index: XIOS/dev/dev_olga/src/string_tools.hpp
===================================================================
--- XIOS/dev/dev_olga/src/string_tools.hpp	(revision 1590)
+++ XIOS/dev/dev_olga/src/string_tools.hpp	(revision 1590)
@@ -0,0 +1,23 @@
+#ifndef __STRING_TOOLS_HPP__
+#define __STRING_TOOLS_HPP__
+
+#include <string>
+#include <regex>
+#include <vector>
+
+namespace xios
+{
+  std::vector<std::string> splitRegex(const std::string& input, const std::string& regex) ;
+
+  inline std::vector<std::string> splitRegex(const std::string& input, const std::string& regex)
+  {
+      // passing -1 as the submatch index parameter performs splitting
+      std::regex re(regex);
+      std::regex_token_iterator<std::string::const_iterator>
+          first{input.begin(), input.end(), re, -1},
+          last;
+      return {first, last}; 
+  }
+
+}
+#endif
