#!/bin/bash

echo "	layers		x	y	E"
echo " --------------------------------------------------------"
cd      layers
for layers in 4 5 6
do
	e_ref=`tail -n1 gp_${layers}/OSZICAR | awk '{print $5}'`
	e=`tail -n1 ${layers}/OSZICAR | awk '{print $5}'`
	cd ${layers}
	cd ..
	E=`python -c "res=${e}-${e_ref}; print '%6.3f' % res"`
	echo "	${layers}		3	3	${E}	"
done
cd ..

#======================================================#

cd      units5

for x in 2 3 4 
do
        e_ref=`tail -n1 gp_${x}_${x}/OSZICAR | awk '{print $5}'`
        e=`tail -n1 ${x}_${x}/OSZICAR | awk '{print $5}'`
	cd ${x}_${x}
        cd ..
	E=`python -c "res=${e}-${e_ref}; print '%6.3f' % res"`
	echo "	5		${x}	${x}	${E}	"
done
cd ..

#======================================================#

cd  units6

for x in 2 3 4 
do
	e_ref=`tail -n1 gp_${x}_${x}/OSZICAR | awk '{print $5}'`
        e=`tail -n1 ${x}_${x}/OSZICAR | awk '{print $5}'`
	cd ${x}_${x}
        cd ..
	E=`python -c "res=${e}-${e_ref}; print '%6.3f' % res"`
	echo "	6		${x}	${x}	${E}	"
done
cd ..

#======================================================#

echo " --------------------------------------------------------"
