This article describes how to deploy a Microsoft Azure compute instance to use with a CP2K compiled from scratch.
First, you need an instance. Login to MS Azure and switch to the resources tab. Select “Add” in the top menu to create a new virtual machine (or dedicated server if you go for the beefy machines). Select “Ubuntu Server” machines from Canonical. Select Ubuntu 16.04, one of the instance sizes matching your needs and fill all mandatory fields. For simple single-node calculations their actual content is of minimal interest. Make sure to paste your public SSH key into the appropriate field (the whole contents of the file .ssh/id_rsa.pub on most machines). As soon as your machine is available, you can directly login via SSH. Note that you specified the username during setup, so that username together with the IP/URL and your SSH key should allow you to connect directly. Depending on the availability provisioning your machine can take up to some 15 minutes.
Update the software database
sudo apt-get upgrade
Install the bare dependencies of CP2K and helpful tools:
sudo apt-get install build-essential gfortran libscalapack-mpi-dev \ libscalapack-openmpi1 libscalapack-pvm-dev libscalapack-pvm1 \ libfftw3-3 libfftw3-dev libblas-dev liblapack-dev libint-dev \ python checkinstall
Now two dependencies have to be built that are either not available in the repository or just compiled with the wrong flags.
cd mkdir libxc cd libxc wget 'http://www.tddft.org/programs/octopus/down.php?file=libxc/libxc-2.2.3.tar.gz' -O 'libxc-2.2.3.tar.gz' tar xzf libxc-2.2.3.tar.gz cd libxc-2.2.3/ ./configure make -j XX
with XX in the last line being the number of cores your machine offers. Now libxc is compiled. To help easy uninstalling, we use checkinstall as follows:
sudo checkinstall
Just answer all the questions quickly – your answers are of no importance to the success of this method.
Then, we do the same with libint
cd mkdir libint cd libint wget 'http://downloads.sourceforge.net/project/libint/v1-releases/libint-1.1.4.tar.gz?r=&ts=1466686515&use_mirror=tenet' -O 'libint-1.1.4.tar.gz' tar xzf libint-1.1.4.tar.gz cd libint-1.1.4 ./configure --with-libint-max-am=6 --with-libderiv-max-am1=4 --with-libderiv-max-am2=3 make -j XX sudo checkinstall<br> with XX in the second-to-last line being the number of cores your machine offers.
Now you can checkout cp2k from your favourite source. Here, we take github:
git clone git@github.com:cp2k/cp2k.git
Now for compilation you need to hint to the compiler where to find all libraries. In CP2K, this information is stored in ARCH files in the cp2k/arch/ directory. Put the following two files there (UbuntuServer.sopt for single-core calculations and UbuntuServer.popt for multicore calculations).
UbuntuServer.sopt:
CC = gcc CPP = FC = gfortran LD = gfortran AR = ar -r FFTW_INC = /usr/include/ FFTW_LIB = /usr/lib/x86_64-linux-gnu/ LIBINT_INC = /usr/local/libint/1.1.4-stable/include LIBINT_LIB = /usr/local/libint/1.1.4-stable/lib LIBXC_INC = /usr/include/ LIBXC_LIB = /usr/lib/x86_64-linux-gnu/ DFLAGS = -D__FFTW3 -D__LIBINT -D__LIBXC2\ -D__LIBINT_MAX_AM=7 -D__LIBDERIV_MAX_AM1=5 -D__MAX_CONTR=4 CPPFLAGS = FCFLAGS = $(DFLAGS) -O2 -ffast-math -ffree-form -ffree-line-length-none\ -ftree-vectorize -funroll-loops\ -mtune=native\ -I$(FFTW_INC) -I$(LIBINT_INC) -I/opt/etsf/include LDFLAGS = $(FCFLAGS) -static-libgfortran LIBS = -L/usr/lib/libblas/ -L/usr/lib/ -L/opt/etsf/lib -L/usr/lib/lapack/ -lblas -llapack\ $(FFTW_LIB)/libfftw3.a\ -lxcf90\ -lxc\ $(LIBINT_LIB)/libderiv.a\ $(LIBINT_LIB)/libint.a
and UbuntuServer.popt:
CC = gcc CPP = FC = mpif90 LD = mpif90 AR = ar -r FFTW_INC = /usr/include/ FFTW_LIB = /usr/lib/x86_64-linux-gnu/ LIBINT_INC = /usr/local/libint/1.1.4-stable/include LIBINT_LIB = /usr/local/libint/1.1.4-stable/lib LIBXC_INC = /usr/include/ LIBXC_LIB = /usr/lib/x86_64-linux-gnu/ DFLAGS = -D__FFTW3 -D__LIBINT -D__LIBXC2\ -D__LIBINT_MAX_AM=7 -D__LIBDERIV_MAX_AM1=5 -D__MAX_CONTR=4\ -D__parallel -D__SCALAPACK CPPFLAGS = FCFLAGS = $(DFLAGS) -O2 -ffast-math -ffree-form -ffree-line-length-none\ -ftree-vectorize -funroll-loops\ -mtune=native\ -I$(FFTW_INC) -I$(LIBINT_INC) -I/opt/etsf/include LDFLAGS = $(FCFLAGS) -static-libgfortran LIBS = -L/usr/lib/libblas/ -L/usr/lib/ -L/opt/etsf/lib -L/usr/lib/lapack/ -lscalapack-openmpi -lblas -lblacs-openmpi -llapack\ $(FFTW_LIB)/libfftw3.a\ -lxcf90\ -lxc\ $(LIBINT_LIB)/libderiv.a\ $(LIBINT_LIB)/libint.a
Now enter the cp2k/makefiles folder and build cp2k
cd cd cp2k/cp2k/makefiles make -j XX ARCH=UbuntuServer VERSION="sopt popt"