#!/usr/bin/env bash

# This script is for a Cray machine. Paths will need to be customized.

#PBS -N si2bs
#PBS -q debug
#PBS -o out.log
#PBS -e err.log
#PBS -l mppwidth=16
#PBS -l walltime=00:30:00
#PBS -m n

MPI_CMD="aprun -n 16"
BINPATH=$HOME
QEPATH=$BINPATH/espresso-5.0/bin
BGWWPATH=$BINPATH/BerkeleyGW/bin
EPSILON_EXEC="$BGWPATH/epsilon.real.x"
SIGMA_EXEC="$BGWPATH/sigma.real.x"
EQP_SCRIPT="$BGWPATH/eqp.py"
INTEQP_EXEC="$BGWPATH/inteqp.real.x"

cd $SCRATCH/BGW/examples/DFT/Si2_bs

$MPI_CMD $QEPATH/pw.x -in ./Si2.scf.in &> ./Si2.scf.out
$MPI_CMD $QEPATH/pw.x -in ./Si2.wfn.in &> ./Si2.wfn.out
$MPI_CMD $QEPATH/pw2bgw.x -in ./Si2.wfn.pp.in &> ./Si2.wfn.pp.out
$MPI_CMD $QEPATH/pw.x -in ./Si2.wfnq.in &> ./Si2.wfnq.out
$MPI_CMD $QEPATH/pw2bgw.x -in ./Si2.wfnq.pp.in &> ./Si2.wfnq.pp.out
$MPI_CMD $QEPATH/pw.x -in ./Si2.wfn_inner.in &> ./Si2.wfn_inner.out
$MPI_CMD $QEPATH/pw2bgw.x -in ./Si2.wfn_inner.pp.in &> ./Si2.wfn_inner.pp.out
$MPI_CMD $QEPATH/pw.x -in ./Si2.kpath.in &> ./Si2.kpath.out
$MPI_CMD $QEPATH/pw2bgw.x -in ./Si2.kpath.pp.in &> ./Si2.kpath.pp.out
ln -s ./WFN_inner ./WFN_co
$MPI_CMD $EPSILON_EXEC &> ./epsilon.out
$MPI_CMD $SIGMA_EXEC &> ./sigma.out
$EQP_SCRIPT eqp1 ./sigma_hp.log ./eqp_co.dat
$MPI_CMD $INTEQP_EXEC &> ./inteqp.out
