Installing Spack

Spack is a package manager which is useful to install scientific software. I usually install basic software gcc and gfortran using my OS like Debian or OpenSUSE, and all other packages using Spack.

Get Spack

sudo mkdir /home/spack
cd /home
sudo chown praveen:users spack
git clone https://github.com/LLNL/spack

Add following to your .bashrc

export SPACK_ROOT=/home/spack
. ${SPACK_ROOT}/share/spack/setup-env.sh

Some useful command

spack info gcc  -- show information for package gcc
spack find      -- shows installed packages
spack compilers -- show available compilers

You may have to add your compilers to the file $HOME/.spack/linux/compilers.yaml; automatically add by

spack compiler find

I will install the deal.II package which automatically installs all other software that I need.

spack install dealii

We will create a view of the softwares by sym linking into another directory

sudo mkdir /home/soft
sudo chown praveen:users /home/soft
$HOME/bin/spack_view.sh

The script spack_view.sh contains command like this

SPACK_VIEW_DIR=/home/soft
ACTION=symlink
spack view -v $ACTION $SPACK_VIEW_DIR openmpi
spack view -v $ACTION $SPACK_VIEW_DIR petsc
spack view -v $ACTION $SPACK_VIEW_DIR slepc
spack view -v $ACTION $SPACK_VIEW_DIR trilinos
spack view -v $ACTION $SPACK_VIEW_DIR oce
spack view -v $ACTION $SPACK_VIEW_DIR suite-sparse
spack view -v $ACTION $SPACK_VIEW_DIR mumps
spack view -v $ACTION $SPACK_VIEW_DIR openblas
spack view -v $ACTION $SPACK_VIEW_DIR bzip2
spack view -v $ACTION $SPACK_VIEW_DIR boost
spack view -v $ACTION $SPACK_VIEW_DIR p4est
spack view -v $ACTION $SPACK_VIEW_DIR hdf5
spack view -v $ACTION $SPACK_VIEW_DIR cmake
spack view -v $ACTION $SPACK_VIEW_DIR gsl
spack view -v $ACTION $SPACK_VIEW_DIR tbb
spack view -v $ACTION $SPACK_VIEW_DIR muparser
spack view -v $ACTION $SPACK_VIEW_DIR netcdf
spack view -v $ACTION $SPACK_VIEW_DIR netcdf-cxx
spack view -v $ACTION $SPACK_VIEW_DIR arpack-ng

You can set some variables in your .bashrc

export PETSC_DIR=/home/soft
export SLEPC_DIR=/home/soft
export METIS_DIR=/home/soft
export HDF5_DIR=/home/soft

export PATH=/home/soft/bin:$PATH

When I want to upgrade, I usually reinstall everything from scratch.

cd /home/spack
git pull
spack uninstall --all
spack install dealii
rm -rf /home/soft/* /home/soft/.*
$HOME/bin/spack_view.sh