#!/bin/bash

work=./results
reference=./reference
. ../../../environment_variables
BIN_DIR=../../../bin

mkdir $work
rm -f $work/*

ld1_command="$PARA_PREFIX $BIN_DIR/ld1.x $PARA_POSTFIX"

echo "ld1_command =" $ld1_command

if test -e difference ; then /bin/rm difference > /dev/null ; fi
touch difference

for atom in o al as pt si_nc ; do
    $ld1_command < $atom.in > $work/$atom.out
    echo "diff -wib ./results/$atom.out ./reference/$atom.out" >> difference
    diff -wib $work/$atom.out $reference/ >> difference
done

/bin/rm ld1.wfc


for file in OPBE.RRKJ3 Al.rrkj3 Asrel.RRKJ3.UPF Ptrel.RRKJ3.UPF SiPBE_nc  ; do
    echo "-------------------------------------------------" >> difference
    echo "diff -wib ./results/$file ./reference/$file" >> difference
    echo "Note that results and reference data may differ for numerical reasons" >> difference
    mv $file $work 
    diff $work/$file $reference/ >> difference
done

