-
Notifications
You must be signed in to change notification settings - Fork 0
/
mk-cluster-script.sh
executable file
·47 lines (40 loc) · 1.2 KB
/
mk-cluster-script.sh
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
#!/bin/bash
STATESDIR=/state/partition1/clustershare/phaslum/states
EXPDIR=/state/partition1/clustershare/phaslum/TRH
PLANNER=/state/partition1/clustershare/phaslum/bin/colin-TRH
states=`ls $STATESDIR/*.pddl | grep -e '[0-9]\\+\\.pddl'`
njobs=`ls $STATESDIR/*.pddl | grep -e '[0-9]\\+\\.pddl' | wc -l`
jobnum=0
# args: $1 = name; $2 = domain file; $3 = problem file
# log is written to $cwd/$name.log
make_job() {
jobnum=$((jobnum + 1))
echo "if [[ \$SGE_TASK_ID == $jobnum ]]; then"
echo " echo \"at \`date\` starting job $1\""
echo " ${PLANNER} $2 $3 > ${1}.log"
echo " echo \"at \`date\` finished job $1\""
echo "fi"
}
## output preamble
echo "#! /bin/bash"
echo "### Set shell."
echo "#$ -S /bin/bash"
echo "### Don't send emails."
echo "#$ -m n"
echo "### Execute job from current working directory."
echo "#$ -cwd"
echo "### redirect stdout and stderr"
echo "#$ -e $EXPDIR/run.err"
echo "#$ -o $EXPDIR/run.log"
echo "### Set timeout."
echo "#$ -l h_cpu=1800"
echo "### Number of tasks"
echo "#$ -t 1-${njobs}"
echo ""
echo "cd $EXPDIR"
echo ""
for pfile in $states; do
pname=`basename $pfile .pddl`
dfile=${STATESDIR}/${pname}domain.pddl
make_job $pname $dfile $pfile
done