Salome HOME
updated copyright message
[tools/medcoupling.git] / src / ParaMEDMEM / MPIProcessorGroup.cxx
index 3bf01b69d864b6197cbc5a2c003be28bee1e1403..0fb2dfe0d538887e2305109e1c24ae5c609a63c0 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2023  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -30,7 +30,7 @@
 using namespace std;
 
 
-namespace ParaMEDMEM
+namespace MEDCoupling
 {
   /*!
    \anchor MPIProcessorGroup-det
@@ -115,7 +115,7 @@ namespace ParaMEDMEM
           throw INTERP_KERNEL::Exception("invalid rank in set<int> argument of MPIProcessorGroup constructor");
         }
       
-    _comm_interface.groupIncl(group_world, _proc_ids.size(), ranks, &_group);
+    _comm_interface.groupIncl(group_world, (int)_proc_ids.size(), ranks, &_group);
   
     _comm_interface.commCreate(_world_comm, _group, &_comm);
 
@@ -181,10 +181,20 @@ namespace ParaMEDMEM
 
   MPIProcessorGroup::~MPIProcessorGroup()
   {
-    _comm_interface.groupFree(&_group);
+    release();
+  }
+
+  /** Destructor involves MPI operations: make sure this is accessible from a proper
+   * method for Python wrapping.
+   */
+  void MPIProcessorGroup::release()
+  {
+    if (_group != MPI_GROUP_EMPTY)
+      _comm_interface.groupFree(&_group);
+    _group = MPI_GROUP_EMPTY;
     if (_comm!=_world_comm && _comm !=MPI_COMM_NULL)
       _comm_interface.commFree(&_comm);
-  
+    _comm = MPI_COMM_NULL;
   }
 
   /*! Translation of the rank id between two processor groups. This method translates rank \a rank
@@ -218,7 +228,7 @@ namespace ParaMEDMEM
     
   }
 
-  ProcessorGroup *MPIProcessorGroup::deepCpy() const
+  MPIProcessorGroup *MPIProcessorGroup::deepCopy() const
   {
     return new MPIProcessorGroup(*this);
   }