#!/usr/bin/env bash

#
PWDIR="$HOME/espresso-5.0/bin"
PW="$PWDIR/pw.x"
PW2BGW="$PWDIR/pw2bgw.x"
PW2WAN="$PWDIR/pw2wannier90.x"
WANNIER="$HOME/wannier90-1.2/wannier90.x"

# put argument for number of procs here too if needed, e.g. -n 8
MPIRUN="mpirun"
#
cd ./01-scf
$MPIRUN $PW -in ./in &> ./out
rm ./*.wfc*
cd ..
#
cd ./02-wfn
$MPIRUN $PW -in ./in &> ./out
$MPIRUN $PW2BGW -in ./pp_in &> ./pp_out
rm ./*.wfc*
cd ..
#
cd ./03-wfnq
$MPIRUN $PW -in ./in &> ./out
$MPIRUN $PW2BGW -in ./pp_in &> ./pp_out
rm ./*.wfc*
cd ..
#
cd ./04-wfn_co
$MPIRUN $PW -in ./in &> ./out
$MPIRUN $PW2BGW -in ./pp_in &> ./pp_out
rm ./*.wfc*
cd ..
#
cd ./05-wfn_fi
$MPIRUN $PW -in ./in &> ./out
$MPIRUN $PW2BGW -in ./pp_in &> ./pp_out
rm ./*.wfc*
cd ..
#
cd ./06-wfnq_fi
$MPIRUN $PW -in ./in &> ./out
$MPIRUN $PW2BGW -in ./pp_in &> ./pp_out
rm ./*.wfc*
cd ..
#
cd ./07-wannier
$MPIRUN $PW -in ./in &> ./out
$WANNIER -pp silicon
$MPIRUN $PW2WAN -in ./silicon.pw2wan &> pw2wan.out 
$WANNIER silicon
# The syntax output by Wannier90 1.2 is considered obsolete by Gnuplot.
sed -i 's/set data style/set style data/' silicon_band.gnu
rm ./*.wfc*
cd ..
#
