Building from scratch

Compiling Octopus on some systems might be difficult, this is mainly because some libraries are required and they have to be all compiled with same Fortran compiler. This is a guide on how to compile Octopus and the required libraries starting from scratch (a Fortran compiler is required) in a standard Unix system.

This page should be considered a last resort. On most systems you will be able to install many of these dependencies from a package manager or other pre-built binaries, which will save you a lot of effort.

Prerequisites

You will need the following:

Compiler flags

Since probably you want Octopus to run fast, you will probably would to set optimization flags for both the C and Fortran compilers on your system (at least -O3). In general Octopus should run fine with aggressive optimization options. We will assume now that you have found a set of flags for <cc> and <f90>, we will call them <cflags> and <fflags>. For example <cflags> could be -O3 -march=native .

If <cc>, <f90>, <cflags> or <fflags> contain spaces you should not enclose them in " ". We will put the " " explicitly when it is necessary.

Compilation of libraries

First we will compile and install the libraries required by Octopus.

BLAS

The first library we will compile is blas. We will use the generic reference implementation, this version is not highly optimized but it is free software and simple to install. So after you have a working version of Octopus you may want to use a more optimized blas implementation as [https://www.tacc.utexas.edu/resources/software/-blas libgoto], [https://math-atlas.sourceforge.net ATLAS], MKL, ACML, ESSL, etc.

 FORTRAN  = <f90>
 OPTS     = <fcflags>
 DRVOPTS  = $(OPTS)
 NOOPT    =
 LOADER   = <f90>
 LOADOPTS =
 mkdir <basedir>/lib

and copy the file blas_LINUX.a to <basedir>/lib/libblas.a

 cp blas_LINUX.a <basedir>/lib/libblas.a

Note: the generated file librrary will be always called blas_LINUX.a independently of the operating system you are using, this is just a name.

LAPACK

We will use the open source reference implementation of Lapack.

 cp make.inc.example make.inc
 FORTRAN  = <f90>
 OPTS     = <fcflags>
 DRVOPTS  = $(OPTS)
 NOOPT    =
 LOADER   = <f90>
 LOADOPTS =
 make lib

GSL

 ./configure CC="<cc>" --prefix=<basedir> --disable-shared --enable-static
 make
 make install

FFTW 3

 ./configure  --prefix=<basedir> CC="<cc>" CFLAGS="<cflags>" F77="<f90>" F77FLAGS="<fflags>"
 make
 make install

LibXC

 tar -xvzf libxc-.tar.gz
 cd libxc-
 ./configure --prefix=<basedir> CC="<cc>" CFLAGS="<cflags>" FC="<f90>" FCFLAGS="<fcflags>"
 make
 make install

Compilation of Octopus

After compiling the libraries, now we are ready to compile Octopus. These are the steps you have to follow:

 export LIBS_BLAS=<basedir>/lib/libblas.a
 export LIBS_LAPACK=<basedir>/lib/liblapack.a
 export LIBS_FFT=<basedir>/lib/libfftw3.a
 ./configure CC="<cc>" CFLAGS="<cflags>" FC="<f90>" FCFLAGS="<fcflags>" --prefix=<basedir> --with-gsl-prefix=<basedir> --with-libxc-prefix=<basedir>
 make
 make install
 make check

All tests should be passed if the compilation is correct. If all of them fail, there is probably a problem with your executable, typically missing dynamic libraries. If just some fail, there might be a more serious problem, we recommend you to look for help in the [[Mailing lists]].