#!/bin/bash
# slurm specific options for Marenostrum4
#SBATCH --qos=debug
#SBATCH -N 1
#SBATCH -n 3
#SBATCH -c 1
#SBATCH -t 0:05:00
#SBATCH --exclusive

# loading required modules and machine dependence paths on MN4 or HPC2020 
source modules.sh 


set -xuve

# setup pyOasis environment
source ../sources/oasis3-mct/generated/python/init.sh  

##

exp_id="ifs_nemo_runoff"

# prepare rundir
testdir=`pwd`
datadir=$testdir/data/ece3-toy-model
srcdir=$testdir/../sources/ece3-toy-model

rundir=${testdir}/work_ece3_toy_model_${exp_id}

rm -rf $rundir
mkdir -p $rundir

for f in masks.nc grids.nc areas.nc rstas.nc rstos.nc; do
    cp -f $datadir/$f $rundir
done
cp -f $datadir/rmp* $rundir
cp -f $srcdir/*.py $rundir
cp -f $srcdir/namcouple $rundir
cp -f $srcdir/*.yaml $rundir

toy_model="toy_model.py"  

echo "prep is finished"

cd $rundir

# run IFS+NEMO+runoff toy model
mpirun -np 1  python3 ${rundir}/${toy_model} --conf ifs_toy_model.yaml : -np 1 python3 ${rundir}/${toy_model}  --conf nemo_toy_model.yaml : -np 1 python3 ${rundir}/${toy_model} --conf runoff_toy_model.yaml

