ug4
BASH Tools

Setting up ugbash

Say YOURUG4ROOT is the root directory of ug4 (it contains ugbase, plugin and so forth). Add the line source YOURUG4ROOT/scripts/shell/ugbash to your ~/.bash_profile or ~/.bashrc. (it depends on your system if .bashrc or .bash_profile is used. See also here.)

Note
The bash configuration files (.bashrc or .bash_profile) are loaded when you open up a new console or log into a computer (and only then). Now every time you change them, you have to reload them (with source .bashrc or source .bash_profile) or just open a new shell to make your changes effective.

ugbash Features

  • $UG4_ROOT will be set automatically to YOURUG4ROOT.
  • $UG4_ROOT/scripts/shell and $UG4_ROOT/bin will be added to your path. That means you can call ugshell from everywhere.
  • Completion

ugbash makes some additional bash commands available:

  • cdug will change directory to UG4_ROOT. cdug subdir will change directory to UG4_ROOT/subdir (completion possible).
  • ugbasegrep "the stuff i search" will do a grep-search for "the stuff i search" in ug4/ugbase, same for ugpluginsgrep in ug4/plugins.
  • ugrelib will delete ug4/lib/*, ug4/bin/ugshell and ug4/bin/plugins/*, so you can re-link ugshell (sometimes necessary).
  • ugsubmit (ugsubmit - Job Scheduling on Clusters)
  • xprun

BASH prompt

The standard bash prompt is not very descriptive, so add source YOURUG4ROOT/scripts/shell/prompt to .bashrc / .bash_profile for a nicer bash prompt. That way you'll always see in which path you are (also in the title of the console). It's also covered here .


Completion


When using ugbash, you have additional completion (used with tab):

  • ugshell
    • all standard parameters
    • -ex, absolute paths and paths in $UG4_ROOT/apps
    • all parameters found for example in myfile.lua when you entered something like ugshell -ex myfile.lua - and hit 'tab', every parameter in your myfile.lua will be completed that is used in util.GetParamNumber etc..
  • ugcmake, which is an alias to cmake, but adds completion of a lot of our parameters for ug4, like -DEMBEDDED_PLUGINS= or -DCMAKE_TOOLCHAIN_FILE=.
  • cdug: subdirectories are completed.
  • ugsubmit

xprun

xprun is a easy script to put each MPI process in its own console. You can even do simple parallel debugging with it. The opens e.g. 4 xterm windows and adjusts size & position so that they fit on the screen inside the windows, a mpi program is started. To adjust window position and max size, see xtermrun. You can access your PID by the variable $PID Example: xprun 4 echo 'hello, world! i am processor $PID'

For debugging, use e.g.

xprun 4 gdb --args ugshell -ex conv_diff/laplace.lua -outproc -1
parameterString ex
Executes the specified script.
Definition: command_line_util.lua:350
parameterNumber outproc
Sets the output-proc to id.
Definition: command_line_util.lua:349

With outproc -1 you ensure that every process will put out data.

For more complex programs, you will need a real parallel debugger like DDT.