Redimp's Blog
15Apr/1422

environment module files

Environment module files are a nice way to provide multile versions of different packages for users. In our network, we provide a nfs mounted /opt-Partition which contains every software which isn't supported (either in no way, or in different versions) by our distribution.

We put all packages in /opt/packkages/$packagename-$version/. When compiling packages, we use --prefix=/opt/packkages/$packagename-$version/, which makes it easy to use for example a library like openmpi.

To install environment modules from the scratch, download the tar.gz from http://sourceforge.net/projects/modules/.

The following at least worked for VERSION=3.2.10.

# Unpack tar xvf modules-$VERSION.tar.gz
# Change directory
cd modules-$VERSION
# Configure (I'm using a network shared /opt partition)
./configure --prefix=/opt/packages/modules/
# Build and install
make && make install
# create default link (i have no idea, why this 
# isn't done by "default"
cd /opt/packages/modules/Modules/
ln -s $VERSION default
# return to the source directory
cd -
# copy profile script to a profile.d directory 
# (in my case again on /opt)
cp etc/global/profile.modules /opt/etc/profile.d/profile.modules.sh
# edit module configuration
vim /opt/packages/modules/Modules/$VERSION/init/.modulespath
# i just commented out all lines and add /opt/modules where
# i put my module files

The next step is, to create the module files. I suggest to keep them as clean and small as possible. Using Variables makes them easy to copy n paste (for example, if you update a library to a new version and want to keep the old version too).

Beware, there are many strange module files to find in the web. I suggest to write them by yourself and use only commands you know and environment variables from which you know what they are doing.

First example cmake, which i build using:

# Download
wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz
# Extract
tar xzf cmake-2.8.12.2.tar.gz
# create build directory
mkdir -p cmake-2.8.12.2/build; cd cmake-2.8.12.2/build
# configure
cmake .. -DCMAKE_INSTALL_PREFIX=/opt/packages/cmake-2.8.12.2
# make and install 
make -j4 && make install

whichs results in a driectory which looks like this

ls /opt/packages/cmake-2.8.12.2/
bin  doc  man  share

So i create a module file /opt/modules/cmake/2.8.12.2 which makes cmake easy useable:

#%Module1.0
#####################
# CMake Module file
 
set package "cmake"
set version "2.8.12.2"
set dir "/opt/packages/$package-$version"
 
# Defines String that is displayed when command "module whatis" is invoked
module-whatis "$package/$version - sets the environment variables to use $package in $dir"
 
 
if { ! [ file exists $dir ] } {
	puts stderr "$package-$version is not available on this machine. directory $dir not found"
	exit 1
}
 
# Set Conflicts: Defines modulefiles that can not be loaded at the same time
conflict $package
 
prepend-path PATH	$dir/bin
prepend-path MANPATH	$dir/man

What a module does, can be tested by using module show:

module show cmake/2.8.12.2 
-------------------------------------------------------------------
/opt/modules/cmake/2.8.12.2:
 
module-whatis	 cmake/2.8.12.2 - sets the environment variables to use cmake in /opt/packages/cmake-2.8.12.2 
conflict	 cmake 
prepend-path	 PATH /opt/packages/cmake-2.8.12.2/bin 
prepend-path	 MANPATH /opt/packages/cmake-2.8.12.2/man 
-------------------------------------------------------------------

next, load the module, and check if we got the right cmake version:

# load module
$ module load cmake/2.8.12.2 
# check which binary is used
$ which cmake
/opt/packages/cmake-2.8.12.2/bin/cmake
# check version
$ cmake --version
cmake version 2.8.12.2

I hope this little howto will help somebody (at least me, if i have to install module files again somewhere else). Commends welcome.

Hint: Useful documentation i've used:

Tagged as: 22 Comments
19Nov/091

Vortrag: Subversion

Im Institut wird dieses Semester ein Mini-Seminar veranstaltet, dass den Titel "Technische Numerik" traegt. Hier werde alle moeglichen technischen Mittel erlaeutert, die man in der Numerik braucht und die (meistens) wenig mit Mathe zu tun haben. Unter den Vortragsthemen sind der gdb, valgrind, mpi und noch ein Haufen anderer, spannender Kram.

Ich habe im Rahmen dieses Seminars einen Vortrag mit dem Thema "Versionskontrolle mit Subversion" gehalten. Meine Folien dazu gibt es hier: Versionskontrolle mit SVN.

Da ich das wiederholt gefragt worden bin... Die "Terminals" habe ich mit dem \LaTeX Paket lstlisting gemacht.

% Paket einbinden
\usepackage{listings}

% Sprache definieren
\lstdefinelanguage{svn}{
morekeywords={commit,import,add,checkout,create,status,
diff,update,propset,propdel,blame,log,resolve,copy,propedit,
propget,proplist,merge,copy},
morekeywords={[2]svn,svnadmin,ls,cd}
}

% Listings konfigurieren
\lstset{lineskip=1pt,numbers=none,linewidth=\linewidth,
basicstyle=\color{white}\ttfamily,
backgroundcolor=\color{black},
keywordstyle=\color{blue},
keywordstyle={[2]\color{green}}}

% Die Umgebung svn erstellen
\lstnewenvironment{svn}[1][]
{\lstset{language=svn,#1}}{}

Das laesst sich im Paket latex-beamer dann wie folgt benutzen:

\begin{frame}[fragile]{Test der svn-Umgebung}
\begin{svn}
> svn update
At revision 1.
\end{svn}
\end{frame}

und sieht dann so aus:

Tagged as: , , 1 Comment