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