#!/bin/bash

set -x 

export revision=$(svn info --show-item revision ../.. 2>&1)
export server_revision=$(svn info --show-item last-changed-revision http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS/dev/dev_trunk_omp 2>&1)

if (( ${server_revision} >= ${revision} ))
then
python config_compile.py

ccc_msub -E "--wait" job_compile_irene.sh

build_dir=${xios_test_suite_repository}/BUILD
mkdir -p $build_dir ; CHMOD $build_dir
mkdir -p ${build_dir}/build_${xios_machine_name}

cp build_*.txt ${build_dir}/build_${xios_machine_name}
CHMOD -R ${build_dir}/build_${xios_machine_name}

bash -c "python ./generate_compile.py"

copy_to_thredds compile_${xios_machine_name}_info.js

else
echo "latest revision ... no need to compile"
fi
