Skip to content

Gadget Quickstart

This chapter starts from a fresh machine and walks through a full Conda-based first run of GADGET-4.

  • Install Conda for your OS (Miniforge).
  • Create and activate a gadget-lab environment.
  • Build and run a documented GADGET-4 example (DM-L50-N128).

Run PowerShell/Windows Terminal as Administrator first.

Terminal window
wsl --install -d Ubuntu
wsl --set-default-version 2
wsl -l -v

If wsl --install only prints help text:

Terminal window
wsl --list --online
wsl --install -d Ubuntu

If installation stalls at 0.0%:

Terminal window
wsl --install --web-download -d Ubuntu

Reboot if prompted, then open Ubuntu and create your Linux username/password.

Terminal window
sudo apt update
sudo apt install -y curl bzip2
curl -L -o ~/miniforge.sh \
"https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-$(uname -m).sh"
bash ~/miniforge.sh -b -p "$HOME/miniforge3"
source "$HOME/miniforge3/etc/profile.d/conda.sh"
conda init bash
Terminal window
conda create -n gadget-lab -c conda-forge \
python=3.11 compilers make cmake git pkg-config \
openmpi mpi4py gsl fftw hdf5 hwloc -y
conda activate gadget-lab
which python
which mpicc
which mpicxx
echo "$CONDA_PREFIX"
Terminal window
cd ~
git clone https://gitlab.mpcdf.mpg.de/vrs/gadget4.git
cd gadget4

If direct clone access is restricted, use your approved mirror/distribution and continue from the source root.

Terminal window
cp Template-Makefile.systype Makefile.systype
cp Template-Config.sh Config.sh
  • Choose your SYSTYPE in Makefile.systype.
  • Point compiler/library include and lib paths to ${CONDA_PREFIX}.
Terminal window
make DIR=examples/DM-L50-N128

If include/link paths are not found, export paths and rebuild:

Terminal window
export CPATH="$CONDA_PREFIX/include:${CPATH:-}"
export LIBRARY_PATH="$CONDA_PREFIX/lib:${LIBRARY_PATH:-}"
export LD_LIBRARY_PATH="$CONDA_PREFIX/lib:${LD_LIBRARY_PATH:-}"
make DIR=examples/DM-L50-N128
Terminal window
cd examples/DM-L50-N128
mpiexec -np 4 ./Gadget4 param.txt
  • Timesteps advance and the run exits normally.
  • Output snapshots/log files are created.
  • No unresolved MPI/FFTW/HDF5 runtime link errors.