I believe there are several ways to build CP2K binaries for Windows. Here I describe how to install Cygwin on Windows 10/11, build CP2K with openmpi on the Cygwin, and run it on a PC without Cygwin.
Cygwin is a large collection of GNU and Open Source tools which provides functionality similar to a Linux distribution on Windows, which has been used for a long time.
You can install Cygwin on your 64 bit Windows by using setup-x86_64.exe
and build cp2k on the Cygwin-Windows system.
When installing Cygwin, make sure that you will install the following additional packages:
Archive hdf5 libhdf5-devel Devel bison byacc cmake gcc-fortran gcc-g++ make GNOME libglade Libs fftw3 lapack libevent-devel libxerces-c31 libxerces-c-devel libfftw3-devel libfftw3-omp3 libfftw3_3 libgsl-devel libgsl0 libgsl19 liblapack-devel liblapack0 libopenmpi-devel libopenmpi12 libopenmpi40 libopenmpicxxl libopenmpifh40 libopenmpiusef08_40 libopenmpiusetkr40 openmpi zlib zlib-devel Python Math libopenblas Science gsl Utils hdf5 libhdf5-devel libhwloc-devel
Follow the wizard instruction to finish the Cygwin (and packages) installation.
Download a release
(use the versioned tarballs, `cp2k-X.Y.tar.bz2`) and extract a tarball on the Cygwin64 bash terminal as follows:
$ tar -xvf cp2k-X.Y.tar.bz2
For more details on downloading CP2K, see https://www.cp2k.org/download.
Source codes of most prerequisities are available not only on individual supplyers but also on https://www.cp2k.org/static/downloads/.
Download and extract "scalapack-2.1.0.tgz".
Rename “SLmake.inc.example” to “SLmake.inc” in the generated “scalapack-2.1.0” directory.
Edit the “SLmake.inc” as follows:
#FCFLAGS = -O3 FCFLAGS = -O3 -w -fallow-argument-mismatch
Edit “BLACS/TESTING/Makefile” as follows:
#blacstest.o : blacstest.f # $(FC) $(NOOPT) -c $*.f blacstest.o : blacstest.f $(FC) -c $(FCFLAGS) $*.f
Change the current directory to “scalapack-2.1.0” on the Cygwin 64 terminal and execute “make”.
After the “make” is completed, copy the generated “libscalapack.a” to “/usr/local/lib” because “make install” does not work.
Download a CP2K-configured LIBINT library from libint-cp2k
and extract the archive (e.g.“libint-v2.6.0-cp2k-lmax-7.tgz”) by using the similar way as the cp2k tarball case or something like 7-zip.
Change the current directory to the generated libint directory and execute the following commands on Cygwin 64 bash terminal:
$ cd libint-v2.6.0-cp2k-lmax-7 $ ./configure --enable-fortran=yes --with-cxx=gcc $ make
If you find a static library file “libint2.a” in “libint-v2.6.0-cp2k-lmax-7/lib/.libs” directory, the “make” is successful.
And then change the current directory to “fortran” and execute “make”.
$ cd fortran $ make
However this may result in:
"Error: missing '(' before "__has_include" operand"
and so on, the “make” is successful if “libint_f.mod” is found in the “fortran” directory.
Copy a generated file “libint-v2.6.0-cp2k-lmax-7/lib/.libs/linint2.a” and a “libint-v2.6.0-cp2k-lmax-7/include/libint2” directory manually into “(cygwin-root)/usr/local/lib” and “(cygwin-root)/usr/local/include” directories respectively.
(“Make install” does not seem to work.)
In the arch file of CP2K: add
-D__LIBINT
to the DFLAGS. Add
-L/usr/local/lib -lint2 -lstdc++
to LIBS and
-I/usr/local/include
to FCFLAGS. lstdc++ is needed because of using the GNU C++ compiler.
The version 5.1.0 (or later) of LIBXC can be downloaded from https://www.tddft.org/programs/libxc.
Download and extract “libxc-5.1.0.tar.gz” by using the similar way as cp2k tarball case or something like 7-zip.
Change the current directory to the “libxc-5.1.0” directory and execute the following commands on the Cygwin 64 bash terminal:
$ cd libxc-5.1.0 $ export F77=gfortran $ ./configure --prefix=/usr/local $ make $ make install
Libxc will be installed into /usr/local/ in this case.
In the arch file of CP2K: add
-D__LIBXC
to DFLAGS,
-I/usr/local/include
to FCFLAGS and
-L$/usr/local/lib -lxcf03 -lxc
to LIBS.
A library for matrix operations and deep learning primitives: https://github.com/hfp/libxsmm/
Download and extract "libxsmm-1.16.1.tar.gz".
Change the current directory to the “libxsmm-1.16.1” and execute the following commands on the Cygwin 64 terminal:
$ make $ make PREFIX=/usr/local install
In the arch file of CP2K: add
-D__LIBXSMM
to enable it, with include and library paths, i.e.,
FCFLAGS += -I/usr/local/include -D__LIBXSMM
and
LIBS += -L/usr/local/lib -lxsmmf -lxsmm -ldl
S
PEXSI requires parmetis, scotch, CombBLAS_bata, upcxx, symPACK and superLU_dist.
Download and extract "parmetis-4.0.3.tar.gz".
Cygwin does'nt have execinfo, edit “metis/GKlib/error.c” and invalidate (comment out) the “#ifdef HAVE_EXECINFO_H to #endif” section such as:
/************************************************************************* * This function prints a backtrace of calling functions **************************************************************************/ void PrintBackTrace() { #ifdef HAVE_EXECINFO_H /* void *array[10]; int i, size; char **strings; size = backtrace(array, 10); strings = backtrace_symbols(array, size); printf("Obtained %d stack frames.\n", size); for (i=0; i<size; i++) { printf("%s\n", strings[i]); } free(strings); */ #endif }
And then execute the following commands on the Cygwin terminal:
$ make config
If you find “ld: cannot find -lmpi_cxx” error during “make config (cmake)”, dupulicate “cygwin/lib/libmpi.dll.a” by using cp(copy) command and rename a half of it to “libmpi_cxx.a”.
After “make config”, execute the following commands:
$ make $ make install
Parmetis will be installed into /usr/local/ by default.
If you have an error during the “make”, delete the all contents in “build” directory and try to rebuild.
Download and extract "scotch_6.0.0.tar.gz".
(It looks like the original supplyer no longer supports v6.0.0.)
Copy “src/Make.inc/Makefile.inc.i686_pc_linux2” into “src” and rename it as “Makefile.inc”.
Add “-DINTSIZE64 -DIDXSIZE64 -DOMPI_BUILDING” to CFLAGS on the “Makefile.inc”.
CFLAGS = -O3 -DCOMMON_FILE_COMPRESS_GZ -DCOMMON_PTHREAD -DCOMMON_RANDOM_FIXED_SEED -DSCOTCH_RENAME -DSCOTCH_PTHREAD -Drestrict=__restrict -DINTSIZE64 -DIDXSIZE64 -DOMPI_BUILDING
And then execute the following commands on the Cygwin terminal:
$ cd scotch_6.0.0/src $ make ptscotch $ make install
Download and extract CombBLAS_beta_16_2.tgz.
Edit “CombBLAS_beta_16_2/CMakeLists.txt” and add a linker flag “-lmpi”.
ADD_SUBDIRECTORY( usort ) target_link_libraries(CombBLAS PUBLIC Usortlib) ADD_SUBDIRECTORY( graph500-1.2/generator ) target_link_libraries(CombBLAS PUBLIC GraphGenlib) # add new SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lmpi") #end add new # Set up exported configuration # This allows CombBLAS to be installed in two ways: # 1. In /usr/local (or whatever prefix is specified) # 2. Exporting the current build directory. This allows a user to make # modifications to CombBLAS and have the changes automatically recompiled for # dependent projects. # Either way, we need to create a CombBLASConfig.cmake
And then execute the following commands on the Cygwin terminal:
$ cd CombBLAS_beta_16_2 $ mkdir build $ mkdir install $ cd build $ cmake .. -DCMAKE_INSTALL_PREFIX=../install $ make $ make install
Download and extract "upcxx-2019.9.0.tar.gz".
Execute the following commands on the Cygwin terminal:
$ ./install /usr/local/upcxx
The successful installation will display “UPC++ successfully installed” at the end.
Download and extract "symPACK-2.0.1.tar.gz".
Execute the following commands on the Cygwin terminal:
$ cd symPACK-2.0.1 $ mkdir build $ cd build $ cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_PREFIX_PATH=/usr/local/upcxx
Download and extract "superlu_dist_6.1.0.tar.gz".
Execute the following commands on the Cygwin terminal:
$ cd SuperLU_DIST_6.1.0 $ export PARMETIS_ROOT=/usr/local $ export PARMETIS_BUILD_DIR=${HOME}/parmetis-4.0.3/build/CYGWIN_NT-10.0-x86_64 $ export COMBBLAS_ROOT=/usr/local/combblas $ export COMBBLAS_BUILD_DIR=${HOME}/CombBLAS_beta_16_2/build $ mkdir build $ cd build $ cmake .. \ -DTPL_PARMETIS_INCLUDE_DIRS="/usr/local/include;${HOME}/parmetis-4.0.3/metis/include" \ -DTPL_PARMETIS_LIBRARIES="/usr/local/lib/libparmetis.a;/usr/local/lib/libmetis.a" \ -DCMAKE_INSTALL_PREFIX=/usr/local
Edit the following generated files after cmake and add the “-lmpi” flag at the end of the line.
For example:
/usr/bin/c++.exe -fopenmp -fexceptions -std=c++11 -Wl,--enable-auto-import -fopenmp CMakeFiles/pddrive.dir/pddrive.c.o CMakeFiles/pddrive.dir/dcreate_matrix.c.o -o pddrive.exe -Wl,--out-implib,libpddrive.dll.a -Wl,--major-image-version,0,--minor-image-version,0 ../SRC/libsuperlu_dist.a -lblas -lm -lmpi -lopen-rte -lopen-pal -Wl,-Bstatic -lm -Wl,-Bdynamic /usr/lib/w32api/libgdi32.a -llapack -lblas /usr/local/lib/libparmetis.a /usr/local/lib/libmetis.a -lm -lmpi
Execute the following commands on the Cygwin terminal:
$ make $ make install
SuperLU_DIST will be installed into /usr/local/ by default.
Download and extract "pexsi_v1.2.0.tar.gz".
Execute the following commands on the Cygwin terminal:
$ cd pexsi_v1.2.0 $ mkdir build
Copy config/build.sh.linux.gnu into “build” directory and rename it as “build.sh”.
$ cp config/build.sh.linux.gnu ./build $ mv build/build.sh.linux.gnu build/build.sh
Edit the content of “build/build.sh” and replace the content with:
CC=mpicc CXX=mpicxx FC=mpif90 PEXSI_INSTALL_DIR=/usr/local/pexsi BLAS_LIB=/lib/libblas.dll.a LAPACK_LIB=/lib/liblapack.dll.a DSUPERLU_DIR=/usr/local PARMETIS_DIR=/usr/local METIS_DIR=/usr/local GFORTRAN_LIB=/lib/gcc/x86_64-pc-cygwin/10/libgfortran.dll.a cmake \ -DCMAKE_INSTALL_PREFIX=$PEXSI_INSTALL_DIR \ -DCMAKE_C_COMPILER=$CC \ -DCMAKE_CXX_COMPILER=$CXX \ -DCMAKE_CXX_FLAGS=-DOMPI_BUILDING \ -DCMAKE_Fortran_COMPILER=$FC \ -Dlinalg_BLAS_LIBRARIES="$BLAS_LIB;-fopenmp;-lm;$GFORTRAN_LIB;-lblas;-lquadmath" \ -Dlinalg_LAPACK_LIBRARIES="$LAPACK_LIB;-lblas;-lquadmath" \ -Dsuperlu_dist_INCLUDE_DIR=$DSUPERLU_DIR/include \ -Dsuperlu_dist_LIBRARIES=$DSUPERLU_DIR/lib/libsuperlu_dist.a \ -Dmetis_INCLUDE_DIR=$METIS_DIR/include \ -Dmetis_LIBRARIES=$METIS_DIR/lib/libmetis.a \ -Dparmetis_INCLUDE_DIR=$PARMETIS_DIR/include \ -Dparmetis_LIBRARIES=$PARMETIS_DIR/lib/libparmetis.a \ ..
Execute the following commands:
$ ./build.sh $ make $ make install
The “make install” will install pexsi into the specified directory “usr/local/pexsi”.
In the arch file of CP2K: Add
-D__LIBPEXSI
to DFLAGS. Add
-I$(PEXSI_DIR)/fortran/ (e.g.-I/(username)/pexsi_v1.2.0/fortran)
to FCFLAGS. Add
-lpexsi -llapack -lblas -lsuperlu_dist -lparmetis -lmetis
, and their paths with
-L/usr/local/pexsi/lib
to LIBS.
Download “QUIP-b4336484fb65b0e73211a8f920ae4361c7c353fd.tar.gz” and extract it.
Execute the following commands on the Cygwin terminal:
$ cd QUIP-b4336484fb65b0e73211a8f920ae4361c7c353fd $ export QUIP_ARCH=linux_x86_64_gfortran $ make config
In the following “make config” example, the defaults are accepted except the python and pip location on the cygwin and cp2k support choice for quip.
Using QUIP_ARCH=linux_x86_64_gfortran, MODULES=libAtoms Potentials Utils, QUIP_ROOT=/home/gan_t/QUIP-b4336484fb65b0e73211a8f920ae4361c7c353fd In the following, hit enter to accept the defaults. BUILD OPTIONS ============= Please enter the linking options for LAPACK and BLAS libraries: Default: -llapack -lblas Please enter the preferred python command: Default: /usr/bin/python /bin/pyton2.7 Please enter the preferred pip command: Default: /bin/pip2.7 Please enter any other extra linking options: Default: none OPTIONAL INTERNAL FEATURES ========================== Would you like to compile with CP2K support? [y/n] Default: n y Would you like to compile with VASP support? [y/n] Default: n Would you like to compile with Tight Binding (TB) support? [y/n] Default: n Would you like to compile with preconditioned minimisation support? (not working with Intel compiler) [y/n] Default: y Would you like to compile with Learn-on-the-fly (LOTF) support? [y/n] Default: n Would you like to compile with ONIOM support? [y/n] Default: n Would you like to compile with LOCAL_E_MIX support? [y/n] Default: n Would you like to compile with QuasiContinuum wrapper support? [y/n] Default: n OPTIONAL FEATURES (EXTRA CODE REQUIRED) ======================================= Would you like to compile with GAP support ? [y/n] Default: n Please enter directories where the Turbo-GAP main directory is: Default: no Turbo-GAP present Would you like to turn on QR decomposition for some GAP operations? [y/n] Default: y Checking for ThirdParty directory... Not found. Would you like to compile with TTM3-F support? [y/n] Default: n Would you like to compile with SCME support ? [y/n] Default: n Would you like to compile with MTP support ? [y/n] Default: n Would you like to compile with many-body dispersion support ? [y/n] Default: n Would you like to compile with TTM_NF support ? [y/n] Default: n Would you like to compile with CH4 support ? [y/n] Default: n OPTIONAL EXTERNAL LIBRARIES =========================== Would you like to compile with NetCDF4 support? [y/n] Default: n Please enter directories where MDCORE libraries are kept: Default: no MDCORE present Please enter directory where the ASAP library is kept: Default: no ASAP library present Please enter directories where CGAL libraries are kept: Default: no CGAL present Please enter directories where METIS libraries are kept: Default: no METIS present Please enter directories where LMTO_TBE libraries are kept: Default: no LMTO_TBE present
After “make config”, execute the following commands on the Cygwin terminal:
$ make $ export QUIP_INSTALLDIR=/usr/local $ make install $ make libquip
If you find “libquip.a” in build/linux_x86_64_gfortran directory, the make was completed successfully.
Copy “build/linux_x86_64_gfortran/libquip.a” into “usr/local/lib” manually and finish the installation.
In the arch file of CP2K: Add
-D__QUIP
to DFLAGS. Add
-lquip
to LIBS. Add
-Wl,--stack,4194304
to FCFLAGS, to avoid a “Exception: STATUS_STACK_OVERFLOW” error.
Download and extract "SpFFT-1.0.5.tar.gz".
Execute the following commands on the Cygwin terminal:
$ cd spFFT-1.0.5 $ mkdir build $ cd build $ cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DSPFFT_FORTRAN=ON -DSPFFT_OMP=ON -DSPFFT_MPI=ON -DSPFFT_SINGLE_PRECISION=OFF -DCMAKE_INSTALL_PREFIX=/usr/local $ make $ make install
Download and extract "spla-1.5.2.tar.gz".
Execute the following commands on the Cygwin terminal:
$ cd spla-1.5.2 $ mkdir build $ cd build $ cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local $ make $ make install
SIRIUS-7.3.0 requires spglib-1.0.2 or later and gsl 2.7 or later.
Download and extract "spglib-1.16.1.tar.gz".
Execute the following commands on the Cygwin terminal:
$ cd spglib-1.16.2 $ mkdir build $ cd build $ cmake .. $ make $ make install
The “make install” will install spglib into /usr/local by default.
In the arch file of CP2K: Add
-D__SPGLIB
to DFLAGS.
If you have the following gsl-related error during building sirius (i.e. “make” sirius), gsl has not been installed on cygwin or the installed gsl is too old for the sirius.
sirius-7.3.0/src/specfunc/specfunc.hpp:31:10: fatal error: gsl/gsl_sf_hermite.h: No such file or directory 31 | #include <gsl/gsl_sf_hermite.h> | ^~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
Gsl 2.7 or later is required in this case. If Cygwin setup.exe does't supply the latest binary, you had better build the gsl from the source.
Download and extract "gsl-2.7.tar.gz".
Execute the following commands on the Cygwin terminal:
$ cd gsl-2.7 $ ./configure $ make $ make install
The “make install” will install gsl into usr/local by default.
Download and extract "SIRIUS-7.3.0.tar.gz".
Execute the following commands on the Cygwin terminal:
$ cd sirius-7.3.0 $ mkdir build $ cd build $ export CXX=mpicxx CC=mpicc FC=mpif90 $ cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/sirius $ make $ make install
If you have a link error “ld: smearing.cpp: undefined reference to `gsl_sf_hermite'” during the “make”,
the error is caused by your own built gsl which installed into “usr/local” instead of Cygwin root.
Edit “build/src/CMakeFiles/sirius.dir/link.txt” and add the string “/usr/local/lib/libgsl.dll.a” as following:
/usr/bin/mpicxx -Wall -O3 -DNDEBUG -shared -Wl,--enable-auto-import -o cygsirius.dll -Wl,--out-implib,libsirius.dll.a -Wl,--major-image-version,0,--minor-image-version,0 CMakeFiles/sirius.dir/hamiltonian/hamiltonian.cpp.o ... CMakeFiles/sirius.dir/context/simulation_context.cpp.o CMakeFiles/sirius.dir/context/simulation_parameters.cpp.o CMakeFiles/sirius.dir/api/sirius_api.cpp.o CMakeFiles/sirius.dir/api/sirius.f90.o /usr/local/lib/libspfft.dll.a /usr/local/lib/libspla.dll.a /usr/local/lib/libgsl.dll.a /usr/lib/libgsl.dll.a /usr/local/lib/libopenblas.dll.a -lm -ldl /usr/local/lib/libxc.a /usr/local/lib/libsymspg.dll.a /usr/lib/libhdf5.dll.a /usr/lib/gcc/x86_64-pc-cygwin/11/libgomp.dll.a -lmpi_usempif08 -lmpi_usempi_ignore_tkr -lmpi_mpifh -lgfortran -lquadmath -lm
Edit the cp2k code, “src/sirius_interface.f” and set the arguments of the subroutine sirius_initialize to “TRUE”.
SUBROUTINE cp_sirius_init() ! brhr editted ! CALL sirius_initialize(.FALSE.) CALL sirius_initialize(.TRUE.) ! end brhr editted END SUBROUTINE cp_sirius_init
In the arch file of CP2K: Add
-D__SIRIUS
to DFLAGS.
Download and extract "libvori-220621.tar.gz".
Execute the following commands on the Cygwin terminal:
$ cd libvori-220621 $ mkdir build $ cd build $ cmake -DCMAKE_CXX_COMPILER=g++ .. $ make $ make install
The “make install” will install libvori into usr/local by default.
In the arch file of CP2K: Add
-D__LIBVORI
to DFLAGS.
Download and extract "libvdwxc-0.4.0.tar.gz".
Execute the following commands on the Cygwin terminal:
$ cd libvdwxc-0.4.0 $ ./configure $ make $ make install
The “make install” will install libvdwxc into usr/local by default.
In the arch file of CP2K: Add
-D__LIBVDWXC
to DFLAGS.
Prepare a arch file. The following is an example with all options.
# Put this file on cp2k-2022.1/arch and execute the following command on the cp2k-2022.1 root directory # make ARCH=Cygwin-x86_64-gfortran VERSION=ssmp # if you wish to clean, do either make ARCH=Cygwin-x86_64-gfortran VERSION=ssmp clean # or make ARCH=Cygwin-x86_64-gfortran VERSION=ssmp distclean CC = gcc FC = mpif90 LD = mpif90 AR = ar -r CFLAGS = -g -O2 -fopenmp -fopenmp-simd -funroll-loops -ftree-vectorize -march=native -mtune=native CPPFLAGS = DFLAGS = -D__GFORTRAN -D__FFTW3 -D__LIBINT -D__LIBXC -D__SPGLIB -D__SIRIUS -D__LIBVDWXC DFLAGS += -D__LIBXSMM -D__LIBPEXSI -D__QUIP -D__LIBVORI FCFLAGS = -ffree-form -ffree-line-length-none -fno-omit-frame-pointer FCFLAGS += -fbacktrace -std=f2008 -Wl,--stack,4194304 FCFLAGS += -I/usr/include -I/usr/local/include -I/home/(usename)/libint-v2.6.0-cp2k-lmax-7/include -I/usr/local/sirius/include FCFLAGS += -I/home/(usename)/pexsi_v1.2.0/fortran $(CFLAGS) $(DFLAGS) LDFLAGS = $(FCFLAGS) -static LIBS = -lpexsi -llapack -lblas -lint2 -lxc -lxcf03 -lvori -lquip -ldl -ldbghelp -lvdwxc -lstdc++ LIBS += -lgsl -lz -ldl -lm -lsuperlu_dist -lparmetis -lmetis -fopenmp -fopenmp-simd LIBS += -L/usr/local/lib -L/usr/local/pexsi/lib LIBS += /usr/lib/gcc/x86_64-pc-cygwin/11/libstdc++.a /usr/local/lib/DbgHelp.Lib LIBS += /usr/lib/libgsl.dll.a /usr/lib/libmpi.dll.a /usr/local/lib/libxc.a /usr/local/lib/libxcf03.a /usr/local/lib/libxcf90.a LIBS += /usr/local/lib/libsymspg.dll.a /usr/lib/libhdf5.dll.a /usr/lib/libhdf5_hl.dll.a /usr/lib/libhdf5.dll.a /usr/lib/liblapack.dll.a LIBS += /usr/lib/libblas.dll.a /usr/lib/libfftw3.dll.a /usr/lib/libfftw3_omp.dll.a /usr/local/lib/libopenblas.a LIBS += /usr/local/lib/libint2.a /usr/local/lib/libsymspg.a /usr/local/lib/libsymspg.dll.a /usr/local/sirius/lib/libsirius.dll.a LIBS += /usr/lib/libfftw3_threads.dll.a /usr/local/lib/libxsmmf.lib /usr/local/lib/libxsmm.lib -llapack -lblas -ldbghelp LIBS += /usr/lib/gcc/x86_64-pc-cygwin/11/libgomp.dll.a OBJECTS_ARCHITECTURE = machine_gfortran.o
Save the arch file in the ARCH directory with the name e.g. “Cygwin-x86_64-gfortran.ssmp”
Prepare three nested empty destination directories (“obj/Cygwin-x86_64-gfortran/ssmp/” for the example) in the cp2k root before starting build.
Put some required FORTRAN modules in the inner-most ssmp directory in advance.
These are:
Execute the “make” commands on the root directory of cp2k on the Cygwin terminal:
$ make ARCH=Cygwin-x86_64-gfortran VERSION=ssmp
When the “make” successfully completed, cp2k.ssmp and other binaries have been generated in “(cp2k-root)/exe/Cygwin-x86_64-gfortran/ssmp/”.
Prepare a empty directory named “cp2k-(version string or a unique string to descriminate your build)” on which you wish to install the cp2k executable binaries.
Prepare five empty directories, “bin”, “dev”, “home”, “lib” and “share” in the cp2k directory.
Copy cp2k binaries which were generated in “(cp2k-root)/exe/Cygwin-x86_64-gfortran/ssmp/” into the “bin” directory.
Copy other DLLs in “(cygwin-root)/bin”,“(cygwin-root)/usr/local/bin”, “(cygwin-root)/usr/local/lib” or your build directory, on which cp2k binaries depend, into the “bin” directory.
The dependent DLLs will vary depending on which libraries you use.
You can parse the dependencies by using either cygcheck command or an executable parser such as Dependency Walker (depends.exe).
The following is an example of dependent DLLs with all options:
(cygwin-root)/bin/cygaec-0.dll (cygwin-root)/lib/lapack/cygblas-0.dll (cygwin-root)/bin/cygevent-2-1-7.dll (cygwin-root)/bin/cygevent_core-2-1-7.dll (cygwin-root)/bin/cygevent_extra-2-1-7.dll (cygwin-root)/bin/cygevent_openssl-2-1-7.dll (cygwin-root)/bin/cygevent_pthreads-2-1-7.dll (cygwin-root)/bin/cygfftw3-3.dll (cygwin-root)/bin/cygfftw3f-3.dll (cygwin-root)/bin/cygfftw3f_omp-3.dll (cygwin-root)/bin/cygfftw3f_threads-3.dll (cygwin-root)/bin/cygfftw3l-3.dll (cygwin-root)/bin/cygfftw3l_omp-3.dll (cygwin-root)/bin/cygfftw3l_threads-3.dll (cygwin-root)/bin/cygfftw3_omp-3.dll (cygwin-root)/bin/cygfftw3_threads-3.dll (cygwin-root)/bin/cyggcc_s-seh-1.dll (cygwin-root)/bin/cyggfortran-4.dll (cygwin-root)/bin/cyggfortran-5.dll (cygwin-root)/bin/cyggomp-1.dll (cygwin-root)/usr/local/bin/cyggsl-25.dll (cygwin-root)/usr/local/bin/cyggslcblas-0.dll (cygwin-root)/bin/cyghdf5-200.dll (cygwin-root)/bin/cyghwloc-15.dll (cygwin-root)/bin/cygiconv-2.dll (cygwin-root)/lib/lapack/cyglapack-0.dll (cygwin-root)/bin/cyglzma-5.dll (cygwin-root)/bin/cygmpi-40.dll (cygwin-root)/bin/cygmpi_mpifh-40.dll (cygwin-root)/bin/cygopen-pal-40.dll (cygwin-root)/bin/cygopen-rte-40.dll (cygwin-root)/bin/cygOpenCL-1.dll (cygwin-root)/bin/cygquadmath-0.dll (cygwin-root)/home/(username)/SIRIUS-7.3.0/build/src/cygsirius.dll (cygwin-root)/usr/local/lib/cygspfft-1.dll (cygwin-root)/usr/local/lib/cygspla-1.dll (cygwin-root)/bin/cygstdc++-6.dll (cygwin-root)/usr/local/bin/cygsymspg-1.dll (cygwin-root)/bin/cygsz-2.dll (cygwin-root)/bin/cygwin1.dll (cygwin-root)/bin/cygxml2-2.dll (cygwin-root)/bin/cygz.dll
Copy also the opemmpi executables into the “bin”.
(cygwin-root)/bin/ompi_info.exe (cygwin-root)/bin/opal_wrapper.exe (cygwin-root)/bin/orte-clean.exe (cygwin-root)/bin/orte-info.exe (cygwin-root)/bin/orte-server.exe (cygwin-root)/bin/orted.exe (cygwin-root)/bin/orterun.exe
Prepare an empty directory named “shm” in “dev” to avoid an warnning on running sirius calculation.
Copy the cp2k data directory into the inside of “home” as similar manner as Cygwin directory structure when you built cp2k.
For example, if you built cp2k in “(cygwin-root)/home/(user-name)/cp2k-2022.1”, prepare two nested directories “(user-name)/cp2k-2022.1” in the “home” directory, put the data directory in the inner-most “cp2k-2022.1” directory.
Prepare a empty directory named “openmpi” in the “lib” directory and
copy “(cygwin-root)/lib/openmpi/cygompi_dbg_msgq.dll” into the “lib/openmpi/” directory.
Copy openmpi help files (the folder and the all contents of (cygwin-root)/share/openmpi) in “share” directory.
Prepare a batch script to launch the cp2k calculations in the upper directory of the “bin”, “dev”, “home”, “lib” and “share” directories.
@echo off set ORGPATH=%PATH% set PATH=%PATH%;%CD%\bin set OPAL_PREFIX=%CD% set PMIX_MCA_gds=hash cp2k.ssmp %* set PATH=%ORGPATH% set OPAL_PREFIX= set PMIX_MCA_gds=
The statement “set ORGPATH=%PATH%” stores the current “path to executables” (the “PATH” environmental variable).
The statement “set PATH=%PATH%;%CD%\bin” adds the path to cp2k executables to the “PATH” environment.
The statement “OPAL_PREFIX=%CD%” sets temporarily the openmpi directory to the current cp2k directory.
The statement “set PMIX_MCA_gds=hash” avoids errors for some versions of opemmpi.
The statement “cp2k.ssmp %*” recieve the arguments and pass them to the cp2k.ssmp.
The set statements after “cp2k.ssmp %*” line restore the original settings.
For details on openmpi environmental variables, please refer to:
39. Can I re-locate my Open MPI installation without re-configuring/re-compiling/re-installing from source?
Save the script as the name “startcp2k.bat”.
Open the folder which contains startcp2k.bat and “bin”, “dev”, “home”, “lib” and “share” directories on Windows explorer.
Enter “cmd” in the address bar and press a return key to open the command prompt.
On the command prompt, execute the following command:
$ startcp2k --version
Then you might see:
CP2K version 2022.1 Source code revision git:2caeb6f cp2kflags: omp libint fftw3 libxc pexsi quip xsmm spglib sirius libvori libbqb compiler: GCC version 11.3.0 compiler options: -cpp -I /usr/include -I /usr/local/include -I /home/username/libint-v2. 6.0-cp2k-lmax-7/include -I /usr/local/sirius/include -I /home/username/ pexsi_v1.2.0-openmpi-4.1.2/fortran -I /home/user/cp2k-2022.1/src/sta rt/ -I /home/user/cp2k-2022.1/obj/Cygwin-x86_64-gfortran-pexsi/ssmp/ exts/dbcsr -I /usr/include -I /usr/lib -idirafter /usr/lib/gcc/x86_6 4-pc-cygwin/11/../../../../lib/../include/w32api -idirafter /usr/lib /gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/lib/../lib/../ ../include/w32api -D __GFORTRAN -D __FFTW3 -D __LIBINT -D __LIBXC -D __SPGLIB -D __SIRIUS -D __LIBVDWXC -D __LIBXSMM -D __LIBPEXSI -D __ QUIP -D __LIBVORI -D __COMPILE_ARCH="Cygwin-x86_64-gfortran-pexsi" - D __COMPILE_DATE="Sun Aug 14 21:16:53 JST 2022" -D __COMPILE_HOST="D ESKTOP-2FK7NUA" -D __COMPILE_REVISION="git:2caeb6f" -D __DATA_DIR="/ home/user/cp2k-2022.1/data" -D __SHORT_FILE__="start/cp2k.F" -march= skylake -mmmx -mpopcnt -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mavx -mavx2 -mno-sse4a -mno-fma4 -mno-xop -mfma -mno-avx512f -mbmi -mbmi2 -mno-aes -mpclmul -mno-avx512vl -mno-avx512bw -mno-avx512dq -mno-avx512cd -mno-avx512er -mno-avx512pf -mno-avx512vbmi -mno-avx51 2ifma -mno-avx5124vnniw -mno-avx5124fmaps -mno-avx512vpopcntdq -mno- avx512vbmi2 -mno-gfni -mno-vpclmulqdq -mno-avx512vnni -mno-avx512bit alg -mno-avx512bf16 -mno-avx512vp2intersect -mno-3dnow -madx -mabm - mno-cldemote -mclflushopt -mno-clwb -mno-clzero -mcx16 -mno-enqcmd - mf16c -mfsgsbase -mfxsr -mno-hle -msahf -mno-lwp -mlzcnt -mmovbe -mn o-movdir64b -mno-movdiri -mno-mwaitx -mno-pconfig -mno-pku -mno-pref etchwt1 -mprfchw -mno-ptwrite -mno-rdpid -mrdrnd -mrdseed -mno-rtm - mno-serialize -msgx -mno-sha -mno-shstk -mno-tbm -mno-tsxldtrk -mno- vaes -mno-waitpkg -mno-wbnoinvd -mxsave -mxsavec -mxsaveopt -mxsaves -mno-amx-tile -mno-amx-int8 -mno-amx-bf16 -mno-uintr -mno-hreset -m no-kl -mno-widekl -mno-avxvnni --param=l1-cache-size=32 --param=l1-c ache-line-size=64 --param=l2-cache-size=9216 -mtune=skylake -g -O2 - std=f2008 -ffree-form -ffree-line-length-none -fno-omit-frame-pointe r -fbacktrace -fopenmp -fopenmp-simd -funroll-loops -ftree-vectorize
Congratulations! You got a hold of CP2K run on Windows.