Back to index

salome-kernel  6.5.0
SALOME_MPIContainer.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #include <mpi.h>
00024 #include <iostream>
00025 #include "MPIContainer_i.hxx"
00026 #include "Utils_ORB_INIT.hxx"
00027 #include "Utils_SINGLETON.hxx"
00028 #include "utilities.h"
00029 
00030 int main(int argc, char* argv[])
00031 {
00032   int nbproc, numproc;
00033 
00034   MPI_Init(&argc,&argv);
00035   MPI_Comm_size(MPI_COMM_WORLD,&nbproc);
00036   MPI_Comm_rank(MPI_COMM_WORLD,&numproc);
00037 
00038   // Initialise the ORB.
00039   ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
00040   CORBA::ORB_var &orb = init( argc , argv ) ;
00041   //  SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
00042  
00043   BEGIN_OF("[" << numproc << "] " << argv[0])
00044   try {
00045     
00046     // Obtain a reference to the root POA.
00047     CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
00048     PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
00049 
00050     // obtain the root poa manager
00051     PortableServer::POAManager_var pman = root_poa->the_POAManager();
00052 
00053     char *containerName = (char *)"";
00054     if (argc >1) 
00055     {
00056         containerName = argv[1] ;
00057     }
00058 
00059     MESSAGE("[" << numproc << "] MPIContainer: load MPIContainer servant");
00060     new Engines_MPIContainer_i(orb,root_poa, containerName,argc,argv);
00061 
00062     pman->activate();
00063 
00064     orb->run();
00065 
00066   }
00067   catch(CORBA::SystemException&){
00068     INFOS("Caught CORBA::SystemException.");
00069   }
00070   catch(PortableServer::POA::WrongPolicy&){
00071     INFOS("Caught CORBA::WrongPolicyException.");
00072   }
00073   catch(PortableServer::POA::ServantAlreadyActive&){
00074     INFOS("Caught CORBA::ServantAlreadyActiveException");
00075   }
00076   catch(CORBA::Exception&){
00077     INFOS("Caught CORBA::Exception.");
00078   }
00079   catch(...){
00080     INFOS("Caught unknown exception.");
00081   }
00082 
00083   MPI_Finalize();
00084 
00085   END_OF("[" << numproc << "] " << argv[0]);
00086 
00087   exit(0);
00088 
00089 }
00090