-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathquick_q
executable file
·169 lines (149 loc) · 2.83 KB
/
quick_q
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/sh
############################################################
# Program: quick_q
# Author : Ryan Layer
############################################################
## BEGIN SCRIPT
usage()
{
cat << EOF
usage: $0 OPTIONS
version: 0.3
OPTIONS can be:
-h Show this message
-m mem Memory (default 1gb)
-t threads Threads per device (default 1)
-d devices Devices (default 1)
-T walltime Max run time [[HH:]MM:]SS (default 168:00:00)
-n name Name (default quick_q)
-c cmd Command
-q queue Queue name
-p priority Job priority (int [-1024,1023], default: 0)
-o output Path for stdout of job (default jobname.ojobid)
-e error Path for stderr of job (default jobname.ejobid)
-W attr Additional attributes
-M mail Mail results (Upon end or abort)
-u email address
Email address to send results to
-z other Other qsub parameters that are passed
directly into qsub
EOF
}
# Show usage when there are no arguments.
if test -z "$1"
then
usage
exit
fi
MEM="1gb"
NAME="quick_q"
THREADS=1
DEVICE=1
WALLTIME="168:00:00"
CMD=1
QUEUE=
PRIORITY=0
OUTPUT=
ERROR=
OTHER=
MAIL=false
EMAIL=
# Check options passed in.
while getopts "h m:t:n:c:d:T:q:p:o:e:W:u:z: M" OPTION
do
case $OPTION in
h)
usage
exit 1
;;
m)
MEM=$OPTARG
;;
t)
THREADS=$OPTARG
;;
d)
DEVICE=$OPTARG
;;
T)
WALLTIME=$OPTARG
;;
n)
NAME=$OPTARG
;;
c)
CMD=$OPTARG
;;
q)
QUEUE=$OPTARG
;;
p)
PRIORITY=$OPTARG
;;
o)
OUTPUT=$OPTARG
;;
e)
ERROR=$OPTARG
;;
M)
MAIL=true
;;
u)
EMAIL=$OPTARG
;;
W)
ATTR=$OPTARG
;;
z)
OTHER=$OPTARG
;;
?)
usage
exit
;;
esac
done
#QSUB="/usr/pbs/bin/qsub"
QSUB=/usr/local/bin/qsub
# for pbs_version = PBSPro_11.2.0.113417
#QSUB_CMD="$QSUB -l select=$DEVICE:mem=$MEM:ncpus=$THREADS -m bae -N $NAME -M [email protected]"
# for version: 3.0.3
QSUB_CMD="$QSUB -l nodes=$DEVICE:ppn=$THREADS,mem=$MEM,walltime=$WALLTIME -N $NAME -p $PRIORITY"
if $MAIL
then
QSUB_CMD+=" -m ae"
else
QSUB_CMD+=" -m n"
fi
if [ ! -z "$EMAIL" ]
then
QSUB_CMD+=" -M $EMAIL"
fi
if [ ! -z "$QUEUE" ]
then
QSUB_CMD+=" -q $QUEUE"
fi
if [ ! -z "$OUTPUT" ]
then
QSUB_CMD+=" -o $OUTPUT"
fi
if [ ! -z "$ERROR" ]
then
QSUB_CMD+=" -e $ERROR"
fi
if [ ! -z "$ATTR" ]
then
QSUB_CMD+=" -W $ATTR"
fi
if [ ! -z "$OTHER" ]
then
QSUB_CMD+=" $OTHER"
fi
#echo $QSUB_CMD
JID=`echo "cd \\$PBS_O_WORKDIR; $CMD" | $QSUB_CMD`
echo $JID
DATE=`date +%Y%m%d_%T`
echo $DATE > $JID.log
echo $JID >> $JID.log
echo $CMD >> $JID.log