]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
- Parallel Salome_file are now ok with parallel applications
authorribes <ribes>
Thu, 27 Sep 2007 14:49:01 +0000 (14:49 +0000)
committerribes <ribes>
Thu, 27 Sep 2007 14:49:01 +0000 (14:49 +0000)
- const char * into HDFPersist constructor of classes
- --warning into Container

17 files changed:
src/Container/Container_i.cxx
src/Container/Salome_file_i.cxx
src/Container/Salome_file_i.hxx
src/HDFPersist/HDFcontainerObject.cc
src/HDFPersist/HDFcontainerObject.hxx
src/HDFPersist/HDFdataset.cc
src/HDFPersist/HDFdataset.hxx
src/HDFPersist/HDFgroup.cc
src/HDFPersist/HDFgroup.hxx
src/HDFPersist/HDFinternalObject.cc
src/HDFPersist/HDFinternalObject.hxx
src/HDFPersist/HDFobject.cc
src/HDFPersist/HDFobject.hxx
src/ParallelContainer/Parallel_Salome_file_i.cxx
src/ParallelContainer/SALOME_ParallelComponent_i.cxx
src/ParallelContainer/SALOME_ParallelComponent_i.hxx
src/ParallelContainer/SALOME_ParallelContainerNodeMpi.cxx

index e5270c67444b3e13ee53d6d505079d5c02217e22..2a7fe8bc619ea4512e155e183c9dc6a5fe298a76 100644 (file)
@@ -189,7 +189,8 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb,
          // if no thread state defined
          if ( !myTstate ) 
            myTstate = PyThreadState_New(KERNEL_PYTHON::_interp);
-         PyThreadState *myoldTstate = PyThreadState_Swap(myTstate);
+//       PyThreadState *myoldTstate = PyThreadState_Swap(myTstate);
+         PyThreadState_Swap(myTstate);
 #else
          Py_ACQUIRE_NEW_THREAD;
 #endif
index 67de702063d6e6763231485d5d369db943fa1260..8f10ad2cfb295a9f427d4435dfdfd44f89ff9791 100644 (file)
@@ -45,6 +45,7 @@ Salome_file_i::Salome_file_i()
   _state.number_of_files = 0;
   _state.files_ok = true;
   _container = Engines::Container::_nil();
+  _default_source_Salome_file = Engines::Salome_file::_nil();
 }
 
 //=============================================================================
@@ -108,7 +109,7 @@ Salome_file_i::load(const char* hdf5_file) {
       std::string dataset_group_name("DATASET");
       dataset_group_name += file_name;
 
-      hdf_group = new HDFgroup((char *) dataset_group_name.c_str(), hdf_file); 
+      hdf_group = new HDFgroup(dataset_group_name.c_str(), hdf_file); 
       hdf_group->OpenOnDisk();
 
       hdf_dataset = new HDFdataset("NAME",hdf_group);
@@ -160,7 +161,7 @@ Salome_file_i::load(const char* hdf5_file) {
 
        std::string group_name("GROUP");
        group_name += file_name;
-       hdf_group = new HDFgroup((char *) group_name.c_str(),hdf_file); 
+       hdf_group = new HDFgroup(group_name.c_str(),hdf_file); 
        hdf_group->OpenOnDisk();
        hdf_dataset = new HDFdataset("FILE DATASET",hdf_group);
        hdf_dataset->OpenOnDisk();
@@ -584,6 +585,12 @@ Salome_file_i::setDistributedFile(const char* comp_file_name)
 
   _fileManaged[file_name] = infos;
 
+  if(!CORBA::is_nil(_default_source_Salome_file)) 
+  {
+    _fileDistributedSource[file_name] = 
+      Engines::Salome_file::_duplicate(_default_source_Salome_file);
+  }
+
   // Update Salome_file state
   _state.number_of_files++;
   _state.files_ok = false;
@@ -598,25 +605,49 @@ Salome_file_i::setDistributedFile(const char* comp_file_name)
 void
 Salome_file_i::connect(Engines::Salome_file_ptr source_Salome_file) 
 {
-  // We can connect this Salome_file if there is only one file managed
-  // by the Salome_file
-  std::string fname;
-  if (_fileManaged.size() == 1) 
+  if(CORBA::is_nil(_default_source_Salome_file)) 
   {
-    // only one file managed 
-    _t_fileManaged::iterator it = _fileManaged.begin();
-    fname = it->first;
-    _fileDistributedSource[fname] = Engines::Salome_file::_duplicate(source_Salome_file);
+    _default_source_Salome_file = Engines::Salome_file::_duplicate(source_Salome_file);
+    _t_fileManaged::iterator begin = _fileManaged.begin();
+    _t_fileManaged::iterator end = _fileManaged.end();
+    for(;begin!=end;begin++) {
+      // Get the name of the file
+      std::string file_name = begin->first;
+      _t_fileDistributedSource::iterator it = _fileDistributedSource.find(file_name);
+      if (it == _fileDistributedSource.end()) 
+      {
+       _fileDistributedSource[file_name] = Engines::Salome_file::_duplicate(source_Salome_file);
+      }
+    }
   }
-  else 
+  else
   {
     SALOME::ExceptionStruct es;
     es.type = SALOME::INTERNAL_ERROR;
-    std::string text = "cannot connect";
+    std::string text = "already connected to a default Salome_file";
     es.text = CORBA::string_dup(text.c_str());
     throw SALOME::SALOME_Exception(es);
   }
+  // We can connect this Salome_file if there is only one file managed
+  // by the Salome_file
+  //std::string fname;
+  //if (_fileManaged.size() == 1) 
+  //{
+    // only one file managed 
+  //  _t_fileManaged::iterator it = _fileManaged.begin();
+  //  fname = it->first;
+  //  _fileDistributedSource[fname] = Engines::Salome_file::_duplicate(source_Salome_file);
+  //}
+  //else 
+  //{
+  //  SALOME::ExceptionStruct es;
+  //  es.type = SALOME::INTERNAL_ERROR;
+  //  std::string text = "cannot connect";
+   // es.text = CORBA::string_dup(text.c_str());
+   // throw SALOME::SALOME_Exception(es);
+  //}
 }
+
 //=============================================================================
 /*! 
  *  CORBA method
index 565cd7f68f1d2c3ae9946dc9b2c0a9d7da003766..16b09034eb8435c124fc177f99da01c829d5d775 100644 (file)
@@ -100,6 +100,7 @@ class CONTAINER_EXPORT Salome_file_i:
     _t_fileDistributedSource _fileDistributedSource;
     Engines::SfState _state;
     Engines::Container_ptr _container;
+    Engines::Salome_file_ptr _default_source_Salome_file;
 };
 
 #endif
index 04324b3b72e4ce0813b47b8763b936564e4b737f..6f8d1c3537312ea15598aec291d0828b07ccf1e6 100644 (file)
@@ -33,7 +33,7 @@ extern "C"
 //#include "utilities.h"
 using namespace std;
 
-HDFcontainerObject::HDFcontainerObject(char *name)
+HDFcontainerObject::HDFcontainerObject(const char *name)
   : HDFinternalObject(name)
 {
   _nsons = 0;
index ea8881e32814d05e1a6e737079c15dd204180da2..dfc237b26665b102e00391617f3ccff70314b90a 100644 (file)
@@ -42,7 +42,7 @@ private :
   HDFinternalObject *_lastson;
   int _nsons;
 public :
-  HDFcontainerObject(char *name);
+  HDFcontainerObject(const char *name);
   virtual ~HDFcontainerObject();
 
   virtual int nInternalObjects();
index de5d07afa97fe64ed9fd17f3a100037faecf10b2..4a0b7b16059e03c25d928862d0d046d4d63ee51d 100644 (file)
@@ -43,7 +43,7 @@ herr_t dataset_attr(hid_t loc_id, const char *attr_name, void *operator_data)
   return 1;
 }
 
-HDFdataset::HDFdataset(char *name, HDFcontainerObject *father,hdf_type type, 
+HDFdataset::HDFdataset(const char *name, HDFcontainerObject *father,hdf_type type, 
                       hdf_size dim[], int dimsize, hdf_byte_order order)
   : HDFinternalObject(name)
 {
@@ -66,7 +66,7 @@ HDFdataset::HDFdataset(char *name, HDFcontainerObject *father,hdf_type type,
 }
 
 
-HDFdataset::HDFdataset(char *name,HDFcontainerObject *father)
+HDFdataset::HDFdataset(const char *name,HDFcontainerObject *father)
   : HDFinternalObject(name)
 {
   _father = father;
index 8375497eafac3ffd59af21e12a1ae56e0aae23ce..1e2a62401346604a1c9123caef378d00c88c95bf 100644 (file)
@@ -48,10 +48,10 @@ private :
   char* _attribute;
 
 public:
-  HDFdataset(char *name, HDFcontainerObject *father,hdf_type type, 
+  HDFdataset(const char *name, HDFcontainerObject *father,hdf_type type, 
             hdf_size dim[],int dimsize, hdf_byte_order order = H5T_ORDER_NONE);
 
-  HDFdataset(char *name,HDFcontainerObject *father);
+  HDFdataset(const char *name,HDFcontainerObject *father);
   virtual ~HDFdataset();
 
   void CreateOnDisk();
index 467525320f44efb15aa075d2e95b0738d39438d2..2b0f2fb19fe72a16492b7a3e3353e9d2379cea39 100644 (file)
@@ -40,7 +40,7 @@ herr_t group_attr(hid_t loc_id, const char *attr_name, void *operator_data)
    return 1;
 }
 
-HDFgroup::HDFgroup(char *name, HDFcontainerObject *father)
+HDFgroup::HDFgroup(const char *name, HDFcontainerObject *father)
   : HDFcontainerObject(name)
 {
   _father = father;
index 01c969d92bbd90740f9c58cdb7082097857458d9..8c0d02b889a758e9bbcd948a12bc88d3f3499533 100644 (file)
@@ -42,7 +42,7 @@ private :
   hdf_idt _mid;
   char* _attribute;
 public :
-  HDFgroup(char *name, HDFcontainerObject *father);
+  HDFgroup(const char *name, HDFcontainerObject *father);
 
   void CreateOnDisk();
   void OpenOnDisk();
index a3cdc1f7f8fe14efe794490c5aa71530b2eaf9ea..716e6da494bc6329828c456d136e14435f1c122d 100644 (file)
@@ -33,7 +33,7 @@ extern "C"
 using namespace std;
 #endif
 
-HDFinternalObject::HDFinternalObject(char *name)
+HDFinternalObject::HDFinternalObject(const char *name)
   : HDFobject(name)
 {
   _previousbrother = NULL;
index 06921850d3216bc24dceb70cb7b7a9305ddf46b0..ee4c32e51ece1e99d43b550ef9aa29059cbc7eb6 100644 (file)
@@ -40,7 +40,7 @@ private :
   HDFinternalObject *_previousbrother;
   HDFinternalObject *_nextbrother;
 public :
-  HDFinternalObject(char *name);
+  HDFinternalObject(const char *name);
 
   HDFinternalObject *GetPreviousBrother();
   HDFinternalObject *GetNextBrother();
index 1a032278a7d2e42ff45f0c397306ede4999521ce..5adb8aafea2a97474c44a33ee973689295575ad3 100644 (file)
@@ -33,7 +33,7 @@ extern "C"
 //#include "utilities.h"
 using namespace std;
 
-HDFobject::HDFobject(char *name)
+HDFobject::HDFobject(const char *name)
 {
   //  MESSAGE("-------- constructor " << name << " " << this);
   HDFerrorModeLock();
index e1396985a30ebc9c154cc5112eb82e5c556d3103..3c829822ab5fa91e2d932c5836c34e5e9a70d06f 100644 (file)
@@ -38,7 +38,7 @@ protected :
   char *_name;
   hdf_idt _id;
 public :
-  HDFobject(char *name);
+  HDFobject(const char *name);
   virtual ~HDFobject();
 
   hdf_idt GetId();
index 19cecbb251be584e1a0f343c19de392490a20ae2..ac06b50057e65b007e42ac82b5168657273dd52e 100644 (file)
@@ -73,12 +73,15 @@ Parallel_Salome_file_i::connect(Engines::Salome_file_ptr source_Salome_file) {
 
   // Test if the file is managed in an another node
   // If yes, node is updated
-  _t_fileManaged::iterator it = _fileManaged.begin();
-  std::string file_name = it->first;
-  if (_fileManaged[file_name].node > 0 && getMyRank() == 0) {
-    if (parallel_file == NULL)
-      parallel_file = Engines::PaCO_Parallel_Salome_file::PaCO_narrow(proxy, _orb);
-    parallel_file->connect(source_Salome_file, _fileManaged[file_name].node);
+  _t_fileManaged::iterator begin = _fileManaged.begin();
+  _t_fileManaged::iterator end = _fileManaged.end();
+  for(;begin!=end;begin++) {
+    std::string file_name = begin->first;
+    if (_fileManaged[file_name].node > 0 && getMyRank() == 0) {
+      if (parallel_file == NULL)
+       parallel_file = Engines::PaCO_Parallel_Salome_file::PaCO_narrow(proxy, _orb);
+      parallel_file->connect(source_Salome_file, _fileManaged[file_name].node);
+    }
   }
 }
 
@@ -296,6 +299,9 @@ Parallel_Salome_file_i::setFileNode(const char* file_name, CORBA::Long node) {
       parallel_file = Engines::PaCO_Parallel_Salome_file::PaCO_narrow(proxy, _orb);
 
     Engines::Container_ptr cont = parallel_file->updateFile(_fileManaged[fname], node);
+    parallel_file->connectDistributedFile(fname.c_str(),
+                                         _fileDistributedSource[fname],
+                                         node);
 
     // Update file infos with the new reference of the container
     _fileManaged[fname].container = Engines::Container::_duplicate(cont);
index 870c4dd921192038194af1a2ac6de9a7a3163839..db60ae5e414d2774d8bd8d531c83db3f4029a5c1 100644 (file)
@@ -43,6 +43,7 @@
 int SIGUSR11 = 1000;
 #endif
 
+#include <paco_dummy.h>
 
 using namespace std;
 
@@ -796,10 +797,14 @@ Engines_Parallel_Component_i::setInputFileToService(const char* service_name,
     _Input_Service_file_map[service_name] = _map;
     _t_Proxy_Salome_file_map * _proxy_map = new _t_Proxy_Salome_file_map();
     _Proxy_Input_Service_file_map[service_name] = _proxy_map;
+    _t_IOR_Proxy_Salome_file_map * _IOR_proxy_map = new _t_IOR_Proxy_Salome_file_map();
+    _IOR_Proxy_Input_Service_file_map[service_name] = _IOR_proxy_map;
   }
   _t_Salome_file_map * _map = _Input_Service_file_map[service_name];
   _t_Proxy_Salome_file_map * _proxy_map = _Proxy_Input_Service_file_map[service_name];
+  _t_IOR_Proxy_Salome_file_map * _IOR_proxy_map = _IOR_Proxy_Input_Service_file_map[service_name];
   
+  pthread_mutex_lock(deploy_mutex);
   std::string proxy_ior;
 
   // Try to find the Salome_file ...
@@ -810,7 +815,6 @@ Engines_Parallel_Component_i::setInputFileToService(const char* service_name,
     // He has the same configuration than
     // his component
 
-    pthread_mutex_lock(deploy_mutex);
     // Firstly, we have to create the proxy object
     // of the Salome_file and transmit his
     // reference to the other nodes.
@@ -818,6 +822,16 @@ Engines_Parallel_Component_i::setInputFileToService(const char* service_name,
       Engines::Parallel_Salome_file_proxy_impl * proxy = 
        new Engines::Parallel_Salome_file_proxy_impl(CORBA::ORB::_duplicate(_orb));
       PaCO_operation * proxy_global_ptr =  proxy->getContext("global_paco_context");
+      // We initialize the object with the context of the Parallel component
+      PaCO_operation * compo_global_ptr =  getContext("global_paco_context");
+      //compo_global_ptr->init_context(proxy_global_ptr);
+      proxy_global_ptr->init_context(compo_global_ptr);
+      
+      paco_fabrique_manager* pfm = paco_getFabriqueManager();
+      pfm->register_com("dummy", new paco_dummy_fabrique());
+      proxy_global_ptr->setComFab(NULL);
+      proxy_global_ptr->setLibCom("dummy",NULL);
+      
       proxy_global_ptr->setTypeClient(true);
       PaCO::PacoTopology_t client_topo;
       client_topo.total = 1;
@@ -826,10 +840,6 @@ Engines_Parallel_Component_i::setInputFileToService(const char* service_name,
       serveur_topo.total = getTotalNode();
       proxy->setTopo(serveur_topo);
 
-      // We initialize the object with the context of the Parallel component
-      PaCO_operation * compo_global_ptr =  getContext("global_paco_context");
-      //compo_global_ptr->init_context(proxy_global_ptr);
-      proxy_global_ptr->init_context(compo_global_ptr);
       // We register the CORBA objet into the POA
       CORBA::Object_ptr proxy_ref = proxy->_this();
 
@@ -846,6 +856,7 @@ Engines_Parallel_Component_i::setInputFileToService(const char* service_name,
     }
 
     proxy_ior = this->get_parallel_proxy_object();
+    (*_IOR_proxy_map)[Salome_file_name] = proxy_ior;
 
     // We register each node of the parallel Salome_file object
     // into the proxy.
@@ -877,10 +888,11 @@ Engines_Parallel_Component_i::setInputFileToService(const char* service_name,
     // Parallel_Salome_file is created and deployed
     delete _proxy;
     _proxy = NULL;
-    pthread_mutex_unlock(deploy_mutex);
   }
-
-  return (*_proxy_map)[Salome_file_name]->_this();
+  pthread_mutex_unlock(deploy_mutex);
+  proxy_ior = (*_IOR_proxy_map)[Salome_file_name];
+  CORBA::Object_ptr proxy_ref = _orb->string_to_object(proxy_ior.c_str());
+  return Engines::Salome_file::_narrow(proxy_ref);
 }
 
 Engines::Salome_file_ptr 
@@ -894,10 +906,14 @@ Engines_Parallel_Component_i::setOutputFileToService(const char* service_name,
     _Output_Service_file_map[service_name] = _map;
     _t_Proxy_Salome_file_map * _proxy_map = new _t_Proxy_Salome_file_map();
     _Proxy_Output_Service_file_map[service_name] = _proxy_map;
+    _t_IOR_Proxy_Salome_file_map * _IOR_proxy_map = new _t_IOR_Proxy_Salome_file_map();
+    _IOR_Proxy_Output_Service_file_map[service_name] = _IOR_proxy_map;
   }
   _t_Salome_file_map * _map = _Output_Service_file_map[service_name];
   _t_Proxy_Salome_file_map * _proxy_map = _Proxy_Output_Service_file_map[service_name];
+  _t_IOR_Proxy_Salome_file_map * _IOR_proxy_map = _IOR_Proxy_Output_Service_file_map[service_name];
   
+  pthread_mutex_lock(deploy_mutex);
   std::string proxy_ior;
 
   // Try to find the Salome_file ...
@@ -908,7 +924,6 @@ Engines_Parallel_Component_i::setOutputFileToService(const char* service_name,
     // He has the same configuration than
     // his component
 
-    pthread_mutex_lock(deploy_mutex);
     // Firstly, we have to create the proxy object
     // of the Salome_file and transmit his
     // reference to the other nodes.
@@ -916,6 +931,16 @@ Engines_Parallel_Component_i::setOutputFileToService(const char* service_name,
       Engines::Parallel_Salome_file_proxy_impl * proxy = 
        new Engines::Parallel_Salome_file_proxy_impl(CORBA::ORB::_duplicate(_orb));
       PaCO_operation * proxy_global_ptr =  proxy->getContext("global_paco_context");
+      // We initialize the object with the context of the Parallel component
+      PaCO_operation * compo_global_ptr =  getContext("global_paco_context");
+      //compo_global_ptr->init_context(proxy_global_ptr);
+      proxy_global_ptr->init_context(compo_global_ptr);
+
+      paco_fabrique_manager* pfm = paco_getFabriqueManager();
+      pfm->register_com("dummy", new paco_dummy_fabrique());
+      proxy_global_ptr->setComFab(NULL);
+      proxy_global_ptr->setLibCom("dummy",NULL);
+
       proxy_global_ptr->setTypeClient(true);
       PaCO::PacoTopology_t client_topo;
       client_topo.total = 1;
@@ -924,10 +949,6 @@ Engines_Parallel_Component_i::setOutputFileToService(const char* service_name,
       serveur_topo.total = getTotalNode();
       proxy->setTopo(serveur_topo);
 
-      // We initialize the object with the context of the Parallel component
-      PaCO_operation * compo_global_ptr =  getContext("global_paco_context");
-      //compo_global_ptr->init_context(proxy_global_ptr);
-      proxy_global_ptr->init_context(compo_global_ptr);
       // We register the CORBA objet into the POA
       CORBA::Object_ptr proxy_ref = proxy->_this();
 
@@ -944,6 +965,7 @@ Engines_Parallel_Component_i::setOutputFileToService(const char* service_name,
     }
 
     proxy_ior = this->get_parallel_proxy_object();
+    (*_IOR_proxy_map)[Salome_file_name] = proxy_ior;
 
     // We register each node of the parallel Salome_file object
     // into the proxy.
@@ -975,10 +997,11 @@ Engines_Parallel_Component_i::setOutputFileToService(const char* service_name,
     // Parallel_Salome_file is created and deployed
     delete _proxy;
     _proxy = NULL;
-    pthread_mutex_unlock(deploy_mutex);
   }
-
-  return (*_proxy_map)[Salome_file_name]->_this();
+  pthread_mutex_unlock(deploy_mutex);
+  proxy_ior = (*_IOR_proxy_map)[Salome_file_name];
+  CORBA::Object_ptr proxy_ref = _orb->string_to_object(proxy_ior.c_str());
+  return Engines::Salome_file::_narrow(proxy_ref);
 }
 
 Engines::Salome_file_ptr 
index afebfc896d42f90e1591ea5a8ea627ecc728ec4c..edadf93cea929b8bb650006da6a0fc7dd304d3d2 100644 (file)
@@ -161,10 +161,12 @@ protected:
   // Map Salome_file_name to Parallel_Salome_file*
   typedef std::map<std::string, Parallel_Salome_file_i*> _t_Salome_file_map;
   typedef std::map<std::string, Engines::Parallel_Salome_file_proxy_impl*> _t_Proxy_Salome_file_map;
+  typedef std::map<std::string, std::string> _t_IOR_Proxy_Salome_file_map;
 
   // Map Service_name to  _Salome_file_map
   typedef std::map<std::string, Engines_Parallel_Component_i::_t_Salome_file_map*> _t_Service_file_map;
   typedef std::map<std::string, Engines_Parallel_Component_i::_t_Proxy_Salome_file_map*> _t_Proxy_Service_file_map;
+  typedef std::map<std::string, Engines_Parallel_Component_i::_t_IOR_Proxy_Salome_file_map*> _t_IOR_Proxy_Service_file_map;
   
   _t_Service_file_map _Input_Service_file_map;
   _t_Service_file_map _Output_Service_file_map;
@@ -176,6 +178,11 @@ protected:
   _t_Proxy_Service_file_map::iterator _Proxy_Service_file_map_it;
   _t_Proxy_Salome_file_map::iterator _Proxy_Salome_file_map_it;
 
+  _t_IOR_Proxy_Service_file_map _IOR_Proxy_Input_Service_file_map;
+  _t_IOR_Proxy_Service_file_map _IOR_Proxy_Output_Service_file_map;
+  _t_IOR_Proxy_Service_file_map::iterator _IOR_Proxy_Service_file_map_it;
+  _t_IOR_Proxy_Salome_file_map::iterator _IOR_Proxy_Salome_file_map_it;
+
   std::string _serviceName ;
   std::string _graphName ;
   std::string _nodeName ;
index c046a2c9f413dbc1ffb8824608c056805d8b66e7..4852bcafb2c0f1c45324a69c79a3cbb51c583988 100644 (file)
@@ -75,20 +75,71 @@ void handler(int t) {
 }
 #endif
 
+typedef void (*sighandler_t)(int);
+sighandler_t setsig(int sig, sighandler_t handler)
+{
+  struct sigaction context, ocontext;
+  context.sa_handler = handler;
+  sigemptyset(&context.sa_mask);
+  context.sa_flags = 0;
+  if (sigaction(sig, &context, &ocontext) == -1)
+    return SIG_ERR;
+  return ocontext.sa_handler;
+}
+
+void AttachDebugger()
+{
+  if(getenv ("DEBUGGER"))
+    {
+      std::stringstream exec;
+      exec << "$DEBUGGER SALOME_ParallelContainerNodeMpi " << getpid() << "&";
+      std::cerr << exec.str() << std::endl;
+      system(exec.str().c_str());
+      while(1);
+    }
+}
+
+void Handler(int theSigId)
+{
+  std::cerr << "SIGSEGV: "  << std::endl;
+  AttachDebugger();
+  //to exit or not to exit
+  exit(1);
+}
+
+void terminateHandler(void)
+{
+  std::cerr << "Terminate: not managed exception !"  << std::endl;
+  AttachDebugger();
+}
+
+void unexpectedHandler(void)
+{
+  std::cerr << "Unexpected: unexpected exception !"  << std::endl;
+  AttachDebugger();
+}
+
 int main(int argc, char* argv[])
 {
        INFOS("Launching a parallel Mpi container node");
 
 #ifdef _DEBUG_
-       struct sigaction action;
-       action.sa_handler = &test;
-       sigaction(SIGSEGV, &action, NULL);
+//     struct sigaction action;
+//     action.sa_handler = &test;
+//     sigaction(SIGSEGV, &action, NULL);
 #endif
        
        // MPI Init
        int provided;
        MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE ,&provided);
 
+  if(getenv ("DEBUGGER"))
+    {
+  std::cerr << "Unexpected: unexpected exception !"  << std::endl;
+      setsig(SIGSEGV,&Handler);
+      set_terminate(&terminateHandler);
+      set_unexpected(&unexpectedHandler);
+    }
 #ifdef _DEBUG_
        cerr << "Level MPI_THREAD_SINGLE : " << MPI_THREAD_SINGLE << endl;
        cerr << "Level MPI_THREAD_SERIALIZED : " << MPI_THREAD_SERIALIZED << endl;