1 // SALOME MPIContainer : implemenation of container based on MPI libraries
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SALOME_MPIContainer.cxx
29 #include "MPIContainer_i.hxx"
30 #include "utilities.h"
31 #include "LocalTraceCollector.hxx"
34 int main(int argc, char* argv[])
36 LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance();
38 MPIContainer_i * myContainer;
43 MESSAGE("Connection MPI");
45 MPI_Init(&argc,&argv);
46 MPI_Comm_size(MPI_COMM_WORLD,&nbproc);
47 MPI_Comm_rank(MPI_COMM_WORLD,&numproc);
49 MESSAGE("Initialisation CORBA");
50 // Initialise the ORB.
51 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
53 // Obtain a reference to the root POA.
54 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
55 PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
57 // obtain the root poa manager
58 PortableServer::POAManager_var pman = root_poa->the_POAManager();
60 // define policy objects
61 PortableServer::ImplicitActivationPolicy_var implicitActivation =
62 root_poa->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION) ;
64 // default = NO_IMPLICIT_ACTIVATION
65 PortableServer::ThreadPolicy_var threadPolicy =
66 root_poa->create_thread_policy(PortableServer::ORB_CTRL_MODEL) ;
67 // default = ORB_CTRL_MODEL, other choice SINGLE_THREAD_MODEL
70 CORBA::PolicyList policyList;
72 policyList[0] = PortableServer::ImplicitActivationPolicy::_duplicate(implicitActivation) ;
73 policyList[1] = PortableServer::ThreadPolicy::_duplicate(threadPolicy) ;
75 // create the child POA
76 PortableServer::POAManager_var nil_mgr = PortableServer::POAManager::_nil() ;
77 PortableServer::POA_var factory_poa =
78 root_poa->create_POA("factory_poa", pman, policyList) ;
79 //with nil_mgr instead of pman, a new POA manager is created with the new POA
81 // destroy policy objects
82 implicitActivation->destroy() ;
83 threadPolicy->destroy() ;
85 char *containerName = "";
88 containerName = argv[1] ;
91 MESSAGE("Chargement container sur proc: " << numproc);
92 myContainer = new MPIContainer_i(nbproc,numproc,orb,factory_poa, containerName);
93 MESSAGE("Fin chargement container");
103 catch(CORBA::SystemException&) {
104 INFOS("Caught CORBA::SystemException.")
106 catch(PortableServer::POA::WrongPolicy&)
108 INFOS("Caught CORBA::WrongPolicyException.")
110 catch(PortableServer::POA::ServantAlreadyActive&)
112 INFOS("Caught CORBA::ServantAlreadyActiveException")
114 catch(CORBA::Exception&) {
115 INFOS("Caught CORBA::Exception.")
118 INFOS("Caught unknown exception.")
121 delete myThreadTrace;