#!/bin/sh
#
# This script runs the available preconditioners twice,
# once with setup from the source code, once with command line
# options overriding the setup in the source.
#
echo "Preliminary cleanup .."
make clean_examples > /dev/null
rm -f Test.*
touch Test.out
#
# Following are the command line options that are used in the second
# run of the various methods.
#
aschwarz_options="-pc_halo_size 3 -sub_pc_type lu" \
    export aschwarz_options
mschwarz_options="-pc_pipeline sequential -sub_pc_type lu" \
    export aschwarz_options
gbssor_options="-pc_noglobal_fac -sub_pc_type sor -sub_pc_sor_symmetric -pc_pipeline none" \
    export aschwarz_options
#
# Loop over the available methods, calling each twice.
#
for method in none jacobi aschwarz mschwarz gbssor mlevel ; 
do  echo $method ".."
    echo 20 | make $method \
        | tee Test.$method.out.1 \
        | awk '/iteration time/ {print method,p} {p=$3}' method=$method \
        | tee Test.tmp
        cat >>Test.out < Test.tmp
    if [ $method != "none" -a $method != "jacobi" ] ; then \
      echo 20 | eval make \$method method_options=\"\$${method}_options\" \
          | tee Test.$method.out.2 \
          | awk '/iteration time/ {print method,p} {p=$3}' method=$method \
          | tee Test.tmp
          cat >>Test.out < Test.tmp
    fi
done

echo "There were" `diff Test.out Reference | wc -l` "errors"
