How to compile CalculiX with different solvers

Motivation:

In this article, we will explain how to compile CalculiX and link it with different solvers. Two solvers have been integrated into CalculiX: Iterative Scaling and Iterative Cholesky. These solvers can be selected using the SOLVER parameter in the analysis card of the step section in the input file:

input file
... omissis ...
*STEP
*STATIC, SOLVER=ITERATIVE CHOLESKY
... omissis ...

In addition to these Iterative solvers the direct solver SPOOLES 2.2 and the eigenvalue solver ARPACK has been available since the first versions of CalculiX. Although they are good solvers, both projects are not longer maintained, and their last versions dates back to around March 1999.

Over the years, many different solvers have been added to CalculiX. A Multi-Thread version of SPOOLES was introduced, along with other solvers such as TAUCS and PARDISO. The most recent solver introduced was PaStiX 6.0.1 in a modified version called PaStiX4CalculiX, added in late 2019.

Even though an updated precompiled LINUX version of CalculiX is avaible on its web site and many users in the community share their compiled versions built on both LINUX and WINDOWS, we encourage you to compile it yourself and link it to different solvers.

Doing so offers many advantages:

  • Customization: Compiling the software yourself allows you to enable or disable specific features, select different solvers, or tailor the build to your unique needs. You can integrate libraries or tools that might not be included in pre-compiled versions.

  • Optimization: By compiling the software for your specific hardware (e.g., CPU or GPU architecture), you can take full advantage of performance optimizations such as vectorization, parallelization, or processor-specific instructions.

  • Latest Features and Bug Fixes: Building from source gives you access to the most recent updates, features, and bug fixes that might not yet be available in pre-built binaries.

  • Learning Opportunity: The compilation process provides a deeper understanding of how the software works, including its dependencies and architecture. This knowledge can be invaluable for troubleshooting or extending the software in the future.

Moreover, keep in mind that, essentially, SPOOLES and TAUCS are no longer maintained. The PARDISO project is proprietary, and the version linked to CalculiX is provided by the INTEL oneAPI MKL Math Kernel Library and is related to the year 2006 version.

The free sparse linear equation solver PaStiX is the newest and, at present, the only maintained and up-to-date. Furthermore, PaStiX can be used to leverage both CPU and GPU using the NVIDIA CUDA library.

Solvers benchmark
Test benchmark for different solvers in CalculiX. The execution time for PARDISO solver was choose as reference

The compilation process can initially seem quite challenging, but the aim of this article is to provide a basic explanation of this process.


Hereafter, we present all the bash shell commands, along with a brief explanationand and a list of all the dependencies that must be satisfied in a LINUX OS.

We prefere Linux over Windows because, in our opinion, it is the natural OS environment for CalculiX.


Compiling procedure:

Folder structure:

The installation folder is choosen as:

bash
/usr/local

The sources download folder and relative archive files are assumed to be in this folder structure:

bash
~/download/fem/CalculiX
├── ccx_2.22.README.INSTALL
├── ccx_2.22.SPOOLEScorrection.tar.bz2
├── ccx_2.22.src.tar.bz2
├── cuda
│ └── cuda-ubuntu2204.pin
└── dependencies
├── ARPACK
│ ├── arpack96.tar.Z
│ └── patch.tar.Z
├── lapack
├── MUMPS_5.7.1.tar.gz
├── pardiso
│ └── intel-onemkl-2025.0.0.940_offline.sh
├── PaStiX
│ ├── hwloc-2.11.2.tar.bz2
│ ├── scotch-master.tar.gz
│ ├── starpu-1.4.7.tar.gz
│ └── PaStiX4CalculiX
├── SPOOLES
│ └── spooles.2.2.tgz
└── TAUCS
└── taucs_full.tgz

The CalculiX i8 builder assume a directory sturcture for it's solvers like this:

bash
/usr/local
├── ARPACK
├── OpenBLAS_i8
├── PaStiX
│ ├── hwloc_i8
│ ├── parsec_i8
│ ├── scotch_i8
│ └── PaStiX4CalculiX
├── SPOOLES.2.2
├── cuda-12.4
├── mpich-4.1
└── openmpi-5.0.0

Moreover the location for Pardiso solver integrated in MKL oneAPI from INTEL:

bash
/opt/intel/oneapi/mkl/2025.0/lib/libmkl_rt.so

Compiling procedure for ARPACK:

First, download the source tar archive from the ARPACK website and place it in the ~/download/fem/CalculiX/dependencies/ARPACK folder.

In the next steps we assume that you gain the superuser root privilege.

bash
su
root password...

Move to the /usr/local folder, create a directory named ARPACK, copy the tar files from the downloads folder, extract them in this precise order, and then navigate into the ARPACK directory:

bash
cd /usr/local
mkdir ARPACK
cp ~/download/fem/CalculiX/dependencies/ARPACK/arpack96.tar.Z .
cp ~/download/fem/CalculiX/dependencies/ARPACK/patch.tar.Z .
tar -zxvf arpack96.tar.Z
tar -zxvf patch.tar.Z
cd ARPACK/

Now, we use the Bash stream editor sed command to comment the line #24 of the file UTIL/second.f source file:

bash
sed -i 's/      EXTERNAL           ETIME/c      EXTERNAL           ETIME/' UTIL/second.f

Still using the sed command, make additional changes to the ARmake.inc makefile:

bash
sed -i 's|home = $(HOME)/ARPACK|home = /usr/local/ARPACK|' ARmake.inc
sed -i 's/PLAT = SUN4/PLAT = INTEL/' ARmake.inc
sed -i 's/FC = f77/FC = gfortran/' ARmake.inc
sed -i 's/FFLAGS = -O -cg89/FFLAGS = -O3/' ARmake.inc
sed -i 's|MAKE = /bin/make|MAKE = /usr/bin/make|' ARmake.inc

Now everything is ready to build the libraries:

bash
make lib

Next, verify that the libarpack_INTEL.a has been created:

bash
ls -l *.a

the output should be:

bash
-rw-r--r-- 1 root 299 1695342 Dec 23  2021 libarpack_INTEL.a

Compiling procedure for SPOOLES 2.2:

Download the spooles.2.2.tgz sources tar archive from the SPOOLES 2.2 website to the ~/download/fem/CalculiX/dependencies/SPOOLES folder.

Move to the /usr/local directory and create the SPOOLES.2.2 folder. Then, enter the folder and copy the spooles.2.2.tgz file there, then untar it.

bash
cd /usr/local
mkdir SPOOLES.2.2
cd SPOOLES.2.2
cp ~/download/fem/CalculiX/dependencies/SPOOLES/spooles.2.2.tgz .
tar -zxvf spooles.2.2.tgz

Now, as with the ARPACK libraries, we will make some changes to the Make.inc file using the sed command:

bash
sed -i 's/# CC = gcc/ CC = gcc/' Make.inc
sed -i 's/ CC = /usr/lang-4.0/bin/cc/# CC = /usr/lang-4.0/bin/cc/' Make.inc
sed -i 's/ OPTLEVEL = -O/# OPTLEVEL = -O/' Make.inc
sed -i 's/# OPTLEVEL = -O3/ OPTLEVEL = -O3/' Make.inc
sed -i 's/# RANLIB = ranlib/ RANLIB = ranlib/' Make.inc
sed -i 's/ RANLIB = echo/# RANLIB = echo/' Make.inc

Now we need to make some corrections to SPOOLES.2.2 for large input decks. Make these changes to the I2Ohash/src/util.c file:

bash
sed -i '42s/^/\/\//' I2Ohash/src/util.c
sed -i '42a long int loc3 = (long int)loc1*(long int)loc2 % hashtable->nlist;' I2Ohash/src/util.c
sed -i '43a loc=(int)loc3;' I2Ohash/src/util.c

In the Tree/src folder, the makeGlobalLib search for the file drawTree.c, which does not exist! To fix this, make the following change:

bash
sed -i 's/drawTree.c/draw.c/' Tree/src/makeGlobalLib

Now everything is ready to build the libraries:

bash
make global

Afterward, verify that the spooles.a has been created:

bash
ls -l *.a

the output should be:

bash
-rw-r--r-- 1 root root 2.7M Dec 23  2021 spooles.a

Compiling procedure for CalculiX:

Navigate to the /usr/local folder, copy the CalculiX source tar file there, and extract its contents.

bash
cd /usr/local
cp ~/download/fem/CalculiX/ccx_2.22.src.tar.bz2 .
tar -jxvf ccx_2.22.src.tar.bz2

Navigate to the CalculiX source folder:

bash
cd CalculiX/ccx_2.22/src/

The standard Makefile is intended to enable only the SPOOLES and ARPACK serial version solvers:

Makefile
CFLAGS = -Wall -O3  -I ../../../SPOOLES.2.2 -DARCH="Linux" -DSPOOLES -DARPACK -DMATRIXSTORAGE -DNETWORKOUT
FFLAGS = -Wall -O3

CC=cc
FC=gfortran

.c.o :
$(CC) $(CFLAGS) -c $<
.f.o :
$(FC) $(FFLAGS) -c $<

include Makefile.inc

SCCXMAIN = ccx_2.22.c

OCCXF = $(SCCXF:.f=.o)
OCCXC = $(SCCXC:.c=.o)
OCCXMAIN = $(SCCXMAIN:.c=.o)

DIR=../../../SPOOLES.2.2

LIBS = \
$(DIR)/spooles.a \
../../../ARPACK/libarpack_INTEL.a \
-lpthread -lm -lc

ccx_2.22: $(OCCXMAIN) ccx_2.22.a $(LIBS)
./date.pl; $(CC) $(CFLAGS) -c ccx_2.22.c; $(FC) -Wall -O3 -o $@ $(OCCXMAIN) ccx_2.22.a $(LIBS) -fopenmp

ccx_2.22.a: $(OCCXF) $(OCCXC)
ar vr $@ $?

To start the compilation process, simply type:

bash
make -j 4

After a while the CalculiX ccx_2.22 executable will be created:

bash
ls -l ccx_2.22*

Clean up the source folder and move the executable to a user-accessible bin folder, such as:

bash
rm *.o *.a
mv ccx_2.22 /usr/local/bin/

Thats'all!

Now your single thread version 2.22 of CalculiX is accessible and ready to use.





As mentioned before there are many other solvers that could be linked to CalculiX. Please refer to the links below for a complete description:

  • Multi Thread version for the SPOOLES solver. Here the complete guide.

  • TAUCS library for Sparse Linear Solver.

  • PARDISO based on the 2006 version and integrated in the Math Kernel Library provided by INTEL. Here the complete guide.

  • PaStiX, this is absolutelly the most recent, maintaned very fast freeware solver able to use the Graphical Processing Unit (GPU). Here the complete guide.

Back to Homepage Back to FEM/FEA Consultancy Back to FEM/FEA Tutorials Back to FoamBuilder Back to Software Development Services Back to Software Development Services foamBuilder Back to Software Development Services DAKOTA interface Back to Software Development Services Post-processing Back to FEM/FEA Courses Back to Who we are Back to Contact Back to Request Back to open resource Back to News