#!/bin/bash

# SLURM configuration for MN5
# information about the queue : https://www.bsc.es/supportkc/docs/MareNostrum5/slurm

# HOW to SUBMIT 
# sbatch -A, --account={account} -q, --qos={qos} {job_script} [args]

# Single job with a single node (default)
##SBATCH --qos=gp_debug
#SBATCH --qos=acc_bsces
##SBATCH --qos=acc_bsces
##SBATCH --qos=gp_bsces
#SBATCH --output=serial_%j.out
#SBATCH --error=serial_%j.err
##SBATCH --ntasks=112
#SBATCH --ntasks=640
#SBATCH --time=12:00:00
#SBATCH --mail-type=end
#SBATCH --mail-user=amirpasha.mozaffari@bsc.es

# SLURM configuration for NORD3
# more information here : https://earth.bsc.es/wiki/doku.php?id=computing:nord3-v2

# HOW to SUBMIT 
# sbatch -A, --account={account} -q, --qos={qos} {job_script} [args]
# sbatch -A bsc32 -q bsc_es launch_remap_NR3.sh

# Single job with a single node (default)
##SBATCH --qos=bsc_es
##SBATCH --output=serial_%j.out
##SBATCH --error=serial_%j.err
##SBATCH --ntasks=10
##SBATCH --time=00:30:00
##SBATCH --mail-type=end
##SBATCH --mail-user=amirpasha.mozaffari@bsc.es
##SBATCH --constraint=highmem
##SBATCH --exclusive

# Load appropriate modules and activate conda environment
if [ "$BSC_MACHINE" = "mn5" ]; then

    export MODULEPATH=$MODULEPATH:/apps/GPP/EASYBUILD/modules/all
    # module load GDAL/3.8.5-foss-2023b
    # module load NCO/5.2.4-foss-2023b
    # module load miniconda
    # module load hdf5/1.14.1-2
    # module load pnetcdf/1.12.3
    # module load netcdf/2023-06-14
    # module load miniconda
    conda init
    source /apps/GPP/MINICONDA/24.1.2/etc/profile.d/conda.sh
    conda activate /home/bsc/bsc032013/.conda/envs/rapids-24.08
    export PYTHONPATH=/home/bsc/bsc032013/.conda/envs/rapids-24.08/lib/python3.11/site-packages:$PYTHONPATH

elif [ "$BSC_MACHINE" = "nord3v2" ]; then
    module load GDAL/3.3.2-foss-2019b-Python-3.7.4
    module load pycdo/1.5.3-foss-2019b-Python-3.7.4
    module load pynco/0.0.2-foss-2019b-Python-3.7.4
fi

# Launch training script 

# Set parameters
START_YEAR=1992
END_YEAR=2015
REGION="ES2"  # ES, EU, UK, AU, GLOBE, , NW, NE, SW, SE , NA1, EU1 , AS1 , AU1 , AF1 
# TRAINING_YEARS="2010"
# TESTING_YEARS="2011"
#TRAINING_YEARS="2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013"

# TRAINING_YEARS="2014 2015 2005 2006 2007 2008 2009 2010 2011 2012"
# TESTING_YEARS="2013"

TRAINING_YEARS="1992 1994 1995 1996 1997 1998 1999 2000 2001 2003 2005 2006 2007 2008 2009 2010 2011 2012 2014 2015"
TESTING_YEARS="1993 2004 2013"

# Run the Python script with different model types
#python train_gpu_debug.py --start_year $START_YEAR --end_year $END_YEAR --region $REGION --model_type random_forest --imputation mean  
python train_rf_rapids.py --start_year $START_YEAR --end_year $END_YEAR --region $REGION --model_type random_forest --imputation mean --train_years $TRAINING_YEARS --test_years $TESTING_YEARS
#python train_rf_gpu.py --start_year $START_YEAR --end_year $END_YEAR --region $REGION --model_type hist_gbm --imputation mean --train_years $TRAINING_YEARS --test_years $TESTING_YEARS

#python train_gpu_debug.py --start_year $START_YEAR --end_year $END_YEAR --region $REGION --model_type gbm --imputation mean 
#python train_gpu_debug.py --start_year $START_YEAR --end_year $END_YEAR --region $REGION --model_type logistic_regression --imputation mean 
# python train_gpu.py --start_year $START_YEAR --end_year $END_YEAR --region $REGION --model_type simple_nn
# python train_gpu.py --start_year $START_YEAR --end_year $END_YEAR --region $REGION --model_type improved_nn
# python train_gpu.py --start_year $START_YEAR --end_year $END_YEAR --region $REGION --model_type cnn
# python train_gpu.py --start_year $START_YEAR --end_year $END_YEAR --region $REGION --model_type advanced_cnn
# python train_gpu.py --start_year $START_YEAR --end_year $END_YEAR --region $REGION --model_type lstm
