#!/bin/bash
#SBATCH --partition=ampere # Submit to queue/partition namedbatch
#SBATCH --job-name=yourJobName
#SBATCH --nodes=1
#SBATCH --gres=gpu:1
#SBATCH --time 0-00:20:00 # Run time ([days-hh:mm:ss|days-hh:mm:ss]) - (max 7days)

# Paths and settings
name="CaseTest"
dirout="${name}_out"
diroutdata="${dirout}/data"

module load DualSPHysics

# Function to run the simulation
run() {

    # Create initial files for simulation
    GenCase_linux64 "${name}_Def" "$dirout/$name" -save:all
    if [ $? -ne 0 ]; then fail; fi

    # Simulation
    DualSPHysics5.4_linux64 -gpu "$dirout/$name" "$dirout"
    if [ $? -ne 0 ]; then fail; fi
}

run