Index: XIOS/dev/branch_openmp/src/client.cpp
===================================================================
--- XIOS/dev/branch_openmp/src/client.cpp	(revision 1207)
+++ XIOS/dev/branch_openmp/src/client.cpp	(revision 1328)
@@ -11,14 +11,12 @@
 #include "timer.hpp"
 #include "buffer_client.hpp"
-#include "log.hpp"
-
+using namespace ep_lib;
 
 namespace xios
 {
-    extern int test_omp_rank;
-    #pragma omp threadprivate(test_omp_rank)
 
     MPI_Comm CClient::intraComm ;
     MPI_Comm CClient::interComm ;
+    //std::list<MPI_Comm> CClient::contextInterComms;
     std::list<MPI_Comm> *CClient::contextInterComms_ptr = 0;
     int CClient::serverLeader ;
@@ -28,7 +26,5 @@
     StdOFStream CClient::m_errorStream;
 
-    StdOFStream CClient::array_infoStream[16];
-
-    void CClient::initialize(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm)
+    void CClient::initialize(const string& codeId,MPI_Comm& localComm,MPI_Comm& returnComm)
     {
       int initialized ;
@@ -41,13 +37,9 @@
       {
 // localComm doesn't given
-
         if (localComm == MPI_COMM_NULL)
         {
           if (!is_MPI_Initialized)
           {
-            //MPI_Init(NULL, NULL);
-            int return_level;
-            MPI_Init_thread(NULL, NULL, 3, &return_level);
-            assert(return_level == 3);
+            MPI_Init(NULL, NULL);
           }
           CTimer::get("XIOS").resume() ;
@@ -61,8 +53,8 @@
           int myColor ;
           int i,c ;
-
-          MPI_Comm_size(CXios::globalComm,&size);
+          MPI_Comm newComm ;
+
+          MPI_Comm_size(CXios::globalComm,&size) ;
           MPI_Comm_rank(CXios::globalComm,&rank);
-       
 
           hashAll=new unsigned long[size] ;
@@ -106,16 +98,7 @@
             MPI_Comm_size(intraComm,&intraCommSize) ;
             MPI_Comm_rank(intraComm,&intraCommRank) ;
-            
-            #pragma omp critical(_output)
-            {
-              info(10)<<"intercommCreate::client "<<test_omp_rank<< " "<< &test_omp_rank <<" intraCommSize : "<<intraCommSize
-                 <<" intraCommRank :"<<intraCommRank<<"  serverLeader "<< serverLeader
-                 <<" globalComm : "<< &(CXios::globalComm) << endl ;  
-            }
-
-            
-            //test_sendrecv(CXios::globalComm);
+            info(50)<<"intercommCreate::client "<<rank<<" intraCommSize : "<<intraCommSize
+                 <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< serverLeader<<endl ;
             MPI_Intercomm_create(intraComm,0,CXios::globalComm,serverLeader,0,&interComm) ;
-
           }
           else
@@ -140,5 +123,5 @@
       }
       // using OASIS
-      else
+/*      else
       {
         // localComm doesn't given
@@ -165,7 +148,6 @@
         else MPI_Comm_dup(intraComm,&interComm) ;
       }
-
+*/
       MPI_Comm_dup(intraComm,&returnComm) ;
-
     }
 
@@ -174,9 +156,5 @@
     {
       CContext::setCurrent(id) ;
-      CContext* context = CContext::create(id);
-
-      int tmp_rank;
-      MPI_Comm_rank(contextComm,&tmp_rank) ;
-      
+      CContext* context=CContext::create(id);
       StdString idServer(id);
       idServer += "_server";
@@ -185,6 +163,6 @@
       {
         int size,rank,globalRank ;
-        //size_t message_size ;
-        //int leaderRank ;
+        size_t message_size ;
+        int leaderRank ;
         MPI_Comm contextInterComm ;
 
@@ -197,5 +175,5 @@
         CMessage msg ;
         msg<<idServer<<size<<globalRank ;
-
+//        msg<<id<<size<<globalRank ;
 
         int messageSize=msg.size() ;
@@ -208,8 +186,5 @@
 
         MPI_Intercomm_create(contextComm,0,CXios::globalComm,serverLeader,10+globalRank,&contextInterComm) ;
-        
-        #pragma omp critical(_output)
-        info(10)<<" RANK "<< tmp_rank<<" Register new Context : "<<id<<endl ;
-
+        info(10)<<"Register new Context : "<<id<<endl ;
 
         MPI_Comm inter ;
@@ -217,11 +192,9 @@
         MPI_Barrier(inter) ;
 
-        
         context->initClient(contextComm,contextInterComm) ;
 
-        
+        //contextInterComms.push_back(contextInterComm);
         if(contextInterComms_ptr == NULL) contextInterComms_ptr = new std::list<MPI_Comm>;
         contextInterComms_ptr->push_back(contextInterComm);
-        
         MPI_Comm_free(&inter);
       }
@@ -240,8 +213,8 @@
         // Finally, we should return current context to context client
         CContext::setCurrent(id);
-        
+
+        //contextInterComms.push_back(contextInterComm);
         if(contextInterComms_ptr == NULL) contextInterComms_ptr = new std::list<MPI_Comm>;
         contextInterComms_ptr->push_back(contextInterComm);
-
       }
     }
@@ -253,5 +226,5 @@
 
       MPI_Comm_rank(intraComm,&rank) ;
-
+ 
       if (!CXios::isServer)
       {
@@ -263,7 +236,7 @@
       }
 
-      for (std::list<MPI_Comm>::iterator it = contextInterComms_ptr->begin(); it != contextInterComms_ptr->end(); ++it)
+      //for (std::list<MPI_Comm>::iterator it = contextInterComms.begin(); it != contextInterComms.end(); it++)
+      for (std::list<MPI_Comm>::iterator it = contextInterComms_ptr->begin(); it != contextInterComms_ptr->end(); it++)
         MPI_Comm_free(&(*it));
-      
       MPI_Comm_free(&interComm);
       MPI_Comm_free(&intraComm);
@@ -274,13 +247,10 @@
       if (!is_MPI_Initialized)
       {
-        if (CXios::usingOasis) oasis_finalize();
-        else MPI_Finalize();
+        //if (CXios::usingOasis) oasis_finalize();
+        //else
+        MPI_Finalize() ;
       }
       
-      #pragma omp critical (_output)
-      info(20) << "Client "<<rank<<" : Client side context is finalized "<< endl ;
-
-   /*#pragma omp critical (_output)
-   {
+      info(20) << "Client side context is finalized"<<endl ;
       report(0) <<" Performance report : Whole time from XIOS init and finalize: "<< CTimer::get("XIOS init/finalize").getCumulatedTime()<<" s"<<endl ;
       report(0) <<" Performance report : total time spent for XIOS : "<< CTimer::get("XIOS").getCumulatedTime()<<" s"<<endl ;
@@ -292,6 +262,4 @@
       report(0)<< " Memory report : increasing it by a factor will increase performance, depending of the volume of data wrote in file at each time step of the file"<<endl ;
       report(100)<<CTimer::getAllCumulatedTime()<<endl ;
-   }*/
-   
    }
 
@@ -322,9 +290,8 @@
 
       fileNameClient << fileName << "_" << std::setfill('0') << std::setw(numDigit) << getRank() << ext;
-      
       fb->open(fileNameClient.str().c_str(), std::ios::out);
       if (!fb->is_open())
         ERROR("void CClient::openStream(const StdString& fileName, const StdString& ext, std::filebuf* fb)",
-            << std::endl << "Can not open <" << fileNameClient << "> file to write the client log(s).");
+              << std::endl << "Can not open <" << fileNameClient << "> file to write the client log(s).");
     }
 
@@ -337,13 +304,9 @@
     void CClient::openInfoStream(const StdString& fileName)
     {
-      //std::filebuf* fb = m_infoStream.rdbuf();
-
-      info_FB[omp_get_thread_num()] = array_infoStream[omp_get_thread_num()].rdbuf();
-          
-      openStream(fileName, ".out", info_FB[omp_get_thread_num()]);
-
-      info.write2File(info_FB[omp_get_thread_num()]);
-      report.write2File(info_FB[omp_get_thread_num()]);
-      
+      std::filebuf* fb = m_infoStream.rdbuf();
+      openStream(fileName, ".out", fb);
+
+      info.write2File(fb);
+      report.write2File(fb);
     }
 
