#!/usr/local/bin/bash
#
# This is a demo submit script for non MPI jobs in the
# Computer Center of the University of Ulm
# It expects GridEngine as the underlaying scheduler.
#
# Check the manpage of qsub(1)

# ----------------------------------------------------------------------
# add resource requests; '#$' is interpreted by qsub(1) so it's
# NOT a comment

# give the job a name

#$ -N batch_demo


# setup resource requests like number of CPUs, memory, ...
# eg 512M of virtual memory and 24 hours of CPU time

#$ -l h_vmem=512M
#$ -l h_cpu=24:0:0


# we assigned special resource like availability of software and the
# like to some nodes
#	request a queue with gaussian support:		gaussian=true
#	request a queue CADENCE... support:		etechnik=true
#	request a queue not running beta OS:		nobeta=true
#
# the defaults are
#	ok to submit to Solaris 9 box
#	no special software requirements
#
# the software dependencies just leave more flexibility to the host
# admins but the software is very likely to be available at every node

#$ -l gaussian=true
 

# to change the default location and name of
#	stderr:	<jobname>.e<job_id>
#	stdout:	<jobname>.o<job_id>
# eg discard stdout

#$ -o /dev/null


# by default we get mail when a job is started/finished/aborted
# but if you don't want it

#$ -m n


# ----------------------------------------------------------------------
# the real sork starts here

# make special 'computer center extensions' available
# and setup environment

. /etc/bash_profile


# make the script abort on any error
set -e


# if you need special packages use the same 'option' commands as
# interactively; you can get a list by 'options'
# eg for Gaussian 98

option g98


# you may want to create a working diretory for this job
# in the local scratch area
#
# WORKBASE=/work/$USER
# WORKDIR=$JOB_NAME.$JOB_ID
# cd $WORKBASE
# mkdir $WORKDIR
# cd $WORKDIR


# if you need files from the submit host to be copied to the
# local scratch area on the execution host add something like
#
# rcp $SGE_O_HOST:<original_path>/<original_name> $WORKBASE/$WORKDIR
#
# be aware that by default the batch system changes the current
# directory to the one from which the job was submitted
#
# also check rsync(1) if it's more than a single file


# ok, start the real work (my app here is just 'date')
# (output gets discarded because we redirected stdout to /dev/null)

date


# do cleanup if required
#
# cd $WORKBASE/$WORKDIR
# ### add code to save important files ###
# cd $WORKBASE
# rm -rf $WORKBASE/$WORKDIR


