/*
 * Copyright (c) 2013:  G-CSC, Goethe University Frankfurt
 * Author: Martin Rupp
 * 
 * This file is part of UG4.
 * 
 * UG4 is free software: you can redistribute it and/or modify it under the
 * terms of the GNU Lesser General Public License version 3 (as published by the
 * Free Software Foundation) with the following additional attribution
 * requirements (according to LGPL/GPL v3 §7):
 * 
 * (1) The following notice must be displayed in the Appropriate Legal Notices
 * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
 * 
 * (2) The following notice must be displayed at a prominent place in the
 * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
 * 
 * (3) The following bibliography is recommended for citation and must be
 * preserved in all covered files:
 * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
 *   parallel geometric multigrid solver on hierarchically distributed grids.
 *   Computing and visualization in science 16, 4 (2013), 151-164"
 * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
 *   flexible software system for simulating pde based models on high performance
 *   computers. Computing and visualization in science 16, 4 (2013), 165-179"
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 */

/** \page pageBashTools BASH Tools

[TOC]

<hr>
\section secBashToolsSetup Setting up ugbash
Say YOURUG4ROOT is the root directory of ug4 (it contains ugbase, plugin and so forth).
Add the line  <tt>source YOURUG4ROOT/scripts/shell/ugbash</tt> to your <tt>~/.bash_profile</tt> or <tt>~/.bashrc</tt>.
(it depends on your system if .bashrc or .bash_profile is used. See also <a href="http://www.joshstaiger.org/archives/2005/07/bash_profile_vs.html">here</a>.)
\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 <tt>source .bashrc</tt> or <tt>source .bash_profile</tt>) or just open a new shell to make your changes effective.

<hr>
\section secBashToolsFeatures ugbash Features

- <tt>$UG4_ROOT</tt> will be set automatically to YOURUG4ROOT.
- <tt>$UG4_ROOT/scripts/shell</tt> and <tt>$UG4_ROOT/bin</tt> will be added to your path. That means you can call <tt>ugshell</tt> from everywhere.
- \ref bashToolsCompletion

ugbash makes some additional bash commands available:
- <tt>cdug</tt> will change directory to <tt>UG4_ROOT</tt>. <tt> cdug subdir</tt> will change directory to <tt>UG4_ROOT/subdir</tt> (completion possible). 
- <tt>ugbasegrep</tt> "the stuff i search" will do a grep-search for "the stuff i search" in ug4/ugbase, same for <tt>ugpluginsgrep</tt> in ug4/plugins.
- <tt>ugrelib</tt> will delete ug4/lib/*, ug4/bin/ugshell and ug4/bin/plugins/*, so you can re-link ugshell (sometimes necessary).
- ugsubmit (\ref pageugsubmit)
- \ref bashToolsXprun

 
 
<hr>
\section bashToolsPrompt BASH prompt
The standard bash prompt is not very descriptive, so add 
<tt>source YOURUG4ROOT/scripts/shell/prompt</tt> 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 <a href="http://mathemartician.blogspot.com/2012/07/ultimate-bash-prompt.html"> here </a>.

 
<hr>
\section bashToolsCompletion Completion
<hr>

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

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


<hr>
\section bashToolsXprun 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.
\code
xprun 4 gdb --args ugshell -ex conv_diff/laplace.lua -outproc -1
\endcode

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.


*/
