Salome HOME
Porting to OCCT 7.8.0
[modules/kernel.git] / src / MPIContainer / MPIObject_i.cxx
index 433300512dc9779da8247ada1a760864e65e3b64..ac51582e782179c9273ec57a5384e719b003a8e7 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-//  SALOME MPIContainer : implemenation of container based on MPI libraries
-//  File   : MPIObject_i.cxx
-//  Module : SALOME
-//
 #include "MPIObject_i.hxx"
 #include "utilities.h"
 #include "Utils_SALOME_Exception.hxx"
+#include "Basics_MpiUtils.hxx"
 
 #define TIMEOUT 5
 
@@ -53,7 +50,7 @@ Engines::IORTab* MPIObject_i::tior()
   for(unsigned int ip=0;ip<tior->length();ip++)
     tior[ip] = (*_tior)[ip];
   return tior._retn(); 
-};
+}
 
 void MPIObject_i::tior(const Engines::IORTab& ior)
 {
@@ -139,6 +136,7 @@ void MPIObject_i::remoteMPI2Connect(std::string service)
   int i;
   char port_name[MPI_MAX_PORT_NAME];
   char port_name_clt[MPI_MAX_PORT_NAME];
+  MPI_Info info;
   std::ostringstream msg;
 
   if( service.size() == 0 )
@@ -156,8 +154,9 @@ void MPIObject_i::remoteMPI2Connect(std::string service)
   _srv[service] = false;
 
   MPI_Barrier(MPI_COMM_WORLD);
-
-  MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+  MPI_ERROR_HANDLER(MPI_ERRORS_RETURN);
+  MPI_Info_create(&info);
+  MPI_Info_set(info, "ompi_unique", "true");
   if( _numproc == 0 )
     { 
       /* rank 0 try to be a server. If service is already published, try to be a cient */
@@ -167,7 +166,7 @@ void MPIObject_i::remoteMPI2Connect(std::string service)
           MESSAGE("[" << _numproc << "] I get the connection with " << service << " at " << port_name_clt << std::endl);
           MPI_Close_port( port_name );
         }
-      else if ( MPI_Publish_name((char*)service.c_str(), MPI_INFO_NULL, port_name) == MPI_SUCCESS )
+      else if ( MPI_Publish_name((char*)service.c_str(), info, port_name) == MPI_SUCCESS )
         {
           _srv[service] = true;
           _port_name[service] = port_name;
@@ -204,7 +203,7 @@ void MPIObject_i::remoteMPI2Connect(std::string service)
           throw SALOME_Exception(msg.str().c_str());
         }
     }
-  MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL);
+  MPI_ERROR_HANDLER(MPI_ERRORS_ARE_FATAL);
   
   /* If rank 0 is server, all processes call MPI_Comm_accept */
   /* If rank 0 is not server, all processes call MPI_Comm_connect */