Repository navigation
Expand file tree
/
Copy pathdistribute_sm2.sh
More file actions
executable file
·88 lines (80 loc) · 2.84 KB
/
Copy pathdistribute_sm2.sh
File metadata and controls
executable file
·88 lines (80 loc) · 2.84 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
###This script works as distributeit3.sh.
datadir=`pwd`
clientfile=clients_sm_tmp
pointsfile=$1
numpoints=$(cat $pointsfile | wc -l)
numiterates=$2
delta=$3
actualpoint=1
##This is in case eixam was not included in the clients list
echo "yes" > eixam_sm_finished
while [ $actualpoint -le $numpoints ]; do
numclients=$(cat $clientfile | wc -l)
for i in `seq 1 1 $numclients`; do
actualclient=$(tail -n +$i $clientfile | head -n 1 | awk '{print $1}')
nprocess=$(tail -n +$i $clientfile | head -n 1 | awk '{print $2}')
if [ "$actualclient" = "eixam" ]; then
rm -f points-eixam-sm
echo "no" > eixam_sm_finished
j=1
startindex=$actualpoint
while [ $j -le $nprocess ];do
tail -n +$actualpoint $pointsfile | head -n 1 >> points-eixam-sm
let j=$j+1
let actualpoint=$actualpoint+1
done
(
rsync points-eixam-sm agranados@eixam.upc.es:/home/agranados/scattering_map/
ssh agranados@eixam.upc.es "cd scattering_map && ./distribute_sm2.sh points-eixam-sm $numiterates $delta $startindex > process_distribute_sm2"
)&
else
niceness=$(tail -n +$i $clientfile | head -n 1 | awk '{print $3}')
a=$(ssh $actualclient "bash -c 'env | grep DISTRIB'"</dev/null)
a=${a:8:8}
b=$(ssh $actualclient "bash -c 'uname -i'"</dev/null)
clientarch=$a$b
clientsystem=$clientarch/find_sm
actcliproc=$(ssh $actualclient 'ps -C find_sm -o pid --no-headers | wc -l | tr -d " "'</dev/null)
while [ $actcliproc -lt $nprocess ]; do
if [ $actualpoint -le $numpoints ]; then
x1=$(tail -n +$actualpoint $pointsfile | head -n 1 | awk '{print $1}')
y1=$(tail -n +$actualpoint $pointsfile | head -n 1 | awk '{print $2}')
x2=$(tail -n +$actualpoint $pointsfile | head -n 1 | awk '{print $3}')
y2=$(tail -n +$actualpoint $pointsfile | head -n 1 | awk '{print $4}')
t0=$(tail -n +$actualpoint $pointsfile | head -n 1 | awk '{print $5}')
poincfile="stroboscopic_$actualpoint-sm.dat"
(
ssh $actualclient "cd $datadir && nice +$niceness $clientsystem $x1 $y1 $x2 $y2 $t0 $delta $poincfile $numiterates "</dev/null
)&
sleep 0.5s
let actualpoint=$actualpoint+1
actcliproc=$(ssh $actualclient 'ps -C find_sm -o pid --no-headers | wc -l | tr -d " "'</dev/null)
else
###This is to quit the loop
actcliproc=$nprocess
fi
done
fi
done
done
sleep 5s
##Now we wait until all the processes are finished
totalprocs=1
while [ $totalprocs != 0 ]; do
totalprocs=0
numclients=$(cat $clientfile | wc -l)
for i in `seq 1 1 $numclients`; do
actualclient=$(tail -n +$i $clientfile | head -n 1 | awk '{print $1}')
if [ "$actualclient" != "eixam" ];then
actcliproc=$(ssh $actualclient 'ps -C find_sm -o pid --no-headers | wc -l | tr -d " "'</dev/null)
let totalprocs=$totalprocs+$actcliproc
fi
done
sleep 2s
done
##We now wait until eixam finishes
tmp=$(cat eixam_sm_finished)
while [ "$tmp" != "yes" ];do
tmp=$(cat eixam_sm_finished)
done