Installation of CERN software

Here I will explain in the following the installation of fortran based CERN software. The base of most of the software is n most cases the cernlib software package.

Create as a first step a temporary directory for the compilation of all the cern software and enter this directory. The installation can happen to any directory you like.

  mkdir /tmp/cern
  cd /tmp/cern

Installation of the lapack and blas library

The Cernlib relies on two libraries which are in most cases not installed on the system. Get the sources and unpack it in the temporary directory. This will create a directory lapack-. At the time of writing this tutorial the version was 3.4.2.

  tar -xzvf lapack.tgz

Enter the directory and create a build directory.

  cd lapack-3.4.2
  mkdir build

Enter the new build directory, run cmake and the make.

  cd build
  cmake ..
  make -j<number of parallel processes>

The static libraries have to be copied to the correct location before starting the compilation of the Cernlib package.

Installtion of Cernlib

First et the software from the CERN webpage. The latest source code dates back to 2006. Since there is no further development this is the actual version of the software. After the download to the temporary directory, unpack the software which will create a subdirectory 2006.

  cd /tmp/cern
  tar -xzvf 2006_src.tar.gz

The Cernlib package was initially written only for 32-bit machines, so we need to apply some patches to run the software also on 64-bit machines. A good description about the issue can be found here. The Debiab project now takes care to build a version of Cernlib, so one could get a running version of Cernlib from Debian. Unfortunately they have many issues with the licencing of parts of cernlib and remove/disable some part of the software. So what we do here is to get the patches from the debian project and appy the to our source code. Actually in the moment we appy only some of the patches and additionally some patches from us. The patches can be found in the tar archive attached to this page. After downloading and installing the patches appy them in the order indicated by the number in the file name.

  cd /tmp/cern
  tar -xzvf cernlib_patches.tar.gz
  patch -p0 < 211-support-amd64-and-itanium.dpatch   
  patch -p0 < 214-fix-kernnum-funcs-on-64-bit.dpatch   
  patch -p0 < 304-update-Imake-config-files.dpatch  
  patch -p0 < 307-use-canonical-cfortran.dpatch     
  patch -p0 < 321-support-gfortran.dpatch
  patch -p0 < 999-My_patch.patch

The installation procedure need the definition of some environment variables and rely on the existence of the program gmake which actually is the gnu make program. If the program does not exist on the system it is enough to create a symlink from gmake to make and add the directory to the PATH. Below is a bash script which set up the correct environment variables.

export CERN=/tmp/cern
export CERN_LEVEL=2006

export CERN_INSTALLDIR=<Installation_directory>

mkdir -p $CERN_BINDIR
mkdir -p $CERN_LIBDIR

# check if gmake exist on the system and create a symlink if it doesn't exist
which gmake
if [ "$?" -ne "0" ]; then
  mkdir -p $CERN/bin
  ln -s /usr/bin/make $CERN/bin/gmake
  export PATH=$CERN/bin:$PATH


mkdir -p $CERN_ROOT/build
cd $CERN_ROOT/build

Save and execute the script above to setup everything correctly.


Now copy the lapack and blas library to the needed location.

  cp /tmp/cern/lapack-3.4.2/build/lib/liblapack.a $CERN_LIBDIR/liblapack3.a
  cp /tmp/cern/lapack-3.4.2/build/lib/libblas.a $CERN_LIBDIR/libblas.a

The build system of cernlib is Imake. To generate the Makefiles needed by gnu make run the following command which will crate the initial Makefile. After the makefile is present you create all other Makefiles.

  gmake tree

Before we can start to build the Cernlib we have to build one binary first which is needed by man targets.

  gmake bin/kuipc

If the binary kuips is found in your path, you can start to build the complete project.

  make -j<number_of_processes>

To compile and install patchy one needs a running version of ypatchy, so we have to bootstarp it.

  mkdir nypatchy
  cd nypatchy
  gfortran -c $CVSCOSRC/p5boot/p5lib/*.f
  ar cr libp5.a *.o
  gfortran -o nypatchy  $CVSCOSRC/p5boot/nypatchy.f libp5.a $CERN_LIBDIR/libkernlib.a
  cp nypatchy $CERN_BINDIR
  ln -s $CERN_BINDIR/nypatchy $CERN_BINDIR/ypatchy

Unfortunately the build process did not install all the nneded binaries and scripts. So we have to do this step by hand.


for (dir in graflib packlib pawlib patchy); do
  cd $dir
  make install.bin
  cd ..

cp $CVSCOSRC/scripts/cernlib $CERN_BINDIR
chmod a+rx $CERN_BINDIR/cernlib
cp $CVSCOSRC/scripts/gxint $CERN_BINDIR
chmod a+rx $CERN_BINDIR/gxint

Now we have a complete Cernlib installation and we can go on with the installation of garfield and magboltz which will be described in the following.

Installation of Garfield

The installation procedure is described in detail here and here.

Get all the necessary source files which are lnked from the cern garfield webpage.


cd /tmp/cern
mkdir garfield
cd garfield





mv garfield-7_linux.cra garfield-7.cra

mv garfield-8_linux.cra garfield-8.cra

mv garfield-9_linux.cra garfield-9.cra

mv garfadd-7_linux.cra garfadd-7.cra

mv garfadd-8_linux.cra garfadd-8.cra

mv garfadd-9_linux.cra garfadd-9.cra

chmod +x patchy_step

# remove the explicit directory from the call of ypatchy
sed 's#/cern/pro/bin/##g' -i'' patchy_step

Open now a new terminal and setup the correct cern environment which point to your installation directory by executing the following script

export CERN=<Installation_directory>
export CERN_LEVEL=2006

export PATH=$CERN_ROOT/bin:$PATH

The first step is to install the nneeded nebem libraries.

  mkdir nebem
  mv neBEMV1.8.13.tgz nebem
  cd nebem
  tar -xzvf neBEMV1.8.13.tgz
  cd V1.8.13

Change the Makefile to find the needed libraries. This can be done by using the following patch

--- makefile_linux   2013-08-11 13:50:13.000000000 +0200
+++ makefile_linux_new   2013-08-26 17:57:11.374820194 +0200
@@ -10,8 +10,8 @@
 # ----
 FC = gfortran
 LF= `cernlib graflib/X11,kernlib,mathlib,packlib`
-BEMDIR = /afs/
+BEMDIR = ./nebem/V1.8.13/
 FF = -O3 -fbounds-check -fbackslash # -Wuninitialized 
 relink-9: $(BEMDIR)/obj/neBEM.o
@@ -26,7 +26,7 @@
 new-9: $(BEMDIR)/obj/neBEM.o
    -rm *.f
    ./patchy_step garfadd-9
-   /cern/pro/bin/fcasplit garfadd-9.f
+   fcasplit garfadd-9.f
    -rm garfadd-9.f garfadd-9.mkfca garfadd-9.shfca y.lis
    $(FC) -c $(FF) *.f
    rm *.f
@@ -53,8 +53,8 @@
    rm *.f
 main-9.f: garfield-9.f
-   /cern/pro/bin/fcasplit garfield-9.f
-   /cern/pro/bin/fcasplit garfadd-9.f
+   fcasplit garfield-9.f
+   fcasplit garfadd-9.f
    -rm garfield-9.f garfield-9.mkfca garfield-9.shfca y.lis
    -rm garfadd-9.f garfadd-9.mkfca garfadd-9.shfca y.lis
    mv main.f main-9.f
@@ -67,7 +67,7 @@
    -rm *.f *.o
    ./patchy_step garfboinc-9
-   /cern/pro/bin/fcasplit garfboinc-9.f
+   fcasplit garfboinc-9.f
    -rm garfboinc-9.f garfboinc-9.mkfca garfboinc-9.shfca y.lis
    $(FC) -c $(FF) -fno-second-underscore *.f
    rm *.f

The patch is applied and the code is compiled using the following commands.


patch -p0 < garfield.patch
make -f makefile_linux garfield-9

Installation of Magboltz

Information about Magboltz can be found here and installation instructions here

First create a directory and get the source code and then compile simply one file. In the end move the executable to the binary directory.

  cd /tmp/cern
  mkdir magboltz
  cd magboltz
  gfortran -o magboltz magboltz-10.0.1.f -L$(CERN_ROOT)/lib -lpacklib -lmathlib -lkernlib
  mv magboltz $CERN_ROOT/bin


After all the installations are done, you can remove the temporary directory.

-- FlorianUhlig - 26 Aug 2013
Topic revision: r4 - 2013-08-27, FlorianUhlig
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding CBM Wiki? Send feedback
Imprint (in German)
Privacy Policy (in German)