#!/bin/bash
#Author: akiyama
#Facebook: b98202054@ntu.edu.tw
#Restriction of the number of Queue
#Please put this .sh file in the directory containing input files(.in)
#Excute input files(.in) and restore outcome as .out files

path=`pwd`
list=$(ls *.in | cut -d '.' -f1)
a=0
for i in $list
do

cat >$i.csh <<OWARU
#!/bin/csh
#PBS -l nodes=1:ppn=1
qchem $path/$i.in $path/$i.out
OWARU

a=$(($a+1))
qsub $i.csh

if [ $a%3 == 0 ]; then
b=0
while [ $b != 1 ]
do
sleep 60
test -e $i.out && b=$(($b+1))
done
fi
done
mkdir $path/0out