#!/bin/bash
#---------------------------------*- sh -*-------------------------------------
# ==  == ====== ====   ====    |
#                   \\     ||  | Multiphase Code Repository by HZDR
# ======   //   ||  || ===//   | Website: https://doi.org/10.14278/rodare.767
# ||  ||  //    ||  // || \\   | License: GPL-3.0-or-later
# ==  == ====== ====   ==  ==  |
#------------------------------------------------------------------------------
# License
#     This file is part of the Multiphase Code Repository by HZDR.
#
#     Copyright (C) 2026 by Helmholtz-Zentrum Dresden-Rossendorf e.V. (HZDR),
#     Website: https://hzdr.de
#
#     Multiphase Code Repository by HZDR is based on the free software for
#     computational fluid dynamics (CFD) from the OpenFOAM Foundation.
#     Copyright (C) 2026 by OpenFOAM Foundation, Website: https://openfoam.org
#
#     If you are interested in which files are original OpenFOAM Foundation
#     files, which OpenFOAM Foundation files were modified, and which files were
#     newly created, see FILES.md.
#
#     Multiphase Code Repository by HZDR is free software: you can redistribute
#     it and/or modify it under the terms of the GNU General Public License as
#     published by the Free Software Foundation, either version 3 of the
#     License, or (at your option) any later version.
#
#     Multiphase Code Repository by HZDR is distributed in the hope that it will
#     be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
#     Public License for more details.
#
#     You should have received a copy of the GNU General Public License along
#     with the Multiphase Code Repository by HZDR. If not, see
#     <http://www.gnu.org/licenses/>.
#
# Description
#     SLURM script template to run jobs on an HPC cluster using Apptainer.
#
#------------------------------------------------------------------------------

# Partition
#SBATCH --partition=cpu-skylake

# Set number of nodes
#SBATCH --nodes=1

# Set number of tasks per node
# Ideally an even value, e.g., 4, 16, 64, 128
#SBATCH --ntasks-per-node=4

# Set the number of tasks per socket.
# If the number of tasks per node is **even**:
#   Set this to a value equal to (ntasks-per-node)/2
#   to maximize memory bandwidth on a two-socket system.
# If the number of tasks per node is **odd**:
#   Do not set this option, as it would cause the error:
#   "Requested node configuration is not available".
#SBATCH --ntasks-per-socket=2

# Set max wallclock time
#SBATCH --time=5-00:00:00

# Set account for accessing a specific cpu time contingent
#SBATCH --account=default

# Set name of the job
#SBATCH --job-name=<job_name>

# Mail alert at BEGIN|END|FAIL|ALL
#SBATCH --mail-type=ALL

# Join stdout and stderr and set file name for output
#SBATCH --output=slurm-%j.out

######## Begin - do not change these settings ########

# Allocate memory local to CPU
#SBATCH --mem-bind=local

# Blockwise packing of tasks
#SBATCH --distribution=block:block

######### End - do not change these settings ########

# Load Apptainer module
module load apptainer

# Define image
#   Nightly build Apptainer image
IMAGE="oras://registry.hzdr.de/fwdc/multiphase/code/13-s.1:multiphase-code-repository-by-hzdr-amd64.sif"

#   Apptainer image from merge request
# IMAGE="oras://registry.hzdr.de/fwdc/multiphase/code/13-s.1:<branch>-amd64.sif"

# Run "Allrun" script supplied with the case
apptainer run -B /bigdata $IMAGE ./Allrun
