Salome HOME
correct previous integration (Porting to Python 2.6)
[modules/kernel.git] / doc / salome / salome_application.dox
1 /*!
2   \page SALOME_Application Salome Application Concept 
3
4
5 The following explains how to configure your own application with your list of
6 modules, how to define and run this application on one or more computers.
7
8 \section S1_sal_appl General principles
9
10 %A %SALOME application is defined by a set of modules (GEOM, SMESH, ASTER...). %A %SALOME application
11 lives in an application  directory.
12 %A %SALOME application is a virtual installation of %SALOME in the application directory 
13 (bin, lib, doc, share...), with, for each file (executable, script, data,
14 library, resources...), symbolic links to the actual files.
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 First, the user must create a %SALOME application configuration file by modifying a
46 copy of ${KERNEL_ROOT_DIR}/bin/salome/config_appli.xml.
47 The file describes the list of %SALOME modules used in the application, with
48 their respective installation path. The configuration file also defines the
49 path of an existing script which sets the %SALOME prerequisites,
50 and optionnaly, the path of samples directory (SAMPLES_SRC).
51 The following command:
52
53 \code
54 python <KERNEL_ROOT_DIR>/bin/salome/appli_gen.py --prefix=<install directory> --config=<configuration file>
55 \endcode
56
57 creates a %SALOME application in the application directory given by the prefix option (local directory
58 by default) with the configuration file given by the config option (config_appli.xml by default).
59
60 Providing an existing script for %SALOME prerequisites (the same one
61 used for modules compilation, or given with the modules installation), the
62 installation works without further modification for a single computer (unless
63 some modules needs a special environment not defined in the above script).
64
65 For a distributed application (several computers), one must copy and adapt
66 CatalogResources.xml from ${KERNEL_ROOT_DIR}/bin/salome/appliskel (see below).
67
68 \section S3_sal_appl General rules
69
70 The application directory must be created on each computer of the application.
71 The easiest way is to use the same relative path (to ${HOME}) on each computer.
72 (Sometimes it is not possible to use the same path everywhere, for instance
73 when ${HOME} is shared with NFS, so it is possible to define different path
74 following the computers).
75
76 The application directory contains scripts for environment and runs. Environment
77 scripts must be configured (by the user) on each computer. All the environment
78 scripts are in the env.d subdirectory. 
79
80 The script envd sources \b all the files (*.sh) in subdirectory env.d
81 in alphanumeric order (after edition, think to remove backup files). The envd
82 script is used by run scripts.
83
84 <ol>
85   <li>
86 <b>env.d scripts</b>
87
88 <b>env.d scripts are built automatically.</b>
89
90 You can add your own environment scripts in env.d subdirectory, they will be sourced as
91 the generated ones provided they have a .sh extension.
92
93   </li>
94   <li>
95 <b>User run scripts</b>
96
97 The %SALOME user can use 4 scripts:
98
99 - runAppli\n
100    Launches a %SALOME Session
101    (similar to ${KERNEL_ROOT_DIR}/bin/salome/runSalome but with a different
102    name to avoid confusions). See parameters below.
103
104 - runSession\n
105    Launches a shell script in the %SALOME application environment, with access
106    to the current (last launched) %SALOME session (naming service), if any.
107    Without arguments, the script is interactive. With arguments, the script
108    executes the command in the %SALOME application environment.
109
110 - runConsole\n
111    Gives a python console connected to the current %SALOME Session.
112    It is also possible to use runSession, then python.
113
114 - runTests\n
115    Similar to runSession, used for unit testing, but runSession tries to use an
116    already existing naming service definition from a running session (hostname
117    and port number), and runTests defines a new configuration for naming service
118    (new port number).
119   </li>
120   <li>
121 <b>%SALOME internal run scripts</b>
122
123 - envd\n
124    Sets %SALOME application environment, envd is sourced by other scripts.
125
126 For remote calls, %SALOME uses one script.
127
128 - runRemote.sh\n
129    This script is mainly used to launch containers. The first 3 arguments
130    define the hostname and port userd for naming service, plus a working directory, the remaining
131    arguments define the command to execute.
132   </li>
133   <li>
134 <b>Other configuration files</b>
135
136 - SALOMEApp.xml\n
137    This file is similar to the default given
138    in ${GUI_ROOT_DIR}/share/SALOME/resources/gui
139
140
141 - CatalogRessources.xml\n
142    This file describes all the computers the application can use. The given
143    example is minimal and suppose application directory is the same relative path
144    to ${HOME}, on all the computers. %A different directory can be set on a
145    particular computer with a line:
146    \code
147 appliPath="my/specific/path/on/this/computer"
148    \endcode
149
150   </li>
151 </ol>
152
153 \section S4_sal_appl Examples of use
154
155 <ol>
156   <li>
157 <b>Launch a %SALOME session with a GUI interface</b>
158
159 Launch is done with a command like:
160
161 \code
162 ./runAppli --logger
163 \endcode
164
165 The --logger option means here : collect all the traces from the all the
166 distributed process, via CORBA, in a single file : logger.log.
167
168 There are a lot of options, a complete list is given by:
169
170 \code
171 ./runAppli --help
172 \endcode
173
174 Note that, without argument, runAppli is a non interactive Python application,
175 and, with arguments, runAppli is an interactive Python interpreter.
176
177 Several options are already defined by default in SALOMEApp.xml files. Optional
178 arguments given in the command override the SALOMEApp.xml configuration.
179
180 Several sessions can run simultaneously, each session use a different port for
181 CORBA naming service, so the sessions are totally separated from each other.
182
183 When the GUI is closed, the different %SALOME servers are still running.
184   </li>
185   <li>
186 <b>Close a %SALOME session, kill all the servers</b>
187
188 Inside the interactive python interpreter you get when you use runAppli
189 with arguments, you can kill all the servers of your session with:
190
191 \code
192 >>> killLocalPort()
193 \endcode
194
195 or the servers of all the sessions with:
196
197 \code
198 >>> killAllPorts()
199 \endcode
200
201 If you have no active Python interpreter connected to your session, you can
202 kill all the %SALOME servers of <b>all the sessions</b> on a given computer:
203
204 \code
205 ./runSession killSalome.py
206 \endcode
207
208 Remember! it's the same idea in <b>Windows (R) operating system</b> (Microsoft and Windows are either registered trademarks or trademarks of
209        Microsoft Corporation in the United States and/or other countries) :
210 use the start menu to stop...
211
212 When you use only one session at a time, you don't need more.
213
214 To kill a given session (when several session are running), one needs
215 the naming service port number:
216
217 \code
218 ./runSession killSalomeWithPort 2810
219 \endcode
220
221 Note that the port number of the last launched session can be found on Linux,
222 in the prompt, within a runSession shell (see below).
223
224 It is also possible to get the Naming Service host and port number of
225 the last launched session with:
226
227 \code
228 ./runSession NSparam.py
229 \endcode
230
231   </li>
232   <li>
233 <b>Launch a %SALOME session without GUI interface</b>
234
235 This is used to launch a %SALOME Python script without GUI
236 (no GUI %server = SALOME_session_server)
237
238 Example of script (test_session_geom.py):
239
240 \code
241 import salome_session
242 salome_session.startSession(modules=["GEOM"])
243 import GEOM_usinggeom
244 raw_input("Press a key and the servers will be killed ...")
245 \endcode
246
247 This script is run in a non interactive way with:
248
249 \code
250 ./runSession python test_session_geom.py
251 \endcode
252
253 All the process are automatically killed when Python is closed
254 (with SALOME_session delete).
255   </li>
256   <li>
257 <b>Add an external Python interpretor to a running session</b>
258
259 It's often easier to develop and try Python scripts outside the GUI embedded
260 Python interpreter. Imagine, for instance, you are writing a script involving
261 geometry and mesh modules.
262 first, launch a %SALOME session with gui, then, on another terminal:
263
264 \code
265 ./runSession
266 python
267 \endcode
268
269 Import salome module. salome_init() without arguments creates a new study
270 in the running session (note: salome_init(n) attachs to a running session whose
271 studyId is n):
272
273 \code
274 import salome
275 salome.salome_init()
276 \endcode
277
278 An example of script given with SMESH:
279
280 \code
281 import ex01_cube2build
282 \endcode
283
284 It is possible to connect the GUI interface to the study created in the above
285 script with the file/connect menu, then browse study and display objects.
286 Further modifications on study can be done either with GUI or external script
287 (use refresh popup in GUI %object browser to see study modifications generated
288 by the external script). <b>AVOID modifications with GUI when a Python script
289 is running</b>. Not all the modules are protected against concurrent actions...
290   </li>
291   <li>
292 <b>Different uses of the runSession shell interpreter</b>
293
294 runSession invoked without arguments gives an interactive shell with the full
295 environment of %SALOME (PATH, LD_LIBRARY_PATH, PYTHONPATH, other variables).
296 If there are running sessions of the same %SALOME application, runSession
297 connects to the last launched session (i.e. gets the naming service references
298 of the session: hostname and port)
299
300 On Linux, the shell prompt (bash) gives information on naming service
301 references, hostname and port:
302
303 \code
304 [NS=cli76cc:2811]prascle@cli76cc:~/SALOME2/Run/Virtual$
305 \endcode
306
307 If there is no running session, prompt looks like:
308
309 \code
310 [NS=:]prascle@cli76cc:~/SALOME2/Run/Virtual$
311 \endcode
312
313 runSession is useful to launch any script or program which needs the complete
314 %SALOME environment, with or without a session already running.
315 For instance, to launch the ddd debugger interface on the gui %server, first
316 launch a %SALOME session with gui, then, on another terminal:
317
318 \code
319 ./runSession ddd
320 \endcode
321
322 Then attach to the running SALOME_Session_Server process.
323   </li>
324 </ol>  
325
326 */