Index: /XIOS/dev/branch_yushan/bld.cfg
===================================================================
--- /XIOS/dev/branch_yushan/bld.cfg	(revision 1108)
+++ /XIOS/dev/branch_yushan/bld.cfg	(revision 1109)
@@ -36,5 +36,5 @@
 #bld::target test_remap.exe
 #bld::target test_new_features.exe test_unstruct_complete.exe 
-bld::target test_omp.exe test_client.exe #test_complete.exe 
+bld::target test_omp.exe test_client.exe test_complete.exe test_complete_omp.exe
 bld::exe_dep
 
Index: /XIOS/dev/branch_yushan/src/interface/c/icdata.cpp
===================================================================
--- /XIOS/dev/branch_yushan/src/interface/c/icdata.cpp	(revision 1108)
+++ /XIOS/dev/branch_yushan/src/interface/c/icdata.cpp	(revision 1109)
@@ -131,5 +131,5 @@
      
      CContext* context = CContext::getCurrent();
-     printf("Check : CContext::getCurrent() = %p\n", CContext::getCurrent());
+     //printf("Check : CContext::getCurrent() = %p\n", CContext::getCurrent());
      context->finalize();
           
Index: /XIOS/dev/branch_yushan/src/node/axis.cpp
===================================================================
--- /XIOS/dev/branch_yushan/src/node/axis.cpp	(revision 1108)
+++ /XIOS/dev/branch_yushan/src/node/axis.cpp	(revision 1109)
@@ -44,10 +44,9 @@
    { /* Ne rien faire de plus */ }
 
-   std::map<StdString, ETranformationType> CAxis::transformationMapList_ = std::map<StdString, ETranformationType>();
-   
-   std::map<StdString, ETranformationType> *CAxis::transformationMapList_ptr = new std::map<StdString, ETranformationType>();
-   
-   bool CAxis::dummyTransformationMapList_ = CAxis::initializeTransformationMap(CAxis::transformationMapList_);
-   //bool CAxis::dummyTransformationMapList_ = CAxis::initializeTransformationMap(*CAxis::transformationMapList_ptr);
+   //std::map<StdString, ETranformationType> CAxis::transformationMapList_ = std::map<StdString, ETranformationType>();
+   //bool CAxis::dummyTransformationMapList_ = CAxis::initializeTransformationMap(CAxis::transformationMapList_);
+
+   std::map<StdString, ETranformationType> *CAxis::transformationMapList_ptr = 0; //new std::map<StdString, ETranformationType>();  
+   //bool CAxis::dummyTransformationMapList_ = CAxis::initializeTransformationMap(CAxis::transformationMapList_ptr);
 
    bool CAxis::initializeTransformationMap(std::map<StdString, ETranformationType>& m)
@@ -58,11 +57,17 @@
      m["reduce_domain"] = TRANS_REDUCE_DOMAIN_TO_AXIS;
      m["extract_domain"] = TRANS_EXTRACT_DOMAIN_TO_AXIS;
-     
-     // m.insert(m.end(), make_pair("zoom_axis", TRANS_ZOOM_AXIS)); printf("zoom_axis insert\n");
-     // m.insert(m.end(), make_pair("interpolate_axis", TRANS_INTERPOLATE_AXIS)); printf("interpolate_axis insert\n");
-     // m.insert(m.end(), make_pair("inverse_axis", TRANS_INVERSE_AXIS)); printf("inverse_axis insert\n");
-     // m.insert(m.end(), make_pair("reduce_domain", TRANS_REDUCE_DOMAIN_TO_AXIS)); printf("reduce_domain insert\n");
-     // m.insert(m.end(), make_pair("extract_domain", TRANS_EXTRACT_DOMAIN_TO_AXIS)); printf("extract_domain insert\n");
-   }
+   }
+
+
+   bool CAxis::initializeTransformationMap()
+   {
+     if(CAxis::transformationMapList_ptr == 0) CAxis::transformationMapList_ptr = new std::map<StdString, ETranformationType>();
+     (*CAxis::transformationMapList_ptr)["zoom_axis"]        = TRANS_ZOOM_AXIS;
+     (*CAxis::transformationMapList_ptr)["interpolate_axis"] = TRANS_INTERPOLATE_AXIS;
+     (*CAxis::transformationMapList_ptr)["inverse_axis"]     = TRANS_INVERSE_AXIS;
+     (*CAxis::transformationMapList_ptr)["reduce_domain"]    = TRANS_REDUCE_DOMAIN_TO_AXIS;
+     (*CAxis::transformationMapList_ptr)["extract_domain"]   = TRANS_EXTRACT_DOMAIN_TO_AXIS;
+   }
+
 
    ///---------------------------------------------------------------
@@ -1015,6 +1020,10 @@
 
         nodeElementName = node.getElementName();
-        std::map<StdString, ETranformationType>::const_iterator ite = transformationMapList_.end(), it;
-        it = transformationMapList_.find(nodeElementName);
+
+        if(transformationMapList_ptr == 0) initializeTransformationMap();
+        //transformationMapList_ptr = new std::map<StdString, ETranformationType>();
+
+        std::map<StdString, ETranformationType>::const_iterator ite = (*CAxis::transformationMapList_ptr).end(), it;
+        it = (*CAxis::transformationMapList_ptr).find(nodeElementName);
         if (ite != it)
         {
@@ -1038,2 +1047,3 @@
 
 } // namespace xios
+
Index: /XIOS/dev/branch_yushan/src/node/axis.hpp
===================================================================
--- /XIOS/dev/branch_yushan/src/node/axis.hpp	(revision 1108)
+++ /XIOS/dev/branch_yushan/src/node/axis.hpp	(revision 1109)
@@ -166,12 +166,14 @@
        private:
          static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m);
-         
-         static std::map<StdString, ETranformationType> transformationMapList_;
+         //static bool initializeTransformationMap(std::map<StdString, ETranformationType>* m);
+         static bool initializeTransformationMap();
+
+         //static std::map<StdString, ETranformationType> transformationMapList_;
          
          static std::map<StdString, ETranformationType> *transformationMapList_ptr;
          #pragma omp threadprivate(transformationMapList_ptr)
 
-         static bool dummyTransformationMapList_;
-         #pragma omp threadprivate(dummyTransformationMapList_)
+         //static bool dummyTransformationMapList_;
+         //#pragma omp threadprivate(dummyTransformationMapList_)
 
          DECLARE_REF_FUNC(Axis,axis)
@@ -185,2 +187,3 @@
 
 #endif // __XIOS_CAxis__
+
Index: /XIOS/dev/branch_yushan/src/node/domain.cpp
===================================================================
--- /XIOS/dev/branch_yushan/src/node/domain.cpp	(revision 1108)
+++ /XIOS/dev/branch_yushan/src/node/domain.cpp	(revision 1109)
@@ -65,6 +65,8 @@
    }
 
-   std::map<StdString, ETranformationType> CDomain::transformationMapList_ = std::map<StdString, ETranformationType>();
-   bool CDomain::_dummyTransformationMapList = CDomain::initializeTransformationMap(CDomain::transformationMapList_);
+   //std::map<StdString, ETranformationType> CDomain::transformationMapList_ = std::map<StdString, ETranformationType>();
+   //bool CDomain::_dummyTransformationMapList = CDomain::initializeTransformationMap(CDomain::transformationMapList_);
+
+   std::map<StdString, ETranformationType> *CDomain::transformationMapList_ptr = 0;
 
    bool CDomain::initializeTransformationMap(std::map<StdString, ETranformationType>& m)
@@ -76,4 +78,15 @@
      m["expand_domain"] = TRANS_EXPAND_DOMAIN;
    }
+
+   bool CDomain::initializeTransformationMap()
+   {
+     CDomain::transformationMapList_ptr = new std::map<StdString, ETranformationType>();
+     (*CDomain::transformationMapList_ptr)["zoom_domain"] = TRANS_ZOOM_DOMAIN;
+     (*CDomain::transformationMapList_ptr)["interpolate_domain"] = TRANS_INTERPOLATE_DOMAIN;
+     (*CDomain::transformationMapList_ptr)["generate_rectilinear_domain"] = TRANS_GENERATE_RECTILINEAR_DOMAIN;
+     (*CDomain::transformationMapList_ptr)["compute_connectivity_domain"] = TRANS_COMPUTE_CONNECTIVITY_DOMAIN;
+     (*CDomain::transformationMapList_ptr)["expand_domain"] = TRANS_EXPAND_DOMAIN;
+   }
+
 
    const std::set<StdString> & CDomain::getRelFiles(void) const
@@ -2189,6 +2202,7 @@
 
         nodeElementName = node.getElementName();
-        std::map<StdString, ETranformationType>::const_iterator ite = transformationMapList_.end(), it;
-        it = transformationMapList_.find(nodeElementName);
+        if(transformationMapList_ptr == 0) initializeTransformationMap();
+        std::map<StdString, ETranformationType>::const_iterator ite = (*transformationMapList_ptr).end(), it;
+        it = (*transformationMapList_ptr).find(nodeElementName);
         if (ite != it)
         {
Index: /XIOS/dev/branch_yushan/src/node/domain.hpp
===================================================================
--- /XIOS/dev/branch_yushan/src/node/domain.hpp	(revision 1108)
+++ /XIOS/dev/branch_yushan/src/node/domain.hpp	(revision 1109)
@@ -211,6 +211,11 @@
        private:
          static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m);
-         static std::map<StdString, ETranformationType> transformationMapList_;
-         static bool _dummyTransformationMapList;
+         static bool initializeTransformationMap();
+         //static std::map<StdString, ETranformationType> transformationMapList_;
+ 
+         static std::map<StdString, ETranformationType> *transformationMapList_ptr;
+         #pragma omp threadprivate(transformationMapList_ptr)
+
+         //static bool _dummyTransformationMapList;
          //#pragma omp threadprivate(_dummyTransformationMapList)
 
Index: /XIOS/dev/branch_yushan/src/node/mesh.cpp
===================================================================
--- /XIOS/dev/branch_yushan/src/node/mesh.cpp	(revision 1108)
+++ /XIOS/dev/branch_yushan/src/node/mesh.cpp	(revision 1109)
@@ -34,4 +34,8 @@
   std::map <StdString, vector<int> > CMesh::domainList = std::map <StdString, vector<int> >();
 
+  std::map <StdString, CMesh> *CMesh::meshList_ptr = 0;
+  std::map <StdString, vector<int> > *CMesh::domainList_ptr = 0;
+
+
 ///---------------------------------------------------------------
 /*!
@@ -41,4 +45,6 @@
  * \param [in] nvertex Number of verteces (1 for nodes, 2 for edges, 3 and up for faces).
  */
+
+/* bkp
   CMesh* CMesh::getMesh (StdString meshName, int nvertex)
   {
@@ -64,4 +70,34 @@
       CMesh::meshList.insert( make_pair(meshName, newMesh) );
       return &meshList[meshName];
+    }
+  }
+*/
+
+  CMesh* CMesh::getMesh (StdString meshName, int nvertex)
+  {
+    if(CMesh::domainList_ptr == NULL) CMesh::domainList_ptr = new std::map <StdString, vector<int> >();
+    if(CMesh::meshList_ptr == NULL)   CMesh::meshList_ptr   = new std::map <StdString, CMesh>();
+
+    (*CMesh::domainList_ptr)[meshName].push_back(nvertex);
+
+    if ( (*CMesh::meshList_ptr).begin() != (*CMesh::meshList_ptr).end() )
+    {
+      for (std::map<StdString, CMesh>::iterator it=(*CMesh::meshList_ptr).begin(); it!=(*CMesh::meshList_ptr).end(); ++it)
+      {
+        if (it->first == meshName)
+          return &((*CMesh::meshList_ptr)[meshName]);
+        else
+        {
+          CMesh newMesh;
+          (*CMesh::meshList_ptr).insert( make_pair(meshName, newMesh) );
+          return &((*CMesh::meshList_ptr)[meshName]);
+        }
+      }
+    }
+    else
+    {
+      CMesh newMesh;
+      (*CMesh::meshList_ptr).insert( make_pair(meshName, newMesh) );
+      return &((*CMesh::meshList_ptr)[meshName]);
     }
   }
Index: /XIOS/dev/branch_yushan/src/node/mesh.hpp
===================================================================
--- /XIOS/dev/branch_yushan/src/node/mesh.hpp	(revision 1108)
+++ /XIOS/dev/branch_yushan/src/node/mesh.hpp	(revision 1109)
@@ -82,4 +82,9 @@
       static std::map <StdString, CMesh> meshList;
       static std::map <StdString, vector<int> > domainList;
+
+      static std::map <StdString, CMesh> *meshList_ptr;
+      static std::map <StdString, vector<int> > *domainList_ptr;
+      #pragma omp threadprivate(meshList_ptr, domainList_ptr)
+   
       CClientClientDHTSizet* pNodeGlobalIndex;                    // pointer to a map <nodeHash, nodeIdxGlo>
       CClientClientDHTSizet* pEdgeGlobalIndex;                    // pointer to a map <edgeHash, edgeIdxGlo>
Index: /XIOS/dev/branch_yushan/src/node/scalar.cpp
===================================================================
--- /XIOS/dev/branch_yushan/src/node/scalar.cpp	(revision 1108)
+++ /XIOS/dev/branch_yushan/src/node/scalar.cpp	(revision 1109)
@@ -27,6 +27,9 @@
    { /* Ne rien faire de plus */ }
 
-   std::map<StdString, ETranformationType> CScalar::transformationMapList_ = std::map<StdString, ETranformationType>();
-   bool CScalar::dummyTransformationMapList_ = CScalar::initializeTransformationMap(CScalar::transformationMapList_);
+   //std::map<StdString, ETranformationType> CScalar::transformationMapList_ = std::map<StdString, ETranformationType>();
+   //bool CScalar::dummyTransformationMapList_ = CScalar::initializeTransformationMap(CScalar::transformationMapList_);
+
+   std::map<StdString, ETranformationType> *CScalar::transformationMapList_ptr = 0;
+   
    bool CScalar::initializeTransformationMap(std::map<StdString, ETranformationType>& m)
    {
@@ -34,4 +37,12 @@
      m["extract_axis"]  = TRANS_EXTRACT_AXIS_TO_SCALAR;
      m["reduce_domain"] = TRANS_REDUCE_DOMAIN_TO_SCALAR;
+   }
+
+   bool CScalar::initializeTransformationMap()
+   {
+     CScalar::transformationMapList_ptr = new std::map<StdString, ETranformationType>();
+     (*CScalar::transformationMapList_ptr)["reduce_axis"]   = TRANS_REDUCE_AXIS_TO_SCALAR;
+     (*CScalar::transformationMapList_ptr)["extract_axis"]  = TRANS_EXTRACT_AXIS_TO_SCALAR;
+     (*CScalar::transformationMapList_ptr)["reduce_domain"] = TRANS_REDUCE_DOMAIN_TO_SCALAR;
    }
 
@@ -147,6 +158,7 @@
 
         nodeElementName = node.getElementName();
-        std::map<StdString, ETranformationType>::const_iterator ite = transformationMapList_.end(), it;
-        it = transformationMapList_.find(nodeElementName);
+        if(CScalar::transformationMapList_ptr == 0) initializeTransformationMap();
+        std::map<StdString, ETranformationType>::const_iterator ite = (*CScalar::transformationMapList_ptr).end(), it;
+        it = (*CScalar::transformationMapList_ptr).find(nodeElementName);
         if (ite != it)
         {
Index: /XIOS/dev/branch_yushan/src/node/scalar.hpp
===================================================================
--- /XIOS/dev/branch_yushan/src/node/scalar.hpp	(revision 1108)
+++ /XIOS/dev/branch_yushan/src/node/scalar.hpp	(revision 1109)
@@ -87,7 +87,11 @@
        private:
            static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m);
-           static std::map<StdString, ETranformationType> transformationMapList_;
-           static bool dummyTransformationMapList_;
-           //#pragma omp threadprivate(dummyTransformationMapList_)
+           static bool initializeTransformationMap();
+           
+           //static std::map<StdString, ETranformationType> transformationMapList_;
+           //static bool dummyTransformationMapList_;
+
+           static std::map<StdString, ETranformationType> *transformationMapList_ptr;
+           #pragma omp threadprivate(transformationMapList_ptr)
 
 
Index: /XIOS/dev/branch_yushan/src/node/transformation.hpp
===================================================================
--- /XIOS/dev/branch_yushan/src/node/transformation.hpp	(revision 1108)
+++ /XIOS/dev/branch_yushan/src/node/transformation.hpp	(revision 1109)
@@ -51,4 +51,5 @@
   {
     int transTypeInt = transType;
+
     typename CallBackMap::const_iterator it = (*transformationCreationCallBacks_).find(transType);
     if ((*transformationCreationCallBacks_).end() == it)
Index: /XIOS/dev/branch_yushan/src/test/test_complete.f90
===================================================================
--- /XIOS/dev/branch_yushan/src/test/test_complete.f90	(revision 1108)
+++ /XIOS/dev/branch_yushan/src/test/test_complete.f90	(revision 1109)
@@ -5,5 +5,5 @@
   IMPLICIT NONE
   INCLUDE "mpif.h"
-  INTEGER :: rank
+  INTEGER :: rank, size
   INTEGER :: size_loc
   INTEGER :: ierr
@@ -28,11 +28,13 @@
   INTEGER, ALLOCATABLE :: kindex(:)
   INTEGER :: ni,ibegin,iend,nj,jbegin,jend
-  INTEGER :: i,j,l,ts,n, nb_pt
+  INTEGER :: i,j,l,ts,n, nb_pt, provided
 
 !!! MPI Initialization
 
-  CALL MPI_INIT(ierr)
-
-  CALL MPI_COMM_RANK(MPI_COMM_WORLD,rank,ierr)  
+  CALL MPI_INIT_THREAD(3, provided, ierr)
+    if(provided .NE. 3) then
+      print*, "provided thread level = ", provided
+      call MPI_Abort()
+    endif 
 
   
@@ -40,5 +42,7 @@
   CALL init_wait
 
-  if (rank <2) then
+  CALL MPI_COMM_RANK(MPI_COMM_WORLD,rank,ierr)
+  CALL MPI_COMM_SIZE(MPI_COMM_WORLD,size,ierr)
+  if(rank < size-1) then
 
 !!! XIOS Initialization (get the local communicator)
@@ -86,5 +90,4 @@
 
   CALL xios_context_initialize("atmosphere",comm)
-!   print*, "init context atmosphere comm = ", comm
 
   CALL xios_get_handle("atmosphere",ctx_hdl)
@@ -96,5 +99,4 @@
 
   CALL xios_set_axis_attr("axis_atm",n_glo=llm ,value=lval) ;
-!  CALL xios_set_zoom_axis_attr("axis_atm_zoom",n=2);
 
   CALL xios_set_domain_attr("domain_atm",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj, type='curvilinear')
@@ -105,5 +107,5 @@
   CALL xios_set_domain_attr("domain_atm_zoom",data_dim=2, data_ibegin=-1, data_ni=ni+2, data_jbegin=-2, data_nj=nj+4)
   CALL xios_set_domain_attr("domain_atm_zoom",lonvalue_2D=lon,latvalue_2D=lat)
-!  CALL xios_set_zoom_domain_attr("domain_atm_zoom",ibegin=39, ni=20, jbegin=39, nj=5)
+
 
 !!! Activation du groupe field_definition
@@ -143,5 +145,5 @@
   CALL xios_close_context_definition()
 
-!   print *, "xios_close_context_definition(atmosphere)"
+   print *, "xios_close_context_definition(atmosphere)"
 
 !!! Test des valeurs des champs/fichiers
@@ -180,5 +182,5 @@
 
   CALL xios_context_initialize("surface",comm)
-!   print*, "init context surface comm = ", comm
+
 
   CALL xios_get_handle("surface",ctx_hdl)
@@ -227,5 +229,5 @@
   CALL xios_close_context_definition()
 
-!  print *, "xios_close_context_definition(surface)" 
+  print *, "xios_close_context_definition(surface)" 
 
 
@@ -266,5 +268,5 @@
     ENDDO
 
-!     print *, "end temporal loop"
+     print *, "end temporal loop"
 
 !####################################################################################
@@ -274,38 +276,43 @@
 !!! Fin des contextes
 
-    !print *, "start : xios_context_finalize(surface)"
 
     CALL xios_get_handle("surface",ctx_hdl) 
-    !print *, "xios_get_handle (surface) OK"
+
     CALL xios_set_current_context(ctx_hdl)
-    !print *, "xios_set_current_context (surface) OK"
+
     CALL xios_context_finalize()
 
-!     print *, "xios_context_finalize(surface)" 
+    print *, "xios_context_finalize(surface)" 
 
      CALL xios_get_handle("atmosphere",ctx_hdl)
-!     !print *, "xios_get_handle (atmosphere) OK"
+
      CALL xios_set_current_context(ctx_hdl)
-!     !print *, "xios_set_current_context (atmosphere) OK"
+
      CALL xios_context_finalize()
 
-!     print *, "xios_context_finalize(atmosphere)"
+     print *, "xios_context_finalize(atmosphere)"
+
+    
+
+!!! Fin de XIOS
+
+    
+
+    CALL xios_finalize()
 
     DEALLOCATE(lon, lat, field_A_atm, lonvalue)
-   ! DEALLOCATE(kindex, field_A_srf)
-
-!!! Fin de XIOS
+    DEALLOCATE(kindex, field_A_srf)
+
+     print *, "Client : xios_finalize "
 
     CALL MPI_COMM_FREE(comm, ierr)
 
-    CALL xios_finalize()
-
-     print *, "Client : xios_finalize "
-
-  else 
+  else
+
     CALL xios_init_server
-
     print *, "Server : xios_finalize "
-  endif
+  
+    endif
+
 
     CALL MPI_FINALIZE(ierr)
Index: /XIOS/dev/branch_yushan/src/test/test_complete_omp.f90
===================================================================
--- /XIOS/dev/branch_yushan/src/test/test_complete_omp.f90	(revision 1109)
+++ /XIOS/dev/branch_yushan/src/test/test_complete_omp.f90	(revision 1109)
@@ -0,0 +1,340 @@
+PROGRAM test_complete_omp
+
+  USE xios
+  USE mod_wait
+  use omp_lib
+  IMPLICIT NONE
+  INCLUDE "mpif.h"
+  INTEGER :: rank, size
+  INTEGER :: size_loc
+  INTEGER :: ierr
+
+  CHARACTER(len=*),PARAMETER :: id="client"
+  INTEGER :: comm, comm2
+  TYPE(xios_duration)  :: dtime
+  TYPE(xios_context) :: ctx_hdl
+  INTEGER,PARAMETER :: ni_glo=100
+  INTEGER,PARAMETER :: nj_glo=100
+  INTEGER,PARAMETER :: llm=5
+  DOUBLE PRECISION  :: lval(llm)=1
+  TYPE(xios_field) :: field_hdl
+  TYPE(xios_fieldgroup) :: fieldgroup_hdl
+  TYPE(xios_file) :: file_hdl
+  LOGICAL :: ok
+  CHARACTER(len=256) :: crname
+
+  DOUBLE PRECISION,DIMENSION(ni_glo,nj_glo) :: lon_glo,lat_glo
+  DOUBLE PRECISION :: field_A_glo(ni_glo,nj_glo,llm)
+  DOUBLE PRECISION,ALLOCATABLE :: lon(:,:),lat(:,:),field_A_atm(:,:,:), field_A_srf(:,:), lonvalue(:,:)
+  INTEGER, ALLOCATABLE :: kindex(:)
+  INTEGER :: ni,ibegin,iend,nj,jbegin,jend
+  INTEGER :: i,j,l,ts,n, nb_pt, provided
+
+!!! MPI Initialization
+
+  CALL MPI_INIT_THREAD(3, provided, ierr)
+    if(provided .NE. 3) then
+      print*, "provided thread level = ", provided
+      call MPI_Abort()
+    endif 
+
+  
+
+  CALL init_wait
+
+  CALL MPI_COMM_RANK(MPI_COMM_WORLD,rank,ierr)
+  CALL MPI_COMM_SIZE(MPI_COMM_WORLD,size,ierr)
+  if(rank < size-1) then
+
+  !$omp parallel default(private)
+
+!!! XIOS Initialization (get the local communicator)
+
+  CALL xios_initialize(id,return_comm=comm)
+
+  CALL MPI_COMM_RANK(comm,rank,ierr)
+  CALL MPI_COMM_SIZE(comm,size_loc,ierr)
+
+  size_loc = size*omp_get_num_threads()
+  rank = rank*omp_get_num_threads() + omp_get_thread_num()
+
+
+!###########################################################################
+! Contexte ATM
+!###########################################################################
+
+!!! Initialisation des coordonnes globales et locales pour la grille rgulire
+
+  DO j=1,nj_glo
+    DO i=1,ni_glo
+      lon_glo(i,j)=(i-1)+(j-1)*ni_glo
+      lat_glo(i,j)=1000+(i-1)+(j-1)*ni_glo
+      DO l=1,llm
+        field_A_glo(i,j,l)=(i-1)+(j-1)*ni_glo+10000*l
+      ENDDO
+    ENDDO
+  ENDDO
+  ni=ni_glo ; ibegin=0
+
+  jbegin=0
+  DO n=0,size_loc-1
+    nj=nj_glo/size_loc
+    IF (n<MOD(nj_glo,size_loc)) nj=nj+1
+    IF (n==rank) exit
+    jbegin=jbegin+nj
+  ENDDO
+
+  iend=ibegin+ni-1 ; jend=jbegin+nj-1
+
+  ALLOCATE(lon(ni,nj),lat(ni,nj),field_A_atm(0:ni+1,-1:nj+2,llm),lonvalue(ni,nj))
+  lon(:,:)=lon_glo(ibegin+1:iend+1,jbegin+1:jend+1)
+  lat(:,:)=lat_glo(ibegin+1:iend+1,jbegin+1:jend+1)
+  field_A_atm(1:ni,1:nj,:)=field_A_glo(ibegin+1:iend+1,jbegin+1:jend+1,:)
+
+
+!!! Context ATMOSPHERE
+
+  CALL xios_context_initialize("atmosphere",comm)
+
+  CALL xios_get_handle("atmosphere",ctx_hdl)
+  CALL xios_set_current_context(ctx_hdl)
+
+  CALL xios_define_calendar(type="Gregorian", &
+                            start_date=xios_date(2000, 01, 01, 00, 00, 00), &
+                            time_origin=xios_date(1999, 01, 01, 15, 00, 00))
+
+  CALL xios_set_axis_attr("axis_atm",n_glo=llm ,value=lval) ;
+
+
+  CALL xios_set_domain_attr("domain_atm",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj, type='curvilinear')
+  CALL xios_set_domain_attr("domain_atm",data_dim=2, data_ibegin=-1, data_ni=ni+2, data_jbegin=-2, data_nj=nj+4)
+  CALL xios_set_domain_attr("domain_atm",lonvalue_2D=lon,latvalue_2D=lat)
+
+  CALL xios_set_domain_attr("domain_atm_zoom",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj)
+  CALL xios_set_domain_attr("domain_atm_zoom",data_dim=2, data_ibegin=-1, data_ni=ni+2, data_jbegin=-2, data_nj=nj+4)
+  CALL xios_set_domain_attr("domain_atm_zoom",lonvalue_2D=lon,latvalue_2D=lat)
+
+
+!!! Activation du groupe field_definition
+
+  CALL xios_set_fieldgroup_attr("field_definition",enabled=.TRUE.)
+
+!!! Cration d un nouveau champ
+
+  CALL xios_get_handle("field_definition",fieldgroup_hdl)
+  CALL xios_add_child(fieldgroup_hdl,field_hdl,"field_B_atm")
+
+!!! Heritage des attributs d un autre champ
+
+  CALL xios_set_attr(field_hdl,field_ref="field_A_atm_zoom",name="field_B_atm")
+
+!!! Affectation de ce nouveau champ au fichier avec un nouveau nom
+
+  CALL xios_get_handle("output_atmosphere",file_hdl)
+  CALL xios_add_child(file_hdl,field_hdl)
+  CALL xios_set_attr(field_hdl,field_ref="field_B_atm",name="field_C_atm")
+
+!!! Definition du timestep
+
+  dtime%second=3600
+  CALL xios_set_timestep(timestep=dtime)
+
+!!! Recupration des valeurs des longitudes et de taille des domaines locaux (pour test de fonctionnalit)
+
+  ni=0 ; lonvalue(:,:)=0
+  CALL xios_get_domain_attr("domain_atm",ni=ni,lonvalue_2D=lonvalue)
+
+  !PRINT *,"ni",ni
+  !PRINT *,"lonvalue",lonvalue;
+
+!!! Fin de la definition du contexte
+
+  CALL xios_close_context_definition()
+
+   print *, "xios_close_context_definition(atmosphere)"
+
+!!! Test des valeurs des champs/fichiers
+
+  !!! Attribut defini ?
+
+  CALL xios_is_defined_field_attr("field_A_atm",enabled=ok)
+  PRINT *,"field_A_atm : attribute enabled is defined ? ",ok
+
+  !!! Recuperer la valeur d un attribut
+
+  CALL xios_get_field_attr("field_A_atm",name=crname)
+  PRINT *,"field_A_atm : attribute name is : ",TRIM(crname)
+
+  !!! Champ actif (besoin de fournir la valeur) ?
+
+    PRINT*,"field field_A_atm is active ? ",xios_field_is_active("field_A_atm")
+
+  !!! Champ defini ?
+
+    PRINT*,"field field_A_atm is valid ?",xios_is_valid_field("field_A_atm")
+
+
+!###########################################################################
+! Contexte SRF
+!###########################################################################
+
+!!! Initialisation des coordonnes globales et locales pour la grille indexee (1 point sur 2)
+
+    nb_pt=ni*nj/2
+    ALLOCATE(kindex(nb_pt),field_A_srf(nb_pt,llm))
+    DO i=1,nb_pt
+      kindex(i)=2*i-1
+    ENDDO
+    field_A_srf(1:nb_pt,:)=RESHAPE(field_A_glo(ibegin+1:iend+1:2,jbegin+1:jend+1,:),(/ nb_pt,llm /))
+
+  CALL xios_context_initialize("surface",comm)
+
+  CALL xios_get_handle("surface",ctx_hdl)
+  CALL xios_set_current_context(ctx_hdl)
+
+  CALL xios_define_calendar(type="Gregorian", &
+                            start_date=xios_date(2000, 01, 01, 00, 00, 00), &
+                            time_origin=xios_date(1999, 01, 01, 15, 00, 00))
+
+  CALL xios_set_axis_attr("axis_srf",n_glo=llm ,value=lval)
+  CALL xios_set_domain_attr("domain_srf",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj, type='curvilinear')
+  CALL xios_set_domain_attr("domain_srf",data_dim=1, data_ibegin=0, data_ni=nb_pt)
+  CALL xios_set_domain_attr("domain_srf",data_i_index=kindex)
+  CALL xios_set_domain_attr("domain_srf",lonvalue_2D=lon,latvalue_2D=lat)
+
+!!! Cration d un nouveau champ
+
+  CALL xios_get_handle("field_definition",fieldgroup_hdl)
+  CALL xios_add_child(fieldgroup_hdl,field_hdl,"field_B_srf")
+
+!!! Heritage des attributs d un autre champ
+
+  CALL xios_set_attr(field_hdl,field_ref="field_A_srf",name="field_B_srf")
+
+!!! Affectation de ce nouveau champ au fichier avec un nouveau nom
+
+  CALL xios_get_handle("output_surface",file_hdl)
+  CALL xios_add_child(file_hdl,field_hdl)
+  CALL xios_set_attr(field_hdl,field_ref="field_B_srf",name="field_C_srf")
+
+!!! Definition du timestep
+
+  dtime%second=1800
+  CALL xios_set_timestep(timestep=dtime)
+
+!!! Recupration des valeurs des longitudes et de taille des domaines locaux (pour test de fonctionnalit)
+
+  ni=0 ; lonvalue(:,:)=0
+  CALL xios_get_domain_attr("domain_srf",ni=ni,lonvalue_2D=lonvalue)
+
+  !PRINT *,"ni",ni
+  !PRINT *,"lonvalue",lonvalue ;
+
+!!! Fin de la definition du contexte SRF
+
+  CALL xios_close_context_definition()
+
+  print *, "xios_close_context_definition(surface)" 
+
+
+!####################################################################################
+!!! Boucle temporelle
+!####################################################################################
+
+    DO ts=1,24*10
+    !DO ts=1,24
+
+      CALL xios_get_handle("atmosphere",ctx_hdl)
+      CALL xios_set_current_context(ctx_hdl)
+
+!!! Mise a jour du pas de temps
+
+      CALL xios_update_calendar(ts)
+
+!!! On donne la valeur du champ atm
+
+      CALL xios_send_field("field_A_atm",field_A_atm)
+
+!!! On change de contexte
+
+      CALL xios_get_handle("surface",ctx_hdl)
+      CALL xios_set_current_context(ctx_hdl)
+
+!!! Mise a jour du pas de temps
+
+      CALL xios_update_calendar(ts)
+
+!!! On donne la valeur du champ srf
+
+      CALL xios_send_field("field_A_srf",field_A_srf)
+
+      CALL wait_us(5000) ;
+
+
+    ENDDO
+
+     print *, "end temporal loop"
+
+!####################################################################################
+!!! Finalisation
+!####################################################################################
+
+!!! Fin des contextes
+
+
+    CALL xios_get_handle("surface",ctx_hdl) 
+
+    CALL xios_set_current_context(ctx_hdl)
+
+    CALL xios_context_finalize()
+
+    print *, "xios_context_finalize(surface)" 
+
+     CALL xios_get_handle("atmosphere",ctx_hdl)
+
+     CALL xios_set_current_context(ctx_hdl)
+
+     CALL xios_context_finalize()
+
+     print *, "xios_context_finalize(atmosphere)"
+
+    
+
+!!! Fin de XIOS
+
+    
+
+    CALL xios_finalize()
+
+    DEALLOCATE(lon, lat, field_A_atm, lonvalue)
+    DEALLOCATE(kindex, field_A_srf)
+
+     print *, "Client : xios_finalize "
+
+    !$omp master
+    CALL MPI_COMM_FREE(comm, ierr)
+    !$omp end master
+
+    !$omp barrier
+
+    print*, "MPI_COMM_FREE OK", rank, size_loc
+
+  !$omp end parallel
+
+  else
+
+    CALL xios_init_server
+    print *, "Server : xios_finalize "
+  
+    endif
+
+
+    CALL MPI_FINALIZE(ierr)
+
+  END PROGRAM test_complete_omp
+
+
+
+
+
+
Index: /XIOS/dev/branch_yushan/src/test/test_omp.f90
===================================================================
--- /XIOS/dev/branch_yushan/src/test/test_omp.f90	(revision 1108)
+++ /XIOS/dev/branch_yushan/src/test/test_omp.f90	(revision 1109)
@@ -44,5 +44,6 @@
 
     CALL MPI_COMM_RANK(MPI_COMM_WORLD,rank,ierr)
-    if(rank < 2) then
+    CALL MPI_COMM_SIZE(MPI_COMM_WORLD,size,ierr)
+    if(rank < size-1) then
 
     !$omp parallel default(private)
@@ -100,13 +101,13 @@
     CALL xios_set_domain_attr("domain_A",lonvalue_2D=lon,latvalue_2D=lat)
     CALL xios_set_fieldgroup_attr("field_definition",enabled=.TRUE.)
-!     print*, "test block OK", rank, size
+     print*, "test block OK", rank, size
 
-!   CALL xios_get_handle("field_definition",fieldgroup_hdl)
-!   CALL xios_add_child(fieldgroup_hdl,field_hdl,"field_B")
-!   CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_B")
+    CALL xios_get_handle("field_definition",fieldgroup_hdl)
+    CALL xios_add_child(fieldgroup_hdl,field_hdl,"field_B")
+    CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_B")
 
-!   CALL xios_get_handle("output",file_hdl)
-!   CALL xios_add_child(file_hdl,field_hdl)
-!   CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_C")
+    CALL xios_get_handle("output",file_hdl)
+    CALL xios_add_child(file_hdl,field_hdl)
+    CALL xios_set_attr(field_hdl,field_ref="field_A_zoom",name="field_C")
 
     dtime%second = 3600
@@ -158,4 +159,8 @@
     print*, "xios_context_finalize OK", rank, size
 
+    CALL xios_finalize()
+    print*, "xios finalize OK", rank, size
+
+    DEALLOCATE(lon, lat, field_A, lonvalue)
     !$omp master 
     !call MPI_Barrier(comm)
@@ -167,8 +172,4 @@
      print*, "MPI_COMM_FREE OK", rank, size
 
-    CALL xios_finalize()
-    print*, "xios finalize OK", rank, size
-
-    DEALLOCATE(lon, lat, field_A, lonvalue)
 
 
Index: /XIOS/dev/branch_yushan/src/transformation/Functions/reduction.cpp
===================================================================
--- /XIOS/dev/branch_yushan/src/transformation/Functions/reduction.cpp	(revision 1108)
+++ /XIOS/dev/branch_yushan/src/transformation/Functions/reduction.cpp	(revision 1109)
@@ -12,51 +12,52 @@
 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();
-// }
-
-bool CReductionAlgorithm::initReductionOperation(std::map<StdString,EReductionType>* m)
+bool CReductionAlgorithm::initReductionOperation(std::map<StdString,EReductionType>& m)
 {
-  if(m==NULL) m=new std::map<StdString,EReductionType>();
   // So so stupid way to intialize operation but it works ...
-  (*m)["sum"] = TRANS_REDUCE_SUM;
+  m["sum"] = TRANS_REDUCE_SUM;
   CSumReductionAlgorithm::registerTrans();
 
-  (*m)["min"] = TRANS_REDUCE_MIN;
+  m["min"] = TRANS_REDUCE_MIN;
   CMinReductionAlgorithm::registerTrans();
 
-  (*m)["max"] = TRANS_REDUCE_MAX;
+  m["max"] = TRANS_REDUCE_MAX;
   CMaxReductionAlgorithm::registerTrans();
 
-  (*m)["extract"] = TRANS_REDUCE_EXTRACT;
+  m["extract"] = TRANS_REDUCE_EXTRACT;
   CExtractReductionAlgorithm::registerTrans();
 
-  (*m)["average"] = TRANS_REDUCE_AVERAGE;
+  m["average"] = TRANS_REDUCE_AVERAGE;
+  CAverageReductionAlgorithm::registerTrans();
+}
+
+
+bool CReductionAlgorithm::initReductionOperation()
+{
+  if(CReductionAlgorithm::ReductionOperations_ptr == NULL) 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;
+  CSumReductionAlgorithm::registerTrans();
+
+  (*CReductionAlgorithm::ReductionOperations_ptr)["min"] = TRANS_REDUCE_MIN;
+  CMinReductionAlgorithm::registerTrans();
+
+  (*CReductionAlgorithm::ReductionOperations_ptr)["max"] = TRANS_REDUCE_MAX;
+  CMaxReductionAlgorithm::registerTrans();
+
+  (*CReductionAlgorithm::ReductionOperations_ptr)["extract"] = TRANS_REDUCE_EXTRACT;
+  CExtractReductionAlgorithm::registerTrans();
+
+  (*CReductionAlgorithm::ReductionOperations_ptr)["average"] = TRANS_REDUCE_AVERAGE;
   CAverageReductionAlgorithm::registerTrans();
 }
 
 //bool CReductionAlgorithm::_dummyInit = CReductionAlgorithm::initReductionOperation(CReductionAlgorithm::ReductionOperations);
-bool CReductionAlgorithm::_dummyInit = CReductionAlgorithm::initReductionOperation(CReductionAlgorithm::ReductionOperations_ptr);
+bool CReductionAlgorithm::_dummyInit = CReductionAlgorithm::initReductionOperation();
 
 CReductionAlgorithm* CReductionAlgorithm::createOperation(EReductionType reduceType)
 {
   int reduceTypeInt = reduceType;
-  if (0 == reductionCreationCallBacks_)
-    reductionCreationCallBacks_ = new CallBackMap();
+  //if (0 == reductionCreationCallBacks_)
+  //  reductionCreationCallBacks_ = new CallBackMap();
 
   CallBackMap::const_iterator it = (*reductionCreationCallBacks_).find(reduceType);
Index: /XIOS/dev/branch_yushan/src/transformation/Functions/reduction.hpp
===================================================================
--- /XIOS/dev/branch_yushan/src/transformation/Functions/reduction.hpp	(revision 1108)
+++ /XIOS/dev/branch_yushan/src/transformation/Functions/reduction.hpp	(revision 1109)
@@ -67,6 +67,6 @@
 
 protected:
-  //static bool initReductionOperation(std::map<StdString,EReductionType>& m);
-  static bool initReductionOperation(std::map<StdString,EReductionType>* m);
+  static bool initReductionOperation(std::map<StdString,EReductionType>& m);
+  static bool initReductionOperation();
   static bool _dummyInit;
   #pragma omp threadprivate(_dummyInit)
