Tuesday, November 10, 2015

The Submission Script (SubScript.sh)

Purpose:
This shell script is meant to submit the Gaussian jobs to the head node of the server and then have these jobs distributed. This is done for the directory in which the script is called and the results from the calculations are then sent back to the this directory. A script was used because this was the easiest way to submit multiple files for calculation without having to worry about scheduling.

The Script: (Written in Bash)
#! /bin/bash
#
#$ -cwd
#$ -j y
#$ -S /bin/bash
#$ -m abes
#$ -pe mpich 2
#$ -notify
#

# Necessary variables

. /share/apps/bin/bashrc
. /share/apps/bin/an_functions.sh

# Gaussian 09
export g09root="/share/apps/gaussian"
. $g09root/g09/bsd/g09.profile

#. $g09root/g09/bsd/g09.login

# Folder where the files are located
export INIT_DIR="$PWD"

# Name of the Gaussian 09 input file
export INAME="Gaussian03"
export ARRAY_JOB=""

# Prepare to run Gaussian 09
## changed by hhe

#export GAUSS_SCRDIR="/misc/hhe1"
export GAUSS_LFLAGS=' -vv -opt "Tsnet.Node.lindarsharg: ssh"'
LINDAWORKERS=$(cat $PE_HOSTFILE | grep -v "catch_rsh" | awk -F '.' '{ print $1}' | tr '\n' ',' | sed 's/,$//')

# Calculation specific information
export LOCATION=`hostname | awk -F '.' '{print $1}'`
cat << EndOfFile > $INIT_DIR/job_info.${JOB_ID}${ARRAY_JOB}

  Job ID               : $JOB_ID
  Username             : $USER
  Primary group        : hhe-users
  Login node           : $SGE_O_HOST
  Working directory    : $PWD
  Program              : Gaussian 09 (parallel)
  Input file           : t
  Exclusive access     : No
  Array job            : No
  Task ID range        : Not applicable
  Dependent job ID     : None specified
  SMS notification     : No
  # of hosts           : $NHOSTS
  # of processors      : $NSLOTS
  Parent node          : $LOCATION
  Worker nodes         : `cat $TMP/machines | sed q`
`cat $TMP/machines | sed '1d' | sed 's/^/                         /'`
  Job submission time  : `sge_jst $JOB_ID `
  Job start time       : `date -R`
EndOfFile

# Start the timer
TIME_START=$(date +%s)
cat << EndOfFile > $INIT_DIR/Status
Running
EndOfFile
chmod 755 Status
# Prepend input deck with necessary information and run
# Gaussian 09 (parallel)

#changed hhe
 $g09root/g09/g09 < ${INAME}.com > ${INAME}_NP${NSLOTS}${ARRAY_JOB}.log

# End the timer

TIME_END=$(date +%s)

# Delete the core* files
rm -f ${INIT_DIR}/core*
rm -f ${INIT_DIR}/g09.sh.o${JOB_ID}${ARRAY_JOB}


# Calculate time difference
TIME_TOTAL=`time2dhms $(( $TIME_END - $TIME_START ))`

cat << EndOfFile >> $INIT_DIR/job_info.${JOB_ID}${ARRAY_JOB}
  Job end time         : `date -R`
  Total run time       : $TIME_TOTAL

EndOfFile
rm -f ${INIT_DIR}/g09.sh.po${JOB_ID}${ARRAY_JOB}

rm -f ${INIT_DIR}/Status

#cat << EndOfFile > $INIT_DIR/Status
#Completed
#EndOfFile