User Tools

Site Tools


dev:makefile

This is an old revision of the document!


Makefile

The CP2K Makefile automatically adopts to changes of the code base.

To add a file to the source tree, just create it. The Makefile will automatically discover it, compile it, and link it. Consequently, files that do not belong into the CP2K libraries must end on an ignored suffix.

The file discovery is based on a simple suffix naming convention:

  • .F files are Fortran files. They are compiled into an object. They should contain either a MODULE or a PROGRAM.
  • .f90 files are included Fortran files. They are not compiled into an object.
  • .c files are C-files. They are compiled into an object.
  • .cu files are Cuda-C-files. They are compiled into an object using Nvidia's nvcc.
  • .h files are C-header files. They are included by .c or .cu files. They are not compiled into an object.

Packages

The code base is structured into directories. This will allow for making CP2K more modular, i.e. consisting of smaller packages with fewer dependencies. Every directory therefore contains a file named PACKAGE . A typical PACKAGE, which uses python syntax, looks like this:

{
"description": "Distributed Block Compressed Sparse Row, A sparse matrix library",
"requires": ["../base", "../mpiwrap", "../acc", "libsmm_acc"],
"public": ["dbcsr_api.F"],
"archive": "libdbcsr",
}

The entries description and requires are mandatory.

The entry requires list all the directories on which the code in the current directory may depend upon. This means, modules in the current directory may only use modules from the listed directories. The requirements between directories must not have cycles. This is checked during compilation.

The optional entry public lists all files, which other packages may use. This allows to hide package internals. If the public entry is absent, all files within the package are public. This is checked during compilation.

The optional entry archive allows to overwrite the filename of the archive, which is created during compilation. The default name is “libcp2k<package_name>”.

Compiling Multiple Versions

The Makefile allows to compile multiple versions of all build targets in parallel:

$ make ARCH=Linux-x86-64-gfortran VERSION="sopt sdbg popt pdbg"

building only the main CP2K binary can be done as

$ make ARCH=Linux-x86-64-gfortran VERSION="sopt sdbg popt pdbg" cp2k
dev/makefile.1406301464.txt.gz · Last modified: 2020/08/21 10:14 (external edit)