#!/bin/bash

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

set -xuve

exp_id="ifs_nemo_runoff"

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

rundir=${srcdir}/../rundir/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 $toydir/*.py $rundir
cp -f $toydir/namcouple $rundir
cp -f $toydir/*.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
