Plasma Simulation Lab.

Simulation Environment Setup

Setup Shell Environment

In the UNIX/Linux environment, users usually operate computers through the program called a shell. There are many shells, such as bash, tcsh, zsh, among which bash is one of the most popular recently. In the following, bash commands for setting up an environment are described. Refer the manual for the corresponding commands if you are using another shell.

There is a specific type of variables called an environment variable to control the behavior of the shell.

printenv

prints out a list of environment variables that are currently set. The list is consisted of variable=value pairs. For example, USER=alice means that there is an environment variable named USER, and it has a value alice. The value of environment variables is refereed by $<variable name> as follows.

echo $USER

shows the value of the environment variable USER. The variable name can be surrounded by braces, ${USER}. (The braces can clearly denote the variable name to avoid confusion if some other character follows.)

There is an import environment variable PATH. It indicates the comma separated directories list where executables exist. The command in the directory listed in PATH can be executed without indicating its path. The ls command is in /bin, and can be executed without indicating its path as /bin/ls because /bin is usually included in PATH. The following commands

ls
/bin/ls

give the same results.

To set an environment variable, type

variable=value

The export command, like "export variable", makes the variable inherited by child processes. For bash, it is possible to export a variable when setting it as

export variable=name

Normally, the setting of environment variables that are necessary to use the computer system is taken care of by the system. So users do not need to care about it. (Important environment variables, such as PATH, are already set.) However, users can freely change the environment. For example, if a user has a directory named bin in his/her home directory (the environment variable HOME is set to indicate the home directory), and has a command of his/her own in that directory, execute the following command to add ${HOME}/bin to PATH.

export PATH=${HOME]/bin:${PATH}

(If there occurs some problems, just logout and login again to cancel the setting.)

Shells have an initial configuration file that is loaded at login. It is convenient to set one's favorite setting using the configuration file. Just list up commands in the configuration file as they are executed sequentially like those executed in the terminal. Users must be careful not to write illegal commands which may prevent logging in. Contact the system administrators if you have some trouble when logging in.

The initial configuration file for bash is .bash_profile for a login shell, and .bashrc for an interactive shell (in the case where bash is launched in the terminal). The following lines are often written in .bash_profile so that .bashrc is loaded at the login time.

if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

Environment Modules

On the super-computer systems, the Environment Modules package is often used to modify a user's environment dynamically. In the Modules framework, users can setup an environment to use a particular software by loading the modulefile corresponding to the software and its version. The setting is canceled by unloading the module.

module load software
module unload software

The available modules are obtained by the following command.

module avail

Note that there may be dependencies (one module requires other modules) or conflicts between modules. It is also possible to load modules by writing the module commands in the shell's initial configuration file.