#!/bin/bash
#SBATCH --ntasks 1
#SBATCH --time 03:00:00
#SBATCH --job-name NES
#SBATCH --output log_jupyter-notebook-%J.out
#SBATCH --error log_jupyter-notebook-%J.err
#SBATCH --exclusive

# get tunneling info
XDG_RUNTIME_DIR=""
port=$(shuf -i8000-9999 -n1)
node=$(hostname -s)
user=$(whoami)

# print tunneling instructions jupyter-log
echo -e "

MacOS or linux terminal command to create your ssh tunnel
ssh -N -L ${port}:${node}:${port} ${user}@nord4.bsc.es

Use a Browser on your local machine to go to:
localhost:${port}  (prefix w/ https:// if using password)
"

# load modules or conda environments here
module load jupyterlab/3.0.9-foss-2019b-Python-3.7.4
module load Python/3.7.4-GCCcore-8.3.0
module load netcdf4-python/1.5.3-foss-2019b-Python-3.7.4
module load xarray/0.19.0-foss-2019b-Python-3.7.4
module load cftime/1.0.1-foss-2019b-Python-3.7.4
module load cfunits/1.8-foss-2019b-Python-3.7.4

export PYTHONPATH=/gpfs/scratch/bsc32/bsc32538/NES_tests/NES:${PYTHONPATH}
# export PYTHONPATH=/esarchive/scratch/avilanova/software/NES:${PYTHONPATH}

# DON'T USE ADDRESS BELOW.
# DO USE TOKEN BELOW
jupyter-lab --no-browser --port=${port} --ip=${node}
