Index: /XIOS/dev/branch_yushan_merged/extern/remap/src/clipper.cpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/extern/remap/src/clipper.cpp	(revision 1145)
+++ /XIOS/dev/branch_yushan_merged/extern/remap/src/clipper.cpp	(revision 1146)
@@ -1047,5 +1047,5 @@
 
   //create a new edge array ...
-  TEdge *edges = new TEdge [highI +1];
+  TEdge *edges = new TEdge[highI+1];
 
   bool IsFlat = true;
@@ -4274,8 +4274,8 @@
 {
   //The equation of a line in general form (Ax + By + C = 0)
-  //given 2 points (x¹,y¹) & (x²,y²) is ...
-  //(y¹ - y²)x + (x² - x¹)y + (y² - y¹)x¹ - (x² - x¹)y¹ = 0
-  //A = (y¹ - y²); B = (x² - x¹); C = (y² - y¹)x¹ - (x² - x¹)y¹
-  //perpendicular distance of point (x³,y³) = (Ax³ + By³ + C)/Sqrt(A² + B²)
+  //given 2 points (x,y) & (x,y) is ...
+  //(y - y)x + (x - x)y + (y - y)x - (x - x)y = 0
+  //A = (y - y); B = (x - x); C = (y - y)x - (x - x)y
+  //perpendicular distance of point (x,y) = (Ax + By + C)/Sqrt(A + B)
   //see http://en.wikipedia.org/wiki/Perpendicular_distance
   double A = double(ln1.Y - ln2.Y);
Index: /XIOS/dev/branch_yushan_merged/extern/remap/src/mapper.cpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/extern/remap/src/mapper.cpp	(revision 1145)
+++ /XIOS/dev/branch_yushan_merged/extern/remap/src/mapper.cpp	(revision 1146)
@@ -548,6 +548,6 @@
     }
 
+    MPI_Waitall(nbSendRequest, sendRequest, status);
     MPI_Waitall(nbRecvRequest, recvRequest, status);
-    MPI_Waitall(nbSendRequest, sendRequest, status);
 
     for (int rank = 0; rank < mpiSize; rank++)
@@ -620,7 +620,7 @@
     }
 
+    MPI_Waitall(nbSendRequest, sendRequest, status);
     MPI_Waitall(nbRecvRequest, recvRequest, status);
-    MPI_Waitall(nbSendRequest, sendRequest, status);
-
+ 
     int nbNeighbourNodes = 0;
     for (int rank = 0; rank < mpiSize; rank++)
@@ -803,7 +803,8 @@
         }
     }
-
+ 
+    MPI_Waitall(nbSendRequest, sendRequest, status);
     MPI_Waitall(nbRecvRequest, recvRequest, status);
-    MPI_Waitall(nbSendRequest, sendRequest, status);
+    
     char **sendBuffer2 = new char*[mpiSize];
     char **recvBuffer2 = new char*[mpiSize];
@@ -886,7 +887,8 @@
         }
     }
-
+    
+    MPI_Waitall(nbSendRequest, sendRequest, status);
     MPI_Waitall(nbRecvRequest, recvRequest, status);
-    MPI_Waitall(nbSendRequest, sendRequest, status);
+   
 
     delete [] sendRequest;
Index: /XIOS/dev/branch_yushan_merged/extern/remap/src/timerRemap.cpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/extern/remap/src/timerRemap.cpp	(revision 1145)
+++ /XIOS/dev/branch_yushan_merged/extern/remap/src/timerRemap.cpp	(revision 1146)
@@ -9,5 +9,5 @@
 using namespace std;
 
-map<string,CTimer*> CTimer::allTimer;
+map<string,CTimer*> *CTimer::allTimer = 0;
 
 CTimer::CTimer(const string& name_) : name(name_)
@@ -55,7 +55,8 @@
 CTimer& CTimer::get(const string name)
 {
+        if(allTimer == 0) allTimer = new map<string,CTimer*>;
 	map<string,CTimer*>::iterator it;
-	it=allTimer.find(name);
-	if (it==allTimer.end()) it=allTimer.insert(pair<string,CTimer*>(name,new CTimer(name))).first;
+	it=(*allTimer).find(name);
+	if (it==(*allTimer).end()) it=(*allTimer).insert(pair<string,CTimer*>(name,new CTimer(name))).first;
 	return *(it->second);
 }
Index: /XIOS/dev/branch_yushan_merged/extern/remap/src/timerRemap.hpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/extern/remap/src/timerRemap.hpp	(revision 1145)
+++ /XIOS/dev/branch_yushan_merged/extern/remap/src/timerRemap.hpp	(revision 1146)
@@ -26,5 +26,8 @@
     double getCumulatedTime(void);
     void print(void);
-    static map<string,CTimer*> allTimer;
+    //static map<string,CTimer*> allTimer;
+    static map<string,CTimer*> *allTimer;
+    #pragma omp threadprivate(allTimer)
+    
     static double getTime(void);
     static CTimer& get(string name);
Index: /XIOS/dev/branch_yushan_merged/extern/src_ep_dev/ep_alltoall.cpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/extern/src_ep_dev/ep_alltoall.cpp	(revision 1145)
+++ /XIOS/dev/branch_yushan_merged/extern/src_ep_dev/ep_alltoall.cpp	(revision 1146)
@@ -10,10 +10,14 @@
   int MPI_Alltoall(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm)
   {
+    assert(static_cast< ::MPI_Datatype>(sendtype) == static_cast< ::MPI_Datatype>(recvtype));
     ::MPI_Aint typesize, llb;
     ::MPI_Type_get_extent(static_cast< ::MPI_Datatype>(sendtype), &llb, &typesize);
+    
+    int ep_size;
+    MPI_Comm_size(comm, &ep_size);
 
-    for(int i=0; i<comm.ep_comm_ptr->size_rank_info[0].second; i++)
+    for(int i=0; i<ep_size; i++)
     {
-      MPI_Gather((char*)sendbuf+i*sendcount*typesize, sendcount, sendtype, recvbuf, recvcount, recvtype, i, comm);
+      MPI_Gather(sendbuf+i*sendcount*typesize, sendcount, sendtype, recvbuf, recvcount, recvtype, i, comm);
     }
 
Index: /XIOS/dev/branch_yushan_merged/extern/src_ep_dev/ep_wait.cpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/extern/src_ep_dev/ep_wait.cpp	(revision 1145)
+++ /XIOS/dev/branch_yushan_merged/extern/src_ep_dev/ep_wait.cpp	(revision 1146)
@@ -86,5 +86,5 @@
 
         int finished = 0;
-        bool finished_index[count];
+        int finished_index[count];
 
         for(int i=0; i<count; i++)
@@ -97,4 +97,5 @@
             for(int i=0; i<count; i++)
             {
+                //MPI_Test(&array_of_requests[i], &finished_index[i], &array_of_statuses[i]);
                 if(finished_index[i] == false) // this request has not been tested.
                 {
@@ -102,10 +103,4 @@
                     {      
                         MPI_Wait(&array_of_requests[i], &array_of_statuses[i]);
-                        if(array_of_requests[i].type == 3)
-                        {
-                            //int check_count;
-                            //MPI_Get_count(&array_of_statuses[i], array_of_requests[i].ep_datatype, &check_count);
-                            //check_sum_recv(array_of_requests[i].buf, count, array_of_requests[i].ep_datatype, array_of_requests[i].ep_src, array_of_requests[i].ep_tag, array_of_requests[i].comm, 2);
-                        }
                         finished++;
                         finished_index[i] = true;
Index: /XIOS/dev/branch_yushan_merged/src/io/netCdfInterface.cpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/src/io/netCdfInterface.cpp	(revision 1145)
+++ /XIOS/dev/branch_yushan_merged/src/io/netCdfInterface.cpp	(revision 1146)
@@ -103,5 +103,7 @@
 int CNetCdfInterface::openPar(const StdString& fileName, int oMode, MPI_Comm comm, MPI_Info info, int& ncId)
 {
-  int status = xios::nc_open_par(fileName.c_str(), oMode, comm, info, &ncId);
+  int status;
+  #pragma omp critical (_netcdf)
+  status = xios::nc_open_par(fileName.c_str(), oMode, comm, info, &ncId);
   if (NC_NOERR != status)
   {
@@ -347,5 +349,7 @@
 int CNetCdfInterface::inqDimLen(int ncid, int dimId, StdSize& dimLen)
 {
-  int status = nc_inq_dimlen(ncid, dimId, &dimLen);
+  int status;
+  #pragma omp critical (_netcdf)
+  status = nc_inq_dimlen(ncid, dimId, &dimLen);
   if (NC_NOERR != status)
   {
Index: /XIOS/dev/branch_yushan_merged/src/io/netCdfInterface_impl.hpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/src/io/netCdfInterface_impl.hpp	(revision 1145)
+++ /XIOS/dev/branch_yushan_merged/src/io/netCdfInterface_impl.hpp	(revision 1146)
@@ -86,5 +86,7 @@
   int CNetCdfInterface::getVaraType(int ncid, int varId, const StdSize* start, const StdSize* count, T* data)
   {
-    int status = ncGetVaraType(ncid, varId, start, count, data);
+    int status;
+    #pragma omp critical (_netcdf)
+    status = ncGetVaraType(ncid, varId, start, count, data);
     if (NC_NOERR != status)
     {
Index: /XIOS/dev/branch_yushan_merged/src/node/context.cpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/src/node/context.cpp	(revision 1145)
+++ /XIOS/dev/branch_yushan_merged/src/node/context.cpp	(revision 1146)
@@ -21,5 +21,5 @@
   shared_ptr<CContextGroup> * CContext::root_ptr = 0;
 
-   /// ////////////////////// DÃ©finitions ////////////////////// ///
+   /// ////////////////////// Dfinitions ////////////////////// ///
 
    CContext::CContext(void)
@@ -184,5 +184,5 @@
       if (!this->hasChild())
       {
-         //oss << "<!-- No definition -->" << std::endl; // fait planter l'incrÃ©mentation
+         //oss << "<!-- No definition -->" << std::endl; // fait planter l'incrmentation
       }
       else
@@ -554,9 +554,9 @@
    void CContext::solveAllInheritance(bool apply)
    {
-     // RÃ©solution des hÃ©ritages descendants (cÃ d des hÃ©ritages de groupes)
+     // Rsolution des hritages descendants (cd des hritages de groupes)
      // pour chacun des contextes.
       solveDescInheritance(apply);
 
-     // RÃ©solution des hÃ©ritages par rÃ©fÃ©rence au niveau des fichiers.
+     // Rsolution des hritages par rfrence au niveau des fichiers.
       const vector<CFile*> allFiles=CFile::getAll();
       const vector<CGrid*> allGrids= CGrid::getAll();
@@ -582,7 +582,7 @@
 
       for (unsigned int i = 0; i < allFiles.size(); i++)
-         if (!allFiles[i]->enabled.isEmpty()) // Si l'attribut 'enabled' est dÃ©fini.
+         if (!allFiles[i]->enabled.isEmpty()) // Si l'attribut 'enabled' est dfini.
          {
-            if (allFiles[i]->enabled.getValue()) // Si l'attribut 'enabled' est fixÃ© Ã  vrai.
+            if (allFiles[i]->enabled.getValue()) // Si l'attribut 'enabled' est fix  vrai.
             {
               if ((initDate + allFiles[i]->output_freq.getValue()) < (initDate + this->getCalendar()->getTimeStep()))
@@ -609,5 +609,5 @@
 
       if (enabledFiles.size() == 0)
-         DEBUG(<<"Aucun fichier ne va Ãªtre sorti dans le contexte nommÃ© \""
+         DEBUG(<<"Aucun fichier ne va tre sorti dans le contexte nomm \""
                << getId() << "\" !");
    }
@@ -849,5 +849,5 @@
       prepareTimeseries();
 
-      //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers Ã  sortir.
+      //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers  sortir.
       this->findEnabledFiles();
       this->findEnabledReadModeFiles();
Index: /XIOS/dev/branch_yushan_merged/src/node/file.cpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/src/node/file.cpp	(revision 1145)
+++ /XIOS/dev/branch_yushan_merged/src/node/file.cpp	(revision 1146)
@@ -612,4 +612,5 @@
      if (time_counter_name.isEmpty()) time_counter_name = "time_counter";
 
+     //#pragma omp critical (_checkFile)
      checkFile();
 
Index: /XIOS/dev/branch_yushan_merged/src/server.cpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/src/server.cpp	(revision 1145)
+++ /XIOS/dev/branch_yushan_merged/src/server.cpp	(revision 1146)
@@ -340,4 +340,5 @@
             MPI_Isend(buff,count,MPI_CHAR,i,2,intraComm,&requests[i-1]) ;
          }
+         
          MPI_Waitall(size-1,requests,status) ;
          registerContext(buff,count,it->second.leaderRank) ;
Index: /XIOS/dev/branch_yushan_merged/src/test/test_remap_omp.f90
===================================================================
--- /XIOS/dev/branch_yushan_merged/src/test/test_remap_omp.f90	(revision 1145)
+++ /XIOS/dev/branch_yushan_merged/src/test/test_remap_omp.f90	(revision 1146)
@@ -52,5 +52,5 @@
   if(rank < size-2) then
 
-  !$omp parallel default(private)
+  !$omp parallel default(firstprivate) 
 
 !!! XIOS Initialization (get the local communicator)
@@ -60,5 +60,9 @@
   CALL MPI_COMM_SIZE(comm,size,ierr)
 
+  
+  !$omp critical (open_file)
   ierr=NF90_OPEN(src_file, NF90_NOWRITE, ncid)
+  !$omp end critical (open_file)
+
   ierr=NF90_INQ_VARID(ncid,"bounds_lon",varid)
   ierr=NF90_INQUIRE_VARIABLE(ncid, varid,dimids=dimids)
@@ -134,5 +138,9 @@
   ENDDO
 
+  !$omp critical (open_file)
   ierr=NF90_OPEN(dst_file, NF90_NOWRITE, ncid)
+  !$omp end critical (open_file)
+
+  
   ierr=NF90_INQ_VARID(ncid,"bounds_lon",varid)
   ierr=NF90_INQUIRE_VARIABLE(ncid, varid,dimids=dimids)
@@ -168,5 +176,5 @@
   CALL xios_get_handle("test",ctx_hdl)
   CALL xios_set_current_context(ctx_hdl)
-
+  
   CALL xios_set_domain_attr("src_domain", ni_glo=src_ni_glo, ibegin=src_ibegin, ni=src_ni, type="unstructured")
   CALL xios_set_domain_attr("src_domain", lonvalue_1D=src_lon, latvalue_1D=src_lat, &
@@ -189,5 +197,4 @@
                             bounds_lon_1D=src_boundslon, bounds_lat_1D=src_boundslat, nvertex=src_nvertex)
 
-
   dtime%second = 3600
   
@@ -195,48 +202,7 @@
 
   CALL xios_close_context_definition()
-  CALL xios_get_domain_attr("src_domain_regular_read", ni=src_tmp_ni, nj=src_tmp_nj)
-  ALLOCATE(tmp_field_0(src_tmp_ni*src_tmp_nj))
-
-  CALL xios_get_axis_attr("src_axis_curvilinear_read", n=src_tmp_n)
-  CALL xios_get_domain_attr("src_domain_curvilinear_read", ni=src_tmp_ni, nj=src_tmp_nj)
-  ALLOCATE(tmp_field_1(src_tmp_ni*src_tmp_nj*src_tmp_n))
-
-  CALL xios_get_domain_attr("src_domain_unstructured_read", ni=src_tmp_ni, nj=src_tmp_nj)
-  ALLOCATE(tmp_field_2(src_tmp_ni*src_tmp_nj))
-  
-  CALL xios_recv_field("src_field_regular", tmp_field_0)
-  CALL xios_recv_field("src_field_curvilinear", tmp_field_1)
-  CALL xios_recv_field("src_field_unstructured", tmp_field_2)
-
-  DO ts=1,10
-    CALL xios_update_calendar(ts)
-    CALL xios_send_field("src_field_2D",src_field_2D)
-    
-    DO i=1,src_ni
-      src_field_2D_clone(i) = src_field_2D(i)
-      IF ((23.5 * ts < src_lat(i)) .AND. (src_lat(i) < 65.5 *ts) .AND. (0 < src_lon(i)) .AND. (src_lon(i) < 30*ts)) THEN      
-        src_field_2D_clone(i) = missing_value    
-      ENDIF
-    ENDDO
-
-    CALL xios_send_field("src_field_2D_clone",src_field_2D_clone)
-    CALL xios_send_field("src_field_3D",src_field_3D)
-    CALL xios_send_field("src_field_3D_clone",src_field_3D)
-    CALL xios_send_field("src_field_4D",src_field_4D)
-    CALL xios_send_field("src_field_3D_pression",src_field_pression)
-    CALL xios_send_field("tmp_field_0",tmp_field_0)
-    CALL xios_send_field("tmp_field_1",tmp_field_1)
-    CALL xios_send_field("tmp_field_2",tmp_field_2)
-    CALL wait_us(5000) ;
-   ENDDO
-
+  
   CALL xios_context_finalize()
-
-  DEALLOCATE(src_lon, src_lat, src_boundslon,src_boundslat, src_field_2D)
-  DEALLOCATE(dst_lon, dst_lat, dst_boundslon,dst_boundslat)
-  DEALLOCATE(tmp_field_0, tmp_field_1, tmp_field_2)
-
-  
-
+  
   CALL xios_finalize()
   
