Salome HOME
Merge from BR_KERNEL_REFACTORING
[modules/kernel.git] / doc / docutils / archives / SALOME_Application.txt
1 ======================================================================
2 SALOME Application Concept. Configuration for one or more computers
3 ======================================================================
4
5 *html version of this document is produced with docutils*::
6
7   rst2html doc.txt > doc.html
8
9 This document corresponds to SALOME2 3.2.0
10
11 .. contents::
12 .. sectnum::
13
14 +-------------------------------------------+
15 | **WORK in PROGRESS, INCOMPLETE DOCUMENT** |
16 +-------------------------------------------+
17
18 -------------------------------------------------------------------------------
19
20 The following explains how to configure your own application with your list of
21 modules, how to define and run this application on one or more computers.
22
23 General principles
24 ------------------
25
26 A SALOME application is defined by a set of modules (GEOM, SMESH, ASTER...).
27
28 A SALOME User can define several SALOME Applications. These applications are
29 runnable from the same user account. These applications may share the same
30 KERNEL and modules. Thus, the application configuration is independant of
31 KERNEL and must not be put in KERNEL_ROOT_DIR.
32
33 Furthermore, prerequisites may not be the same on all the applications.
34
35 A SALOME Session can run on a several computers.
36
37 Binary modules and prerequisites are installed on the different computers.
38 There is no need to have all the modules on each computer (the minimum is
39 KERNEL).
40
41 There is no need of standardization or centralised information on the details
42 of configuration on each computer (PATH, LD_LIBRARY_PATH, environment
43 variables) provided the application modules are version - compatible. Details
44 of configuration stay private to the computer, and are held by scripts on each
45 computer.
46
47 There is no hierarchy between the computers (for example only one master
48 computer used to launch application).
49
50 The SALOME user has an account on all the computers. Access between
51 account@computer is via rsh or ssh and must be configured for use without
52 password (key exchange for ssh). Account may be different on each
53 computer.
54
55 Application Directory
56 ---------------------
57
58 Two ways for creation of an application directory
59 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
60
61 First way - references to different module directories
62 ''''''''''''''''''''''''''''''''''''''''''''''''''''''
63
64 The script createAppli.sh in ${KERNEL_ROOT_DIR}/bin/salome creates an
65 application directory with the given path in parameter. ${APPLI} is a path
66 relative to ${HOME}.
67
68 The directory is only a skeleton, the user has to edit several files to
69 configure his own application. These files are described after, the list is:
70
71 - env.d/atFirst.sh
72 - env.d/envProducts.sh
73 - env.d/envSalome.sh
74 - CatalogResources.xml
75 - SalomeApp.xml
76
77 Second and easiest way - one single virtual install directory
78 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
79
80 The user must create a SALOME application configuration file by modifying a
81 copy of ${KERNEL_ROOT_DIR}/bin/salome/config_appli.xml.
82 The file describes the list of SALOME modules used in the application, with
83 their respective installation path. The configuration file also defines the
84 path of an existing script which sets the SALOME prerequisites,
85 and optionnaly, the path of samples directory (SAMPLES_SRC).
86 The following command::
87
88     python <KERNEL_ROOT_DIR>/bin/salome/appli_gen.py --prefix=<install directory> --config=<configuration file>
89
90 creates a virtual installation of SALOME in the application directory ${APPLI}
91 (bin, lib, doc, share...), with, for each file (executable, script, data,
92 library, resources...), symbolic links to the actual file.
93
94 Providing an existing script for SALOME prerequisites (the same one
95 used for modules compilation, or given with the modules installation), the
96 installation works without further modification for a single computer (unless
97 some modules needs a special environment not defined in the above script).
98 For a distributed application (several computers), one must copy and adapt
99 CatalogResources.xml from ${KERNEL_ROOT_DIR}/bin/salome/appliskel (see below).
100
101 General rules
102 -------------
103
104 Directory ${APPLI} must be created on each computer of the application.
105 The easiest way is to use the same relative path (to ${HOME}) on each computer.
106 (Sometimes it is not possible to use the same path everywhere, for instance
107 when ${HOME} is shared with NFS, so it is possible to define different path
108 following the computers).
109
110 The ${APPLI} directory contains scripts for environment and runs. Environment
111 scripts must be configured (by the user) on each computer. All the environment
112 scripts are in the ${APPLI}/env.d directory.
113
114 The script  ${APPLI}/envd sources **all** the files (\*.sh) in ${APPLI}/env.d
115 in alphanumeric order (after edition, think to remove backup files). the envd
116 script is used by run scripts.
117
118
119 env.d scripts
120 ~~~~~~~~~~~~~
121 With the first way of installation, each user **must define** his own
122 configuration for these scripts, following the above rules.
123 With the virtual installation (second way, above), env.d
124 scripts are built automatically.
125
126  **The following is only an example proposed by createAppli.sh, (first way of installation) not working as it is**.
127
128 atFirst.sh
129     Sets the computer configuration not directly related to SALOME,
130     like useful tools, default PATH.
131
132 envProducts.sh
133     Sets the SALOME prerequisites.
134
135 envSALOME.sh
136     Sets all the MODULE_ROOT_DIR that can be used in the SALOME application.
137
138     SalomeAppConfig is also defined by::
139
140       export SalomeAppConfig=${HOME}/${APPLI}
141
142     where SalomeAppConfig designates the directory containing SalomeApp.xml.
143     Note that ${APPLI} is already defined by the calling scripts when
144     env.d/envSalome.sh is sourced.
145
146 User run scripts
147 ~~~~~~~~~~~~~~~~
148
149 The SALOME user can use 4 scripts:
150
151 runAppli
152    Launches a SALOME Session
153    (similar to ${KERNEL_ROOT_DIR}/bin/salome/runSalome but with a different
154    name to avoid confusions).
155
156 runSession
157    Launches a shell script in the SALOME application environment, with access
158    to the current (last launched) SALOME session (naming service), if any.
159    Without arguments, the script is interactive. With arguments, the script
160    executes the command in the SALOME application environment.
161
162 runConsole
163    Gives a python console connected to the current SALOME Session.
164    It is also possible to use runSession, then python.
165
166 runTests
167    Similar to runSession, used for unit testing. runSession tries to use an
168    already existing naming service definition from a running session (hostname
169    and port number), runTests defines a new configuration for naming service
170    (new port number).
171
172 SALOME internal run scripts
173 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
174
175 envd
176    Sets SALOME application environment, envd is sourced by other scripts.
177
178 For remote calls, SALOME uses one script.
179
180 runRemote.sh
181    This script is mainly used to launch containers. The first 2 arguments
182    define the hostname and port userd for naming service, the remaining
183    arguments define the command to execute.
184
185 Other configuration files
186 ~~~~~~~~~~~~~~~~~~~~~~~~~
187
188 SalomeApp.xml
189    This file is similar to the default given
190    in ${GUI_ROOT_DIR}/share/salome/resources/gui
191
192
193 CatalogRessources.xml
194    This files describes all the computers the application can use. The given
195    example is minimal and suppose ${APPLI} is the same relative path
196    to ${HOME}, on all the computers. A different directory can be set on a
197    particular computer with a line::
198
199        appliPath="my/specific/path/on/this/computer"
200
201
202 Examples of use
203 ---------------
204
205 Launch a SALOME session with a GUI interface
206 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
207
208 Launch is done with a command like::
209
210    ./runAppli --logger
211
212 The --logger option means here : collect all the traces from the all the
213 distributed process, via CORBA, in a single file : logger.log.
214
215 There are a lot of options, a complete list is given by::
216
217    ./runAppli --help
218
219 Note that, without argument, runAppli is a non interactive Python application,
220 and, with arguments, runAppli is an interactive Python interpreter.
221
222 Several options are already defined by default in SalomeApp.xml files. Optional
223 arguments given in the command override the SalomeApp.xml configuration.
224
225 Several sessions can run simultaneously, each session use a different port for
226 CORBA naming service, so the sessions are totally separated from each other.
227
228 When the GUI is closed, the different SALOME servers are still running.
229
230 Close a SALOME session, kill all the servers
231 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
232
233 Inside the interactive python interpreter you get when you use runAppli
234 with arguments, you can kill all the servers of your session with::
235
236    >>> killLocalPort()
237
238 or the servers of all the sessions with::
239
240    >>> killAllPorts()
241
242 If you have no active Python interpreter connected to your session, you can
243 kill all the SALOME servers of **all the sessions** on a given computer::
244
245    ./runSession killSalome.py
246
247 Remember! it's the same idea in *Windows (R) operating system* [#]_ :
248 use the start menu to stop...
249
250 When you use only one session at a time, you don't need more.
251
252 To kill a given session (when several session are running), one needs
253 the naming service port number::
254
255    ./runSession killSalomeWithPort 2810
256
257 Note that the port number of the last launched session can be found on Linux,
258 in the prompt, within a runSession shell (see below).
259
260 It is also possible to get the Naming Service host and port number of
261 the last launched session with::
262
263    ./runSession NSparam.py
264
265 .. [#] Microsoft and Windows are either registered trademarks or trademarks of
266        Microsoft Corporation in the United States and/or other countries.
267
268 Launch a SALOME session without GUI interface
269 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
270
271 This is used to launch a SALOME Python script without GUI
272 (no GUI server = SALOME_session_server)
273
274 Example of script (test_session_geom.py)::
275
276    import salome_session
277    salome_session.startSession(modules=["GEOM"])
278    import GEOM_usinggeom
279    raw_input("Press a key and the servers will be killed ...")
280
281 This script is run in a non interactive way with::
282
283    ./runSession python test_session_geom.py
284
285 All the process are automatically killed when Python is closed
286 (with salome_session delete).
287
288 Add an external Python interpretor to a running session
289 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
290
291 It's often easier to develop and try Python scripts outside the GUI embedded
292 Python interpreter. Imagine, for instance, you are writing a script involving
293 geometry and mesh modules.
294 First, launch a SALOME session with gui, then, on another terminal::
295
296    ./runSession
297    python
298
299 Import salome module. salome_init() without arguments creates a new study
300 in the running session (note: salome_init(n) attachs to a running session whose
301 studyId is n)::
302
303    import salome
304    salome.salome_init()
305
306 An example of script given with SMESH::
307
308    import ex01_cube2build
309
310 It is possible to connect the GUI interface to the study created in the above
311 script with the file/connect menu, then browse study and display objects.
312 Further modifications on study can be done either with GUI or external script
313 (use refresh popup in GUI object browser to see study modifications generated
314 by the external script). **AVOID modifications with GUI when a Python script
315 is running**. Not all the modules are protected against concurrent actions...
316
317
318 Different uses of the runSession shell interpreter
319 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
320
321 runSession invoked without arguments gives an interactive shell with the full
322 environment of SALOME (PATH, LD_LIBRARY_PATH, PYTHONPATH, other variables).
323 If there are running sessions of the same SALOME application, runSession
324 connects to the last launched session (i.e. gets the naming service references
325 of the session: hostname and port)
326
327 On Linux, the shell prompt (bash) gives information on naming service
328 references, hostname and port::
329
330    [NS=cli76cc:2811]prascle@cli76cc:~/SALOME2/Run/Virtual$
331
332 If there is no running session, prompt looks like::
333
334    [NS=:]prascle@cli76cc:~/SALOME2/Run/Virtual$
335
336 runSession is useful to launch any script or program which needs the complete
337 SALOME environment, with or without a session already running.
338 For instance, to launch the ddd debugger interface on the gui server, first
339 launch a SALOME session with gui, then, on another terminal::
340
341    ./runSession ddd
342
343 Then attach to the running SALOME_Session_Server process.
344
345
346 -------------------------------------------------------------------------------
347
348 +----------------------------------+------------------------------------------+
349 | `General KERNEL documentation`_  | `End User KERNEL Doxygen documentation`_ |
350 +----------------------------------+------------------------------------------+
351
352 .. _`General KERNEL documentation`:           ./index.html
353 .. _`End User KERNEL Doxygen documentation`:  ./tui/KERNEL/index.html