Install ATS on a fresh Ubuntu 20.04 LTS
Published:
Notes:
- Last updated: Sept. 2023
- This tutorial mostly follows github.com/amanzi/amanzi/blob/master/INSTALL_ATS.md and github.com/pinshuai/pinshuai.github.io/blob/master/_posts/2021-03-09-Compile-ATS-Master-on-Linux.md
- The goal is to install
master
branch of ATS at$HOME/ATS/
and the build type isRelease
. Changemaster
,$HOME
orRelease
if needed. - It has been tested in WSL and VirtualBox on a Win 10 machine. Ubuntu 22 also tested. See ubuntu.com/tutorials/how-to-run-ubuntu-desktop-on-a-virtual-machine-using-virtualbox for how to run Ubuntu on a virtual machine using VirtualBox.
Install essential packages:
sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y
sudo apt install curl git make cmake gcc g++ gfortran
sudo apt install openmpi-bin openmpi-doc libopenmpi-dev
sudo apt install liblapack3 liblapack-dev liblapack-doc libblas3 libblas-dev libsuperlu-dist-dev
sudo apt install zlib1g-dev libssl-dev libcurl4-openssl-dev
note: If in WSL 2,
sudo apt update
might fail because of the ‘no network connection’ issue. Search in github.com/microsoft/WSL/issues for solutions (e.g., github.com/microsoft/WSL/issues/5336 and github.com/microsoft/WSL/issues/4926).
note: Use
cmake --version
to check cmake version. If it’s too old, see apt.kitware.com/ for instruction on how to install a newer cmake throughapt install
.
Install miniconda and Python packages:
- Download and install miniconda:
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -o miniconda.sh
bash miniconda.sh
- After miniconda successfully installed, restart terminal.
note: If in WSL, running
wsl --shutdown
in Windows command prompt is required because of the CondaHTTPError github.com/conda/conda/issues/9948.
- Create a virtual environment for Python:
conda create -n myatsenv python=3 numpy scipy matplotlib pandas jupyter pytest h5py
conda activate myatsenv
note: Change
myatsenv
to whatever other environment names.
Set up environment variables
- Create an empty file
set_ats_env.sh
:
vi set_ats_env.sh
- Copy the followings to
set_ats_env.sh
:
#!/usr/bin/env bash
# EDIT THESE!
export ATS_VERSION=master
export AMANZI_VERSION=master
export ATS_BASE=${HOME}/ATS/${ATS_VERSION}
export ATS_BUILD_TYPE=Release
export OPENMPI_DIR=/usr
# END EDIT THESE!
export AMANZI_TPLS_BUILD_DIR=${ATS_BASE}/amanzi_tpls-build-${ATS_VERSION}-${ATS_BUILD_TYPE}
export AMANZI_TPLS_DIR=${ATS_BASE}/amanzi_tpls-install-${ATS_VERSION}-${ATS_BUILD_TYPE}
export AMANZI_SRC_DIR=${ATS_BASE}/repos/amanzi
export AMANZI_BUILD_DIR=${ATS_BASE}/amanzi-build-${ATS_VERSION}-${ATS_BUILD_TYPE}
export AMANZI_DIR=${ATS_BASE}/amanzi-install-${ATS_VERSION}-${ATS_BUILD_TYPE}
export ATS_SRC_DIR=${AMANZI_SRC_DIR}/src/physics/ats
export ATS_DIR=${AMANZI_DIR}
export PATH=${ATS_DIR}/bin:${PATH}
export PATH=${AMANZI_TPLS_DIR}/bin:${PATH}
export PYTHONPATH=${ATS_SRC_DIR}/tools/utils:${PYTHONPATH}
export PYTHONPATH=${AMANZI_TPLS_DIR}/SEACAS/lib:${PYTHONPATH}
note: It’s important to set
OPENMPI_DIR=/usr
instead ofOPENMPI_DIR=/usr/bin
, thoughwhich mpicc
gives you/usr/bin
. See this group discussion groups.google.com/g/ats-users/c/NBE1HegnJwY/m/ALXQjkiTAgAJ.
note: Change
master
toats-1.4
forATS_VERSION
andmaster
toamanzi-1.4
forAMANZI_VERSION
if try to install ATS 1.4 instead of master.
- Source
set_ats_env.sh
:
source set_ats_env.sh
Download and build ATS
- Download ATS:
git clone -b $AMANZI_VERSION http://github.com/amanzi/amanzi $AMANZI_SRC_DIR
- Edit
build_ATS_generic.sh
:
vi ${AMANZI_SRC_DIR}/build_ATS_generic.sh
${AMANZI_SRC_DIR}/bootstrap.sh \
${dbg_option} \
--with-mpi=${OPENMPI_DIR} \
--enable-shared \
--disable-clm \
--disable-structured --enable-unstructured \
--disable-stk_mesh --enable-mstk_mesh \
--enable-hypre \
--disable-silo \
--disable-petsc \
--disable-amanzi_physics \
--enable-ats_physics \
--disable-ats_dev \
--enable-geochemistry \
--amanzi-install-prefix=${AMANZI_DIR} \
--amanzi-build-dir=${AMANZI_BUILD_DIR} \
--tpl-install-prefix=${AMANZI_TPLS_DIR} \
--tpl-build-dir=${AMANZI_TPLS_BUILD_DIR} \
--tpl-download-dir=${ATS_BASE}/amanzi-tpls/Downloads \
--tools-download-dir=${ATS_BASE}/amanzi-tpls/Downloads \
--tools-build-dir=${ATS_BASE}/build \
--tools-install-prefix=${ATS_BASE}/install \
--with-cmake=`which cmake` \
--with-ctest=`which ctest` \
--branch_ats=${ATS_VERSION} \
--parallel=8
- Build ATS:
bash ${AMANZI_SRC_DIR}/build_ATS_generic.sh
note: If in WSL, it’s better to run WSL as administrator, because there might be a file rename permission issue if not as administrator.