Index: XIOS/dev/dev_trunk_omp/extern/remap/src/cputime.cpp
===================================================================
--- XIOS/dev/dev_trunk_omp/extern/remap/src/cputime.cpp	(revision 1601)
+++ XIOS/dev/dev_trunk_omp/extern/remap/src/cputime.cpp	(revision 1602)
@@ -1,3 +1,4 @@
 #include "mpi.hpp"
+using namespace ep_lib;
 
 namespace sphereRemap {
Index: XIOS/dev/dev_trunk_omp/extern/remap/src/gridRemap.cpp
===================================================================
--- XIOS/dev/dev_trunk_omp/extern/remap/src/gridRemap.cpp	(revision 1601)
+++ XIOS/dev/dev_trunk_omp/extern/remap/src/gridRemap.cpp	(revision 1602)
@@ -11,5 +11,8 @@
 
 CRemapGrid srcGrid;
+#pragma omp threadprivate(srcGrid)
+
 CRemapGrid tgtGrid;
+#pragma omp threadprivate(tgtGrid)
 
 }
Index: XIOS/dev/dev_trunk_omp/extern/remap/src/gridRemap.hpp
===================================================================
--- XIOS/dev/dev_trunk_omp/extern/remap/src/gridRemap.hpp	(revision 1601)
+++ XIOS/dev/dev_trunk_omp/extern/remap/src/gridRemap.hpp	(revision 1602)
@@ -14,6 +14,6 @@
 Coord readPole(std::istream&);
 
-extern CRemapGrid srcGrid;
-extern CRemapGrid tgtGrid;
+//extern CRemapGrid srcGrid;
+//extern CRemapGrid tgtGrid;
 
 }
Index: XIOS/dev/dev_trunk_omp/extern/remap/src/intersect.cpp
===================================================================
--- XIOS/dev/dev_trunk_omp/extern/remap/src/intersect.cpp	(revision 1601)
+++ XIOS/dev/dev_trunk_omp/extern/remap/src/intersect.cpp	(revision 1602)
@@ -14,4 +14,10 @@
 
 namespace sphereRemap {
+
+extern CRemapGrid srcGrid;
+#pragma omp threadprivate(srcGrid)
+
+extern CRemapGrid tgtGrid;
+#pragma omp threadprivate(tgtGrid)
 
 using namespace std;
Index: XIOS/dev/dev_trunk_omp/extern/remap/src/intersection_ym.cpp
===================================================================
--- XIOS/dev/dev_trunk_omp/extern/remap/src/intersection_ym.cpp	(revision 1601)
+++ XIOS/dev/dev_trunk_omp/extern/remap/src/intersection_ym.cpp	(revision 1602)
@@ -19,4 +19,11 @@
 namespace sphereRemap {
 
+extern CRemapGrid srcGrid;
+#pragma omp threadprivate(srcGrid)
+
+extern CRemapGrid tgtGrid;
+#pragma omp threadprivate(tgtGrid)
+
+
 using namespace std;
 using namespace ClipperLib ;
Index: XIOS/dev/dev_trunk_omp/extern/remap/src/libmapper.cpp
===================================================================
--- XIOS/dev/dev_trunk_omp/extern/remap/src/libmapper.cpp	(revision 1601)
+++ XIOS/dev/dev_trunk_omp/extern/remap/src/libmapper.cpp	(revision 1602)
@@ -15,4 +15,6 @@
 #include "cputime.hpp" // cputime
 
+using namespace ep_lib;
+
 using namespace sphereRemap ;
 
@@ -20,5 +22,5 @@
    and deallocated during the second step (computing the weights) */
 Mapper *mapper;
-
+#pragma omp threadprivate(mapper)
 
 /** xxx_bounds_yyy is of length n_vert_per_cell_xxx*n_cell_xxx
Index: XIOS/dev/dev_trunk_omp/extern/remap/src/mapper.cpp
===================================================================
--- XIOS/dev/dev_trunk_omp/extern/remap/src/mapper.cpp	(revision 1601)
+++ XIOS/dev/dev_trunk_omp/extern/remap/src/mapper.cpp	(revision 1602)
@@ -12,6 +12,14 @@
 
 #include "mapper.hpp"
+using namespace ep_lib;
 
 namespace sphereRemap {
+
+extern CRemapGrid srcGrid;
+#pragma omp threadprivate(srcGrid)
+
+extern CRemapGrid tgtGrid;
+#pragma omp threadprivate(tgtGrid)
+
 
 /* A subdivition of an array into N sub-arays
@@ -303,12 +311,12 @@
 			MPI_Issend(sendValue[rank],  nbRecvElement[rank], MPI_DOUBLE, rank, 0, communicator, &sendRequest[nbSendRequest]);
 			nbSendRequest++;
-			MPI_Issend(sendArea[rank],  nbRecvElement[rank], MPI_DOUBLE, rank, 0, communicator, &sendRequest[nbSendRequest]);
+			MPI_Issend(sendArea[rank],  nbRecvElement[rank], MPI_DOUBLE, rank, 1, communicator, &sendRequest[nbSendRequest]);
 			nbSendRequest++;
 			if (order == 2)
 			{
 				MPI_Issend(sendGrad[rank], 3*nbRecvElement[rank]*(NMAX+1),
-								MPI_DOUBLE, rank, 0, communicator, &sendRequest[nbSendRequest]);
+								MPI_DOUBLE, rank, 2, communicator, &sendRequest[nbSendRequest]);
 				nbSendRequest++;
-				MPI_Issend(sendNeighIds[rank], 4*nbRecvElement[rank]*(NMAX+1), MPI_INT, rank, 0, communicator, &sendRequest[nbSendRequest]);
+				MPI_Issend(sendNeighIds[rank], 4*nbRecvElement[rank]*(NMAX+1), MPI_INT, rank, 3, communicator, &sendRequest[nbSendRequest]);
 //ym  --> attention taille GloId
 				nbSendRequest++;
@@ -316,5 +324,5 @@
 			else
 			{
-				MPI_Issend(sendNeighIds[rank], 4*nbRecvElement[rank], MPI_INT, rank, 0, communicator, &sendRequest[nbSendRequest]);
+				MPI_Issend(sendNeighIds[rank], 4*nbRecvElement[rank], MPI_INT, rank, 4, communicator, &sendRequest[nbSendRequest]);
 //ym  --> attention taille GloId
 				nbSendRequest++;
@@ -325,12 +333,12 @@
 			MPI_Irecv(recvValue[rank],  nbSendElement[rank], MPI_DOUBLE, rank, 0, communicator, &recvRequest[nbRecvRequest]);
 			nbRecvRequest++;
-			MPI_Irecv(recvArea[rank],  nbSendElement[rank], MPI_DOUBLE, rank, 0, communicator, &recvRequest[nbRecvRequest]);
+			MPI_Irecv(recvArea[rank],  nbSendElement[rank], MPI_DOUBLE, rank, 1, communicator, &recvRequest[nbRecvRequest]);
 			nbRecvRequest++;
 			if (order == 2)
 			{
 				MPI_Irecv(recvGrad[rank], 3*nbSendElement[rank]*(NMAX+1),
-						MPI_DOUBLE, rank, 0, communicator, &recvRequest[nbRecvRequest]);
+						MPI_DOUBLE, rank, 2, communicator, &recvRequest[nbRecvRequest]);
 				nbRecvRequest++;
-				MPI_Irecv(recvNeighIds[rank], 4*nbSendElement[rank]*(NMAX+1), MPI_INT, rank, 0, communicator, &recvRequest[nbRecvRequest]);
+				MPI_Irecv(recvNeighIds[rank], 4*nbSendElement[rank]*(NMAX+1), MPI_INT, rank, 3, communicator, &recvRequest[nbRecvRequest]);
 //ym  --> attention taille GloId
 				nbRecvRequest++;
@@ -338,5 +346,5 @@
 			else
 			{
-				MPI_Irecv(recvNeighIds[rank], 4*nbSendElement[rank], MPI_INT, rank, 0, communicator, &recvRequest[nbRecvRequest]);
+				MPI_Irecv(recvNeighIds[rank], 4*nbSendElement[rank], MPI_INT, rank, 4, communicator, &recvRequest[nbRecvRequest]);
 //ym  --> attention taille GloId
 				nbRecvRequest++;
Index: XIOS/dev/dev_trunk_omp/extern/remap/src/mapper.hpp
===================================================================
--- XIOS/dev/dev_trunk_omp/extern/remap/src/mapper.hpp	(revision 1601)
+++ XIOS/dev/dev_trunk_omp/extern/remap/src/mapper.hpp	(revision 1602)
@@ -18,5 +18,6 @@
 {
 public:
-       Mapper(MPI_Comm comm=MPI_COMM_WORLD) : communicator(comm), verbose(SILENT), neighbourElements(NULL), sstree(comm) {}
+       Mapper(ep_lib::MPI_Comm comm) : communicator(comm), verbose(SILENT), neighbourElements(NULL), sstree(comm) {}
+
        ~Mapper();
        void setVerbosity(verbosity v) {verbose=v ;}
@@ -67,5 +68,5 @@
 
        CParallelTree sstree;
-       MPI_Comm communicator ;
+       ep_lib::MPI_Comm communicator ;
        std::vector<Elt>  sourceElements ;
        std::vector<Node> sourceMesh ;
Index: XIOS/dev/dev_trunk_omp/extern/remap/src/mpi_cascade.cpp
===================================================================
--- XIOS/dev/dev_trunk_omp/extern/remap/src/mpi_cascade.cpp	(revision 1601)
+++ XIOS/dev/dev_trunk_omp/extern/remap/src/mpi_cascade.cpp	(revision 1602)
@@ -1,4 +1,5 @@
 #include "mpi_cascade.hpp"
 #include <iostream>
+using namespace ep_lib;
 
 namespace sphereRemap {
Index: XIOS/dev/dev_trunk_omp/extern/remap/src/mpi_cascade.hpp
===================================================================
--- XIOS/dev/dev_trunk_omp/extern/remap/src/mpi_cascade.hpp	(revision 1601)
+++ XIOS/dev/dev_trunk_omp/extern/remap/src/mpi_cascade.hpp	(revision 1602)
@@ -12,21 +12,21 @@
 {
 public:
-	CCascadeLevel(MPI_Comm comm) : comm(comm)
-	{
-		MPI_Comm_size(comm, &size);
-		MPI_Comm_rank(comm, &rank);
-	}
-	int colour() const { return rank % group_size; };
-	int key() const { return p_colour() + rank/(p_grp_size*group_size)*p_grp_size; }
+  CCascadeLevel(ep_lib::MPI_Comm comm) : comm(comm)
+  {
+    ep_lib::MPI_Comm_size(comm, &size);
+    ep_lib::MPI_Comm_rank(comm, &rank);
+  }
+  int colour() const { return rank % group_size; };
+  int key() const { return p_colour() + rank/(p_grp_size*group_size)*p_grp_size; }
 
-	// perpendicular group
-	int p_colour() const { return (rank%group_size + rank/group_size) % p_grp_size; }
-	int p_key() const { return colour() + rank/(p_grp_size*group_size)*group_size; }
+  // perpendicular group
+  int p_colour() const { return (rank%group_size + rank/group_size) % p_grp_size; }
+  int p_key() const { return colour() + rank/(p_grp_size*group_size)*group_size; }
 
-	MPI_Comm comm, pg_comm;
-	int rank;
-	int size;
-	int group_size; // group_size and p_grp_size are interchanged?? FIXME
-	int p_grp_size;
+  ep_lib::MPI_Comm comm, pg_comm;
+  int rank;
+  int size;
+  int group_size; // group_size and p_grp_size are interchanged?? FIXME
+  int p_grp_size;
 };
 
@@ -34,9 +34,8 @@
 {
 public:
-	// 
-	CMPICascade(int nodes_per_level, MPI_Comm comm);
+  CMPICascade(int nodes_per_level, ep_lib::MPI_Comm comm);
 
-	int num_levels;
-	std::vector<CCascadeLevel> level;
+  int num_levels;
+  std::vector<CCascadeLevel> level;
 };
 
Index: XIOS/dev/dev_trunk_omp/extern/remap/src/mpi_routing.cpp
===================================================================
--- XIOS/dev/dev_trunk_omp/extern/remap/src/mpi_routing.cpp	(revision 1601)
+++ XIOS/dev/dev_trunk_omp/extern/remap/src/mpi_routing.cpp	(revision 1602)
@@ -5,4 +5,5 @@
 #include "timerRemap.hpp"
 #include <iostream>
+using namespace ep_lib;
 
 namespace sphereRemap {
@@ -150,12 +151,10 @@
 	for (int i = 0; i < nbSource; i++)
 	{
-		MPI_Irecv(&sourceRank[i], 1, MPI_INT, MPI_ANY_SOURCE, 0, communicator, &request[indexRequest]);
-		indexRequest++;
-	}
-	MPI_Barrier(communicator);
-	for (int i = 0; i < nbTarget; i++)
-	{
-		MPI_Isend(&mpiRank, 1, MPI_INT, targetRank[i], 0, communicator, &request[indexRequest]);
-		indexRequest++;
+		MPI_Irecv(&sourceRank[i], 1, MPI_INT, -2, 0, communicator, &request[indexRequest++]);
+	}
+	MPI_Barrier(communicator);
+	for (int i = 0; i < nbTarget; i++)
+	{
+		MPI_Isend(&mpiRank, 1, MPI_INT, targetRank[i], 0, communicator, &request[indexRequest++]);
 	}
 	MPI_Waitall(indexRequest, request, status);
@@ -170,5 +169,5 @@
 	for (int i = 0; i < nbSource; i++)
 	{
-		MPI_Irecv(&sourceRank[i], 1, MPI_INT, MPI_ANY_SOURCE, 0, communicator, &request[indexRequest]);
+		MPI_Irecv(&sourceRank[i], 1, MPI_INT, -2, 0, communicator, &request[indexRequest]);
 		indexRequest++;
 	}
Index: XIOS/dev/dev_trunk_omp/extern/remap/src/mpi_routing.hpp
===================================================================
--- XIOS/dev/dev_trunk_omp/extern/remap/src/mpi_routing.hpp	(revision 1601)
+++ XIOS/dev/dev_trunk_omp/extern/remap/src/mpi_routing.hpp	(revision 1602)
@@ -11,5 +11,5 @@
 {
 
-	MPI_Comm communicator;
+	ep_lib::MPI_Comm communicator;
 	int mpiRank;
 	int mpiSize;
@@ -29,5 +29,5 @@
 
 public:
-	CMPIRouting(MPI_Comm comm);
+	CMPIRouting(ep_lib::MPI_Comm comm);
 	~CMPIRouting();
 	template<typename T> void init(const std::vector<T>& route, CMPICascade *cascade = NULL);
@@ -44,9 +44,9 @@
 template <typename T>
 void alltoalls_known(const std::vector<std::vector<T> >& send, std::vector<std::vector<T> >& recv,
-                     const std::vector<int>& ranks, MPI_Comm communicator);
+                     const std::vector<int>& ranks, ep_lib::MPI_Comm communicator);
 
 template <typename T>
 void alltoalls_unknown(const std::vector<std::vector<T> >& send, std::vector<std::vector<T> >& recv,
-                       const std::vector<int>& ranks, MPI_Comm communicator);
+                       const std::vector<int>& ranks, ep_lib::MPI_Comm communicator);
 }
 #endif
Index: XIOS/dev/dev_trunk_omp/extern/remap/src/parallel_tree.cpp
===================================================================
--- XIOS/dev/dev_trunk_omp/extern/remap/src/parallel_tree.cpp	(revision 1601)
+++ XIOS/dev/dev_trunk_omp/extern/remap/src/parallel_tree.cpp	(revision 1602)
@@ -12,6 +12,13 @@
 
 #include "parallel_tree.hpp"
+using namespace ep_lib;
 
 namespace sphereRemap {
+
+extern CRemapGrid srcGrid;
+#pragma omp threadprivate(srcGrid)
+
+extern CRemapGrid tgtGrid;
+#pragma omp threadprivate(tgtGrid)
 
 static const int assignLevel = 2;
@@ -114,10 +121,9 @@
 }
 
-//CParallelTree::CParallelTree(MPI_Comm comm) : communicator(comm), cascade(MIN_NODE_SZ*MIN_NODE_SZ, comm)
-CParallelTree::CParallelTree(MPI_Comm comm) : communicator(comm), cascade(MAX_NODE_SZ*MAX_NODE_SZ*2, comm)
-{
-	treeCascade.reserve(cascade.num_levels);
-	for (int lev = 0; lev < cascade.num_levels; lev++)
-		treeCascade.push_back(CSampleTree(cascade.level[lev].group_size, assignLevel));
+CParallelTree::CParallelTree(MPI_Comm comm) : communicator(comm), cascade(MIN_NODE_SZ*MIN_NODE_SZ*2, comm)
+{
+  treeCascade.reserve(cascade.num_levels);
+  for (int lev = 0; lev < cascade.num_levels; lev++)
+    treeCascade.push_back(CSampleTree(cascade.level[lev].group_size, assignLevel));
 }
 
Index: XIOS/dev/dev_trunk_omp/extern/remap/src/parallel_tree.hpp
===================================================================
--- XIOS/dev/dev_trunk_omp/extern/remap/src/parallel_tree.hpp	(revision 1601)
+++ XIOS/dev/dev_trunk_omp/extern/remap/src/parallel_tree.hpp	(revision 1602)
@@ -12,27 +12,27 @@
 {
 public:
-	CParallelTree(MPI_Comm comm);
-	~CParallelTree();
+  CParallelTree(ep_lib::MPI_Comm comm);
+  ~CParallelTree();
 
-	void build(vector<Node>& node, vector<Node>& node2);
+  void build(vector<Node>& node, vector<Node>& node2);
 
-	void routeNodes(vector<int>& route, vector<Node>& nodes, int level = 0);
-	void routeIntersections(vector<vector<int> >& route, vector<Node>& nodes, int level = 0);
+  void routeNodes(vector<int>& route, vector<Node>& nodes, int level = 0);
+  void routeIntersections(vector<vector<int> >& route, vector<Node>& nodes, int level = 0);
 
-	int nbLocalElements;
-	Elt* localElements;
+  int nbLocalElements;
+  Elt* localElements;
 
-	CTree localTree;
+  CTree localTree;
 
 private:
-	void updateCirclesForRouting(Coord rootCentre, double rootRadius, int level = 0);
-	void buildSampleTreeCascade(vector<Node>& sampleNodes, int level = 0);
-	void buildLocalTree(const vector<Node>& node, const vector<int>& route);
-	void buildRouteTree();
+  void updateCirclesForRouting(Coord rootCentre, double rootRadius, int level = 0);
+  void buildSampleTreeCascade(vector<Node>& sampleNodes, int level = 0);
+  void buildLocalTree(const vector<Node>& node, const vector<int>& route);
+  void buildRouteTree();
 
-	//CSampleTree sampleTree;
-	vector<CSampleTree> treeCascade; // first for sample tree, then for routing tree
-	CMPICascade cascade;
-  MPI_Comm communicator ;
+  //CSampleTree sampleTree;
+  vector<CSampleTree> treeCascade; // first for sample tree, then for routing tree
+  CMPICascade cascade;
+  ep_lib::MPI_Comm communicator ;
 
 };
Index: XIOS/dev/dev_trunk_omp/extern/remap/src/timerRemap.cpp
===================================================================
--- XIOS/dev/dev_trunk_omp/extern/remap/src/timerRemap.cpp	(revision 1601)
+++ XIOS/dev/dev_trunk_omp/extern/remap/src/timerRemap.cpp	(revision 1602)
@@ -4,4 +4,5 @@
 #include <map>
 #include <iostream>
+using namespace ep_lib;
 
 namespace sphereRemap {
@@ -9,5 +10,6 @@
 using namespace std;
 
-map<string,CTimer*> CTimer::allTimer;
+//map<string,CTimer*> CTimer::allTimer;
+map<string,CTimer*> *CTimer::allTimer_ptr = 0;
 
 CTimer::CTimer(const string& name_) : name(name_)
@@ -56,6 +58,9 @@
 {
 	map<string,CTimer*>::iterator it;
-	it=allTimer.find(name);
-	if (it==allTimer.end()) it=allTimer.insert(pair<string,CTimer*>(name,new CTimer(name))).first;
+	if(allTimer_ptr == 0) allTimer_ptr = new map<string,CTimer*>;
+	//it=allTimer.find(name);
+	it=allTimer_ptr->find(name);
+	//if (it==allTimer.end()) it=allTimer.insert(pair<string,CTimer*>(name,new CTimer(name))).first;
+	if (it==allTimer_ptr->end()) it=allTimer_ptr->insert(pair<string,CTimer*>(name,new CTimer(name))).first;
 	return *(it->second);
 }
Index: XIOS/dev/dev_trunk_omp/extern/remap/src/timerRemap.hpp
===================================================================
--- XIOS/dev/dev_trunk_omp/extern/remap/src/timerRemap.hpp	(revision 1601)
+++ XIOS/dev/dev_trunk_omp/extern/remap/src/timerRemap.hpp	(revision 1602)
@@ -26,5 +26,7 @@
     double getCumulatedTime(void);
     void print(void);
-    static map<string,CTimer*> allTimer;
+    //static map<string,CTimer*> allTimer;
+    static map<string,CTimer*> *allTimer_ptr;
+    #pragma omp threadprivate(allTimer_ptr)
     static double getTime(void);
     static CTimer& get(string name);
