#!/usr/bin/env bash

#SBATCH --job-name=barakuda
#SBATCH --time=47:55:00
##SBATCH --time=05:55:00
#SBATCH --ntasks=1
#SBATCH --mem-per-cpu=2048
##SBATCH --partition=debug
#
##SBATCH --mail-user=noname@uclouvain.be
##SBATCH --mail-type=ALL
##SBATCH --open-mode=append
set -ueo pipefail

stdout_file=${SLURM_SUBMIT_DIR-$PWD}/${SLURM_JOB_NAME-"local"}_${SLURM_JOB_ID-"id"}.log
exec > ${stdout_file}
echo "------------------ Job Info --------------------"
echo "jobid : ${SLURM_JOB_ID-"id"}"
echo "jobname : ${SLURM_JOB_NAME-"local"}"
echo "submit dir : ${SLURM_SUBMIT_DIR-$PWD}"

set -ue 

exp="NE4_70"
starting_year=1800
slice=5
path_out="/scratch/ucl/elic/pbarriat/nemo/archive/${exp}"
path_exe="/home/ucl/elic/pbarriat/modeles/barakuda"

###

# Configure and load modules
module purge
module load releases/2018b use.own
module load netCDF-Fortran/4.4.4-foss-2018b ELIC_Python/1-foss-2018b-Python-2.7.15
module load ImageMagick/7.0.8-11-GCCcore-7.3.0 FFmpeg/4.1-foss-2018b

cd ${path_exe}

./barakuda.sh -C ORCA1_L75_NEMO4_lm3 -R ${exp} -f ${slice} -y ${starting_year}

# IF grep "Diagnostics built and saved" *

./barakuda.sh -C ORCA1_L75_NEMO4_lm3 -R ${exp} -f ${slice} -y ${starting_year} -e

echo ----- BARAKUDA post finished
