#!/bin/sh
set -e

SRC_ROOT=`pwd`

export HOME_LORENE=/usr/lib/`dpkg-architecture -qDEB_HOST_MULTIARCH`/lorene


mkdir -p ${ADTTMP}/gyoto-lorene-mpi
mkdir -p ${ADT_ARTIFACTS}

cd ${ADTTMP}/gyoto-lorene-mpi
rm -Rf .check-lorene
cp -a ${HOME_LORENE}/Codes/Nrotstar ./.check-lorene
cd .check-lorene
rm -f nrotstar *.o
cp -f Parameters/GR/Kepler/*.d ./
sed -i.bak 's/1       graph/0       graph/' par_rot.d
make
./nrotstar
cd ..

EXAMPLES_DIR=${SRC_ROOT}/doc/examples
BASE_NAMES=`basename -s.xml ${EXAMPLES_DIR}/*-rotstar3_1.xml`
GYOTO="/usr/bin/gyoto --nprocesses=4 --nthreads=1 --resolution=32"
export GYOTO_PLUGINS="stdplug,lorene"
export OMPI_MCA_orte_rsh_agent=/bin/false


for base in ${BASE_NAMES} ; do
    orterun --mca btl_tcp_if_include lo ${GYOTO} ${EXAMPLES_DIR}/${base}.xml \!${ADT_ARTIFACTS}/${base}-mpi.fits ;
done

exit 0
