Set Environment variables and Path in SERC

There are many environment variables used by programs in Linux. For example, the environment variable HOME points to the home folder of the user. To see the usage, try :

username@tyrone-cluster:~$ echo $HOME

This shows your home directory. PATH is another important environment variable which sets the locations in which programs search for the required files/executables.

In SERC, many programs (like compilers, matlab, etc.) are installed in various folders. We need to actually go to these folders and then run the desired programs which is a messy task. Instead, we can specify the locations of these executables in a configuration file so that the system automatically looks into these places when we try to, say, compile a program. There are many other uses of setting environment variables. But which variables to set depends on the requirements of the user. Let us see how to do this in SERC clusters.

First you need to find out which shell you are using in the terminal by the command,

username@tyrone-cluster:~$ echo $0

The above indicates that you are using the C shell. Some Linux systems may be using the bash shell as default. Whichever shell you are using, there is a configuration file which sets up the environmental variables and default paths for that shell. For C shell, this will located in ~/.cshrc and, for bash shell, this will be ~/.bashrc. Note that ~ indicates your home directory (/home/course/year/username).

Steps to modify the .cshrc/.bashrc file:
1. Open the file in a text editor: (you can use vi or gedit)

username@tyrone-cluster:~$ vi ~/.cshrc

  1. Insert the appropriate paths and environment variables for your required software. I have given the most used ones at the end of this post.
  2. Save the file and close.
  3. You have to source that file for the changes to take effect. Do:

username@tyrone-cluster:~$ source ~/.cshrc

Add the following lines to the ~/.cshrc file for the corresponding software mentioned.
For Tyrone cluster:
 Torque batch system:
You must add this to submit any job in Tyrone cluster.

set path=(/opt/toque-305/bin $path)
set path=(/opt/toque-305/sbin $path)

Intel Fortran compiler:

source /opt/intel/composerxe-2011.5.220/bin/compilervars.csh intel64

MPI support for Intel compilers: (by mvapich2)

set path=(/opt/mvapich2-1.8-r5423/intel/bin $path)
setenv LD_LIBRARY_PATH /opt/mvapich2-1.8-r5423/intel/lib
source /opt/mvapich2-1.8-r5423/intel/etc/mvapich_vars.csh

Ansys – Fluent:

set path=($path /home/pkg/lic/ansys/13/linux/64/v130/fluent/bin)


set path=(/home/pkg/lic/matlab-R2014a/bin $path)


set path=(/home/pkg/lic/mathematica-9.0.1/bin $path)

For IBM Blue Gene/L :

set path=(/opt/ibmll/LoadL/full/bin $path)
set path=(/opt/ibmcmp/xlf/bg/10.1/bin $path)
set path=(/opt/blrts-gnu/bin/ $path)

where the first line is for the load leveler which schedules jobs, the second line is for the IBM XL Fortran compiler and the last line for the GNU compilers for Blue Gene/L.

If you want access to other softwares, you can have a look at the directories /home/pkg/lic and /opt. After adding these paths and sourcing the .cshrc file, you can start the desired program by simply entering the executable name in the terminal from anywhere. e.g. matlab will start the Matlab R2014a program.

—-> Previous article in this series

—-> Next article in this series

Leave a Comment