Compiling Nmag on Iridis 3

On Iridis 3 the compilation of Nmag is complicated by the fact that one has to use the Intel provided versions of BLAS/LAPACK. On the other hand, such libraries are able to exploit the hardware of the machine and should allow Nmag to use the multi-core architecture of the CPUs.

Using Intel Math Kernel Library (MKL)

To compile against the Intel MKL one has to load the appropriate module on Iridis 3.
Login on Iridis 3, ssh and type:

module load intel/mkl

Documentation for the library can be found by typing:


These are two shell scripts launching acrobat reader with the appropriate path for the PDF files.
Try less `which mkl_ref` and less `which mkl_use`.
In theory you could now compile Nmag, download the tarball, place it somewhere on the system


Note that PETSc configuration may fail due to a problem with python and (which on Iridis3 does reference a symbol, pqueue_size, which is not defined anywhere). If you have this problem, then jump to the section about Python later before reading this one.

For PETSc 2.3.3-p15 the following works:

python ./config/ --with-shared \
 --with-mpi-dir=/temp/franchin/i3/nmag-0.1/lib/mpich2 \
 --COPTFLAGS=-O3 --CXXOPTFLAGS=-O3 --with-debugging=no \
 --with-blas-lapack-lib="-L/local/software/intel/mkl/ -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -lm" 

While for PETSc 3.1-p5 the following works:

python ./config/ --with-shared --with-single-library=1 \
 --with-mpi-dir=/temp/franchin/i3/nmag-0.1/lib/mpich2 \
 --COPTFLAGS=-O3 --CXXOPTFLAGS=-O3 --with-debugging=no \
 --with-blas-lapack-lib="" --LDFLAGS="-L/local/software/intel/mkl/ -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -lm" 


To configure HLib:

With sequential MKL:
./configure --with-blas-ldflags='-lm -L/local/software/intel/mkl/ -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread' --prefix=/home/franchin/nmag-0.1/nsim/interface/extra'
With parallel MKL:
./configure --prefix=/work/franchin/par/nmag-0.1/nsim/interface/extra --with-blas-ldflags="-L/local/software/intel/mkl/ -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core -liomp5 -lm -lpthread" 


If compilation of Python fails, do as follows. First, Iridis 3 has its own version of Python, in particular what we need is Python 2.6 or above. Get it from Iridis:

cd nmag-0.1
cp /local/software/rh53/python/2.6.5/source/Python-2.6.5.tar pkgs/

Now adjust the package (it looks as a .tar file but it actually isn't, it is a zipped tar file):

cd nmag-0.1/pkgs
mv Python-2.6.5.tar Python-2.6.5.tar.gz
gunzip Python-2.6.5.tar.gz
bzip2 Python-2.6.5.tar

Now change the nmag-0.1/Makefile so that it uses this file. Type make. Python 2.6.5 should be compiled. PETSc is the next to be compiled and it fails. Indeed, Iridis 3 is apparently broken: the symbol pqueue_size in is not defined anywhere else (at least at the time of writing) and this makes it impossible to import modules such as md5 or hashlib. No worries, Iridis 3 has its own python2.6 (apparently it has been compiled before the package damage) we can steal it.

cd nmag-0.1/lib
mv python2.6 old-python2.6
cp -r /local/software/rh53/python/2.6.5/gcc/lib/python2.6 .

Now your local python almost works, but you still needs some adjustments:

cd nmag-0.1/lib
cp old-python2.6/config/libpython2.6.a python2.6/config/
# ^^^ This is needed because the Iridis 3 guys didn't use --enable-shared when configuring
cp old-python2.6/config/Makefile python2.6/config/
# ^^^ This will let python compile new modules appropriately

You now have your own working copy of Python 2.6. Note that you cannot easily use the Iridis 3 Python, as it doesn't have pytables (and maybe other modules). This is why here we build our own version of Python, so that we can install on it whatever we want.
Note that Python >= 2.6 is necessary, since Nmag is using syntax features which are not present in Python 2.4. Now you can use Python to compile PETSc and Nmag.

You may also have to do the following in order for the pycaml module to compile correctly

cd nmag-0.1/lib
ln -s /usr/lib64/ .

Indeed, in order to link against libpython one also needs to link against libutil (sometimes), which is not stored inside /usr/lib for some reasons...

Also available in: HTML TXT