#!/bin/bash

cp -n  ../context_grid_dynamico.xml ./
cp -n ../dynamico_grid.nc ./


rm -f sub_config1.py
rm -f sub_config2.py
rm -f sub_check.py
rm -f default_param.py

cp -n ../../user_config.py sub_config1.py
cp -n ../../config.py sub_config2.py
cp -n ../../check.py sub_check.py
cp -n ../../default_param.py default_param.py


touch report.txt
> report.txt
echo " " >> report.txt
echo " " >> report.txt
echo "testing maximum reduce..." >> report.txt 
echo " " >> report.txt

nb_config=$(python sub_config1.py 2>&1)                                                                                                                    


counter=0
while [ $counter -lt $nb_config ]
do

rm -f user_param.py

cp user_param.py.$counter user_param.py

((counter++))

nb_proc=$(python sub_config2.py 2>&1) 

if [$machine_name == irene]
then
    ccc_mprun -n $nb_proc ../../../build_prod/bin/generic_testcase.exe
else
    mpirun -np $nb_proc ../../../build_prod/bin/generic_testcase.exe
fi

python sub_check.py

rm -f iodef.xml
mv iodef.xml.bkp iodef.xml

done
