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