-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_job
95 lines (81 loc) · 1.58 KB
/
create_job
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
while getopts 'n:t:P:l:q:d:' flag; do
case "${flag}" in
n) gpus=${OPTARG} ;;
t) time=${OPTARG} ;;
P) proj=${OPTARG} ;;
l) largs=${OPTARG} ;;
q) queue=${OPTARG} ;;
d) dir=${OPTARG} ;;
*) echo invalid flag -$flag; exit 1 ;;
esac
done
if [ -z $dir ];
then
echo "store in current dir"
dir=$PWD
fi
if [ -z $proj ];
then
echo "#1st arg not provided for proj. Set default $PROJECT"
proj=$PROJECT
fi
if [ -z $gpus ];
then
gpus=1
echo "#2st arg not provided for gpus. Set default 1"
fi
if [ -z $time ];
then
time=00:40:00
echo No -t. Default length: $time
fi
if [ -z $largs ];
then
echo no args
largs=""
else
largs=",${largs}"
fi
if [ -z $queue ];
then
echo No Queue type. Use default gpuvolta
queue="gpuvolta"
fi
if [ "$queue" != "gpuvolta" ];
then
echo play non-gpu jobs
gpus=0
ncpus=1
else
ncpus=$(expr $gpus \* 12)
fi
if test -f "$dir/job.sh"; then
while true; do
read -p "$dir/job.sh exists. Do you want to overwrite it? (y/n)" yn
case $yn in
[nN] ) echo exit; exit;;
[yY] ) rm $dir/job.sh; break;;
* ) echo invalid respnse;;
esac
done
fi
echo write to $dir/job.sh
{
echo '#!/bin/bash'
echo "#PBS -P $proj"
echo "#PBS -q $queue"
echo "#PBS -l ncpus=${ncpus}"
echo "#PBS -l ngpus=$gpus"
echo "#PBS -l mem=64GB"
echo "#PBS -l storage=scratch/sz65"
echo "#PBS -l walltime=${time}"
for i in ${largs//,/ }
do
echo "#PBS -l $i"
done
echo 'args=$(echo ${args}| envsubst)'
echo 'args=${args//|/ }'
echo 'echo $args'
echo "cd $dir"
} >> $dir/job.sh
echo done!