File: execer

package info (click to toggle)
mpich 1.1.0-3
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 22,116 kB
  • ctags: 27,349
  • sloc: ansic: 193,435; sh: 11,172; fortran: 6,545; makefile: 5,801; cpp: 5,020; tcl: 3,548; asm: 3,536; csh: 1,079; java: 614; perl: 183; awk: 168; sed: 70; f90: 62
file content (165 lines) | stat: -rwxr-xr-x 4,158 bytes parent folder | download | duplicates (8)
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/bin/sh
# We use sh because it is quiter while spawning jobs.  It is awkward 
# because the original code used arrays in csh
#
jobid=5555  # default
dbx=0
j=1
line=0
islocal=0
for arg in "$@" ; do
    case $arg in 
      -echo)
	set -x
	;;
      -jobid=*)
        jobid=`echo $arg | sed 's/-jobid=//'`
	;;
      -arch=*)
        line=`expr $line + 1`
        eval repeat$line=1
        eval numprocs$line=1
        eval arch$line=`echo $arg | sed 's/-arch=//'`
        echo -arch not yet implemented
        ;;
      -islocal)
	islocal=1
	;;
      -host=*)
        line=`expr $line + 1`
        eval repeat$line=1  
        eval numprocs$line=1
        eval host$line=`echo $arg | sed 's/-host=//'`
        ;;
      -pgm=*)
        eval pgm$line=`echo $arg | sed 's/-pgm=//'`
        ;;
      -numprocs=*)
	echo $arg
	# This wierd code is because a -n at the begining of echo 
	# causes echo to silently IGNORE THE LINE!!!!!!
	value=`echo a"$arg" | sed 's/a-numprocs=//'`
        eval numprocs$line=$value
        ;;
      -repeat=*)
        eval repeat$line=`echo $arg | sed 's/-repeat=//'`
        ;;
      -logname=*)
        eval logname$line=`echo $arg | sed 's/-logname=//'`
        ;;
      -comm=*)
        eval comm$line=`echo $arg | sed 's/-comm=//'`
        ;;
      -args=*)
        eval args$line="`echo $arg | sed 's/-args=//'`"
        ;;
      -arg=*)
        eval args=$"args$line"
        eval args$line="'""$args `echo $arg | sed 's/-arg=//'`""'"
        ;;
      -dbx)
        dbx=1
	;;
      *)
        echo invalid argument $arg argument should be one of
        echo '-host=<host> -arch=<arch> numprocs repeat logname comm args'
    esac
done

# Count number of processes (nodes) to be started.  This includes
# multiple nodes on a single host, if requested.
numnodes=0
i=1
while [ $i -le $line ] ; do
    eval repeat=$"repeat$line"
    numnodes=`expr $numnodes + $repeat`
    i=`expr $i + 1`
done

# Compute remoteinfo
# @ i=2
# while ( $i <= $line )
    # remoteinfo=" $host[$i] $i $numprocs[$i] $pgm[$i] "
# end
MYDISPLAY=`hostname`:0
# Start the processes.
nodenum=1
i=$line
while [ $i -ge 1 ] ; do
    j=1   
    eval repeati=$"repeat$i"
    while [ $j -le $repeati ] ; do
        nodenum=`expr $i - 1`
	if [ $dbx != 1 ] ; then
            eval pgm=$"pgm$i"
	    remotecmd=" $pgm "
        else
	    remotecmd=" "
        fi
	remotecmd=" $remotecmd -execer_id PDQS "
        remotecmd=" $remotecmd -master_host $host1 "
	eval host=$"host$i"
        remotecmd=" $remotecmd -my_hostname $host "
        remotecmd=" $remotecmd -my_nodenum $nodenum "
	eval numprocs=$"numprocs$i"
	if [ -z "$numprocs" ] ; then
	   echo "Invalid number of processes for host $host ($i)"
	   exit 1
	fi
        remotecmd=" $remotecmd -my_numprocs $numprocs "
	remotecmd=" $remotecmd -total_numnodes $numnodes "
	remotecmd=" $remotecmd -job_id $jobid "
	remotecmd=" $remotecmd -remote_info "
	k=1
	while [ $k -le $line ] ; do
	    eval host=$"host$k"
	    remotecmd=" $remotecmd $host "
	    n=`expr $k - 1`
	    eval numprocs=$"numprocs$k"
	    eval pgm=$"pgm$k"
	    remotecmd=" $remotecmd $n $numprocs $pgm "
	    k=`expr $k + 1`
	done
	eval args=$"args$i"
	remotecmd=" $remotecmd $args "
	if [ $dbx = 1 ] ; then
	    cat > ~/.exs$i <<.
cd `pwd`
run $remotecmd	
.
	fi
	eval repeat=$"repeat$i"
	eval host=$"host$i"
	eval pgm=$"pgm$i"
	if [ $j -eq $repeat -a $i -eq 1 ] ; then
#	  echo backgrounding on $host
#	  echo remotecmd: $remotecmd
	  if [ $dbx = 1 ] ; then
	      if [ $islocal = 1 ] ; then
	          xterm -display $MYDISPLAY -e /usr/ucb/dbx $pgm -sr ~/.exs$i
	      else
	      rsh -n $host xterm -display $MYDISPLAY -e /usr/ucb/dbx $pgm -sr ~/.exs$i
	      fi
          else
	      if [ $islocal = 1 ] ; then
		  $remotecmd
	      else
	          rsh -n $host $remotecmd
	      fi
	  fi
        else
#	  echo backgrounding on $host
#	  echo remotecmd: $remotecmd
	  if [ $dbx = 1 ] ; then
	      rsh -n $host xterm -display $MYDISPLAY -e /usr/ucb/dbx $pgm -sr ~/.exs$i &
	  else
              rsh -n $host $remotecmd &
          fi
	fi
#	echo ""
	nodenum=`expr $nodenum + 1`
        j=`expr $j + 1`
    done
    i=`expr $i - 1`
done
wait