From f0b40dc6c38498e0d7e38b378fad0746853757d6 Mon Sep 17 00:00:00 2001 From: ribes Date: Tue, 21 Jul 2009 09:08:59 +0000 Subject: [PATCH] - Ajout des exemples PaCO++ --- Examples/paco2/README.txt | 25 +++++++++++ Examples/paco2/components.py | 39 +++++++++++++++++ Examples/paco2/coupling.xml | 34 +++++++++++++++ Examples/paco3/README.txt | 25 +++++++++++ Examples/paco3/components.py | 85 ++++++++++++++++++++++++++++++++++++ Examples/paco3/coupling.xml | 52 ++++++++++++++++++++++ 6 files changed, 260 insertions(+) create mode 100644 Examples/paco2/README.txt create mode 100644 Examples/paco2/components.py create mode 100644 Examples/paco2/coupling.xml create mode 100644 Examples/paco3/README.txt create mode 100644 Examples/paco3/components.py create mode 100644 Examples/paco3/coupling.xml diff --git a/Examples/paco2/README.txt b/Examples/paco2/README.txt new file mode 100644 index 0000000..efa5554 --- /dev/null +++ b/Examples/paco2/README.txt @@ -0,0 +1,25 @@ +A C++ component dynamically loadable +========================================= + +To build this example, modify the components.py file +to take into account your configuration. + +1- your prerequisite file +2- your KERNEL_ROOT_DIR + +Then set the environment (including PYTHONPATH for YACGEN, ../.. from here and execute components.py :: + + source + python components.py + +You should get a SALOME module in source form (cppcompos_SRC), its installation (install) and +a SALOME application (appli) composed of modules KERNEL, GUI, YACS and cppcompos. + +To run a coupling: + + 1. start SALOME in background : ./appli/runAppli -t + 2. start a SALOME session : ./appli/runSession + 3. start YACS coupler with coupling file : driver coupling.xml + 4. examine output files in /tmp + 5. shutdown SALOME : shutdowSalome.py + 6. exit session : CTRL-D (or exit) diff --git a/Examples/paco2/components.py b/Examples/paco2/components.py new file mode 100644 index 0000000..c5eb466 --- /dev/null +++ b/Examples/paco2/components.py @@ -0,0 +1,39 @@ +import os +from module_generator import Generator,Module,Service,PACOComponent + +context={'update':1, + "prerequisites":"/home/aribes/Dev/Scripts_env/prerequis.sh", + "kernel":"/home/aribes/Dev/Install/SALOME/KERNEL_INSTALL-RIBES", + "paco":"/home/aribes/Dev/Install/PaCO++_install", + "mpi":"/usr/lib/openmpi" + } + +cwd=os.getcwd() + +body=""" +c = a + b; +""" + +c1=PACOComponent("paco1", + "mpi", + services=[ + Service("run",inport=[("a","double"),("b","double")], + outport=[("c","double")], + body=body, + impl_type="parallel" + ), + ], + ) + + +g=Generator(Module("pacocompos",components=[c1],prefix="./install"),context) +g.generate() +g.bootstrap() +g.configure() +g.make() +g.install() +g.make_appli("appli", + restrict=["KERNEL","GUI","YACS"], + altmodules={"GUI":"/home/aribes/Dev/Install/SALOME/GUI_INSTALL", + "YACS":"/home/aribes/Dev/Install/SALOME/YACS_INSTALL"}) + diff --git a/Examples/paco2/coupling.xml b/Examples/paco2/coupling.xml new file mode 100644 index 0000000..704d919 --- /dev/null +++ b/Examples/paco2/coupling.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + paco1 + + run + + + + + + run0a + 5 + + + run0b + 4 + + + + diff --git a/Examples/paco3/README.txt b/Examples/paco3/README.txt new file mode 100644 index 0000000..efa5554 --- /dev/null +++ b/Examples/paco3/README.txt @@ -0,0 +1,25 @@ +A C++ component dynamically loadable +========================================= + +To build this example, modify the components.py file +to take into account your configuration. + +1- your prerequisite file +2- your KERNEL_ROOT_DIR + +Then set the environment (including PYTHONPATH for YACGEN, ../.. from here and execute components.py :: + + source + python components.py + +You should get a SALOME module in source form (cppcompos_SRC), its installation (install) and +a SALOME application (appli) composed of modules KERNEL, GUI, YACS and cppcompos. + +To run a coupling: + + 1. start SALOME in background : ./appli/runAppli -t + 2. start a SALOME session : ./appli/runSession + 3. start YACS coupler with coupling file : driver coupling.xml + 4. examine output files in /tmp + 5. shutdown SALOME : shutdowSalome.py + 6. exit session : CTRL-D (or exit) diff --git a/Examples/paco3/components.py b/Examples/paco3/components.py new file mode 100644 index 0000000..759679a --- /dev/null +++ b/Examples/paco3/components.py @@ -0,0 +1,85 @@ +# -*- coding: utf-8 *- +import os +from module_generator import Generator,Module,Service,PACOComponent + +context={'update':1, + "makeflags":"-j2", + "prerequisites":"/home/aribes/Dev/Scripts_env/prerequis.sh", + "kernel":"/home/aribes/Dev/Install/SALOME/KERNEL_INSTALL-RIBES", + "paco":"/home/aribes/Dev/Install/PaCO++_install", + "mpi":"/usr/lib/openmpi" + } + +cwd=os.getcwd() + +master_body=""" + // Init data + Ports::Param_Double_Port::seq_double data; + data.length(10); + for (double i=0; i< 10; i++) + data[i] = i; + _master_port_port->configure_port_method_put(10); + _master_port_port->put(data); + + Ports::Param_Double_Port::seq_double * results; + _master_port_port->get_results(results); + std::cerr << "Master receive a sequence of length = " << results->length() << std::endl; + for (int i = 0; i < results->length(); i++) + std::cerr << "Master receive data : " << (*results)[i] << std::endl; + delete results; +""" + +worker_body=""" + // Réception des données + Ports::Param_Double_Port::seq_double * data = _worker_port_port->get_data(); + std::cerr << "Node " << getMyRank() << " receive a sequence of length = " << data->length() << std::endl; + for (int i = 0; i < data->length(); i++) + std::cerr << "Node " << getMyRank() << " receive data : " << (*data)[i] << std::endl; + delete data; + + // Envoi des données + data = new Ports::Param_Double_Port::seq_double(); + data->length(5); + for (double i=0; i< 5; i++) + { + (*data)[i] = i + i + (getMyRank() * 20); + } + _worker_port_port->configure_set_data(5, 5*getTotalNode(), 5*getMyRank()); + _worker_port_port->set_data(data); + delete data; +""" + +c1=PACOComponent("MASTER", + "dummy", + services=[ + Service("StartMaster", + parallel_outstream=[("master_port", "Param_Double_Port")], + body=master_body, + impl_type="parallel" + ), + ], + ) + +c2=PACOComponent("WORKER", + "mpi", + services=[ + Service("StartWorker", + parallel_instream=[("worker_port", "Param_Double_Port")], + body=worker_body, + impl_type="parallel" + ), + ], + ) + + +g=Generator(Module("DSC_PARALLEL_PARAM",components=[c1, c2],prefix="./install"),context) +g.generate() +g.bootstrap() +g.configure() +g.make() +g.install() +g.make_appli("appli", + restrict=["KERNEL","GUI","YACS"], + altmodules={"GUI":"/home/aribes/Dev/Install/SALOME/GUI_INSTALL", + "YACS":"/home/aribes/Dev/Install/SALOME/YACS_INSTALL"}) + diff --git a/Examples/paco3/coupling.xml b/Examples/paco3/coupling.xml new file mode 100644 index 0000000..6c35b5b --- /dev/null +++ b/Examples/paco3/coupling.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + MASTER + + StartMaster + + + + WORKER + + StartWorker + + + + StartMaster2 master_port + StartWorker3 worker_port + + + + + ForLoop0nsteps + 10 + + + + + + + -- 2.39.2