From: tajchman Date: Thu, 29 Mar 2012 13:26:56 +0000 (+0000) Subject: Generates Salome layers for MPI-parallel codes without additional parameters for... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c67303141b2c01d9135d1e7a0c22ef1baf5aa879;p=tools%2Fyacsgen.git Generates Salome layers for MPI-parallel codes without additional parameters for component services, and no supplementary initialize/terminate-coupling component methods. --- diff --git a/module_generator/hxx_para_tmpl.py b/module_generator/hxx_para_tmpl.py index 7df0ed7..da20ba5 100644 --- a/module_generator/hxx_para_tmpl.py +++ b/module_generator/hxx_para_tmpl.py @@ -87,6 +87,14 @@ extern "C" bool regist; int numproc; + int flag; + + MPI_Initialized(&flag); + if (!flag) { + int argc = 0; + char ** argv = NULL; + MPI_Init(&argc, &argv); + } MPI_Comm_rank( MPI_COMM_WORLD, &numproc ); if( numproc == 0 ) diff --git a/module_generator/hxxparacompo.py b/module_generator/hxxparacompo.py index 89f5d80..a8a3328 100644 --- a/module_generator/hxxparacompo.py +++ b/module_generator/hxxparacompo.py @@ -107,7 +107,6 @@ class HXX2SALOMEParaComponent(Component): cpp2yacs_mapping["ParaMEDMEM::MEDCouplingFieldDouble*&"]="SALOME_MED/MPIMEDCouplingFieldDoubleCorbaInterface" cpp2yacs_mapping["ParaMEDMEM::MEDCouplingFieldDouble*"]="SALOME_MED/MPIMEDCouplingFieldDoubleCorbaInterface" list_of_services=[] - list_of_services_with_in_fields=[] service_definition={} result_parsing=open("parse_type_result","r") for line in result_parsing.readlines(): @@ -137,13 +136,8 @@ class HXX2SALOMEParaComponent(Component): assert inout=="in" or inout=="ou",'Error in table cpp2idl_mapping' if inout == "in": service_definition[list_of_services[-1]]["inports"].append( (argname,typename) ) - if typename=="const ParaMEDMEM::MEDCouplingFieldDouble*": - list_of_services_with_in_fields.append(list_of_services[-1]) else: service_definition[list_of_services[-1]]["outports"].append( (argname,typename) ) - for servNane in list_of_services_with_in_fields: - service_definition[servNane]["inports"].append(("coupling","const char*")) - service_definition[servNane]["ports"].append(("coupling","const char*")) if service_definition.has_key('getInputFieldTemplate'): del service_definition['getInputFieldTemplate'] @@ -152,10 +146,10 @@ class HXX2SALOMEParaComponent(Component): # store it in service_definition[serv]["impl"] # from hxx_awk import cpp_impl_a,cpp_impl_b,cpp_impl_c # these tables contain the part of code which depends upon c++ types - cpp_impl_b["ParaMEDMEM::MEDCouplingFieldDouble*"]="""\tParaMEDMEM::MPIMEDCouplingFieldDoubleServant * _rtn_field_i = new ParaMEDMEM::MPIMEDCouplingFieldDoubleServant(_orb,this,_rtn_cpp); + cpp_impl_b["ParaMEDMEM::MEDCouplingFieldDouble*"]="""\tParaMEDMEM::MPIMEDCouplingFieldDoubleServant * _rtn_field_i = new ParaMEDMEM::MPIMEDCouplingFieldDoubleServant(_orb,_poa,this,_rtn_cpp); \t_rtn_cpp->decrRef(); \tSALOME_MED::MPIMEDCouplingFieldDoubleCorbaInterface_ptr _rtn_ior = _rtn_field_i->_this();\n""" - cpp_impl_a["const ParaMEDMEM::MEDCouplingFieldDouble*"]="\tParaMEDMEM::MEDCouplingFieldDouble* _%(arg)s=cppCompo_->getInputFieldTemplate();\n\t_setInputField(coupling,%(arg)s,_%(arg)s);\n" + cpp_impl_a["const ParaMEDMEM::MEDCouplingFieldDouble*"]="\tParaMEDMEM::MEDCouplingFieldDouble* _%(arg)s=cppCompo_->getInputFieldTemplate();\n\t_setInputField(%(arg)s,_%(arg)s);\n\t_initializeCoupling(%(arg)s);\n" from yacstypes import corbaTypes,corbaOutTypes format_thread_signature="void * th_%s(void * st);" # this thread declaration will be included in servant's header @@ -283,8 +277,7 @@ void *th_%(serv_name)s(void *s) if argtype == "const MEDMEM::MESH&" or argtype == "const MEDMEM::SUPPORT&" : pre="*" # we cannot create MESHClient on the stack (private constructor), so we create it on the heap and dereference it post+="," # separator between arguments - if(argname!="coupling"): # coupling is a special argument added for input fields - it should not be transferred to the underlying c++ component - s_call_cpp_function += " %s_%s%s" % ( pre,argname,post) + s_call_cpp_function += " %s_%s%s" % ( pre,argname,post) if s_call_cpp_function[-1]==',': s_call_cpp_function=s_call_cpp_function[0:-1] # get rid of trailing comma s_call_cpp_function=s_call_cpp_function+');\n'