Since version 2.17, CalculiX can be built with the PaStiX library to increase performance with CUDA. Building the preCICE adapter is somehow harder with this version. This page gives a detailed walkthrough to build the modified adapter.


To build the preCICE adapter for CalculiX with PaStiX, it is first necessary to build PaStiX. A manual build is necessary for most steps, as specific compilation flags must be used for the dependencies: pre-built packages cannot be used. In particular, PaStiX (and CalculiX) must be compiled with flags to use 8-byte integers. On this page, we provide a step-by-step building guide of the adapter, tested on Ubuntu 20.04. This should work with some modifications on other systems. You may also need to tweak this depending on your needs, e.g. if you want to build some dependencies yourself instead of using a package manager.

Required packages

Make sure you have a working installation of preCICE. Also run these installation commands, (after a call to sudo apt update and sudo apt upgrade) : sudo apt install build-essential cmake git gfortran flex bison zlib1g-dev nvidia-cuda-toolkit-gcc libspooles-dev libyaml-cpp-dev

Downloading CalculiX source

This guide assumes Calculix’s source code is in the user’s home folder /home/user_name, with the alias ~. If you don’t want to follow this convention, you may have to adapt slightly the instructions below. Donwload can be done on command line:

    cd ~ && wget
    bunzip2 ccx_2.17.src.tar.bz2
    tar -xvf ccx_2.17.src.tar

This contains the source code of CalculiX, but also scripts useful for building some libraries below with the correct flags.

Building PaStiX dependencies

It is assumed that all these libraries will be built on the user home folder, ~. Minor modifications will be required otherwise. PaStiX requires OpenBLAS, hwloc, Scotch and PaRSEC. All of these will be built before PaStiX itself. We need to build them from source because specific flags are necessary to work with CalculiX’ version of PaStiX, mostly the use of 8 bytes integers.

Building OpenBLAS

Clone OpenBLAS source code and build it with 8-byte integers.

    cd ~ 
    git clone 
    mv OpenBLAS ./OpenBLAS_i8
    cd OpenBLAS_i8 
    make -j 4 INTERFACE64=1 
    sudo make install

You can also specify a custom installation path (to avoid calling sudo) by using the PREFIX=path/to/install option of the Makefile.

Building hwloc

This library will be put in a subfolder of the PaStiX folder.

    mkdir -p ~/PaStiX/ 
    cd ~/PaStiX/ 
    bunzip2 hwloc-2.1.0.tar.bz2 && tar -xf hwloc-2.1.0.tar
    cp ~/CalculiX/ccx_2.17/src/ ~/PaStiX/hwloc-2.1.0/
    cd hwloc-2.1.0
    ./configure --prefix=$HOME/PaStiX/hwloc_i8 CC=gcc CXX=g++
    make -j8
    make install

Building PaRSEC

    cd ~/PaStiX && git clone -b pastix-6.0.2 --single-branch
    cd parsec
    cp ~/CalculiX/ccx_2.17/src/ ~/PaStiX/parsec

Building Scotch

    cd ~/PaStiX
    tar -xf scotch-master.tar.gz
    cp ~/CalculiX/ccx_2.17/src/ ~/PaStiX/scotch-master
    cd scotch-master

Building PaStiX

    cd ~/PaStiX
    git clone 
    mv PaStiX4CalculiX pastix_src
    cd pastix_src
    cp ~/CalculiX/ccx_2.17/src/ .


  • On some occasions, a Python script called by CMake (cmake_modules/morse_cmake/modules/precision_generator/ generates an incorrect Makefile because of errors in regular expressions. This should be fixed by calling pip install regex (which requires installing the python3-pip Ubuntu package). You may also need to replace the import re line in that script by import regex as re, but the necessity seems to fluctuate among different machines.
  • Some parts of the code require older versions of the GNU compilers. You may have to replace gcc by gcc-7 and similarly for g++ and gfortran in the script. This requires installing the relevant Ubuntu packages.

Building ARPACK, a CalculiX dependency

Calculix relies on ARPACK, and when built with PaStiX, we cannot rely on standard distributions of that library, because it doesn’t feature 8-byte integers by default. We need to build the ARPACK code ourselves:

cd ~
zcat arpack96.tar.gz | tar -xvf -
zcat patch.tar.gz    | tar -xvf -

Before building the library, the following modifications are required:

  • In, change PLAT by the appropriate suffix (the adapter’s makefile assumes INTEL)
  • In, change the Fortran compilation flags to add -fdefault-integer-8. You may also need to remove the flag -cg89.
  • If you extracted the archive on another folder than your home repository, update home in accordingly.
  • In the file UTIL/second.f, comment with a star the line containing EXTERNAL ETIME.

Once all of these are done, simply run make lib in the ARPACK folder.

Building the adapter

To build the adapter, clone its repository and checkout the 2.17 branch :

    git clone -b v2.17
    cd calculix-adapter

Fixing the code

Due to some conflicts between CalculiX, PaStiX and the adapter (both CalculiX and PaStiX have a pastix.h file, and neither of them is local from the point of view of the adapter), some changes are required in the CalculiX codebase. We provide a script, that does these changes. Run it.



To build the adapter, use the provided Makefile_i8_PaStiX: the regular Makefile would build the adapter without PaStiX. Assuming you followed the previous steps, it should be useable without modifications other than giving Calculix’ path; otherwise, some other paths updates could be required. You also need to ensure then Makefile finds the required dependencies when calling pkg-config. This can be done by changing the PKG_PATH_CONFIG environment variable. Assuming you used suggested paths, this would look like this:

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:~/PaStiX/pastix_i8/lib/pkgconfig/:~/PaStiX/hwloc_i8/lib/pkgconfig/:~/PaStiX/parsec_i8/lib/pkgconfig/

Then you can build the adapter with this command in the calculix-adapter (and be sure to checkout the 2.17 branch) folder :

    make -f Makefile_i8_PaStiX -j 4 CCX=~/CalculiX/ccx_2.17/src

Once the build is successful, the adapter should be in ./bin/ccx_preCICE.

Updating shared libraries

Running the adapter at this point should fail because of a missing shared library: You can fix this by adding its path to the environment variable LD_LIBRARY_PATH: export LD_LIBRARY_PATH=:$LD_LIBRARY_PATH:~/PaStiX/parsec_i8/lib. You may have to do this everytime you load a new terminal, which is why we advise you to make this change permanent, for instance by adding this export commande at the end of your .bashrc file.