File: mpirun.ch_cenju3.in

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 (233 lines) | stat: -rwxr-xr-x 6,335 bytes parent folder | download | duplicates (2)
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
#! /bin/sh
if [ "$MPIR_HOME" = "" ] ; then 
    MPIR_HOME=#MPIR_HOME#
fi
if [ "$MPIR_HOME" = "#""MPIR_HOME""#" ] ; then
    MPIR_HOME=`pwd`/..
fi
if [ "#MPIRUN_BIN#" = "#""MPIRUN_BIN""#" ] ; then 
    MPIRUN_HOME=$MPIR_HOME/bin
else
    MPIRUN_HOME=$MPIR_HOME/#MPIRUN_BIN#
fi
if [ "$argsset" = "" ] ; then
   . $MPIRUN_HOME/mpirun.args
   argsset=1
fi
#
#==================== machine dependent =============================
#
#  Options which depends on the queuing system used on the machine :
#  -----------------------------------------------------------------
#
#  use : Option which kind of commands should be used in order
#        to execute and submit programs.
#
#        use = CJ   : Use native CJ commands
#        use = EASY : Use Easy commands
#
#  easybin  : Full path name (including last /) of directory
#             containing the EASY commands of Cenju-3 or
#             empty string if general path should be used.
#  easywait : Option for interactive mode of EASY
#             easywait = prompt : Wait for prompt of user
#                                 before user program is started.
#             easywait = wait   : Wait and inspect easy queue
#                                 and try to start user program.
#
#===> Select one of the following
#
    use=CJ
#
#   use=EASY
    easybin=/opt/EASY/bin/
#   easybin=
    easywait=wait
#
#============ End of machine dependent =============================
#
#---------------- Batch Mode -------------------------------------
#
    if [ -n "$batch" ] ; then
#
#   Execute Job in batch mode
#
       if [ $mpirun_verbose = 1 ] ; then
          echo executing job in batch mode
       fi
#
       case $use in 
#
       EASY)
            if [ -z "$stdoutfile" ] ; then
               stdoutfile=$PWD_TRIAL/stdout.$$
            else
               tail=`echo $stdoutfile | sed 's/\/.*//'`
               if  [ -z "$tail" = "" ] ; then
                  stdoutfile="$PWD_TRIAL/$stdoutfile"
               fi
            fi
#
            if [ -z "$stderrfile" ] ; then
               stderrfile=$PWD_TRIAL/stderr.$$
            else
               tail=`echo $stderrfile | sed 's/\/.*//'`
               if  [ -z "$tail" = "" ] ; then
                  stderrfile="$PWD_TRIAL/$stderrfile"
               fi
            fi
#
            if [ -z "$stdinfile" ] ; then
               stdinfile=/dev/null
            else
               tail=`echo $stdinfile | sed 's/\/.*//'`
               if  [ -z "$tail" = "" ] ; then
                  stderrfile="$PWD_TRIAL/$stdinfile"
               fi
            fi
#
#           tempfile=$PWD_TRIAL/batch_script.mpirun.$$
            tempfile=batch_script.mpirun.$$
#
            rm -f $tempfile
#
            cat << EOF > $tempfile
#! /bin/sh
cd $PWD_TRIAL
#
# Standard-Input  will be read from  $stdinfile
# Standard-Output will be written to $stdoutfile
# Error   -Output will be written to $stderrfile
#
${easybin}prun -j \$1 -n $np -p $progname -a "$cmdLineArgs" < $stdinfile > $stdou
tfile 2> $stderrfile
EOF
#
            echo "=== submitting batch job : Number of processors = $np"
            echo "===                        Maximal time         = $max_time min
utes"
            chmod +x $tempfile
            $Show ${easybin}psubmit -n $np -t $max_time -b $tempfile
            rm -f $tempfile
            ;;

       CJ | *)
            cjarg=
#
            if [ -n "$stdinfile" ] ; then
               cjarg="-i $stdinfile"
            else
               cjarg=
            fi
#
            if [ -n "$stdoutfile" ] ; then
               cjarg="$cjarg -o $stdoutfile"
            fi
#
            if [ -n "$stderrfile" ] ; then
               cjarg="$cjarg -e $stderrfile"
            fi
#
            $Show cjbr $cjarg $np $progname $cmdLineArgs
#
            ;;
       esac
#
    else
#
#------------------------- Interactive mode ----------------------------
#
       case $use in 
#
       EASY)
          if [ -n "$easy_jid" ] ; then
#
#===> ... user has allocated node. Execute parallel program
#
             $Show ${easybin}prun -j $easy_jid -n $np -p $progname -a \"$cmdLineArgs\"
          else

             tempfile=.tEmP_EaSy.OuTpUt.$$
             rm -f $tempfile
#
             sleep=0
#
             while [ "$status" != 0 -o -z "$easy_jid" ]
             do
                if [ $sleep != 0 ] ; then
                    echo "=== mpirun doesn't return a job id; waiting"
                    sleep 30
                fi
#
                $Show ${easybin}psubmit -i -n $np -t $max_time | tee -a $tempfile
                status=$?
                easy_jid=`fgrep 'JID for this job is' $tempfile | sed -e 's/.*: *\([0-9]*\) */\1/'`
#
                rm -f $tempfile
                sleep=30
             done
#
             if [ "$easywait" = wait ] ; then
#
                tempfile=.tEmP.sEdFiLe.$$
                cat << EOF > $tempfile
/^$easy_jid/!d
s/$easy_jid  *[^ ]* * [^ ]* *[^ ]* . . *\(.\).*/\1/
EOF
#
                echo === Waiting until processors are available
#
                status=W
                while [ "$status" != R ]
                do
                   sleep 5
                   status=`pq | sed -f $tempfile`
                done
#
                rm -f $tempfile
             else
#
#===> Wait for a prompt
#
                cat << EOF
=== Type <ENTER> if the CENJU-3 nodes requested for JID \`\`$easy_jid''
===                 are available (i.e. if you got mail) :"
=== After that, this script will start the parallel program
=== \`\`$progname''.

EOF
#
                read answer
                if [ $? != 0 ]
                then
                   echo '### Error in read : Probably attempted background read'
                exit 1
                fi 
             fi
#
#===> Start parallel program
#
             $Show ${easybin}prun -j $easy_jid -n $np -p $progname -a \"$cmdLineArgs\"
#
#===> Release nodes allocated
#
             $Show ${easybin}prelease $easy_jid < /dev/null
          fi
          ;;

       CJ | *)
#
#===> Get number of processors available
#
          free=`cjpes | fgrep ST_PE_ACTIV | wc -l`
          if [ $mpirun_verbose = 1 -o "$free" -lt $np ] ; then
             echo === waiting for $np processors available
          fi
#
          $Show cjsh -w -n $np $progname $cmdLineArgs
#
          ;;
       esac
    fi
#
    exit 0