-
Notifications
You must be signed in to change notification settings - Fork 1
/
qqsub
executable file
·51 lines (43 loc) · 1.65 KB
/
qqsub
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# torqq -- run Portable Batch System scripts locally
# torqq is released under the New BSD license (see LICENSE.txt).
# Go to the project home page for more info:
# https://github.com/abernatskiy/torqq
# This script imitates qsub, supporting the following subset of its options:
# -q queue - locally no meaning
# -l resorceVars - those are not enforced, of course
# -v environmentVars - the only working option
# Additionally, the built-in variable ${PBS_O_WORKDIR} is provided
# Test command:
# ./qqsub -q shortq -l walltime=01:00:00 -v PYTHON=/usr/bin/python2,PBSGRIDWALKER_HOME=$HOME/morphMod/pbsGridWalker,PARENT_SCRIPT=$HOME/morphMod/twoMorphologies3.py,
# POINTS_PER_JOB=25 $HOME/morphMod/pbsGridWalker/pbs.sh
STARTED_FILE=/tmp/torqq-started
FINISHED_FILE=/tmp/torqq-finished
while getopts ":q::l::v:" opt; do
case $opt in
q)
QUEUE="$OPTARG"
;;
l)
RESOURCES="$OPTARG"
;;
v)
ENVIRONMENT="$OPTARG"
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
for EXECUTABLE in $@; do true; done # get the last command line argument
ID=${BASHPID}
# Debug
# echo -e "Got the following params:\nQUEUE=${QUEUE}\nRESOURCES=${RESOURCES}\nENVIRONMENT=${ENVIRONMENT}\nEXECUTABLE=${EXECUTABLE}\nID=${ID}"
# Executing the excutable with environment variables supplied with -v and the additional PBS_O_WORKDIR varaible
bash -c "echo ${ID} >> ${STARTED_FILE}; PBS_O_WORKDIR="`pwd`" `echo "$ENVIRONMENT" | sed -e 's/\([a-zA-Z_]\+=[^=]*\),/\1 /g'` /bin/bash ${EXECUTABLE}; echo ${ID} >> ${FINISHED_FILE}" > o${ID} 2>e${ID} &
echo -n $BASHPID