-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmlqsub
More file actions
executable file
·69 lines (62 loc) · 2.1 KB
/
mlqsub
File metadata and controls
executable file
·69 lines (62 loc) · 2.1 KB
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
#!/bin/tcsh -f
# usage: mlqsub toolboxes script [numloops]
# e.g. mlqsub "( Signal_Toolbox Statistics_Toolbox )" event.m
# e.g. mlqsub "( )" event.m 36 * note space inside brackets is important
# to get complete list of toolboxes, do lmstat -a
# rename arguments
set f1 = $1
set script = $2
if( $3 == "") then
@ loops = 1
else
@ loops = $3
endif
# get features to test
# add Matlab to list of features
set features = ( MATLAB $f1[*] )
@ nfeatures = ${#features}
# set path of lmstat
set lmstat = /home/programs/matlab13/etc/lmstat
# loop over cells
@ n = 1
while ( $n <= $loops )
set avail = 1
@ feature = 1
# stop checking if any feature is not available or if we have
# checked all features
while( $avail && ($feature <= $nfeatures) )
# check feature
@ total = `$lmstat -f $features[$feature] | grep Total | awk '{print $6}'`
# get number being used
@ used = `$lmstat -f $features[$feature] | grep node | wc -l`
if (${used} == ${total}) then
set avail = 0
else
@ remain = $total - $used
endif
echo "Loop ${n}: Feature ${features[${feature}]} available ${remain} of ${total}"
@ feature++
end
if( $avail ) then
echo "Starting job $n"
# start job
if ( $loops > 1) then
# echo 'hostname; unset DISPLAY; cd $PBS_O_WORKDIR; '"sed 's/@/$n/g' $script | matlab -nojvm" | qsub -V -l nodes=1 -j oe -o $PWD/mlqsub$n -N $script -
# echo 'hostname; unset DISPLAY; cd $PBS_O_WORKDIR; '"sed 's/@/$n/g' $script | matlab -nojvm" > sm$n
# swarm -f sm$n -V -j oe -o $PWD/mlqsub$n -N $script
else
# no loop required so just run script
# echo 'hostname; unset DISPLAY; cd $PBS_O_WORKDIR; '"cat $script | matlab -nojvm" | qsub -V -l nodes=1 -j oe -o $PWD/mlqsub$n -N $script -
# echo 'hostname; unset DISPLAY; cd $PBS_O_WORKDIR; '"cat $script | matlab -nojvm" > sm$n
# swam -f sm$n -V -j oe -o $PWD/mlqsub$n -N $script
endif
# go to the next cell
@ n++
# wait a little bit till matlab starts up and grabs the necessary license
sleep 10
else
echo "Licenses not available. Will check again in 10 mins..."
# features not available so wait a while and check again
sleep 600
endif
end