echo "==========================================================="
echo "========================GAMESS============================="
echo "==========================================================="
echo ""
echo "This is a GAMESS submission script"
echo "The input file must exist in the current working directory"

echo ""
read -p "Enter the input filename(without .inp): " input
echo ""
echo  "Enter the number of CPUS requested: " 
read -p "(For /rungms test 00 10 10 >> test.log; no. of cpus =10) " np
echo ""
echo "For nodes=x; enter the x value"
read -p "For ex. (nodes=node5; enter node5) or (nodes=1; enter 1): " node
echo ""
echo "For ppn=y; enter the y value "
read -p "For ex. ppn=64; enter 64  : " ppn
echo ""

echo "The submission script generated is $input.sh"

echo '#!/bin/bash -l' > $input.sh
echo "#PBS -N $input" >> $input.sh
echo "#PBS -l nodes=$node:ppn=$ppn,walltime=9999:00:00" >> $input.sh
echo '#PBS -j oe' >> $input.sh
echo '#****************************************' >> $input.sh
echo 'cd $PBS_O_WORKDIR' >> $input.sh
echo "Project=$input" >> $input.sh
echo 'rm -rf $Project.dat' >> $input.sh
echo 'export SCR=/lscratch/$PBS_JOBID' >> $input.sh
echo 'mkdir -p $SCR' >> $input.sh
echo '#*********** fix the problem of sysv semaphores ******************' >> $input.sh
echo '#*** This may occur if the GAMESS job terminated abrouptly ******* ' >> $input.sh
echo '#***************** Load intel ************************************' >> $input.sh
echo "module load compilers/gcc-9.3.0" >> $input.sh
echo "module load compilers/openmpi-4.1.1" >> $input.sh
echo '#****************  Submit the gamess job **********************************' >> $input.sh
echo '/apps/scratch/compile/gamess_2024/rungms-dev $Project 00'" $np $np"'  > $Project.log' >> $input.sh
echo '#****************  Remove the scratch directory *****************' >> $input.sh
echo 'rm -rf $SCR' >> $input.sh
echo '#****************************************************************' >> $input.sh
#*********************************************************
qsub $input.sh

