#!/bin/bash

#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=32    #No. spp. in batch +1
#SBATCH --partition=highmem
#SBATCH --exclusive
#SBATCH --time=60:00:00       #Average processing time ~20 hrs.
#SBATCH --job-name=SDM_XX     #Replace 'XX' with batch number here & in 2 lines below
#SBATCH --output=SDM_XX.out
#SBATCH --error=SDM_XX.err
#SBATCH --mail-type=ALL
#SBATCH --mail-user=your.email@server.com

# load R module
module load R/4.2.1 gdal/3.0.1 proj/6.1.1 geos/3.6.2

# Set the number of cores to use (No. of spp. in batch +1)
NUM_CORES=32

# Run the R script using srun (for parallel execution)
srun --ntasks=1 --cpus-per-task=$NUM_CORES Rscript SDM_XX.R #Change according to batch number