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"
33 int main(int argc, char* argv[])
36 MPIContainer_i * myContainer;
41 MESSAGE("Connection MPI");
43 MPI_Init(&argc,&argv);
44 MPI_Comm_size(MPI_COMM_WORLD,&nbproc);
45 MPI_Comm_rank(MPI_COMM_WORLD,&numproc);
47 MESSAGE("Initialisation CORBA");
48 // Initialise the ORB.
49 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
51 // Obtain a reference to the root POA.
52 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
53 PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
55 // obtain the root poa manager
56 PortableServer::POAManager_var pman = root_poa->the_POAManager();
58 // define policy objects
59 PortableServer::ImplicitActivationPolicy_var implicitActivation =
60 root_poa->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION) ;
62 // default = NO_IMPLICIT_ACTIVATION
63 PortableServer::ThreadPolicy_var threadPolicy =
64 root_poa->create_thread_policy(PortableServer::ORB_CTRL_MODEL) ;
65 // default = ORB_CTRL_MODEL, other choice SINGLE_THREAD_MODEL
68 CORBA::PolicyList policyList;
70 policyList[0] = PortableServer::ImplicitActivationPolicy::_duplicate(implicitActivation) ;
71 policyList[1] = PortableServer::ThreadPolicy::_duplicate(threadPolicy) ;
73 // create the child POA
74 PortableServer::POAManager_var nil_mgr = PortableServer::POAManager::_nil() ;
75 PortableServer::POA_var factory_poa =
76 root_poa->create_POA("factory_poa", pman, policyList) ;
77 //with nil_mgr instead of pman, a new POA manager is created with the new POA
79 // destroy policy objects
80 implicitActivation->destroy() ;
81 threadPolicy->destroy() ;
83 char *containerName = "";
86 containerName = argv[1] ;
89 MESSAGE("Chargement container sur proc: " << numproc);
90 myContainer = new MPIContainer_i(nbproc,numproc,orb,factory_poa, containerName);
91 MESSAGE("Fin chargement container");
101 catch(CORBA::SystemException&) {
102 INFOS("Caught CORBA::SystemException.")
104 catch(PortableServer::POA::WrongPolicy&)
106 INFOS("Caught CORBA::WrongPolicyException.")
108 catch(PortableServer::POA::ServantAlreadyActive&)
110 INFOS("Caught CORBA::ServantAlreadyActiveException")
112 catch(CORBA::Exception&) {
113 INFOS("Caught CORBA::Exception.")
116 INFOS("Caught unknown exception.")