Salome HOME
updated copyright message
[modules/kernel.git] / src / MPIContainer / SALOME_MPIContainer.cxx
1 // Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include <mpi.h>
24 #include <iostream>
25 #include "ArgvKeeper.hxx"
26 #include "MPIContainer_i.hxx"
27 #include "OpUtil.hxx"
28 #include "utilities.h"
29
30 int main(int argc, char* argv[])
31 {
32   int nbproc, numproc;
33
34   MPI_Init(&argc,&argv);
35   MPI_Comm_size(MPI_COMM_WORLD,&nbproc);
36   MPI_Comm_rank(MPI_COMM_WORLD,&numproc);
37
38   // Initialise the ORB.
39   SetArgcArgv(argc, argv);
40   CORBA::ORB_ptr orb = KERNEL::GetRefToORB();
41   //  SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
42  
43   BEGIN_OF("[" << numproc << "] " << argv[0])
44   try {
45     
46     // Obtain a reference to the root POA.
47     CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
48     PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
49
50     // obtain the root poa manager
51     PortableServer::POAManager_var pman = root_poa->the_POAManager();
52
53     char *containerName = (char *)"";
54     if (argc >1) 
55     {
56         containerName = argv[1] ;
57     }
58
59     MESSAGE("[" << numproc << "] MPIContainer: load MPIContainer servant");
60     new Engines_MPIContainer_i(orb,root_poa, containerName,argc,argv);
61
62     pman->activate();
63
64     orb->run();
65
66   }
67   catch(CORBA::SystemException&){
68     INFOS("Caught CORBA::SystemException.");
69   }
70   catch(PortableServer::POA::WrongPolicy&){
71     INFOS("Caught CORBA::WrongPolicyException.");
72   }
73   catch(PortableServer::POA::ServantAlreadyActive&){
74     INFOS("Caught CORBA::ServantAlreadyActiveException");
75   }
76   catch(CORBA::Exception&){
77     INFOS("Caught CORBA::Exception.");
78   }
79   catch(...){
80     INFOS("Caught unknown exception.");
81   }
82
83   MPI_Finalize();
84
85   END_OF("[" << numproc << "] " << argv[0]);
86
87   exit(0);
88
89 }
90