Install ATS on a fresh Ubuntu 20.04 LTS

2 minute read

Published:

Notes:

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 through apt 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 of OPENMPI_DIR=/usr/bin, though which mpicc gives you /usr/bin. See this group discussion groups.google.com/g/ats-users/c/NBE1HegnJwY/m/ALXQjkiTAgAJ.

note: Change master to ats-1.4 for ATS_VERSION and master to amanzi-1.4 for AMANZI_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.