User Tools

Site Tools


howto:compile_on_mac

How to Compile CP2K on Mac OS X

1.Acquiring the code

If you don't have it already, you need an X11 server. Download and install XQuartz.

After that, go to the Sourceforge website, and download the 2.6.2 version of cp2k.

Using the Mac terminal, go to the directory where cp2k has been downloaded (if it has been downloaded in the Downloads directory type cd ~/Downloads). To unpack the archive files type the command given below

tar -xvf cp2k-2.6.2.tar.bz2

2.Compilation on Mac

An example CP2K ARCH file for a serial build of CP2K on Mac is as follows:

# With GCC 4.9 or later, for gcc and gfortran
# libxc is installed in LIBXC_INCLUDE_DIR / LIBXC_LIB_DIR
# libint is installed in LIBINT_LIB_DIR
CC       = gcc
CPP      =
FC       = gfortran
LD       = gfortran
AR       = ar -r
RANLIB   = ranlib
DFLAGS   = -D__NO_STATM_ACCESS -D__ACCELERATE
FCFLAGS  = -I $(LIBXC_INCLUDE_DIR) -O2 -ffast-math -funroll-loops \
           -ftree-vectorize -ffree-form $(DFLAGS)
LDFLAGS  = $(FCFLAGS)
LIBS     = -framework Accelerate

Remove the -DLIBXC -DLIBINT flag if you compile CP2K. Save it as Darwin-IntelMacintosh-gfortran.sopt in the cp2k-2.6.2/arch directory alongside the other ARCH files.
Launch the Terminal and change the working directory to cp2k-2.6.2/makefiles. Type make command as follows:

make ARCH=Darwin-IntelMacintosh-gfortran VERSION=sopt

It may take quite a while until a compilation is completed. If you have a multi-core machine you may use e.g. make -j 4 to compile in parallel with 4 tasks.
If you find cp2k.sopt in cp2k-2.6.2/exe directory, then compilation is successfully done.

howto/compile_on_mac.txt · Last modified: 2018/04/16 12:08 by gtocci