1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "MPIMEDCouplingFieldDoubleServant.hxx"
21 #include "utilities.h"
23 using namespace ParaMEDMEM;
31 MPIMEDCouplingFieldDoubleServant::MPIMEDCouplingFieldDoubleServant(CORBA::ORB_ptr orb,PortableServer::POA_ptr poa,ParaMEDMEMComponent_i *pcompo,MEDCouplingFieldDouble* field):ParaMEDCouplingFieldDoubleServant(orb,field)
36 CORBA::Object_var my_ref = poa->servant_to_reference (pcompo);
37 SALOME_MED::ParaMEDMEMComponent_var compo = SALOME_MED::ParaMEDMEMComponent::_narrow(my_ref);
38 _ref = orb->object_to_string(compo);
40 Engines::MPIObject_var pobj = POA_SALOME_MED::MPIMEDCouplingFieldDoubleCorbaInterface::_this();
41 BCastIOR(orb,pobj,false);
44 void MPIMEDCouplingFieldDoubleServant::getDataByMPI(const char* coupling) throw(SALOME::SALOME_Exception)
52 th = new pthread_t[_nbproc];
53 for(int ip=1;ip<_nbproc;ip++)
55 thread_st *st = new thread_st;
58 st->coupling = coupling;
59 pthread_create(&(th[ip]),NULL,th_getdatabympi,(void*)st);
65 _pcompo->_getOutputField(coupling,_field);
67 catch(const std::exception &ex)
70 THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::INTERNAL_ERROR);
75 for(int ip=1;ip<_nbproc;ip++)
77 pthread_join(th[ip],&ret_th);
78 est = (except_st*)ret_th;
82 msg << "[" << ip << "] " << est->msg;
83 THROW_SALOME_CORBA_EXCEPTION(msg.str().c_str(),SALOME::INTERNAL_ERROR);
91 void *th_getdatabympi(void *s)
94 thread_st *st = (thread_st*)s;
95 except_st *est = new except_st;
96 est->exception = false;
100 SALOME_MED::MPIMEDCouplingFieldDoubleCorbaInterface_var fieldPtr=SALOME_MED::MPIMEDCouplingFieldDoubleCorbaInterface::_narrow((*(st->tior))[st->ip]);
101 fieldPtr->getDataByMPI(st->coupling.c_str());
103 catch(const SALOME::SALOME_Exception &ex)
105 est->exception = true;
106 est->msg = ex.details.text;
108 catch(const CORBA::Exception &ex)
110 est->exception = true;
111 msg << "CORBA::Exception: " << ex;
112 est->msg = msg.str();
118 char *MPIMEDCouplingFieldDoubleServant::getRef()
120 return CORBA::string_dup(_ref.c_str());