Cp2K

1.  Running cp2k


CP2K is a freely available (GPL) program that can be used to perform atomistic and molecular simulations of solid state, liquid, molecular and biological systems. It provides a general framework for different methods such as e.g. density functional theory (DFT) using a mixed Gaussian and plane waves approach (GPW), and classical pair and many-body potentials. For any further information please check the project webpage.

A recent version of CP2K is available on HG1 already compiled and ready for use. The recommended version is compiled with the Intel Fortran Compiler 10.1 and full MPI support. MKL libraries are used for linear algebra calculations. You can load it with the command

$ module load cp2k

and the module will provide the path to the executables. You don't need to load any other modules in order to use CP2K as the module will take care to configure the working environment properly. To run CP2K you should just include in your PBS scripts a line like the following

mpirun -x PATH -x LD_LIBRARY_PATH cp2k.popt < infile.dat > outfile.dat

and the program will run fine. To check what libraries are being used by CP2K use the module list command.

2.  Compiling CP2K


If you need to compile your own version of the program this section offers some guidelines to help you build it successfully from source. If you need a version that "just works" don't bother with the following information and stick to the instructions given in the first section. A great "thank you" goes to Axel Kohlmayer for providing the tips'n'tricks.

CP2K requires the following libraries to work:

  • BLAS and LAPack, usually included in the ACML or MKL package
  • a working MPI environment
  • FFTW2, FFTW3 library or ACML/MKL fft routines
  • BLACS and ScalaPACK libraries built on top of BLAS and MPI

An optional library that enables additional functionalities is libint (see this page for more information).

2.1  Intel Compiler Suite + MKL + FFTW3

The bulding process should start by loading the modules that configure the working environment. In this case you should load the following modules:

  • intel
  • openmpi
  • mkl

To compile CP2K on Cerbero, you can use the following makefile

CC       = mpicc
CPP      = 
FC       = mpif90 
LD       = mpif90
AR       = ar -r

DFLAGS   = -D__INTEL -D__FFTSG -D__parallel -D__BLACS -D__SCALAPACK -D__FFTW3
FCFLAGS  = $(DFLAGS) -I$(FFTW_INC) -O2 -unroll -march=pentiumpro -pc64 -fpp -free -heap-arrays 64
LDFLAGS = $(FCFLAGS) -i-static
LIBS     = -L$(MKL_LIB) -Wl,-rpath,$(MKL_LIB) \
           -lmkl_scalapack_lp64 -lmkl_blacs_openmpi_lp64 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core \
           $(FFTW_LIB)/libfftw3.a

and place it in the arch subdirectory under the name "Linux-x86-64-intel.popt". To compile the program you should go to the makefiles subdirectory, type

$ make ARCH=Linux-x86-64-intel VERSION=popt

and CP2K should build correctly.

If you need to include the libint library in the program you should enter the libint_tools subdirectory and type

$ icpc -O3 -c libint_cpp_wrapper.cpp -I/opt/libint/1.1.4/intel/include

This command will build a wrapper in order to call the library (written in C++) from CP2K (written in Fortran95). To link the wrapper and the library properly you should use the following makefile

CC       = mpicc
CPP      = 
FC       = mpif90 
LD       = mpif90
AR       = ar -r

LIBINT_DIR=/opt/libint/1.1.4/intel/lib
MYCP2KDIR=$MYHOME/cp2k

DFLAGS   = -D__INTEL -D__FFTSG -D__parallel -D__BLACS -D__SCALAPACK -D__FFTW3 -D_LIBINT
FCFLAGS  = $(DFLAGS) -I$(FFTW_INC) -O2 -unroll -march=pentiumpro -pc64 -fpp -free -heap-arrays 64
LDFLAGS = $(FCFLAGS) -i-static
LIBS     = -L$(MKL_LIB) -Wl,-rpath,$(MKL_LIB) \
           -lmkl_scalapack_lp64 -lmkl_blacs_openmpi_lp64 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core \
           $(FFTW_LIB)/libfftw3.a \
           $(MYCP2KDIR)/libint_tools/libint_cpp_wrapper.o \
           $(LIBINT_DIR)/libderiv.a \
           $(LIBINT_DIR)/libint.a \
           -lstdc++

and remeber to set the MYCP2KDIR to the path of your CP2K source code directory. Finally proceed to compile in the same way as before.