#!/bin/bash

OriginalDir=`pwd`

VASPDir=$TkPerlDir/VASP
CMD="/usr/bin/perl $VASPDir/VASP.pl"
VASPCommand=./DoVASP.sh

iSite=$1
x=$2
y=$3
post=$4
DebugMode=0

WorkDir=$x$y$post
echo Work for [$WorkDir]


if [ "$DebugMode" = "1" ]; then
	mkdir $WorkDir
else
	cd $WorkDir
	echo === Working in \"`pwd`\"
	echo === Files in \"$wd\"
	ls

#================================
# Modify POSCAR
#================================
	Command="$CMD --Action=ModifyPOSCAR --Positions=$iSite:x:0.$x;$iSite:y:0.$y POSCAR"
	echo ''
	echo === Execute [$Command]
	$Command

#================================
# Execute VASP
#================================
	Command=$VASPCommand
	echo ''
	echo === Execute [$Command]
	$Command

	echo ''
	echo === Exit to \"$OriginalDir\"
	cd $OriginalDir
	echo ''
	echo ''

#================================
# Copy to symmetry positions
#================================
	$SCRIPTDir/ExpandSymmetry.sh $iSite $x $y $post
fi
