#!/bin/bash
#SBATCH --job-name=velmass_ics_model_cola
#SBATCH --nodes=1
#SBATCH --exclusive
#SBATCH --ntasks=40
#SBATCH --ntasks-per-node=40
#SBATCH --time=48:00:00
#SBATCH --partition=pscomp
#SBATCH --gres=gpu
#SBATCH --output=/data101/bartlett/fsigma8/borg_velocity/out_files/velocity_inference_%j.out
#SBATCH --error=/data101/bartlett/fsigma8/borg_velocity/out_files/velocity_inference_%j.err
#SBATCH --mail-user=deaglan.bartlett@iap.fr
#SBATCH --mail-type=END,FAIL  

# Modules
module purge
module restore myborg
module load cuda/12.6

# Environment
source /home/bartlett/.bashrc
source /home/bartlett/anaconda3/etc/profile.d/conda.sh
conda deactivate
# conda activate borg_env 
conda activate borg_new

# Kill job if there are any errors
set -e

# Path variables
BORG=/data101/bartlett/build_borg/tools/hades_python/hades_python
RUN_DIR=/data101/bartlett/fsigma8/borg_velocity/velmass_ics_model_cola_v3

mkdir -p $RUN_DIR
cd $RUN_DIR

# Create a custom file descriptor (3) for tracing
exec 3>$RUN_DIR/trace_file.txt

# Redirect trace output to the custom file descriptor
BASH_XTRACEFD="3"
set -x

# Run BORG
INI_FILE=/home/bartlett/fsigma8/borg_velocity/conf/velmass_ini.ini
# cp $INI_FILE ini_file.ini
# $BORG INIT ini_file.ini
$BORG RESUME ini_file.ini

conda deactivate

# Disable tracing and close the custom file descriptor
set +x
exec 3>&-

exit 0
