Skip to content

Instantly share code, notes, and snippets.

@finsberg
Created June 27, 2022 18:18
Show Gist options
  • Select an option

  • Save finsberg/2ff3c98f61b8398a09ae936eb436349e to your computer and use it in GitHub Desktop.

Select an option

Save finsberg/2ff3c98f61b8398a09ae936eb436349e to your computer and use it in GitHub Desktop.
# Change prefix to what ever you want - I usually install everything in a python virtual environment
export PREFIX=$HOME/.venv
# Activate the virtual environment
source $PREFIX/bin/activate
export HDF5_MPI="ON"
export CC=mpicc
wget https://hdf-wordpress-1.s3.amazonaws.com/wp-content/uploads/manual/HDF5/HDF5_1_12_2/source/hdf5-1.12.2.tar
tar -xvf hdf5-1.12.2.tar && cd hdf5-1.12.2/ && ./configure --enable-parallel --prefix=$PREFIX && make install && cd ..
python -m pip install "numpy<1.22"
unset PETSC_DIR
# Install petsc
git clone -b release https://gitlab.com/petsc/petsc petsc \
&& cd petsc \
&& ./configure --COPTFLAGS="-O2" \
--CXXOPTFLAGS="-O2" \
--FOPTFLAGS="-O2" \
--with-cc=mpicc \
--with-fc=mpifc F77=mpifc F90=mpifc \
--with-cxx=mpigxx \
--with-mpiexec=mpiexec \
--COPTFLAGS="${CFLAGS}" \
--CXXOPTFLAGS="${CXXFLAGS}" \
--FOPTFLAGS="${FFLAGS}" FCFLAGS="${FFLAGS}" F90FLAGS="${F90FLAGS}" \
--CFLAGS="${CFLAGS}" \
--FFLAGS="${FFLAGS}" \
--CXXFLAGS="${CXXFLAGS}" \
--LDFLAGS="${LDFLAGS}" \
--with-blaslapack-dir=$MKLROOT \
--download-metis \
--download-parmetis \
--download-suitesparse \
--download-scalapack \
--download-hypre \
--download-mumps \
--download-superlu_dist \
--download-ml \
--download-cmake \
--prefix=$PREFIX/petsc \
&& make \
&& make install \
&& cd ..
# Add the following lines to your .bashrc
export PETSC_DIR=$PREFIX/petsc
export SLEPC_DIR=$PREFIX/slepc
export LD_LIBRARY_PATH=$PREFIX/lib:$LD_LIBRARY_PATH
export PATH=$PREFIX/bin:$PATH
export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH
export MANPATH=$PREFIX/share/man:$MANPATH
export CMAKE_PREFIX_PATH=$PREFIX/lib/python3.10/site-packages:$CMAKE_PREFIX_PATH
export OMPI_MCA_btl_base_warn_component_unused=0
export HDF5_DIR=$PREFIX
python -m pip install wheel cmake --no-cache-dir \
&& python -m pip install dev-fenics-ffc mpi4py petsc4py pybind11 --no-cache-dir \
&& python -m pip install h5py --no-binary=h5py
# Install dolfin
git clone https://bitbucket.org/fenics-project/dolfin.git dolfin \
&& cd dolfin \
&& cmake -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_PREFIX_PATH=$PREFIX -DCMAKE_BUILD_TYPE=Release -B build -S . \
&& cmake --build build -j6 \
&& cmake --install build
# Install the python API
cd python && python -m pip install . --no-cache-dir
cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment