Gadget Quickstart
This chapter starts from a fresh machine and walks through a full Conda-based first run of GADGET-4.
Goal Checklist
Section titled “Goal Checklist”- Install Conda for your OS (Miniforge).
- Create and activate a
gadget-labenvironment. - Build and run a documented GADGET-4 example (
DM-L50-N128).
Installation
Section titled “Installation”0) Install and verify WSL2 + Ubuntu
Section titled “0) Install and verify WSL2 + Ubuntu”Run PowerShell/Windows Terminal as Administrator first.
wsl --install -d Ubuntuwsl --set-default-version 2wsl -l -vIf wsl --install only prints help text:
wsl --list --onlinewsl --install -d UbuntuIf installation stalls at 0.0%:
wsl --install --web-download -d UbuntuReboot if prompted, then open Ubuntu and create your Linux username/password.
1) Install Miniforge (inside Ubuntu)
Section titled “1) Install Miniforge (inside Ubuntu)”sudo apt updatesudo 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 bash0) Install Miniforge
Section titled “0) Install Miniforge”xcode-select --install
curl -L -o ~/miniforge.sh \ https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-$(uname -m).shbash ~/miniforge.sh -b -p "$HOME/miniforge3"
source "$HOME/miniforge3/etc/profile.d/conda.sh"conda init zsh0) Install Miniforge
Section titled “0) Install Miniforge”sudo apt updatesudo 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 bash1) Create gadget-lab
Section titled “1) Create gadget-lab”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-labwhich pythonwhich mpiccwhich mpicxxecho "$CONDA_PREFIX"2) Get source code
Section titled “2) Get source code”cd ~git clone https://gitlab.mpcdf.mpg.de/vrs/gadget4.gitcd gadget4If direct clone access is restricted, use your approved mirror/distribution and continue from the source root.
3) Prepare build config files
Section titled “3) Prepare build config files”cp Template-Makefile.systype Makefile.systypecp Template-Config.sh Config.sh- Choose your
SYSTYPEinMakefile.systype. - Point compiler/library include and lib paths to
${CONDA_PREFIX}.
4) Build an official example
Section titled “4) Build an official example”make DIR=examples/DM-L50-N128If include/link paths are not found, export paths and rebuild:
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-N1285) Run the example
Section titled “5) Run the example”cd examples/DM-L50-N128mpiexec -np 4 ./Gadget4 param.txt6) Quick validation
Section titled “6) Quick validation”- Timesteps advance and the run exits normally.
- Output snapshots/log files are created.
- No unresolved MPI/FFTW/HDF5 runtime link errors.