DIRAC is configured using CMake, typically via the setup script, and subsequently compiled using make or gmake.
To compile and run DIRAC you need CMake 2.8 or higher and python 2.4 or higher.
It is your machine and you have Ubuntu or Debian:
$ sudo apt-get install cmake
On Fedora:
$ sudo yum install cmake
Similar mechanisms exist for other distributions or operating systems. Please consult Google.
If it is a cluster, please ask the Administrator to install/upgrade CMake.
If it is a cluster, but you prefer to install it yourself (it’s easy):
DIRAC is configured using CMake. The setup script is a useful front-end to CMake. It does nothing else than create the directory “build” and call CMake with appropriate environment variables and flags:
$ ./setup [--flags]
$ cd build
$ make
To see all available options:
$ ./setup --help
You can see the CMake command using:
$ ./setup [--flags] --show
and use it directly to call CMake without setup.
In order to get familiar with the configuration setup, let us demonstrate some of the most typical configuration scenarios.
Configure for parallel compilation using MPI (make sure to properly export MPI paths):
$ ./setup --fc=mpif90 --cc=mpicc
Configure for parallel compilation using MPI and 64-bit integers:
$ ./setup --fc=mpif90 --cc=mpicc --int64
Configure for sequential compilation using ifort/icc:
$ ./setup --fc=ifort --cc=icc
Configure for sequential compilation using gfortran/gcc:
$ ./setup --fc=gfortran --cc=gcc
You get the idea. The configuration is normally pretty good at detecting math libraries automatically, provided you export proper environment variables, see Linking math libraries.
By default CMake builds out of source. This means that all object files and the final binary are generated outside of the src/ directory. Typically the build directory is called “build”, but you can modify this default behavior:
$ .setup [--flags] alternative-build-path
The out of source compilation is in contrast to previous DIRAC releases. This strategy offers several advantages. One obvious advantage is that you can now build several binaries with the same source:
$ cd /sourcepath
$ ./setup --fc=gfortran --cc=gcc /gfortran-buildpath
$ cd /gfortran-buildpath
$ make
$ cd /sourcepath
$ ./setup --fc=ifort --cc=icc /ifort-buildpath
$ cd /ifort-buildpath
$ make
If you are familiar with CMake you don’t have to use the setup script. The setup script does nothing else than calling CMake with appropriate environment variables and flags, it is a convenient front-end.
Minimal example:
$ mkdir build
$ cd build
$ cmake ..
$ make
The two following strategies are completely equivalent:
Using CMake directly:
$ mkdir build
$ cd build
$ FC=mpif90 CC=mpicc cmake -DENABLE_MPI=1 -DCMAKE_BUILD_TYPE=Release ..
$ make
Using setup:
$ ./setup --fc=mpif90 --cc=mpicc
$ cd build
$ make
If the compiler contains “mpi”, then you can omit the flag –mpi, setup will set it in this case automatically.
Please note that the defaults for performance optimization are different for setup and direct CMake: by default setup configures for optimization, whereas direct CMake commands configure code without optimization. Both defaults can be changed.
There is nothing special about the directory “build”. You can do this instead:
$ mkdir /buildpath
$ cd /buildpath
$ cmake /sourcepath
$ make
Make install is very useful to make DIRAC available to other users on the same machine:
$ ./setup [--flags] --prefix=/path
$ cd build
$ make
$ make install
We recommend to let $PATH point to the install directory:
$ ./setup [--flags] --prefix=/install/path
$ cd build
$ make
$ make install
This way everything (binary, scripts, basis sets) will be at the right place under /install/path and $PATH should contain /install/path.
Sometimes you want to see the actual compiler flags and definitions:
$ make VERBOSE=1
Yes, it works. Try:
$ make -j4
We have successfully compiled DIRAC on 64 cores. With the new configuration based on CMake, compilation race condition errors do not appear.
If you want to turn optimization off (debug mode), there are several ways to do that.
Either use setup:
$ ./setup --debug [other flags]
$ cd build
$ make
Or use CMake directly (default here is debug mode):
$ mkdir build
$ cd build
$ [FC=ifort CC=icc] cmake ..
$ make