-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdistrib
executable file
·115 lines (102 loc) · 2.81 KB
/
distrib
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
#!/bin/bash
ppath=$(realpath "$BASH_SOURCE")
cdir=$(dirname "$ppath")
pn=$(basename "$ppath")
. "$cdir"/functions
: ${PINCRAM_ARCH:="bash"}
export cdir PINCRAM_ARCH
# parameters
datalist=
ijobs="100%"
mem=7900
while [ $# -gt 0 ]
do
case "$1" in
-script) script="$2"; shift;;
-datalist) datalist="$2"; shift;;
-jobs) ijobs="$2"; shift;;
-level) ilevel="$2"; shift;;
--) shift; break;;
-*)
echo >&2 \
"Usage: $0 -script script.sh -datalist list.sh -jobs max-parallel -level level"
exit 1;;
*) break;;# terminate while loop
esac
shift
done
jobs=$ijobs
[[ $jobs =~ ^[0-9]+%?$ ]] || fatal "Non-numeric setting for -jobs"
[[ -n "$PINCRAM_ARCH" ]] && arch="$PINCRAM_ARCH"
[[ $arch =~ pbs|ge|bash|bash-single ]] || fatal "Architecture not set or not implemented (\$arch=$arch)"
level=$ilevel
[[ $level =~ ^[0-9]+%?$ ]] || fatal "Non-numeric setting for -level. level = $level ilevel = $ilevel"
[[ -e $datalist ]] || fatal "Data list $datalist not found"
datalist=$(realpath $datalist)
msg "$arch"
export LEVEL=$level
case $arch in
ge)
fatal "$arch not implemented"
;;
pbs)
cd "$PINCRAM_WORKDIR"
atlasn=$(cat $datalist | wc -l)
if [[ -n $PINCRAM_CHUNKSIZE ]]
then
chunkn=$PINCRAM_CHUNKSIZE
else
chunkn=$[$[$level-3]**2]
fi
levelplus=$[$level + 3]
tsec=$[$levelplus ** 5 * $chunkn]
csec=$[$levelplus ** 4 * $chunkn]
chfactor=$chunkn ; [[ $chunkn -gt $atlasn ]] && chfactor=$atlasn
jobn=$[$atlasn / $chfactor + 1]
[[ -n "$PINCRAM_QUEUE" ]] && qu="-q $PINCRAM_QUEUE"
job_state=nosuch
set -- $(ls distrib-$level-* 2>/dev/null)
[[ -n $1 ]] && eval $(qstat -f $(echo $1 | cut -d '-' -f 3) | grep job_state | tr -d '[:blank:]')
case $job_state in
B|Q)
echo "Job state is $job_state -- continue waiting" >&2
;;
nosuch)
[[ -n $1 ]] && rm distrib-$level-*
jparam= ; [[ $chunkn -lt $atlasn ]] && jparam="-J 1-$jobn"
pbsjob=$(qsub -V $jparam -l walltime=$tsec "$PINCRAM_PBS_OPTION" -j oe -N reg${level}n$chunkn $qu $script)
touch distrib-$level-$pbsjob
echo "Job submitted" >&2
;;
*)
fatal "PBS error"
;;
esac
msg "Estimated processing time $csec seconds"
echo $csec
;;
bash)
atlasn=$(cat $datalist | wc -l)
levelplus=$[$level + 3]
[[ $jobs == "100%" ]] && jobs=$(nproc --all)
chunkn=$[ $atlasn / $jobs ]
[[ $chunkn -eq 0 ]] && chunkn=1
csec=$[$levelplus ** 4 * $chunkn]
cat $datalist | xargs -L 1 -P $jobs $script &
msg "Estimated processing time $csec seconds"
echo $csec
;;
bash-single)
atlasn=$(cat $datalist | wc -l)
levelplus=$[$level + 3]
chunkn=$[ $atlasn / $jobs ]
[[ $chunkn -eq 0 ]] && chunkn=1
csec=$[$levelplus ** 4 * $chunkn]
cat $datalist | xargs -L 1 -P 1 $script &
msg "Estimated processing time $csec seconds"
echo $csec
;;
*)
fatal "$arch not implemented"
esac
exit 0