How do I setup one .bashrc for both MSI labs and clusters?

(Updated 1/11/13)

MSI provides all users with home directories on a shared file-system that allows uniform access to data whether the user is on a lab machine (e.g., SDVL or CGL workstations) or a cluster (e.g., Calhoun or Itasca). When a user logs in, a file in their home direcory ($HOME) named $HOME/.bashrc is parsed to setup the shell/execution environment. Typically, the contents of the .bashrc may configure program aliases, modify paths and/or set environment variables. Users can customize this file for themselves. Refer to this page regarding usage of .bashrc vs .bash_profile.

A common issue with the shared file-system is users modify the .bashrc for one environment (e.g., Lab machines) and then encounter problems when they login to another system (e.g., Itasca or Calhoun). This can occur if .bashrc points to executables/directories/libraries that exist in different directories across systems.

MSI recommends adding a "case" statement similar to the following in your .bashrc to easily customize your environment based on the system you are accessing. Users can modify the commands for each case; cases do not fall through.

#### BEGIN CUT ####
#====================
# The MSICLUSTER variable is defined globally on MSI systems.
case $MSICLUSTER in
   "lab")
       # Customization for Lab Queue machines and Workstations in SDVL, LMVL, CGL, BSCL, BMSDL
       alias grep='grep --color'
       # GPUT is now included in the lab queue
       case $HOSTNAME in
           gput*) module load cuda;;
           *);;
       esac
   ;;
   "calhoun")
       # Customization for Calhoun
       module load intel ompi/intel
       export MPI_PATH=$OPEN_MPI_PATH
   ;;
   "itasca")
       # Itasca has a variety of MPI options. The Platform MPI (pmpi) is recommended.       
       module load intel pmpi/intel
       export MPI_MAX_REMSH=16
       export MPI_MAX_MPID_WAITING=64
       export MPI_BUNDLE_MPIDS=N
       export OMP_NUM_THREADS=1
   ;;
   "cascade")
       # For GPGPU:  
       module load cuda
   ;;
   *)
       # Put additional .bash_profile commands here for all other machines 
   ;;
esac

# Finish with common commands for ALL systems
alias vi=vim
export EDITOR=vi
#### END CUT ####

Please refer to this FAQ for systems that do not source .bashrc on login.