User:Fkannema
Here is a bash script to submit Gaussian jobs on placentia2 (Download). Put it in your home directory, do
chmod u+x g03sub
Then you can submit jobs with
./g03sub filename [jobname] [test | runtimehours]
The requested memory and number of CPUs for parallel jobs is read from the Gaussian input file. The default runtime is 48 hours which can be overwritten by specifying the runtime in hours on the commandline, eg:
./g03sub ch4.gjf ch4 20
to request a runtime of 20 hours.
#!/bin/bash # # bash script for submitting gaussian jobs on placentia2 (Acenet) # Felix Kannemann <felix.kannemann [ AT ] dal.ca>, 2009-02-11 # # usage: g03sub filename [jobname] [test | runtimehours] # example: g03sub ch4.gjf ch4 20 # # reads memory (MB, GB, MW or GW) and number of CPUs for parallel jobs # from input file and adjusts job submission parameters accordingly # also works for multi-step jobs # # to submit all *.gjf in current directory at once (bash): # for i in *.gjf; do g03sub $i `expr substr ${i%.*} 1 10`; done # the job name is given by the name of the input file (without extension) # truncated to 10 characters, names of input files therefore have to # start with character # get name of input file if [ "$1" == "" ]; then echo "Name of input file with or without extension (*.gjf or *.com):" read FILE else if [ -e "$1" ]; then FILE="$1" else echo "File $1 does not exist!" echo "Name of input file with or without extension (*.gjf or *.com):" read FILE fi fi # remove filename extensions for internal use FILENAME=`basename $FILE .gjf` FILENAME=`basename $FILENAME .com` # rename input file from .gjf to .com if [ -e ${FILENAME}.gjf ]; then echo "Renaming ${FILENAME}.gjf to ${FILENAME}.com" mv ${FILENAME}.gjf ${FILENAME}.com fi # convert input file to unix line endings dos2unix ${FILENAME}.com # get jobname if [ "$2" == "" ]; then echo "Job name (start with character):" read JOBNAME else JOBNAME=$2 fi # get number of processors from gaussian input file # works with "%nproc=" and "%nprocs=" nprocline=`grep -m 1 nproc ${FILENAME}.com` nproc=${nprocline#%nproc*=} # set default number of processors to 1 if [ "$nproc" == "" ]; then nproc=1 fi # get memory from gaussian input file memline=`grep -m 1 mem ${FILENAME}.com` memIn=${memline#%mem=} case "$memIn" in *MB ) mem=${memIn%MB} memMB=$mem ;; *GB ) mem=${memIn%GB} memMB=$[$mem * 1024] ;; *MW ) mem=${memIn%MW} memMB=$[$mem * 8] ;; *GW ) mem=${memIn%GW} memMB=$[$mem * 8192] ;; esac # calculate memory requirements if [ "$nproc" -eq 1 ]; then # for serial jobs add 1024MB to memory from gaussian input file memJob=$[$memMB + 1024] else # for parallel jobs use formula from acenet wiki memJob=$[($memMB + 1024) * ($nproc + 1) / $nproc] fi # write job parameters to output echo "filename:" ${FILENAME}.com echo "jobname:" ${JOBNAME} echo "requested number of CPUs:" $nproc echo "requested memory in input file:" $memIn "=" $memMB"MB" echo "requested memory in job script:" $memJob"MB" # write jobfile # default options: serial job, 1024MB memory, runtime 48 hours cat > ${JOBNAME}.csh <<JOBFILE #$ -S /bin/csh #$ -N $JOBNAME #$ -cwd #$ -j y #$ -o ${JOBNAME}.out #$ -l h_vmem=${memJob}M #$ -l h_rt=48:00:00 source /usr/local/lib/gaussian.sh hostname date g03 < $FILENAME.com > $FILENAME.log JOBFILE # submit job to Gaussian # if 3rd command line argument equals "test", submit as test job if [ "$3" == "test" ]; then echo "qsub command line: qsub -l h_rt=0:30:0,test=true ${JOBNAME}.csh" qsub -l h_rt=0:30:0,test=true ${JOBNAME}.csh # if 3rd command line argument is not empty, use as runtime in hours elif [ -n "$3" ]; then if [ $nproc -gt 1 ]; then echo "qsub command line: qsub -l h_rt=${3}:0:0 -pe gaussian $nproc ${JOBNAME}.csh" qsub -l h_rt=${3}:0:0 -pe gaussian $nproc ${JOBNAME}.csh else echo "qsub command line: qsub -l h_rt=${3}:0:0 ${JOBNAME}.csh" qsub -l h_rt=${3}:0:0 ${JOBNAME}.csh fi # otherwise submit job with default runtime from job script else if [ $nproc -gt 1 ]; then echo "qsub command line: qsub -pe gaussian $nproc ${JOBNAME}.csh" qsub -pe gaussian $nproc ${JOBNAME}.csh else echo "qsub command line: qsub ${JOBNAME}.csh" qsub ${JOBNAME}.csh fi fi # cat ${JOBNAME}.csh # delete job script #~ rm ${JOBNAME}.csh # eof