#!/bin/bash

#
# Job submission scripts for the SGE batch submission system.
#
# - options to the SGE queuing system are added to the submission 
#   script using lines beginning with #$
#
# find more information concerning these options in qsub(1)
#


# The appropriate MPI module must be loaded. For example:
#source /clumeq/Modules/3.2.7/init/bash
#module load compilers/intel/11.1.059 mpi/openmpi/1.3.4_intel
#module load compilers/gcc/4.4.2 mpi/openmpi/1.3.4_gcc
. ~/.bashrc

# The name of the job.
#$ -N wien


# Specifies  the  project (RAPI number from CCDB) to  which this job is assigned.
# 
#$ -P une-864-aa


# Parallel programming environment (PE) to instantiate and the numbers of cores.
#$ -pe mpi 4     # 4 slots (allocated among the available hosts)
##$ -pe hosts 1       # 6 slots (allocated on a single host max=8)
##$ -pe hosts 16       # 8 slots per host. (numbers of cores should be a multiple of 8)


# Serial Array jobs (format = min-max:step)
# Ex: 2-10:2 = jobs # 2,4,6,8,10
##$ -t 1-5:1


# All jobs must be submitted with an estimated run time. (hh:mm:ss)
#$ -l h_rt=24:00:00


# The path used for the standard output stream of the job.
#$ -o job.out
   

# The path used for the standard error stream of the job.
#$ -e job.err


# The interpreting shell for the job.
#$ -S /bin/bash


# Execute the job from the current working directory.
#$ -cwd


# Send "warning" signals to a running job prior to sending the signals themselves. 
# (If a SIGKILL is pending, the job will receive a SIGUSR2 several seconds before the SIGKILL.)
#$ -notify


# List of users to which the server that executes the job has to send mail
##$ -M user@domain.com


# Under which circumstances mail is to be sent?
# "b" = when job begins
# "e" = when job ends
# "a" = when job aborts
# "s" = when job suspended (someone kicks you off)
# "n" = don't send mail
##$ -m bea


# Set the number of OpenMP threads to share the work.
# This is actually the same as the default value as each node has 8 cores
# It is here only for demonstration purposes.
#export OMP_NUM_THREADS=8

# Command to run
echo 'granularity:1' > .machines
awk '{for (i=1; i<=$2; i++) print "1:"$1":1"}' $PE_HOSTFILE >> .machines

runsp_lapw -p -i 2
