#!/bin/bash
make clean
make

bash run_example.sh fortran fortran 4 4
bash run_example.sh fortran python 4 4
bash run_example.sh python fortran 4 4
bash run_example.sh python python 4 4

cat ./work_fortran_fortran_4_4/atmos_fortran.out_* > ./work_fortran_fortran_4_4/atmos__all.out
cat ./work_python_fortran_4_4/atmos_fortran.out_* > ./work_python_fortran_4_4/atmos__all.out
cat ./work_fortran_python_4_4/atmos_python.out_* > ./work_fortran_python_4_4/atmos__all.out
cat ./work_python_python_4_4/atmos_python.out_* > ./work_python_python_4_4/atmos__all.out

cat ./work_fortran_fortran_4_4/ocean_fortran.out_* > ./work_fortran_fortran_4_4/ocean__all.out
cat ./work_python_fortran_4_4/ocean_python.out_* > ./work_python_fortran_4_4/ocean__all.out
cat ./work_fortran_python_4_4/ocean_fortran.out_* > ./work_fortran_python_4_4/ocean__all.out
cat ./work_python_python_4_4/ocean_python.out_* > ./work_python_python_4_4/ocean__all.out

echo '*****************************************************************'
echo "Checking results..."

diff -w --from-file=./work_fortran_fortran_4_4/atmos__all.out \
        ./work_python_fortran_4_4/atmos__all.out ./work_fortran_python_4_4/atmos__all.out ./work_python_python_4_4/atmos__all.out \
        && echo "atmos PASSED" || ( echo "atmos ERROR"; exit 1 )

diff -w --from-file=./work_fortran_fortran_4_4/ocean__all.out \
        ./work_python_fortran_4_4/ocean__all.out ./work_fortran_python_4_4/ocean__all.out ./work_python_python_4_4/ocean__all.out \
        && echo "ocean PASSED" || ( echo "ocean ERROR"; exit 1 )