Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/distributed_view.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/distributed_view.cpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/distributed_view.cpp	(revision 2267)
@@ -6,5 +6,5 @@
 {
 
-  CDistributedView::CDistributedView(CDistributedElement* parent, CElementView::type, const std::map<int,CArray<int,1>>& indexView) 
+  CDistributedView::CDistributedView(shared_ptr<CDistributedElement> parent, CElementView::type, const std::map<int,CArray<int,1>>& indexView) 
                                     : globalIndex_(parent->globalIndex_), globalSize_(parent->globalSize_), localSize_(parent->localSize_) 
   {
@@ -16,5 +16,5 @@
   }
 
-  CDistributedView::CDistributedView(CDistributedElement* parent, CElementView::type, const std::map<int,CArray<bool,1>>& maskView) 
+  CDistributedView::CDistributedView(shared_ptr<CDistributedElement> parent, CElementView::type, const std::map<int,CArray<bool,1>>& maskView) 
                                     : globalIndex_(parent->globalIndex_), globalSize_(parent->globalSize_), localSize_(parent->localSize_) 
   {
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/distributed_view.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/distributed_view.hpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/distributed_view.hpp	(revision 2267)
@@ -14,6 +14,6 @@
     public:
 
-      CDistributedView(CDistributedElement* parent, CElementView::type type, const std::map<int,CArray<int,1>>& indexView) ;
-      CDistributedView(CDistributedElement* parent, CElementView::type type, const std::map<int,CArray<bool,1>>& maskView) ;
+      CDistributedView(shared_ptr<CDistributedElement> parent, CElementView::type type, const std::map<int,CArray<int,1>>& indexView) ;
+      CDistributedView(shared_ptr<CDistributedElement> parent, CElementView::type type, const std::map<int,CArray<bool,1>>& maskView) ;
       
       std::map<int,CArray<int,1>>&  getIndex(void) { return index_ ;}
@@ -48,5 +48,5 @@
     }   
 
-    void getGlobalIndex(int rank, vector<size_t>& globalIndex, size_t sliceIndex, size_t* sliceSize, CDistributedView** view, int pos)
+    void getGlobalIndex(int rank, vector<size_t>& globalIndex, size_t sliceIndex, size_t* sliceSize, shared_ptr<CDistributedView>* view, int pos)
     {
       // using map can be expensive, find an otherway later
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/element.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/element.cpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/element.cpp	(revision 2267)
@@ -28,10 +28,10 @@
   void CDistributedElement::addView(CElementView::type type, std::map<int, CArray<int,1>>& indexView)
   {
-    views_[type] = new CDistributedView(this, type, indexView) ;
+    views_[type] = make_shared<CDistributedView>(shared_from_this(), type, indexView) ;
   } 
 
   void CDistributedElement::addView(CElementView::type type, std::map<int, CArray<bool,1>>& maskView)
   {
-    views_[type] = new CDistributedView(this, type, maskView) ;
+    views_[type] = make_shared<CDistributedView>(shared_from_this(), type, maskView) ;
   } 
 
@@ -120,10 +120,10 @@
   void CLocalElement::addView(CElementView::type type, CArray<int,1>& indexView)
   {
-    views_[type] = new CLocalView(this, type, indexView) ;
+    views_[type] = make_shared<CLocalView>(static_pointer_cast<CLocalElement>(shared_from_this()), type, indexView) ;
   } 
 
   void CLocalElement::addView(CElementView::type type, CArray<bool,1>& maskView)
   {
-    views_[type] = new CLocalView(this, type, maskView) ;
+    views_[type] = make_shared<CLocalView>(static_pointer_cast<CLocalElement>(shared_from_this()), type, maskView) ;
   } 
 
@@ -137,5 +137,11 @@
   } 
 
-  CLocalConnector* CLocalElement::getConnector(CElementView::type srcType, CElementView::type dstType) 
+  shared_ptr<CLocalView> CLocalElement::getView(CElementView::type type) 
+  { 
+    if (views_[(size_t)type]==nullptr) { ERROR("CLocalElement::getView(CElementView::type type)",<<"View is not initialized");} 
+    else return static_pointer_cast<CLocalView>(views_[(size_t)type]) ;
+  }
+
+  shared_ptr<CLocalConnector> CLocalElement::getConnector(CElementView::type srcType, CElementView::type dstType) 
   { 
     auto newPair = pair<CElementView::type,CElementView::type>(srcType,dstType);
@@ -143,5 +149,5 @@
     if (it==connectors_.end()) 
     {
-      auto insertPair=pair<pair<CElementView::type,CElementView::type>, CLocalConnector*>(newPair,new CLocalConnector(getView(srcType),getView(dstType))) ;
+      auto insertPair=pair<pair<CElementView::type,CElementView::type>, shared_ptr<CLocalConnector>>(newPair,make_shared<CLocalConnector>(getView(srcType),getView(dstType))) ;
       it=connectors_.insert(insertPair).first ;
       it->second->computeConnector() ;
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/element.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/element.hpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/element.hpp	(revision 2267)
@@ -15,5 +15,5 @@
   class CLocalConnector ;
 
-  class CDistributedElement
+  class CDistributedElement : public std::enable_shared_from_this<CDistributedElement>
   {
 
@@ -22,5 +22,5 @@
     std::map<int, int> localSize_ ;
     size_t globalSize_ ;
-    std::vector<CDistributedView*> views_= std::vector<CDistributedView*>(CElementView::numViewType_) ;
+    std::vector<shared_ptr<CDistributedView>> views_= std::vector<shared_ptr<CDistributedView>>(CElementView::numViewType_) ;
     CDistributedElement(void) {} ;
     
@@ -34,5 +34,5 @@
     std::map<int, CArray<size_t,1>>& getGlobalIndex(void) { return globalIndex_;}
     
-    CDistributedView* getView(CElementView::type type) 
+    shared_ptr<CDistributedView> getView(CElementView::type type) 
     { 
       if (views_[(size_t)type]==nullptr) { ERROR("CDistributedElement::getView(CElementView::type type)",<<"View is not initialized");} 
@@ -51,5 +51,5 @@
   {
     // keep local connector inside    
-      std::map<pair<CElementView::type,CElementView::type>, CLocalConnector*> connectors_  ;
+      std::map<pair<CElementView::type,CElementView::type>, shared_ptr<CLocalConnector>> connectors_  ;
  
     public: 
@@ -61,11 +61,12 @@
       void addView(CElementView::type type, CArray<bool,1>& maskView) ;
       void addFullView(void) ;
-      CLocalView* getView(CElementView::type type) 
-      { 
+      
+      shared_ptr<CLocalView> getView(CElementView::type type) ;
+ /*     { 
         if (views_[(size_t)type]==nullptr) { ERROR("CLocalElement::getView(CElementView::type type)",<<"View is not initialized");} 
-        else return (CLocalView*) views_[(size_t)type] ; 
+        else return static_pointer_cast<CLocalView>(views_[(size_t)type]) ;
       }
-      
-      CLocalConnector* getConnector(CElementView::type srcType, CElementView::type dstType) ;
+*/      
+      shared_ptr<CLocalConnector> getConnector(CElementView::type srcType, CElementView::type dstType) ;
 
     private :
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/gatherer_connector.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/gatherer_connector.hpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/gatherer_connector.hpp	(revision 2267)
@@ -17,6 +17,6 @@
   {
     private:
-      CDistributedView* srcView_;
-      CLocalView* dstView_;
+      shared_ptr<CDistributedView> srcView_;
+      shared_ptr<CLocalView> dstView_;
       map<int, vector<int>> connector_ ;
       map<int, vector<bool>> mask_ ;  // mask is on src view
@@ -25,5 +25,5 @@
 
     public:
-      CGathererConnector(CDistributedView* srcView, CLocalView* dstView) : srcView_(srcView), dstView_(dstView) {} ;
+      CGathererConnector(shared_ptr<CDistributedView> srcView, shared_ptr<CLocalView> dstView) : srcView_(srcView), dstView_(dstView) {} ;
       void computeConnector(void) ;
       
@@ -75,5 +75,5 @@
 
       template<typename T>
-      void transfer(int rank,  CGathererConnector** connectors, int nConnectors, const T* input, T* output)
+      void transfer(int rank,  shared_ptr<CGathererConnector>* connectors, int nConnectors, const T* input, T* output)
       {
         auto& connector = connector_[rank] ; // probably costly, find a better way to avoid the map
@@ -111,5 +111,5 @@
 
       // hook for transfering mask in grid connector, maybe find an other way to doing that...
-      void transfer_or(int rank,  CGathererConnector** connectors, int nConnectors, const bool* input, bool* output)
+      void transfer_or(int rank,  shared_ptr<CGathererConnector>* connectors, int nConnectors, const bool* input, bool* output)
       {
         auto& connector = connector_[rank] ; // probably costly, find a better way to avoid the map
@@ -210,8 +210,8 @@
       }
 
-    int getSrcSliceSize(int rank, CGathererConnector** connectors, int nConnectors) 
+    int getSrcSliceSize(int rank, shared_ptr<CGathererConnector>* connectors, int nConnectors) 
     { if (nConnectors==0) return srcSize_[rank] ; else return srcSize_[rank] * (*(connectors-1))->getSrcSliceSize(rank, connectors-1,nConnectors-1) ; }
 
-    int getDstSliceSize(CGathererConnector** connectors, int nConnectors) 
+    int getDstSliceSize(shared_ptr<CGathererConnector>* connectors, int nConnectors) 
     { if (nConnectors==0) return dstSize_ ; else return dstSize_ * (*(connectors-1))->getDstSliceSize(connectors-1,nConnectors-1) ; }
   
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_client_server_remote_connector.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_client_server_remote_connector.cpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_client_server_remote_connector.cpp	(revision 2267)
@@ -10,5 +10,6 @@
    * \param remoteSize Size of the remote communicator
    */ 
-  CGridClientServerRemoteConnector::CGridClientServerRemoteConnector(vector<CLocalView*>& srcFullView, vector<CLocalView*>& srcWorkflowView, vector<CDistributedView*>& dstView, MPI_Comm localComm, int remoteSize) 
+  CGridClientServerRemoteConnector::CGridClientServerRemoteConnector( vector<shared_ptr<CLocalView> >& srcFullView, vector<shared_ptr<CLocalView>>& srcWorkflowView, 
+                                                                      vector<shared_ptr<CDistributedView>>& dstView, MPI_Comm localComm, int remoteSize) 
                        : CGridRemoteConnector(srcFullView, dstView, localComm, remoteSize) , srcWorkflowView_(srcWorkflowView)
   {}
@@ -17,14 +18,14 @@
   void CGridClientServerRemoteConnector::computeConnector(void)
   {
-    CGridRemoteConnector workflowRemoteConnector(srcWorkflowView_,dstView_,localComm_,remoteSize_) ;
-    workflowRemoteConnector.computeConnector() ;
+    auto workflowRemoteConnector=make_shared<CGridRemoteConnector>(srcWorkflowView_,dstView_,localComm_,remoteSize_) ;
+    workflowRemoteConnector->computeConnector() ;
     computeViewDistribution() ;
     
-    for(int i=0;i<srcView_.size();i++) isSrcViewDistributed_[i] =  isSrcViewDistributed_[i] || workflowRemoteConnector.getIsSrcViewDistributed()[i]  ;
+    for(int i=0;i<srcView_.size();i++) isSrcViewDistributed_[i] =  isSrcViewDistributed_[i] || workflowRemoteConnector->getIsSrcViewDistributed()[i]  ;
     computeConnectorMethods() ;
     computeRedondantRanks() ;
 
     for(auto& rank : rankToRemove_)
-      if (workflowRemoteConnector.getRankToRemove().count(rank)!=0)
+      if (workflowRemoteConnector->getRankToRemove().count(rank)!=0)
         for(auto& element : elements_) element.erase(rank) ;
   }
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_client_server_remote_connector.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_client_server_remote_connector.hpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_client_server_remote_connector.hpp	(revision 2267)
@@ -12,7 +12,7 @@
     public:
 
-      CGridClientServerRemoteConnector(vector<CLocalView*>& srcView, vector<CLocalView*>& worflowSrcView, vector<CDistributedView*>& dstView, MPI_Comm localComm, int remoteSize) ;
+      CGridClientServerRemoteConnector(vector<shared_ptr<CLocalView>>& srcView, vector<shared_ptr<CLocalView>>& worflowSrcView, vector<shared_ptr<CDistributedView>>& dstView, MPI_Comm localComm, int remoteSize) ;
       void computeConnector(void) ;
-      vector<CLocalView*> srcWorkflowView_ ;   
+      vector<shared_ptr<CLocalView>> srcWorkflowView_ ;   
   } ;
 
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_elements.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_elements.cpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_elements.cpp	(revision 2267)
@@ -6,11 +6,11 @@
 {
 
-  CGridLocalView* CGridLocalElements::getView(CElementView::type type)
+  shared_ptr<CGridLocalView> CGridLocalElements::getView(CElementView::type type)
   { 
-    if (views_[type]==nullptr) views_[type] = new CGridLocalView(this, type) ;
+    if (views_[type]==nullptr) views_[type] = make_shared<CGridLocalView>(shared_from_this(), type) ;
     return views_[type] ;
   }
   
-  CGridLocalConnector* CGridLocalElements::getConnector(CElementView::type srcType, CElementView::type dstType, bool withMask)
+  shared_ptr<CGridLocalConnector> CGridLocalElements::getConnector(CElementView::type srcType, CElementView::type dstType, bool withMask)
   {
     auto newPair = pair<CElementView::type,CElementView::type>(srcType,dstType);
@@ -18,5 +18,5 @@
     if (it==connectors_.end()) 
     {
-      auto insertPair=pair<pair<CElementView::type,CElementView::type>, CGridLocalConnector*>(newPair,new CGridLocalConnector(this, srcType, dstType, withMask)) ;
+      auto insertPair=pair<pair<CElementView::type,CElementView::type>, shared_ptr<CGridLocalConnector>>(newPair, make_shared<CGridLocalConnector>(shared_from_this(), srcType, dstType, withMask)) ;
       it=connectors_.insert(insertPair).first ;
     }
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_elements.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_elements.hpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_elements.hpp	(revision 2267)
@@ -11,22 +11,22 @@
   class CGridLocalConnector ;
 
-  class CGridLocalElements  
+  class CGridLocalElements : public std::enable_shared_from_this<CGridLocalElements>
   {
     private:
-      std::vector<CLocalElement*> elements_ ;
-      std::vector<CGridLocalView*> views_= std::vector<CGridLocalView*>(CElementView::numViewType_) ;
-      std::map<pair<CElementView::type,CElementView::type>, CGridLocalConnector*> connectors_ ;
+      std::vector<shared_ptr<CLocalElement>> elements_ ;
+      std::vector<shared_ptr<CGridLocalView>> views_= std::vector<shared_ptr<CGridLocalView>>(CElementView::numViewType_) ;
+      std::map<pair<CElementView::type,CElementView::type>, shared_ptr<CGridLocalConnector>> connectors_ ;
       vector<bool> localMask_ ;
   
     public:
-      CGridLocalElements(vector<CLocalElement*> elements) : elements_(elements) {}
-      CGridLocalElements(vector<CLocalElement*> elements, vector<bool>& localMask) : elements_(elements), localMask_(localMask) {}
+      CGridLocalElements(vector<shared_ptr<CLocalElement> > elements) : elements_(elements) {}
+      CGridLocalElements(vector<shared_ptr<CLocalElement>> elements, vector<bool>& localMask) : elements_(elements), localMask_(localMask) {}
 
       bool hasLocalMask() { return !localMask_.empty() ;}
       vector<bool>& getLocalMask(void) { return localMask_ ;}
 
-      std::vector<CLocalElement*>& getElements(void) { return elements_ ; }
-      CGridLocalView* getView(CElementView::type type) ;
-      CGridLocalConnector* getConnector(CElementView::type srcType, CElementView::type dstType, bool withMask=false) ;
+      std::vector<shared_ptr<CLocalElement>>& getElements(void) { return elements_ ; }
+      shared_ptr<CGridLocalView> getView(CElementView::type type) ;
+      shared_ptr<CGridLocalConnector> getConnector(CElementView::type srcType, CElementView::type dstType, bool withMask=false) ;
   } ;
 }
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_gatherer_connector.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_gatherer_connector.hpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_gatherer_connector.hpp	(revision 2267)
@@ -19,9 +19,9 @@
     private:
     
-      vector<CGathererConnector*> elementsConnector_ ;
+      vector<shared_ptr<CGathererConnector>> elementsConnector_ ;
       int dstSize_ ;
 
     public:
-      CGridGathererConnector(vector<CGathererConnector*> elementsConnector) : elementsConnector_(elementsConnector)
+      CGridGathererConnector(vector<shared_ptr<CGathererConnector>> elementsConnector) : elementsConnector_(elementsConnector)
       {
         dstSize_ = 1 ;
@@ -33,5 +33,5 @@
       {
         int n = elementsConnector_.size()-1 ;
-        CGathererConnector** connector = elementsConnector_.data() + n ;
+       shared_ptr<CGathererConnector>* connector = elementsConnector_.data() + n ;
         output.resize(dstSize_) ;
         for(auto& rankDataIn : input) 
@@ -45,5 +45,5 @@
       {
         int n = elementsConnector_.size()-1 ;
-        CGathererConnector** connector = elementsConnector_.data() + n ;
+        shared_ptr<CGathererConnector>* connector = elementsConnector_.data() + n ;
         output.resize(dstSize_) ;
         output = missingValue ;
@@ -93,5 +93,5 @@
       {
         int n = elementsConnector_.size()-1 ;
-        CGathererConnector** connector = elementsConnector_.data() + n ;
+        shared_ptr<CGathererConnector>* connector = elementsConnector_.data() + n ;
         output.resize(dstSize_) ;
         output = false ;
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_local_connector.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_local_connector.cpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_local_connector.cpp	(revision 2267)
@@ -8,5 +8,5 @@
 {
  
-  CGridLocalConnector::CGridLocalConnector(const std::vector<CLocalConnector*>& elementsConnector) : elementsConnector_(elementsConnector)
+  CGridLocalConnector::CGridLocalConnector(const std::vector<shared_ptr<CLocalConnector>>& elementsConnector) : elementsConnector_(elementsConnector)
   {
     srcSize_=1 ;
@@ -16,13 +16,13 @@
   } 
 
-  CGridLocalConnector::CGridLocalConnector(CGridLocalElements* parent, CElementView::type srcType, CElementView::type dstType, bool withMask)
+  CGridLocalConnector::CGridLocalConnector(shared_ptr<CGridLocalElements> parent, CElementView::type srcType, CElementView::type dstType, bool withMask)
   {
-    CGridLocalView* srcView=parent->getView(srcType) ;
-    CGridLocalView* dstView=parent->getView(dstType) ;
+    shared_ptr<CGridLocalView> srcView=parent->getView(srcType) ;
+    shared_ptr<CGridLocalView> dstView=parent->getView(dstType) ;
 
-    vector<CLocalView*> srcViews = srcView->getViews() ; 
-    vector<CLocalView*> dstViews = dstView->getViews() ;
+    vector<shared_ptr<CLocalView>> srcViews = srcView->getViews() ; 
+    vector<shared_ptr<CLocalView>> dstViews = dstView->getViews() ;
     
-    vector<CLocalElement*>& elements = parent->getElements();
+    vector<shared_ptr<CLocalElement>>& elements = parent->getElements();
     for(auto element : elements) elementsConnector_.push_back(element->getConnector(srcType, dstType)) ;
     srcSize_=1 ;
@@ -33,15 +33,15 @@
     if (parent->hasLocalMask() && withMask)
     {
-      vector<CLocalConnector*> elementsConnector ;
+      vector<shared_ptr<CLocalConnector>> elementsConnector ;
       for(auto element : elements) elementsConnector.push_back(element->getConnector(CElementView::FULL, dstType)) ;
-      CGridLocalConnector localToDst(elementsConnector) ;
-      CArray<bool,1> maskIn(localToDst.getSrcSize()) ;
-      CArray<bool,1> maskOut1(localToDst.getDstSize()) ;
-      CArray<bool,1> maskOut2(localToDst.getDstSize()) ;
+      auto localToDst=make_shared<CGridLocalConnector>(elementsConnector) ;
+      CArray<bool,1> maskIn(localToDst->getSrcSize()) ;
+      CArray<bool,1> maskOut1(localToDst->getDstSize()) ;
+      CArray<bool,1> maskOut2(localToDst->getDstSize()) ;
       maskIn=true ;
-      localToDst.transfer(maskIn,maskOut1,false) ;
+      localToDst->transfer(maskIn,maskOut1,false) ;
       auto& localMask = parent->getLocalMask() ;
       for(int i=0 ; i < maskIn.numElements() ; i++) maskIn(i)=localMask[i] ;
-      localToDst.transfer(maskIn,maskOut2,false) ;
+      localToDst->transfer(maskIn,maskOut2,false) ;
       mask_.assign(dstSize_,true) ;
       for(int i=0;i<dstSize_;i++) if (maskOut1(i)==true && maskOut2(i)==false) mask_[i]=false ;
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_local_connector.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_local_connector.hpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_local_connector.hpp	(revision 2267)
@@ -17,5 +17,5 @@
 
     private:  
-      std::vector<CLocalConnector*> elementsConnector_ ;
+      std::vector<shared_ptr<CLocalConnector>> elementsConnector_ ;
       int srcSize_ ;
       int dstSize_ ;
@@ -24,6 +24,6 @@
     public:
       
-      CGridLocalConnector(const std::vector<CLocalConnector*>& elementsConnector)  ;
-      CGridLocalConnector(CGridLocalElements* parent, CElementView::type srcType, CElementView::type dstType, bool withMask=false) ;
+      CGridLocalConnector(const std::vector<shared_ptr<CLocalConnector>>& elementsConnector)  ;
+      CGridLocalConnector(shared_ptr<CGridLocalElements> parent, CElementView::type srcType, CElementView::type dstType, bool withMask=false) ;
       int getSrcSize(void) { return srcSize_ ;}
       int getDstSize(void) { return dstSize_ ;}
@@ -37,5 +37,5 @@
       {
         int n = elementsConnector_.size()-1 ;
-        CLocalConnector** connector = elementsConnector_.data() + n ;
+        shared_ptr<CLocalConnector>* connector = elementsConnector_.data() + n ;
         elementsConnector_[n]->transfer(connector, n, input.dataFirst(), output.dataFirst()) ;
       }
@@ -45,5 +45,5 @@
       {
         int n = elementsConnector_.size()-1 ;
-        CLocalConnector** connector = elementsConnector_.data() + n ;
+        shared_ptr<CLocalConnector>* connector = elementsConnector_.data() + n ;
         elementsConnector_[n]->transfer(connector, n, input.dataFirst(), output.dataFirst(), missingValue) ;
         if (!computeMask_done_) computeMask() ;
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_local_view.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_local_view.cpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_local_view.cpp	(revision 2267)
@@ -4,5 +4,5 @@
 namespace xios
 {
-  CGridLocalView::CGridLocalView(CGridLocalElements* parent, CElementView::type type) : localMask_(parent->getLocalMask())
+  CGridLocalView::CGridLocalView(shared_ptr<CGridLocalElements> parent, CElementView::type type) : localMask_(parent->getLocalMask())
   {
     size_ = 1 ;
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_local_view.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_local_view.hpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_local_view.hpp	(revision 2267)
@@ -12,12 +12,12 @@
   {
     private:
-      std::vector<CLocalView*> views_ ;
+      std::vector<shared_ptr<CLocalView>> views_ ;
       std::vector<bool>& localMask_ ;
       int size_ ;
     
     public:
-      CGridLocalView(CGridLocalElements* parent, CElementView::type type) ;
-      std::vector<CLocalView*>& getViews(void) {return views_ ;}
-      CLocalView* getView(int i) {return views_[i] ;}
+      CGridLocalView(shared_ptr<CGridLocalElements> parent, CElementView::type type) ;
+      std::vector<shared_ptr<CLocalView>>& getViews(void) {return views_ ;}
+      shared_ptr<CLocalView> getView(int i) {return views_[i] ;}
       int getSize() { return size_ ;}
   } ;
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_mask_connector.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_mask_connector.hpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_mask_connector.hpp	(revision 2267)
@@ -15,5 +15,5 @@
     public:
 
-      CGridMaskConnector(vector<CLocalView*>& views) : views_(views) {}
+      CGridMaskConnector(vector<shared_ptr<CLocalView>>& views) : views_(views) {}
       void computeConnector(CArray<bool,1>& mask) ;
      
@@ -22,5 +22,5 @@
     
     private:
-      vector<CLocalView*> views_ ;
+      vector<shared_ptr<CLocalView>> views_ ;
       vector<CArray<bool,1>> elementsMask_ ; 
 
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_remote_connector.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_remote_connector.cpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_remote_connector.cpp	(revision 2267)
@@ -15,5 +15,5 @@
    * \param remoteSize Size of the remote communicator
    */ 
-  CGridRemoteConnector::CGridRemoteConnector(vector<CLocalView*>& srcView, vector<CDistributedView*>& dstView, MPI_Comm localComm, int remoteSize) 
+  CGridRemoteConnector::CGridRemoteConnector(vector<shared_ptr<CLocalView>>& srcView, vector<shared_ptr<CDistributedView>>& dstView, MPI_Comm localComm, int remoteSize) 
                        : srcView_(srcView), dstView_(dstView), localComm_(localComm), remoteSize_(remoteSize) 
   {}
@@ -26,8 +26,8 @@
    * \param remoteSize Size of the remote communicator
    */ 
-  CGridRemoteConnector::CGridRemoteConnector(vector<CLocalView*>& srcView, vector<CLocalView*>& dstView, MPI_Comm localComm, int remoteSize) 
+  CGridRemoteConnector::CGridRemoteConnector(vector<shared_ptr<CLocalView>>& srcView, vector< shared_ptr<CLocalView> >& dstView, MPI_Comm localComm, int remoteSize) 
                        : srcView_(srcView), localComm_(localComm), remoteSize_(remoteSize) 
   {
-    for(auto& it : dstView) dstView_.push_back((CDistributedView*) it) ; 
+    for(auto& it : dstView) dstView_.push_back((shared_ptr<CDistributedView>) it) ; 
   }
 
@@ -135,6 +135,6 @@
   void CGridRemoteConnector::computeConnectorMethods(void)
   {
-    vector<CLocalView*> srcView ;
-    vector<CDistributedView*> dstView ;
+    vector<shared_ptr<CLocalView>> srcView ;
+    vector<shared_ptr<CDistributedView>> dstView ;
     vector<int> indElements ;
     elements_.resize(srcView_.size()) ;
@@ -435,5 +435,5 @@
   *  \param indElements Index of the view making the correspondance between all views and views distributed (that are in input)
   */
-  void CGridRemoteConnector::computeGenericMethod(vector<CLocalView*>& srcView, vector<CDistributedView*>& dstView, vector<int>& indElements)
+  void CGridRemoteConnector::computeGenericMethod(vector<shared_ptr<CLocalView>>& srcView, vector<shared_ptr<CDistributedView>>& dstView, vector<int>& indElements)
   {
     // generic method, every element can be distributed
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_remote_connector.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_remote_connector.hpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_remote_connector.hpp	(revision 2267)
@@ -18,10 +18,10 @@
     public:
 
-      CGridRemoteConnector(vector<CLocalView*>& srcView, vector<CDistributedView*>& dstView, MPI_Comm localComm, int remoteSize) ;
-      CGridRemoteConnector(vector<CLocalView*>& srcView, vector<CLocalView*>& dstView, MPI_Comm localComm, int remoteSize) ;
+      CGridRemoteConnector(vector<shared_ptr<CLocalView>>& srcView, vector<shared_ptr<CDistributedView>>& dstView, MPI_Comm localComm, int remoteSize) ;
+      CGridRemoteConnector(vector<shared_ptr<CLocalView>>& srcView, vector<shared_ptr<CLocalView>>& dstView, MPI_Comm localComm, int remoteSize) ;
       void computeViewDistribution(void) ;
       void computeConnector(void) ;
       void computeConnectorMethods(void) ;
-      void computeGenericMethod(vector<CLocalView*>& srcView, vector<CDistributedView*>& dstView, vector<int>& indElements) ;
+      void computeGenericMethod(vector<shared_ptr<CLocalView>>& srcView, vector<shared_ptr<CDistributedView>>& dstView, vector<int>& indElements) ;
       void computeSrcDstNonDistributed(int i, map<int,bool>& ranks) ;
       void computeDstNonDistributed(int i, map<int,bool>& ranks) ;
@@ -39,5 +39,5 @@
      * It is feed at construction time
      */
-      vector<CLocalView*> srcView_ ;
+      vector<shared_ptr<CLocalView>> srcView_ ;
 
     /** 
@@ -45,5 +45,5 @@
      * It is feed at construction time
      */
-      vector<CDistributedView*> dstView_ ;
+      vector<shared_ptr<CDistributedView>> dstView_ ;
 
     /**  
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_scatterer_connector.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_scatterer_connector.hpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_scatterer_connector.hpp	(revision 2267)
@@ -18,5 +18,5 @@
   {
     private:
-     vector<CScattererConnector*> elementsConnector_ ;
+     vector<shared_ptr<CScattererConnector>> elementsConnector_ ;
      map<int,int> nbSenders_ ;
      vector<int> ranks_ ;
@@ -25,5 +25,5 @@
 
     public:
-      CGridScattererConnector(vector<CScattererConnector*> elementsConnector) : elementsConnector_(elementsConnector) 
+      CGridScattererConnector(vector<shared_ptr<CScattererConnector>> elementsConnector) : elementsConnector_(elementsConnector) 
       {
         nbSenders_ = elementsConnector[0]->getNbSenders() ;
@@ -48,5 +48,5 @@
       {
         int n = elementsConnector_.size()-1 ;
-        CScattererConnector** connector = elementsConnector_.data() + n ;
+        shared_ptr<CScattererConnector>* connector = elementsConnector_.data() + n ;
         for(int rank : ranks_) 
         {
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_transform_connector.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_transform_connector.cpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_transform_connector.cpp	(revision 2267)
@@ -16,8 +16,8 @@
     int nElements = srcViews_.size() ;
 
-    CGridRemoteConnector remoteConnector(srcViews_, remoteViews_, localComm_, commSize) ;  
-    remoteConnector.computeConnector() ;
+    auto remoteConnector = make_shared<CGridRemoteConnector>(srcViews_, remoteViews_, localComm_, commSize) ;  
+    remoteConnector->computeConnector() ;
     
-    vector<CDistributedElement*> sendElements(nElements) ;
+    vector<shared_ptr<CDistributedElement>> sendElements(nElements) ;
     scattererConnector_.resize(nElements) ;
     gathererConnector_.resize(nElements) ;
@@ -25,7 +25,7 @@
     for(int i=0;i<nElements;i++)
     {
-      sendElements[i] = new CDistributedElement(srcViews_[i]->getGlobalSize(), remoteConnector.getDistributedGlobalIndex(i)) ;
+      sendElements[i] = make_shared<CDistributedElement>(srcViews_[i]->getGlobalSize(), remoteConnector->getDistributedGlobalIndex(i)) ;
       sendElements[i]->addFullView() ;
-      scattererConnector_[i] = new CScattererConnector(srcViews_[i], sendElements[i]->getView(CElementView::FULL), localComm_, commSize) ;
+      scattererConnector_[i] = make_shared<CScattererConnector>(srcViews_[i], sendElements[i]->getView(CElementView::FULL), localComm_, commSize) ;
       scattererConnector_[i]->computeConnector() ;
       std::map<int, CArray<size_t,1>>& sendIndex = sendElements[i]->getGlobalIndex() ;
@@ -75,12 +75,12 @@
       // create gatherer connector
 
-      CDistributedElement recvElement(remoteViews_[i]->getGlobalSize(), recvIndex) ;
-      recvElement.addFullView() ;
-      gathererConnector_[i] = new CGathererConnector(recvElement.getView(CElementView::FULL), remoteViews_[i]) ;
+      auto recvElement = make_shared<CDistributedElement>(remoteViews_[i]->getGlobalSize(), recvIndex) ;
+      recvElement->addFullView() ;
+      gathererConnector_[i] = make_shared<CGathererConnector>(recvElement->getView(CElementView::FULL), remoteViews_[i]) ;
       gathererConnector_[i]->computeConnector() ;
     }
 
-    gridScattererConnector_ = new CGridScattererConnector(scattererConnector_) ;
-    gridGathererConnector_  = new CGridGathererConnector(gathererConnector_) ;
+    gridScattererConnector_ = make_shared<CGridScattererConnector>(scattererConnector_) ;
+    gridGathererConnector_  = make_shared<CGridGathererConnector>(gathererConnector_) ;
   }
 
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_transform_connector.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_transform_connector.hpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_transform_connector.hpp	(revision 2267)
@@ -18,5 +18,5 @@
      
     public:
-      CGridTransformConnector(vector<CLocalView*> srcViews, vector<CLocalView*> remoteViews, MPI_Comm localComm) 
+      CGridTransformConnector(vector<shared_ptr<CLocalView>> srcViews, vector<shared_ptr<CLocalView>> remoteViews, MPI_Comm localComm) 
                           : srcViews_(srcViews), remoteViews_(remoteViews), localComm_(localComm) 
                           { computeConnector();}
@@ -25,12 +25,12 @@
     protected:
      MPI_Comm localComm_ ;
-     vector<CLocalView*> srcViews_ ;
-     vector<CLocalView*> remoteViews_ ;
+     vector<shared_ptr<CLocalView>> srcViews_ ;
+     vector<shared_ptr<CLocalView>> remoteViews_ ;
      map<int,int> recvRankSize_ ;
 
-     vector<CScattererConnector*> scattererConnector_ ;
-     vector<CGathererConnector*>  gathererConnector_ ;
-     CGridScattererConnector* gridScattererConnector_ ;
-     CGridGathererConnector* gridGathererConnector_ ;
+     vector<shared_ptr<CScattererConnector>> scattererConnector_ ;
+     vector<shared_ptr<CGathererConnector>>  gathererConnector_ ;
+     shared_ptr<CGridScattererConnector> gridScattererConnector_ ;
+     shared_ptr<CGridGathererConnector> gridGathererConnector_ ;
   
     public:
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/local_connector.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/local_connector.hpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/local_connector.hpp	(revision 2267)
@@ -15,6 +15,6 @@
     
     private:
-      CLocalView* srcView_;
-      CLocalView* dstView_;
+      shared_ptr<CLocalView> srcView_;
+      shared_ptr<CLocalView> dstView_;
       int srcSize_ ;
       int dstSize_ ;
@@ -24,5 +24,5 @@
     public:
     
-      CLocalConnector(CLocalView* srcView, CLocalView* dstView) : srcView_(srcView), dstView_(dstView), 
+      CLocalConnector(shared_ptr<CLocalView> srcView, shared_ptr<CLocalView> dstView) : srcView_(srcView), dstView_(dstView), 
                                                                   srcSize_(srcView->getSize()), dstSize_(dstView->getSize()) {}
       void computeConnector(void);
@@ -59,5 +59,5 @@
       }
 
-      template<typename T> void transfer(CLocalConnector** connectors, int nConnectors, const T* input, T* output)
+      template<typename T> void transfer(shared_ptr<CLocalConnector>* connectors, int nConnectors, const T* input, T* output)
       {
 
@@ -91,5 +91,5 @@
       }
 
-      template<typename T> void transfer(CLocalConnector** connectors, int nConnectors, const T* input, T* output, T missingValue)
+      template<typename T> void transfer(shared_ptr<CLocalConnector>* connectors, int nConnectors, const T* input, T* output, T missingValue)
       {
         int size=mask_.size() ;
@@ -123,8 +123,8 @@
       }
 
-      int getSrcSliceSize(CLocalConnector** connectors, int nConnectors) 
+      int getSrcSliceSize(shared_ptr<CLocalConnector>* connectors, int nConnectors) 
       { if (nConnectors==0) return srcSize_ ; else return srcSize_ * (*(connectors-1))->getSrcSliceSize(connectors-1,nConnectors-1) ; }
 
-      int getDstSliceSize(CLocalConnector** connectors, int nConnectors) 
+      int getDstSliceSize(shared_ptr<CLocalConnector>* connectors, int nConnectors) 
       { if (nConnectors==0) return dstSize_ ; else return dstSize_ * (*(connectors-1))->getDstSliceSize(connectors-1,nConnectors-1) ; }
 
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/local_view.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/local_view.cpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/local_view.cpp	(revision 2267)
@@ -6,5 +6,5 @@
 namespace xios
 {
-  CLocalView::CLocalView(CLocalElement* parent, CElementView::type type, const CArray<int,1>& indexView) 
+  CLocalView::CLocalView(shared_ptr<CLocalElement> parent, CElementView::type type, const CArray<int,1>& indexView) 
                         : CDistributedView( parent, type, {{  parent->localRank_,  indexView }} ),
                           localRank_(parent->localRank_),
@@ -15,5 +15,5 @@
   }
 
-  CLocalView::CLocalView(CLocalElement* parent, CElementView::type type, const CArray<bool,1>& maskView) 
+  CLocalView::CLocalView(shared_ptr<CLocalElement> parent, CElementView::type type, const CArray<bool,1>& maskView) 
                         : CDistributedView( parent, type, {{  parent->localRank_,  maskView }} ),
                           localRank_(parent->localRank_),
@@ -24,5 +24,5 @@
   }
 
-  void CLocalView::sendRemoteElement(CRemoteConnector& connector, CContextClient* client, CEventClient& event, const CMessage& messageHeader)
+  void CLocalView::sendRemoteElement(shared_ptr<CRemoteConnector> connector, CContextClient* client, CEventClient& event, const CMessage& messageHeader)
   {
     int n = index_.numElements() ;
@@ -36,5 +36,5 @@
     CMessage message(messageHeader) ;
     message<<globalSize_ ;
-    connector.transferToServer(ind, client, event, message) ;
+    connector->transferToServer(ind, client, event, message) ;
   }
 
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/local_view.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/local_view.hpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/local_view.hpp	(revision 2267)
@@ -16,6 +16,6 @@
   {
     public:
-    CLocalView(CLocalElement* parent, CElementView::type type, const CArray<int,1>& indexView) ;
-    CLocalView(CLocalElement* parent, CElementView::type type, const CArray<bool,1>& maskView) ;
+    CLocalView(shared_ptr<CLocalElement> parent, CElementView::type type, const CArray<int,1>& indexView) ;
+    CLocalView(shared_ptr<CLocalElement> parent, CElementView::type type, const CArray<bool,1>& maskView) ;
 
     const CArray<int,1>& getIndex(void) { return index_ ;}
@@ -38,5 +38,5 @@
     }    
 
-    void getGlobalIndex(vector<size_t>& globalIndex, size_t sliceIndex, size_t* sliceSize, CLocalView** localView, int pos)
+    void getGlobalIndex(vector<size_t>& globalIndex, size_t sliceIndex, size_t* sliceSize, shared_ptr<CLocalView>* localView, int pos)
     {
       if (pos==0)
@@ -56,5 +56,5 @@
     int getLocalSize(void) {return localSize_ ;}
     int getSize(void) {return size_;} 
-    void sendRemoteElement(CRemoteConnector& connector, CContextClient* client, CEventClient& event, const CMessage& messageHeader) ;
+    void sendRemoteElement(shared_ptr<CRemoteConnector> connector, CContextClient* client, CEventClient& event, const CMessage& messageHeader) ;
    
     CArray<size_t,1>& globalIndex_ ;
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/reduce_transform_connector.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/reduce_transform_connector.cpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/reduce_transform_connector.cpp	(revision 2267)
@@ -5,5 +5,5 @@
 {
 
-  CReduceTransformConnector::CReduceTransformConnector(CLocalView* srcView, CLocalView* dstView, EReduction op, 
+  CReduceTransformConnector::CReduceTransformConnector(shared_ptr<CLocalView> srcView, shared_ptr<CLocalView> dstView, EReduction op, 
                                                        unordered_map<int, std::vector<int>>& indexMap, bool detectMissingValue)
    : srcView_(srcView), dstView_(dstView), detectMissingValue_(detectMissingValue)
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/reduce_transform_connector.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/reduce_transform_connector.hpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/reduce_transform_connector.hpp	(revision 2267)
@@ -17,6 +17,6 @@
     
     private:
-      CLocalView* srcView_;
-      CLocalView* dstView_;
+      shared_ptr<CLocalView> srcView_;
+      shared_ptr<CLocalView> dstView_;
 
       vector<int> connector_;  //  sizeof sum(nWeights_)  
@@ -34,5 +34,5 @@
     public:
 
-    CReduceTransformConnector(CLocalView* srcView, CLocalView* dstView, EReduction op, unordered_map<int, std::vector<int>>& indexMap, 
+    CReduceTransformConnector(shared_ptr<CLocalView> srcView, shared_ptr<CLocalView> dstView, EReduction op, unordered_map<int, std::vector<int>>& indexMap, 
                               bool detectMissingValue=true) ;
  
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/remote_connector.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/remote_connector.hpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/remote_connector.hpp	(revision 2267)
@@ -17,6 +17,6 @@
   {
     private:
-      CLocalView* srcView_;
-      CDistributedView* dstView_;
+      shared_ptr<CLocalView> srcView_;
+      shared_ptr<CDistributedView> dstView_;
       map<int, vector<int>> connector_ ; // connector[rank][srcIndex]
 
@@ -26,5 +26,5 @@
     
     public:
-      CRemoteConnector(CLocalView* srcView, CDistributedView* dstView, MPI_Comm localComm) : srcView_(srcView), dstView_(dstView), localComm_(localComm){} ;
+      CRemoteConnector(shared_ptr<CLocalView> srcView, shared_ptr<CDistributedView> dstView, MPI_Comm localComm) : srcView_(srcView), dstView_(dstView), localComm_(localComm){} ;
       void computeConnector(void) ;
       map<int, CArray<size_t,1>>& getDistributedGlobalIndex() { return element_ ;} 
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/scatterer_connector.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/scatterer_connector.hpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/scatterer_connector.hpp	(revision 2267)
@@ -23,6 +23,6 @@
       int remoteCommSize_ ;
 
-      CLocalView* srcView_ ;
-      CDistributedView* dstView_ ;
+      shared_ptr<CLocalView> srcView_ ;
+      shared_ptr<CDistributedView> dstView_ ;
       map<int,int> nbSenders_ ; // number of participant when sending remote buffer
       int srcSize_ ;
@@ -31,5 +31,5 @@
     public:
 
-    CScattererConnector(CLocalView* srcView, CDistributedView* dstView, MPI_Comm localComm, int remoteCommSize) 
+    CScattererConnector(shared_ptr<CLocalView> srcView, shared_ptr<CDistributedView> dstView, MPI_Comm localComm, int remoteCommSize) 
                        : srcView_(srcView), dstView_(dstView), localComm_(localComm), remoteCommSize_(remoteCommSize) {}
     void computeConnector(void) ;
@@ -147,5 +147,5 @@
 
     template<typename T> 
-    void transfer(int rank, CScattererConnector** connectors, int nConnectors, const T* input, T* output)
+    void transfer(int rank, shared_ptr<CScattererConnector>* connectors, int nConnectors, const T* input, T* output)
     {
       auto& connector = connector_[rank] ; // probably costly, find a better way to avoid the map
@@ -197,8 +197,8 @@
     }
 
-    int getSrcSliceSize(CScattererConnector** connectors, int nConnectors) 
+    int getSrcSliceSize(shared_ptr<CScattererConnector>* connectors, int nConnectors) 
     { if (nConnectors==0) return srcSize_ ; else return srcSize_ * (*(connectors-1))->getSrcSliceSize(connectors-1,nConnectors-1) ; }
 
-    int getDstSliceSize(int rank, CScattererConnector** connectors, int nConnectors) 
+    int getDstSliceSize(int rank, shared_ptr<CScattererConnector>* connectors, int nConnectors) 
     { if (nConnectors==0) return dstSize_[rank] ; else return dstSize_[rank] * (*(connectors-1))->getDstSliceSize(rank, connectors-1,nConnectors-1) ; }
 
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/transfer_transform_connector.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/transfer_transform_connector.cpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/transfer_transform_connector.cpp	(revision 2267)
@@ -4,5 +4,5 @@
 {
 
-  CTransferTransformConnector::CTransferTransformConnector(CLocalView* srcView, CLocalView* dstView, unordered_map<int, int>& indexMap) 
+  CTransferTransformConnector::CTransferTransformConnector(shared_ptr<CLocalView> srcView, shared_ptr<CLocalView> dstView, unordered_map<int, int>& indexMap) 
     : srcView_(srcView), dstView_(dstView)
   {
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/transfer_transform_connector.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/transfer_transform_connector.hpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/transfer_transform_connector.hpp	(revision 2267)
@@ -15,6 +15,6 @@
     
     private:
-      CLocalView* srcView_;
-      CLocalView* dstView_;
+      shared_ptr<CLocalView> srcView_;
+      shared_ptr<CLocalView> dstView_;
 
       vector<int> connector_;    
@@ -27,5 +27,5 @@
     public:
 
-    CTransferTransformConnector(CLocalView* srcView, CLocalView* dstView, unordered_map<int, int>& indexMap) ;
+    CTransferTransformConnector(shared_ptr<CLocalView> srcView, shared_ptr<CLocalView> dstView, unordered_map<int, int>& indexMap) ;
  
     void transfer(int repeat, int sizeT, const CArray<double,1>& dataIn, CArray<double,1>& dataOut)
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/transform_connector.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/transform_connector.cpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/transform_connector.cpp	(revision 2267)
@@ -56,11 +56,11 @@
 
     // distributed element : where to send data
-    CDistributedElement dstElement(srcView_->getGlobalSize(), dstArrayIndex) ;
-    dstElement.addFullView() ;
+    auto dstElement = make_shared<CDistributedElement>(srcView_->getGlobalSize(), dstArrayIndex) ;
+    dstElement->addFullView() ;
     
     // create scatterer connector
     int commSize ;
     MPI_Comm_size(localComm_, &commSize) ;
-    scattererConnector_ = new CScattererConnector(srcView_, dstElement.getView(CElementView::FULL), localComm_, commSize ) ;
+    scattererConnector_ = make_shared<CScattererConnector>(srcView_, dstElement->getView(CElementView::FULL), localComm_, commSize ) ;
     scattererConnector_->computeConnector() ;
 
@@ -98,7 +98,7 @@
     MPI_Waitall(sendReq.size(),sendReq.data(),sendStatus.data()) ;
 
-    CDistributedElement remoteElement(dstView_->getGlobalSize(), remoteArrayIndex) ;
-    remoteElement.addFullView() ;
-    gathererConnector_=new CGathererConnector(remoteElement.getView(CElementView::FULL),dstView_) ;
+    auto remoteElement = make_shared<CDistributedElement>(dstView_->getGlobalSize(), remoteArrayIndex) ;
+    remoteElement->addFullView() ;
+    gathererConnector_= make_shared<CGathererConnector>(remoteElement->getView(CElementView::FULL),dstView_) ;
     gathererConnector_->computeConnector() ;
 
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/transform_connector.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/transform_connector.hpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/transform_connector.hpp	(revision 2267)
@@ -18,5 +18,5 @@
      
     public:
-      CTransformConnector(CLocalView* srcView, CLocalView* dstView, MPI_Comm localComm) 
+      CTransformConnector(shared_ptr<CLocalView> srcView, shared_ptr<CLocalView> dstView, MPI_Comm localComm) 
                           : srcView_(srcView), dstView_(dstView), localComm_(localComm) {}
     
@@ -25,9 +25,9 @@
 
       MPI_Comm localComm_ ;
-      CLocalView* srcView_ ;
-      CLocalView* dstView_ ;
+      shared_ptr<CLocalView> srcView_ ;
+      shared_ptr<CLocalView> dstView_ ;
       map<int,int> recvRankSize_ ;
-      CScattererConnector* scattererConnector_=nullptr ;
-      CGathererConnector*  gathererConnector_=nullptr ;
+      shared_ptr<CScattererConnector> scattererConnector_ ;
+      shared_ptr<CGathererConnector>  gathererConnector_ ;
    
     public:
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/weight_transform_connector.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/weight_transform_connector.cpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/weight_transform_connector.cpp	(revision 2267)
@@ -4,5 +4,5 @@
 {
 
-  CWeightTransformConnector::CWeightTransformConnector(CLocalView* srcView, CLocalView* dstView, unordered_map<int, std::vector<int>>& indexMap, 
+  CWeightTransformConnector::CWeightTransformConnector(shared_ptr<CLocalView> srcView, shared_ptr<CLocalView> dstView, unordered_map<int, std::vector<int>>& indexMap, 
                                                    unordered_map<int, std::vector<double>>& weightMap) : srcView_(srcView), dstView_(dstView)
   {
Index: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/weight_transform_connector.hpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/weight_transform_connector.hpp	(revision 2246)
+++ XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/weight_transform_connector.hpp	(revision 2267)
@@ -15,6 +15,6 @@
     
     private:
-      CLocalView* srcView_;
-      CLocalView* dstView_;
+      shared_ptr<CLocalView> srcView_;
+      shared_ptr<CLocalView> dstView_;
 
       vector<double> weights_; //  sizeof sum(nWeights_)  
@@ -28,5 +28,5 @@
     public:
 
-    CWeightTransformConnector(CLocalView* srcView, CLocalView* dstView, unordered_map<int, std::vector<int>>& indexMap, 
+    CWeightTransformConnector(shared_ptr<CLocalView> srcView, shared_ptr<CLocalView> dstView, unordered_map<int, std::vector<int>>& indexMap, 
                               unordered_map<int, std::vector<double>>& weightMap) ;
  
