Note

This is an advanced topic. Before building your own package, please consider using an exiting one or get into contact with us via support@dkrz.de

Building your own package: spack

As a fully featured package manager you can build and install packages on your own. This can be done in multiple ways, but in this first chapter only the most simple way will be described: No installation of spack is needed, no extra setup of compilers. Packages definitions are limitated to the versions DKRZ is currently using for the software tree. spack list can be used to search the available packages for given package name patterns. With spack info <name> a detailed view of a given package name is possible include available versions, variants and dependencies.

The first step is to create a directory called .spack in the your $HOME directory. In there you need to create a file called config.yaml with the following content:

config:
  install_tree:
    root: <your-installation-directory>

This setting overwrites the system installation path. To make sure the packages installed by DKRZ are still accessible a second file called upstreams.yaml needs to be added. It should look like this:

upstreams:
  system_installs:
    install_tree: /sw/spack-levante

With those two files in ~/.spack it is possible to install packages into your private path (in my case I use /work/k20200/sw). In the following example I used the nvhpc compiler

spack install libelf %nvhpc
==> Installing libelf-0.8.13-ellsaygtw33563jcz3cwwsbaspl5pack
==> No binary for libelf-0.8.13-ellsaygtw33563jcz3cwwsbaspl5pack found: installing from source
==> Fetching https://mirror.spack.io/_source-cache/archive/59/591a9b4ec81c1f2042a97aa60564e0cb79d041c52faa7416acb38bc95bd2c76d.tar.gz
==> No patches needed for libelf
==> libelf: Executing phase: 'autoreconf'
==> libelf: Executing phase: 'configure'
==> libelf: Executing phase: 'build'
==> libelf: Executing phase: 'install'
==> libelf: Successfully installed libelf-0.8.13-ellsaygtw33563jcz3cwwsbaspl5pack
  Fetch: 1.14s.  Build: 8.05s.  Total: 9.20s.
[+] /work/k20200/sw/libelf-0.8.13-ellsay

For using other compilers please check all available ones with spack compilers

spack compilers
==> Available compilers
-- dpcpp rhel8-x86_64 -------------------------------------------
dpcpp@2022.0.0

-- gcc rhel8-x86_64 ---------------------------------------------
gcc@11.2.0

-- intel rhel8-x86_64 -------------------------------------------
intel@2021.5.0

-- nvhpc rhel8-x86_64 -------------------------------------------
nvhpc@21.11

-- oneapi rhel8-x86_64 ------------------------------------------
oneapi@2022.0.0

With the % symbol you can choose the compiler for the package installation

With more recent packages

In case you want to build software in a more recent version compared to what DKRZ is using, you need to download spack from https://github.com/spack/spack.git and follow the installation instructions. Basically you clone the repository and read in the environment file from inside the repository

source ./share/spack/setup-env.sh

Now you can use the package definitions from the repository instead of the ones from DKRZ.

If you want to build software competely on your own you can just follow the official documention at https://spack.readthedocs.io