#!/usr/bin/env bash


#
# Run the following command from the directory where the slurm files should be created
#
# Invocation
# ./submitJobs.sh <hpcDirectory> <partition>
#
# partition: ampere, gpu
#

# Check if a directory argument is given
if [[ -z "$1" ]]; then
    echo "Usage: $0 <directory> <partition>"
    exit 1
fi

# Submission parameters
QOS="small"
PARTITION="$2"   # ampere or gpu
SCRIPT_DIR="$1"  # Directory containing the job scripts

# Range of values for the -q parameter
VERSIONS=("V0" "V1" "V2")
Q_START=20
Q_END=30

# Submitting the jobs
for version in "${VERSIONS[@]}"; do
  for ((q = Q_START; q <= Q_END; q++)); do
    script_name="Bitnc${version}Q${q}.sh"
    script_path="${SCRIPT_DIR}/${script_name}"

    if [[ -f "$script_path" ]]; then
      echo "Submitting: $script_path"
      sbatch --qos="$QOS" -p "$PARTITION" "$script_path"
      #sbatch -p "$PARTITION" "$script_path"
    else
      echo "Warning: File not found - $script_path"
    fi
  done
done


