Index: /XIOS/dev/branch_yushan_merged/extern/remap/src/gridRemap.cpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/extern/remap/src/gridRemap.cpp	(revision 1154)
+++ /XIOS/dev/branch_yushan_merged/extern/remap/src/gridRemap.cpp	(revision 1155)
@@ -11,5 +11,8 @@
 
 CRemapGrid srcGrid;
+#pragma omp threadprivate(srcGrid)
+
 CRemapGrid tgtGrid;
+#pragma omp threadprivate(tgtGrid)
 
 }
Index: /XIOS/dev/branch_yushan_merged/extern/remap/src/gridRemap.hpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/extern/remap/src/gridRemap.hpp	(revision 1154)
+++ /XIOS/dev/branch_yushan_merged/extern/remap/src/gridRemap.hpp	(revision 1155)
@@ -14,6 +14,5 @@
 Coord readPole(std::istream&);
 
-extern CRemapGrid srcGrid;
-extern CRemapGrid tgtGrid;
+
 
 }
Index: /XIOS/dev/branch_yushan_merged/extern/remap/src/intersect.cpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/extern/remap/src/intersect.cpp	(revision 1154)
+++ /XIOS/dev/branch_yushan_merged/extern/remap/src/intersect.cpp	(revision 1155)
@@ -16,4 +16,10 @@
 
 using namespace std;
+
+extern CRemapGrid srcGrid;
+#pragma omp threadprivate(srcGrid)
+
+extern CRemapGrid tgtGrid;
+#pragma omp threadprivate(tgtGrid)
 
 /** returns index of edge of a that is shared with b,
Index: /XIOS/dev/branch_yushan_merged/extern/remap/src/intersection_ym.cpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/extern/remap/src/intersection_ym.cpp	(revision 1154)
+++ /XIOS/dev/branch_yushan_merged/extern/remap/src/intersection_ym.cpp	(revision 1155)
@@ -16,4 +16,10 @@
 using namespace std;
 using namespace ClipperLib ;
+
+extern CRemapGrid srcGrid;
+#pragma omp threadprivate(srcGrid)
+
+extern CRemapGrid tgtGrid;
+#pragma omp threadprivate(tgtGrid)
 
 double intersect_ym(Elt *a, Elt *b)
Index: /XIOS/dev/branch_yushan_merged/extern/remap/src/libmapper.cpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/extern/remap/src/libmapper.cpp	(revision 1154)
+++ /XIOS/dev/branch_yushan_merged/extern/remap/src/libmapper.cpp	(revision 1155)
@@ -14,11 +14,19 @@
 #include "mapper.hpp"
 #include "cputime.hpp" // cputime
+#include "gridRemap.hpp"
 
 using namespace sphereRemap ;
+
+extern CRemapGrid srcGrid;
+#pragma omp threadprivate(srcGrid)
+
+extern CRemapGrid tgtGrid;
+#pragma omp threadprivate(tgtGrid)
+
 
 /* mapper is a ponter to a global class instance whoes members are allocated in the first step (finding the sizes of the weight arrays)
    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
@@ -148,5 +156,8 @@
 	char **argv = NULL;
 	MPI_Init(&argc, &argv);*/
-	MPI_Init(NULL, NULL);
+	//MPI_Init(NULL, NULL);
+        int provided;
+        MPI_Init_thread(NULL, NULL, 3, &provided);
+        assert(provided >= 3);
 }
 
Index: /XIOS/dev/branch_yushan_merged/extern/remap/src/mapper.cpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/extern/remap/src/mapper.cpp	(revision 1154)
+++ /XIOS/dev/branch_yushan_merged/extern/remap/src/mapper.cpp	(revision 1155)
@@ -14,4 +14,10 @@
 
 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
Index: /XIOS/dev/branch_yushan_merged/extern/remap/src/node.cpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/extern/remap/src/node.cpp	(revision 1154)
+++ /XIOS/dev/branch_yushan_merged/extern/remap/src/node.cpp	(revision 1155)
@@ -254,31 +254,30 @@
 NodePtr insert(NodePtr thIs, NodePtr node)
 {
-	int la = thIs->level; // node to be inserted
-	int lb = node->level; // node where insertation
-	assert(la < lb); // node to be inserted must have lower level then parent
-	//if (thIs->parent) assert(find_in_tree1(thIs) == true);
-	NodePtr q = NULL;
-	NodePtr chd = NULL;
-	node->move(thIs);
-	if (la == lb - 1)
-	{
+  int la = thIs->level; // node to be inserted
+  int lb = node->level; // node where insertation
+  assert(la < lb); // node to be inserted must have lower level then parent
+  //if (thIs->parent) assert(find_in_tree1(thIs) == true);
+  NodePtr q = NULL;
+  NodePtr chd = NULL;
+  node->move(thIs);
+  if (la == lb - 1)
+  {
     node->child.push_back(thIs);
-		thIs->parent = node;
-		if (node->child.size() > MAX_NODE_SZ &&  node->tree->canSplit() ) // with us as additional child `node` is now too large :(
-			return (node->reinserted || node->parent == NULL) ? split(node) : reinsert(node);
-	}
-	else // la < lb - 1
-	{
-		chd = thIs->closest(node->child);
-		q = insert(thIs, chd);
-	}
-	if ((node->updateCount + 1) % UPDATE_EVERY == 0)
-		node->update();
-	else
-	{
-		if (q) node->remove(q);
-		node->inflate(chd);
-	}
-
+    thIs->parent = node;
+    if (node->child.size() > MAX_NODE_SZ &&  node->tree->canSplit() ) // with us as additional child `node` is now too large :(
+    return (node->reinserted || node->parent == NULL) ? split(node) : reinsert(node);
+  }
+  else // la < lb - 1
+  {
+    chd = thIs->closest(node->child);
+    q = insert(thIs, chd);
+  }
+  if ((node->updateCount + 1) % UPDATE_EVERY == 0)
+    node->update();
+  else
+  {
+    if (q) node->remove(q);
+    node->inflate(chd);
+  }
 
   return q;
Index: /XIOS/dev/branch_yushan_merged/extern/remap/src/parallel_tree.cpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/extern/remap/src/parallel_tree.cpp	(revision 1154)
+++ /XIOS/dev/branch_yushan_merged/extern/remap/src/parallel_tree.cpp	(revision 1155)
@@ -16,4 +16,10 @@
 
 static const int assignLevel = 2;
+
+extern CRemapGrid srcGrid;
+#pragma omp threadprivate(srcGrid)
+
+extern CRemapGrid tgtGrid;
+#pragma omp threadprivate(tgtGrid)
 
 // only the circle is packed, rest of node will be initialized on unpacking
Index: /XIOS/dev/branch_yushan_merged/inputs/REMAP/iodef.xml
===================================================================
--- /XIOS/dev/branch_yushan_merged/inputs/REMAP/iodef.xml	(revision 1154)
+++ /XIOS/dev/branch_yushan_merged/inputs/REMAP/iodef.xml	(revision 1155)
@@ -67,5 +67,5 @@
       </file_group>
      <file_group id="read_then_write_files" enabled=".TRUE.">
-       <file id="output_regular_pole" name="output_dst_regular" >
+       <file id="output_regular_pole" name="output_dst_regular" enabled=".FALSE." >
           <field field_ref="tmp_field_0" name="field_regular_0" />
           <field field_ref="dst_field_regular" name="field_regular" />
Index: /XIOS/dev/branch_yushan_merged/src/node/field.cpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/src/node/field.cpp	(revision 1154)
+++ /XIOS/dev/branch_yushan_merged/src/node/field.cpp	(revision 1155)
@@ -292,9 +292,11 @@
     while (currentDate >= lastDataRequestedFromServer)
     {
-      info(20) << "currentDate : " << currentDate << endl ;
-      info(20) << "lastDataRequestedFromServer : " << lastDataRequestedFromServer << endl ;
-      info(20) << "file->output_freq.getValue() : " << file->output_freq.getValue() << endl ;
-      info(20) << "lastDataRequestedFromServer + file->output_freq.getValue() : " << lastDataRequestedFromServer + file->output_freq << endl ;
-
+      #pragma omp critical (_output)
+      {
+        info(20) << "currentDate : " << currentDate << endl ;
+        info(20) << "lastDataRequestedFromServer : " << lastDataRequestedFromServer << endl ;
+        info(20) << "file->output_freq.getValue() : " << file->output_freq.getValue() << endl ;
+        info(20) << "lastDataRequestedFromServer + file->output_freq.getValue() : " << lastDataRequestedFromServer + file->output_freq << endl ;
+      }
       dataRequested |= sendReadDataRequest(lastDataRequestedFromServer + file->output_freq);
     }
Index: /XIOS/dev/branch_yushan_merged/src/transformation/Functions/reduction.cpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/src/transformation/Functions/reduction.cpp	(revision 1154)
+++ /XIOS/dev/branch_yushan_merged/src/transformation/Functions/reduction.cpp	(revision 1155)
@@ -11,28 +11,10 @@
 //std::map<StdString,EReductionType> CReductionAlgorithm::ReductionOperations = std::map<StdString,EReductionType>();
 std::map<StdString,EReductionType> *CReductionAlgorithm::ReductionOperations_ptr = 0; 
-
-bool CReductionAlgorithm::initReductionOperation(std::map<StdString,EReductionType>& m)
-{
-  // So so stupid way to intialize operation but it works ...
-  m["sum"] = TRANS_REDUCE_SUM;
-  CSumReductionAlgorithm::registerTrans();
-
-  m["min"] = TRANS_REDUCE_MIN;
-  CMinReductionAlgorithm::registerTrans();
-
-  m["max"] = TRANS_REDUCE_MAX;
-  CMaxReductionAlgorithm::registerTrans();
-
-  m["extract"] = TRANS_REDUCE_EXTRACT;
-  CExtractReductionAlgorithm::registerTrans();
-
-  m["average"] = TRANS_REDUCE_AVERAGE;
-  CAverageReductionAlgorithm::registerTrans();
-}
+//#pragma omp threadprivate(CReductionAlgorithm::ReductionOperations_ptr)
 
 
 bool CReductionAlgorithm::initReductionOperation()
 {
-  if(CReductionAlgorithm::ReductionOperations_ptr == NULL) CReductionAlgorithm::ReductionOperations_ptr = new std::map<StdString,EReductionType>();
+  CReductionAlgorithm::ReductionOperations_ptr = new std::map<StdString,EReductionType>();
   // So so stupid way to intialize operation but it works ...
   (*CReductionAlgorithm::ReductionOperations_ptr)["sum"] = TRANS_REDUCE_SUM;
@@ -50,16 +32,12 @@
   (*CReductionAlgorithm::ReductionOperations_ptr)["average"] = TRANS_REDUCE_AVERAGE;
   CAverageReductionAlgorithm::registerTrans();
-
-  printf("*CReductionAlgorithm::ReductionOperations_ptr = %p\t %p\n", *CReductionAlgorithm::ReductionOperations_ptr, &(*CReductionAlgorithm::ReductionOperations_ptr));
 }
 
 //bool CReductionAlgorithm::_dummyInit = CReductionAlgorithm::initReductionOperation(CReductionAlgorithm::ReductionOperations);
-bool CReductionAlgorithm::_dummyInit = CReductionAlgorithm::initReductionOperation();
+//bool CReductionAlgorithm::_dummyInit = CReductionAlgorithm::initReductionOperation();
 
 CReductionAlgorithm* CReductionAlgorithm::createOperation(EReductionType reduceType)
 {
   int reduceTypeInt = reduceType;
-  //if (0 == reductionCreationCallBacks_)
-  //  reductionCreationCallBacks_ = new CallBackMap();
 
   CallBackMap::const_iterator it = (*reductionCreationCallBacks_).find(reduceType);
Index: /XIOS/dev/branch_yushan_merged/src/transformation/Functions/reduction.hpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/src/transformation/Functions/reduction.hpp	(revision 1154)
+++ /XIOS/dev/branch_yushan_merged/src/transformation/Functions/reduction.hpp	(revision 1155)
@@ -28,5 +28,5 @@
 
 public:
-  CReductionAlgorithm() {}
+  CReductionAlgorithm() { }
 
   /*!
Index: /XIOS/dev/branch_yushan_merged/src/transformation/axis_algorithm_extract_domain.cpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/src/transformation/axis_algorithm_extract_domain.cpp	(revision 1154)
+++ /XIOS/dev/branch_yushan_merged/src/transformation/axis_algorithm_extract_domain.cpp	(revision 1155)
@@ -13,5 +13,4 @@
 #include "grid.hpp"
 #include "grid_transformation_factory_impl.hpp"
-#include "reduction.hpp"
 
 namespace xios {
@@ -62,4 +61,8 @@
 
   pos_ = algo->position;
+
+  if(CReductionAlgorithm::ReductionOperations_ptr == 0) 
+    CReductionAlgorithm::initReductionOperation();
+
   reduction_ = CReductionAlgorithm::createOperation((*CReductionAlgorithm::ReductionOperations_ptr)[op]);
 }
Index: /XIOS/dev/branch_yushan_merged/src/transformation/axis_algorithm_extract_domain.hpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/src/transformation/axis_algorithm_extract_domain.hpp	(revision 1154)
+++ /XIOS/dev/branch_yushan_merged/src/transformation/axis_algorithm_extract_domain.hpp	(revision 1155)
@@ -12,4 +12,5 @@
 #include "axis_algorithm_transformation.hpp"
 #include "transformation.hpp"
+#include "reduction.hpp"
 
 namespace xios {
@@ -25,5 +26,5 @@
   Extract a domain to an axis
 */
-class CAxisAlgorithmExtractDomain : public CAxisAlgorithmTransformation
+class CAxisAlgorithmExtractDomain : public CAxisAlgorithmTransformation, public CReductionAlgorithm
 {
 public:
Index: /XIOS/dev/branch_yushan_merged/src/transformation/axis_algorithm_reduce_domain.cpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/src/transformation/axis_algorithm_reduce_domain.cpp	(revision 1154)
+++ /XIOS/dev/branch_yushan_merged/src/transformation/axis_algorithm_reduce_domain.cpp	(revision 1155)
@@ -13,5 +13,4 @@
 #include "grid.hpp"
 #include "grid_transformation_factory_impl.hpp"
-#include "reduction.hpp"
 
 namespace xios {
@@ -70,4 +69,8 @@
 
   dir_ = (CReduceDomainToAxis::direction_attr::iDir == algo->direction)  ? iDir : jDir;
+
+  if(CReductionAlgorithm::ReductionOperations_ptr == 0) 
+    CReductionAlgorithm::initReductionOperation();
+
   reduction_ = CReductionAlgorithm::createOperation((*CReductionAlgorithm::ReductionOperations_ptr)[op]);
 }
Index: /XIOS/dev/branch_yushan_merged/src/transformation/axis_algorithm_reduce_domain.hpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/src/transformation/axis_algorithm_reduce_domain.hpp	(revision 1154)
+++ /XIOS/dev/branch_yushan_merged/src/transformation/axis_algorithm_reduce_domain.hpp	(revision 1155)
@@ -12,4 +12,5 @@
 #include "axis_algorithm_transformation.hpp"
 #include "transformation.hpp"
+#include "reduction.hpp"
 
 namespace xios {
@@ -24,5 +25,5 @@
   Reduce a domain to an axis
 */
-class CAxisAlgorithmReduceDomain : public CAxisAlgorithmTransformation
+class CAxisAlgorithmReduceDomain : public CAxisAlgorithmTransformation, public CReductionAlgorithm
 {
 public:
Index: /XIOS/dev/branch_yushan_merged/src/transformation/domain_algorithm_interpolate.cpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/src/transformation/domain_algorithm_interpolate.cpp	(revision 1154)
+++ /XIOS/dev/branch_yushan_merged/src/transformation/domain_algorithm_interpolate.cpp	(revision 1155)
@@ -111,5 +111,6 @@
   const int constNVertex = 4; // Value by default number of vertex for rectangular domain
   int nVertexSrc, nVertexDest;
-  nVertexSrc = nVertexDest = constNVertex;
+  nVertexSrc = constNVertex;
+  nVertexDest = constNVertex;
 
   // First of all, try to retrieve the boundary values of domain source and domain destination
Index: /XIOS/dev/branch_yushan_merged/src/transformation/scalar_algorithm_extract_axis.cpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/src/transformation/scalar_algorithm_extract_axis.cpp	(revision 1154)
+++ /XIOS/dev/branch_yushan_merged/src/transformation/scalar_algorithm_extract_axis.cpp	(revision 1155)
@@ -14,5 +14,5 @@
 #include "grid_transformation_factory_impl.hpp"
 
-#include "reduction.hpp"
+
 
 namespace xios {
@@ -49,4 +49,8 @@
   StdString op = "extract";
   pos_ = algo->position;
+  
+  if(CReductionAlgorithm::ReductionOperations_ptr == 0) 
+    CReductionAlgorithm::initReductionOperation();
+  
   reduction_ = CReductionAlgorithm::createOperation((*CReductionAlgorithm::ReductionOperations_ptr)[op]);
 }
Index: /XIOS/dev/branch_yushan_merged/src/transformation/scalar_algorithm_extract_axis.hpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/src/transformation/scalar_algorithm_extract_axis.hpp	(revision 1154)
+++ /XIOS/dev/branch_yushan_merged/src/transformation/scalar_algorithm_extract_axis.hpp	(revision 1155)
@@ -12,4 +12,5 @@
 #include "scalar_algorithm_transformation.hpp"
 #include "transformation.hpp"
+#include "reduction.hpp"
 
 namespace xios {
@@ -24,5 +25,5 @@
   Extract a scalar from an axis
 */
-class CScalarAlgorithmExtractAxis : public CScalarAlgorithmTransformation
+class CScalarAlgorithmExtractAxis : public CScalarAlgorithmTransformation, public CReductionAlgorithm
 {
 public:
Index: /XIOS/dev/branch_yushan_merged/src/transformation/scalar_algorithm_reduce_axis.cpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/src/transformation/scalar_algorithm_reduce_axis.cpp	(revision 1154)
+++ /XIOS/dev/branch_yushan_merged/src/transformation/scalar_algorithm_reduce_axis.cpp	(revision 1155)
@@ -13,9 +13,10 @@
 #include "grid.hpp"
 #include "grid_transformation_factory_impl.hpp"
-#include "reduction.hpp"
-
-#include "reduction.hpp"
 
 namespace xios {
+
+//extern std::map<StdString,EReductionType> *CReductionAlgorithm::ReductionOperations_ptr; 
+//#pragma omp threadprivate(CReductionAlgorithm::ReductionOperations_ptr)
+
 CGenericAlgorithmTransformation* CScalarAlgorithmReduceAxis::create(CGrid* gridDst, CGrid* gridSrc,
                                                                      CTransformation<CScalar>* transformation,
@@ -75,10 +76,12 @@
   }
   
-  //if ((*CReductionAlgorithm::ReductionOperations_ptr).end() == (*CReductionAlgorithm::ReductionOperations_ptr).find(op))
-  //  if ((CReductionAlgorithm::ReductionOperations_ptr)->end() == (CReductionAlgorithm::ReductionOperations_ptr)->find(op))
-  //  ERROR("CScalarAlgorithmReduceAxis::CScalarAlgorithmReduceAxis(CAxis* axisDestination, CAxis* axisSource, CReduceAxisToScalar* algo)",
-  //     << "Operation '" << op << "' not found. Please make sure to use a supported one"
-  //     << "Axis source " <<axisSource->getId() << std::endl
-  //     << "Scalar destination " << scalarDestination->getId());
+  if(CReductionAlgorithm::ReductionOperations_ptr == 0) 
+    CReductionAlgorithm::initReductionOperation();
+  
+  if ((*CReductionAlgorithm::ReductionOperations_ptr).end() == (*CReductionAlgorithm::ReductionOperations_ptr).find(op))
+    ERROR("CScalarAlgorithmReduceAxis::CScalarAlgorithmReduceAxis(CAxis* axisDestination, CAxis* axisSource, CReduceAxisToScalar* algo)",
+       << "Operation '" << op << "' not found. Please make sure to use a supported one"
+       << "Axis source " <<axisSource->getId() << std::endl
+       << "Scalar destination " << scalarDestination->getId());
 
   reduction_ = CReductionAlgorithm::createOperation((*CReductionAlgorithm::ReductionOperations_ptr)[op]);
Index: /XIOS/dev/branch_yushan_merged/src/transformation/scalar_algorithm_reduce_axis.hpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/src/transformation/scalar_algorithm_reduce_axis.hpp	(revision 1154)
+++ /XIOS/dev/branch_yushan_merged/src/transformation/scalar_algorithm_reduce_axis.hpp	(revision 1155)
@@ -12,4 +12,5 @@
 #include "scalar_algorithm_transformation.hpp"
 #include "transformation.hpp"
+#include "reduction.hpp"
 
 namespace xios {
@@ -24,5 +25,5 @@
   Reducing an axis to a scalar
 */
-class CScalarAlgorithmReduceAxis : public CScalarAlgorithmTransformation
+class CScalarAlgorithmReduceAxis : public CScalarAlgorithmTransformation, public CReductionAlgorithm
 {
 public:
Index: /XIOS/dev/branch_yushan_merged/src/transformation/scalar_algorithm_reduce_domain.cpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/src/transformation/scalar_algorithm_reduce_domain.cpp	(revision 1154)
+++ /XIOS/dev/branch_yushan_merged/src/transformation/scalar_algorithm_reduce_domain.cpp	(revision 1155)
@@ -14,5 +14,5 @@
 #include "grid_transformation_factory_impl.hpp"
 
-#include "reduction.hpp"
+
 
 namespace xios {
@@ -68,5 +68,8 @@
 
   }
-  
+
+  if(CReductionAlgorithm::ReductionOperations_ptr == 0) 
+    CReductionAlgorithm::initReductionOperation();
+
   if ((*CReductionAlgorithm::ReductionOperations_ptr).end() == (*CReductionAlgorithm::ReductionOperations_ptr).find(op))
     ERROR("CScalarAlgorithmReduceDomain::CScalarAlgorithmReduceDomain(CDomain* domainDestination, CDomain* domainSource, CReduceDomainToScalar* algo)",
Index: /XIOS/dev/branch_yushan_merged/src/transformation/scalar_algorithm_reduce_domain.hpp
===================================================================
--- /XIOS/dev/branch_yushan_merged/src/transformation/scalar_algorithm_reduce_domain.hpp	(revision 1154)
+++ /XIOS/dev/branch_yushan_merged/src/transformation/scalar_algorithm_reduce_domain.hpp	(revision 1155)
@@ -12,4 +12,5 @@
 #include "scalar_algorithm_transformation.hpp"
 #include "transformation.hpp"
+#include "reduction.hpp"
 
 namespace xios {
@@ -24,5 +25,5 @@
   Reducing an DOMAIN to a scalar
 */
-class CScalarAlgorithmReduceDomain : public CScalarAlgorithmTransformation
+class CScalarAlgorithmReduceDomain : public CScalarAlgorithmTransformation, public CReductionAlgorithm
 {
 public:
