#!/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

#load python and netcdf modules
export PYTHONPATH=""
module load python/3.6.1
module load netcdf/4.2

set -xuve

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

##

model_names="ifs_nemo_runoff"

# prepare rundir
datadir=/gpfs/scratch/bsc32/bsc32051/git/python-amip-reader/tests/data/ece3-toy-model
testdir=`pwd`
srcdir=$testdir/../sources/ece3-toy-model

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

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

