1 | #!/bin/ksh |
---|
2 | |
---|
3 | # mrun - script for running PALM jobs |
---|
4 | |
---|
5 | #--------------------------------------------------------------------------------# |
---|
6 | # This file is part of PALM. |
---|
7 | # |
---|
8 | # PALM is free software: you can redistribute it and/or modify it under the terms |
---|
9 | # of the GNU General Public License as published by the Free Software Foundation, |
---|
10 | # either version 3 of the License, or (at your option) any later version. |
---|
11 | # |
---|
12 | # PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
13 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
14 | # A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
15 | # |
---|
16 | # You should have received a copy of the GNU General Public License along with |
---|
17 | # PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
18 | # |
---|
19 | # Copyright 1997-2015 Leibniz Universitaet Hannover |
---|
20 | #--------------------------------------------------------------------------------# |
---|
21 | # |
---|
22 | # Current revisions: |
---|
23 | # ------------------ |
---|
24 | # |
---|
25 | # |
---|
26 | # Former revisions: |
---|
27 | # ----------------- |
---|
28 | # $Id: mrun 1805 2016-04-05 16:32:34Z maronga $ |
---|
29 | # |
---|
30 | # 1804 2016-04-05 16:30:18Z maronga |
---|
31 | # test: implementing an execute mechanism where the execute command is given in the |
---|
32 | # configuration file |
---|
33 | # ROPTS removed from execution commands |
---|
34 | # Warnings about missing optional files or user code changed to informative messages |
---|
35 | # Removed parameter file check |
---|
36 | # |
---|
37 | # 1755 2016-02-22 13:53:39Z maronga |
---|
38 | # Minor bugfix to last commit |
---|
39 | # |
---|
40 | # 1753 2016-02-22 13:49:49Z maronga |
---|
41 | # Bugfix: use random job number when PBS job nummer retrieval fails on lccray* |
---|
42 | # |
---|
43 | # 1622 2015-07-20 06:21:36Z heinze |
---|
44 | # bugfix for Mistral (lcbullhh) |
---|
45 | # |
---|
46 | # 1621 2015-07-17 11:39:33Z heinze |
---|
47 | # adjustments for Mistral at DKRZ Hamburg (lcbullhh) |
---|
48 | # |
---|
49 | # 1609 2015-07-03 15:37:58Z maronga |
---|
50 | # Modified the random number of the temporary working directory to match the |
---|
51 | # queuing system number on HLRN-III (lccray*). |
---|
52 | # |
---|
53 | # 1604 2015-06-23 15:48:03Z suehring |
---|
54 | # Enable coupled runs for lcmuk |
---|
55 | # |
---|
56 | # 1598 2015-05-29 06:45:40Z raasch |
---|
57 | # bugfix for creating hostfile and total number of MPI tasks if run in openmp-mode on one node |
---|
58 | # |
---|
59 | # 1549 2015-01-30 14:26:16Z suehring |
---|
60 | # Enable interactive debug sessions with allinea debugger |
---|
61 | # |
---|
62 | # 1547 2015-01-29 15:09:12Z witha |
---|
63 | # adjustments for ForWind computing cluster (lcflow) |
---|
64 | # |
---|
65 | # 1491 2014-11-12 08:12:57Z heinze |
---|
66 | # correct setting of batch_job allowed for ibm-machines |
---|
67 | # |
---|
68 | # 1468 2014-09-24 14:06:57Z maronga |
---|
69 | # Typo removed (addres->address) |
---|
70 | # Bugfix: returning files to IMUK via ssh did not work for lccrayh and lcycrayb |
---|
71 | # Added support for restart runs (remote) for lcxe6 |
---|
72 | # |
---|
73 | # 1442 2014-07-28 07:09:10Z raasch |
---|
74 | # default queues for HLRN-III (lccrayb/lccrayh) defined |
---|
75 | # |
---|
76 | # 1422 2014-07-02 10:01:25Z kanani |
---|
77 | # automatic restarts enabled for lccrayb, |
---|
78 | # adjustment of path to compilervars.sh at IMUK (see automatic restarts) |
---|
79 | # |
---|
80 | # 1420 2014-06-10 06:24:14Z raasch |
---|
81 | # -j1 option added to aprung command for lccrayf (CSC) |
---|
82 | # |
---|
83 | # 1402 2014-05-09 14:25:13Z raasch |
---|
84 | # batch_job added to envpar-NAMELIST |
---|
85 | # |
---|
86 | # 1357 2014-04-11 15:02:03Z witha |
---|
87 | # adjustments for lccrayh (automatic restarts on lccrayh outside of IMUK are now |
---|
88 | # possible) |
---|
89 | # |
---|
90 | # 1320 2014-03-20 08:40:49Z raasch |
---|
91 | # check namelist file set false by default |
---|
92 | # |
---|
93 | # 1304 2014-03-12 10:29:42Z raasch |
---|
94 | # ulimit option changed from -Ss to -s |
---|
95 | # |
---|
96 | # bugfix: missing "fi" in r1289 |
---|
97 | # |
---|
98 | # 1289 2014-03-04 07:12:34Z raasch |
---|
99 | # comments translated to English |
---|
100 | # necriam-, fimm-, ibmy-, and sgi-specific code removed |
---|
101 | # export of variables for palm and interpret_config removed |
---|
102 | # |
---|
103 | # 1281 2014-02-01 07:55:49Z raasch |
---|
104 | # rsync-copy restricted to Cray machines, since command is unavailable on some |
---|
105 | # other systems |
---|
106 | # |
---|
107 | # 1279 2014-01-28 12:10:14Z raasch |
---|
108 | # tasks_per_node must not be an integral divisor of numprocs any more. This was done |
---|
109 | # in order to remove annoying restrictions concerning the number of processors which |
---|
110 | # appear on machines with larger nodes (e.g. containing 24 cores). Now without this |
---|
111 | # restriction, one of the nodes will be filled with less than the given number of |
---|
112 | # tasks per node. A respective warning is given. |
---|
113 | # |
---|
114 | # 1274 2014-01-09 13:14:54Z heinze |
---|
115 | # adjustments for lccrayh |
---|
116 | # |
---|
117 | # 1272 2014-01-08 10:19:32Z witha |
---|
118 | # small adjustment for lcflow |
---|
119 | # |
---|
120 | # 1270 2013-12-16 11:05:01Z fricke |
---|
121 | # call of combine_plot_fields adjusted for lccrayb/lccrayh |
---|
122 | # |
---|
123 | # 1255 2013-11-07 14:43:35Z raasch |
---|
124 | # further adjustments for lccrayb remote access |
---|
125 | # |
---|
126 | # 1241 2013-10-30 11:36:58Z heinze |
---|
127 | # Enable use of nudging input and input of large scale forcing from |
---|
128 | # external files |
---|
129 | # |
---|
130 | # 1229 2013-09-20 06:55:19Z raasch |
---|
131 | # further adjustments for lccrayb |
---|
132 | # |
---|
133 | # 1224 2013-09-16 07:27:23Z raasch |
---|
134 | # first adjustments for lccrayb |
---|
135 | # |
---|
136 | # 1210 2013-08-14 10:58:20Z raasch |
---|
137 | # fftw support added |
---|
138 | # |
---|
139 | # 1201 2013-07-10 16:17:59Z witha |
---|
140 | # adjustments for Forwind cluster (lcflow) |
---|
141 | # |
---|
142 | # 1199 2013-07-05 14:52:22Z raasch |
---|
143 | # adjustments for CSC Helsinki (lccrayf), |
---|
144 | # executables for batch jobs can be created in advance, in order to avoid calling |
---|
145 | # the compiler within the batch job (only works if batch jobs are submitted on |
---|
146 | # local host) |
---|
147 | # |
---|
148 | # 1190 2013-06-25 09:39:21Z heinze |
---|
149 | # enable use of automatic restarts for ibmh |
---|
150 | # use of cluster/express queue enabled (ibmh) |
---|
151 | # |
---|
152 | # 1124 2013-04-09 15:46:52Z raasch |
---|
153 | # variable "memory" is exported via typeset option -x, because otherwise an unknown |
---|
154 | # side effect may lead to data loss while getopts is reading the script-option arguments |
---|
155 | # |
---|
156 | # 1122 2013-04-09 08:37:16Z heinze |
---|
157 | # Bugfix: change type of variable last_char |
---|
158 | # |
---|
159 | # 1119 2013-04-05 15:11:19Z raasch |
---|
160 | # Bugfix for setting -T option for subjob |
---|
161 | # |
---|
162 | # 1108 2013-03-05 07:03:32Z raasch |
---|
163 | # bugfix for coupled runs on lckyut/lckyuh |
---|
164 | # |
---|
165 | # 1106 2013-03-04 05:31:38Z raasch |
---|
166 | # --stdin argument for mpiexec on lckyuh |
---|
167 | # -y and -Y settings output to header |
---|
168 | # |
---|
169 | # 1103 2013-02-20 02:15:53Z raasch |
---|
170 | # default script runs again under ksh, because of unsolved problems with read |
---|
171 | # from stdin: when bash script is called from a ksh, message "read error: 0: |
---|
172 | # Resource temporarily unavailable" appears and script does not stop, |
---|
173 | # further bash compatibility adjustments, |
---|
174 | # shebang line replaced by /bin/bash when running jobs on lckyuh; no restarts |
---|
175 | # on lckyuh, but mrun does not terminate and issues a warning instead |
---|
176 | # |
---|
177 | # 1101 2013-02-17 10:20:21Z raasch |
---|
178 | # script now running under bash instead of ksh, which required small adjustments |
---|
179 | # (output formatting with printf instead "typeset -L/-R", print replaced by echo, |
---|
180 | # read from stdin), |
---|
181 | # cross compilername on lckyuh compute nodes replaced by real compiler name |
---|
182 | # |
---|
183 | # 1099 2013-02-10 01:47:43Z raasch |
---|
184 | # adjustments for Kyushu-University computing center (lckyuh - hayaka) |
---|
185 | # and for Forwind cluster (lcflow) |
---|
186 | # small further adjustments for lckyut |
---|
187 | # |
---|
188 | # 1094 2013-02-03 01:52:12Z raasch |
---|
189 | # explicit ssh/scp port can be set in config file with environment variable |
---|
190 | # scp_port. This port is handled to all ssh/scp/batch_scp calls. |
---|
191 | # decalpha parts (yonsei) removed |
---|
192 | # |
---|
193 | # 2013-02-02 07:06:13Z raasch |
---|
194 | # adjustments for Kyushu-University computing center (lckyut - tatara) |
---|
195 | # |
---|
196 | # 1083 2013-01-04 10:22:09Z maronga |
---|
197 | # bugfix in parameter file check (read %cpp_options was missing) |
---|
198 | # |
---|
199 | # 1069 2012-11-28 16:18:43Z maronga |
---|
200 | # bugfix: coupling mode was always set to mpi2, typos removed |
---|
201 | # |
---|
202 | # 1058 2012-11-21 07:00:35Z raasch |
---|
203 | # Intel inspector (inspxe) is given the number of PEs instead of the number of |
---|
204 | # nodes |
---|
205 | # |
---|
206 | # 1046 2012-11-09 14:38:45Z maronga |
---|
207 | # code put under GPL (PALM 3.9) |
---|
208 | # |
---|
209 | # 21/03/94 - Siggi - first version finished |
---|
210 | # 03/03/94 - Siggi - script development started |
---|
211 | # |
---|
212 | #--------------------------------------------------------------------------------# |
---|
213 | # mrun - script for running PALM jobs |
---|
214 | #--------------------------------------------------------------------------------# |
---|
215 | |
---|
216 | |
---|
217 | |
---|
218 | # DECLARATION OF VARIABLES AND THEIR DEFUALT VALUES |
---|
219 | |
---|
220 | set +o allexport # SUPPRESS EXPORT OF ALL VARIABLES, SINCE IN THE PAST THIS |
---|
221 | # LES TO PROBLEMS IN ROUTINES CALLED BY MRUN |
---|
222 | # (TOO MANY ARGUMENTS - PROBLEM) |
---|
223 | set +o noclobber # EXISTING FILES ARE ALLOWED TO BE OVERWRITTEN |
---|
224 | |
---|
225 | AddFilenames="" |
---|
226 | additional_conditions="" |
---|
227 | add_source_path="" |
---|
228 | afname="" |
---|
229 | archive_save=true |
---|
230 | archive_system=none |
---|
231 | check_namelist_files=false |
---|
232 | combine_plot_fields=true |
---|
233 | compiler_name="" |
---|
234 | cond1="" |
---|
235 | cond2="" |
---|
236 | config_file=.mrun.config |
---|
237 | coupled_dist="" |
---|
238 | coupled_mode="mpi1" |
---|
239 | cpp_opts="" |
---|
240 | cpp_options="" |
---|
241 | cpumax=0 |
---|
242 | cpurest=0 |
---|
243 | create_executable_for_batch=false |
---|
244 | delete_temporary_catalog=true |
---|
245 | do_batch=false |
---|
246 | do_compile=true |
---|
247 | do_remote=false |
---|
248 | do_stagein=true |
---|
249 | do_stageout=true |
---|
250 | do_trace=false |
---|
251 | email_notification="none" |
---|
252 | exclude="" |
---|
253 | executable="" |
---|
254 | execute_command="none" |
---|
255 | execution_error=false |
---|
256 | fftw_inc="" |
---|
257 | fftw_lib="" |
---|
258 | fftw_support=false |
---|
259 | fname=test |
---|
260 | fromhost="" |
---|
261 | global_revision="" |
---|
262 | group_number=none |
---|
263 | host="" |
---|
264 | host_file="" |
---|
265 | hp="" |
---|
266 | ignore_archive_error=false |
---|
267 | input_list="" |
---|
268 | interpreted_config_file="" |
---|
269 | job_catalog="~/job_queue" |
---|
270 | job_on_file="" |
---|
271 | keep_data_from_previous_run=false |
---|
272 | link_local_input=false |
---|
273 | link_local_output=false |
---|
274 | localhost_realname=$(hostname) |
---|
275 | local_dvrserver_running=.FALSE. |
---|
276 | locat=normal |
---|
277 | mainprog="" |
---|
278 | makefile="" |
---|
279 | max_par_io_str="" |
---|
280 | mc=$0 |
---|
281 | while [[ $(echo $mc | grep -c "/") != 0 ]] |
---|
282 | do |
---|
283 | mc=`echo $mc | cut -f2- -d"/"` |
---|
284 | done |
---|
285 | module_calls="" |
---|
286 | mrun_script_name=$mc |
---|
287 | netcdf_inc="" |
---|
288 | netcdf_lib="" |
---|
289 | netcdf_support=false |
---|
290 | node_usage=default |
---|
291 | numprocs="" |
---|
292 | numprocs_atmos=0 |
---|
293 | numprocs_ocean=0 |
---|
294 | OOPT="" |
---|
295 | openmp=false |
---|
296 | output_list="" |
---|
297 | package_list="" |
---|
298 | queue=none |
---|
299 | read_from_config="" |
---|
300 | restart_run=false |
---|
301 | if [[ `hostname` = rte10 ]] |
---|
302 | then |
---|
303 | return_address=133.5.185.60 |
---|
304 | echo "+++ WARNING: fixed return_address = $return_address is used !!!!!" |
---|
305 | elif [[ `hostname` = climate0 ]] |
---|
306 | then |
---|
307 | return_address=165.132.26.68 |
---|
308 | echo "+++ WARNING: fixed return_address = $return_address is used !!!!!" |
---|
309 | elif [[ `hostname` = urban00 ]] |
---|
310 | then |
---|
311 | return_address=147.46.30.151 |
---|
312 | echo "+++ WARNING: fixed return_address = $return_address is used !!!!!" |
---|
313 | else |
---|
314 | return_address=$(nslookup `hostname` 2>&1 | grep "Address:" | tail -1 | awk '{print $2}') |
---|
315 | fi |
---|
316 | return_password="" |
---|
317 | return_username=$LOGNAME |
---|
318 | remotecall=false |
---|
319 | remote_username="" |
---|
320 | run_coupled_model=false |
---|
321 | run_mode="" |
---|
322 | store_on_archive_system=false |
---|
323 | dashes=" ----------------------------------------------------------------------------" |
---|
324 | silent=false |
---|
325 | source_list="" |
---|
326 | source_path=SOURCE |
---|
327 | tasks_per_node="" |
---|
328 | threads_per_task=1 |
---|
329 | tmpcreate=false |
---|
330 | tmp_data_catalog="" |
---|
331 | transfer_problems=false |
---|
332 | usern=$LOGNAME |
---|
333 | use_openmp=false |
---|
334 | version="MRUN 2.1 Rev$Rev: 1805 $" |
---|
335 | working_directory=`pwd` |
---|
336 | TOPT="" |
---|
337 | XOPT="" |
---|
338 | zeit=$( date | cut -c 12-19 ) |
---|
339 | |
---|
340 | typeset -i iec=0 iic=0 iin=0 ioc=0 iout=0 stagein_anz=0 stageout_anz=0 |
---|
341 | typeset -x -i memory=0 # HAS TO BE EXPORTED HERE, OTHERWISE AN UNKNOWN SIDE |
---|
342 | # SIDE EFFECT MAY CAUSE DATA LOSS WHEN GETOPTS IS READING THE |
---|
343 | # SCRIPT-OPTION ARGUMENTS |
---|
344 | typeset -i cputime i ii iia iii iio icycle inode ival jobges jobsek last_char_int maxcycle minuten nodes pes remaining_pes sekunden tp1 |
---|
345 | |
---|
346 | # ERROR HANDLING IN CASE OF EXIT |
---|
347 | trap 'rm -rf $working_directory/tmp_mrun |
---|
348 | if [[ $locat != normal && $locat != control_c ]] |
---|
349 | then |
---|
350 | |
---|
351 | # CARRY OUT ERROR-COMMANDS GIVEN IN THE CONFIGURATION FILE (EC:) |
---|
352 | (( i = 0 )) |
---|
353 | while (( i < iec )) |
---|
354 | do |
---|
355 | (( i = i + 1 )) |
---|
356 | printf "\n *** Execution of ERROR-command:\n" |
---|
357 | printf " >>> ${err_command[$i]}\n" |
---|
358 | eval ${err_command[$i]} |
---|
359 | done |
---|
360 | if [[ -n $interpreted_config_file ]] |
---|
361 | then |
---|
362 | rm -rf $interpreted_config_file |
---|
363 | fi |
---|
364 | if [[ -n .mrun_environment ]] |
---|
365 | then |
---|
366 | rm -rf .mrun_environment |
---|
367 | fi |
---|
368 | if [[ $tmpcreate = true ]] |
---|
369 | then |
---|
370 | printf "\n *** Contents of \"$TEMPDIR\":\n" |
---|
371 | ls -al; cd |
---|
372 | [[ $delete_temporary_catalog = true ]] && rm -rf $TEMPDIR |
---|
373 | fi |
---|
374 | if [[ "$dvrserver_id" != "" ]] |
---|
375 | then |
---|
376 | echo "+++ killing dvrserver_id=$dvrserver_id" |
---|
377 | kill $dvrserver_id |
---|
378 | fi |
---|
379 | if [[ -f ~/job_queue/JOBINFO.$QSUB_REQID ]] |
---|
380 | then |
---|
381 | rm -rf ~/job_queue/JOBINFO.$QSUB_REQID |
---|
382 | fi |
---|
383 | printf "\n\n+++ MRUN killed \n\n" |
---|
384 | elif [[ $locat != control_c ]] |
---|
385 | then |
---|
386 | printf "\n\n --> all actions finished\n\n" |
---|
387 | printf " Bye, bye $usern !!\n\n" |
---|
388 | fi' exit |
---|
389 | |
---|
390 | |
---|
391 | # ACTIONS IN CASE OF TERMINAL-BREAK (CONTROL-C): |
---|
392 | trap 'rm -rf $working_directory/tmp_mrun |
---|
393 | rm -rf $working_directory/tmp_check_namelist_files |
---|
394 | [[ $tmpcreate = true ]] && (cd; rm -rf $TEMPDIR) |
---|
395 | if [[ -f ~/job_queue/JOBINFO.$QSUB_REQID ]] |
---|
396 | then |
---|
397 | rm -rf ~/job_queue/JOBINFO.$QSUB_REQID |
---|
398 | fi |
---|
399 | if [[ "$dvrserver_id" != "" ]] |
---|
400 | then |
---|
401 | echo "+++ killing dvrserver_id=$dvrserver_id" |
---|
402 | kill $dvrserver_id |
---|
403 | fi |
---|
404 | printf "\n+++ MRUN killed by \"^C\" \n\n" |
---|
405 | locat=control_c |
---|
406 | exit |
---|
407 | ' 2 |
---|
408 | |
---|
409 | |
---|
410 | # CHECK IF THE PATH FOR THE PALM BINARIES (SCRIPTS+UTILITY-PROGRAMS) HAS |
---|
411 | # BEEN SET |
---|
412 | if [[ "$PALM_BIN" = "" ]] |
---|
413 | then |
---|
414 | printf "\n +++ environment variable PALM_BIN has not been set" |
---|
415 | printf "\n please set it to the directory where the PALM scripts are located" |
---|
416 | locat=palm_bin; exit |
---|
417 | fi |
---|
418 | export PATH=$PALM_BIN:$PATH |
---|
419 | |
---|
420 | |
---|
421 | |
---|
422 | # READ SHELLSCRIPT-OPTIONS AND REBUILD THE MRUN-COMMAND STRING (MC), |
---|
423 | # WHICH WILL BE USED TO START RESTART-JOBS |
---|
424 | while getopts :a:AbBc:Cd:D:Fg:G:h:H:i:IkK:m:M:n:o:O:p:P:q:r:R:s:St:T:u:U:vw:xX:yY:zZ option |
---|
425 | do |
---|
426 | case $option in |
---|
427 | (a) afname=$OPTARG;; |
---|
428 | (A) store_on_archive_system=true; mc="$mc -A";; |
---|
429 | (b) do_batch=true; mc="$mc -b";; |
---|
430 | (B) delete_temporary_catalog=false; mc="$mc -B";; |
---|
431 | (c) config_file=$OPTARG; mc="$mc -c$OPTARG";; |
---|
432 | (C) restart_run=true; mc="$mc -C";; |
---|
433 | (d) fname=$OPTARG; mc="$mc -d$OPTARG";; |
---|
434 | (D) cpp_opts="$cpp_opts $OPTARG"; mc="$mc -D'$OPTARG'";; |
---|
435 | (F) job_on_file="-D"; mc="$mc -F";; |
---|
436 | (g) group_number=$OPTARG; mc="$mc -g$OPTARG";; |
---|
437 | (G) global_revision=$OPTARG; mc="$mc -G'$OPTARG'";; |
---|
438 | (h) host=$OPTARG; mc="$mc -h$OPTARG";; |
---|
439 | (H) fromhost=$OPTARG; mc="$mc -H$OPTARG";; |
---|
440 | (i) input_list=$OPTARG; mc="$mc -i'$OPTARG'";; |
---|
441 | (I) ignore_archive_error=true; mc="$mc -I";; |
---|
442 | (k) keep_data_from_previous_run=true; mc="$mc -k";; |
---|
443 | (K) additional_conditions="$OPTARG"; mc="$mc -K'$OPTARG'";; |
---|
444 | (m) memory=$OPTARG; mc="$mc -m$OPTARG";; |
---|
445 | (M) makefile=$OPTARG; mc="$mc -M$OPTARG";; |
---|
446 | (n) node_usage=$OPTARG; mc="$mc -n$OPTARG";; |
---|
447 | (o) output_list=$OPTARG; mc="$mc -o'$OPTARG'";; |
---|
448 | (O) use_openmp=true; threads_per_task=$OPTARG; mc="$mc -O$OPTARG";; |
---|
449 | (p) package_list=$OPTARG; mc="$mc -p'$OPTARG'";; |
---|
450 | (P) return_password=$OPTARG; mc="$mc -P$OPTARG";; |
---|
451 | (q) queue=$OPTARG; mc="$mc -q$OPTARG";; |
---|
452 | (r) run_mode=$OPTARG; mc="$mc -r'$OPTARG'";; |
---|
453 | (R) remotecall=true;return_address=$OPTARG; mc="$mc -R$OPTARG";; |
---|
454 | (s) source_list=$OPTARG; mc="$mc -s'$OPTARG'";; |
---|
455 | (S) read_from_config=false; mc="$mc -S";; |
---|
456 | (t) cpumax=$OPTARG; mc="$mc -t$OPTARG";; |
---|
457 | (T) mrun_tasks_per_node=$OPTARG; mc="$mc -T$OPTARG";; |
---|
458 | (u) remote_username=$OPTARG; mc="$mc -u$OPTARG";; |
---|
459 | (U) return_username=$OPTARG; mc="$mc -U$OPTARG";; |
---|
460 | (v) silent=true; mc="$mc -v";; |
---|
461 | (w) max_par_io_str=$OPTARG; mc="$mc -w$OPTARG";; |
---|
462 | (x) do_trace=true;set -x; mc="$mc -x";; |
---|
463 | (X) numprocs=$OPTARG; mc="$mc -X$OPTARG";; |
---|
464 | (y) ocean_file_appendix=true; mc="$mc -y";; |
---|
465 | (Y) run_coupled_model=true; coupled_dist=$OPTARG; mc="$mc -Y'$OPTARG'";; |
---|
466 | (z) check_namelist_files=false; mc="$mc -z";; |
---|
467 | (Z) combine_plot_fields=false; mc="$mc -Z";; |
---|
468 | (\?) printf "\n +++ unknown option $OPTARG \n" |
---|
469 | printf "\n --> type \"$0 ?\" for available options \n" |
---|
470 | locat=parameter;exit;; |
---|
471 | esac |
---|
472 | done |
---|
473 | |
---|
474 | |
---|
475 | # SKIP GIVEN OPTIONS TO READ POSITIONAL PARAMETER, IF GIVEN |
---|
476 | # CURRENTLY ONLY PARAMETER ? (TO OUTPUT A SHORT COMMAND INFO) IS ALLOWED |
---|
477 | (( to_shift = $OPTIND - 1 )) |
---|
478 | shift $to_shift |
---|
479 | |
---|
480 | # PRINT SHORT DESCRIPTION OF MRUN OPTIONS |
---|
481 | if [[ "$1" = "?" ]] |
---|
482 | then |
---|
483 | (printf "\n *** mrun can be called as follows:\n" |
---|
484 | printf "\n $mrun_script_name -b -c.. -d.. -D.. -f.. -F -h.. -i.. -I -K.. -m.. -o.. -p.. -r.. -R -s.. -t.. -T.. -v -x -X.. -y -Y.. -Z <modus> \n" |
---|
485 | printf "\n Description of available options:\n" |
---|
486 | printf "\n Option Description Default-Value" |
---|
487 | printf "\n -a base name of input files equiv. -d" |
---|
488 | printf "\n -A archiving when using file-attribute fl" |
---|
489 | printf "\n -b batch-job on local machine ---" |
---|
490 | printf "\n -B do not delete temporary directory at end ---" |
---|
491 | printf "\n -c configuration file .mrun.config" |
---|
492 | printf "\n -d base name of files attached to program test" |
---|
493 | printf "\n -D preprocessor(cpp)-directives \"\" " |
---|
494 | printf "\n -F create remote job file only ---" |
---|
495 | printf "\n -h execution host $localhost_realname" |
---|
496 | printf "\n -i INPUT control list \"\" " |
---|
497 | printf "\n -I archiving errors of previous batch-jobs" |
---|
498 | printf "\n will be ignored" |
---|
499 | printf "\n -k keep data from previous run" |
---|
500 | printf "\n -K additional conditions for controling" |
---|
501 | printf "\n usage of conditional code and" |
---|
502 | printf "\n env-variables in configuration file \"\" " |
---|
503 | printf "\n -m memory demand in MB (batch-jobs) 0 MB" |
---|
504 | printf "\n -M Makefile name Makefile" |
---|
505 | printf "\n -n node usage (shared/not_shared) depending on -h" |
---|
506 | printf "\n -o OUTPUT control list \"\" " |
---|
507 | printf "\n -O threads per openMP task ---" |
---|
508 | printf "\n -p software package list \"\" " |
---|
509 | printf "\n -q queue \"$queue\" " |
---|
510 | printf "\n -r run control list (combines -i -o) \"\" " |
---|
511 | printf "\n -s filenames of routines to be compiled \"\" " |
---|
512 | printf "\n must end with .f, .f90, .F, or .c !" |
---|
513 | printf "\n use \"..\" for more than one file and wildcards" |
---|
514 | printf "\n -s LM compiles all locally modified files" |
---|
515 | printf "\n -S config file interpreted by shellscript ---" |
---|
516 | printf "\n -t allowed cpu-time in seconds (batch) 0" |
---|
517 | printf "\n -T tasks per node depending on -h" |
---|
518 | printf "\n -u username on remote machine \"\" " |
---|
519 | printf "\n -v no prompt for confirmation ---" |
---|
520 | printf "\n -w maximum parallel io streams as given by -X" |
---|
521 | printf "\n -x tracing of mrun for debug purposes ---" |
---|
522 | printf "\n -X # of processors (on parallel machines) 1" |
---|
523 | printf "\n -y add appendix \"_O\" to all local output" |
---|
524 | printf "\n files (ocean precursor runs followed by" |
---|
525 | printf "\n coupled atmosphere-ocean runs) ---" |
---|
526 | printf "\n -Y run coupled model, \"#1 #2\" with" |
---|
527 | printf "\n #1 atmosphere and #2 ocean processors \"#/2 #/2\" depending on -X" |
---|
528 | printf "\n -Z skip combine_plot_fields at the end of " |
---|
529 | printf "\n the simulation ---" |
---|
530 | printf "\n " |
---|
531 | printf "\n Possible values of positional parameter <modus>:" |
---|
532 | printf "\n \"?\" - this outline \n\n") | more |
---|
533 | exit |
---|
534 | elif [[ "$1" != "" ]] |
---|
535 | then |
---|
536 | printf "\n +++ positional parameter $1 unknown \n" |
---|
537 | locat=parameter; exit |
---|
538 | fi |
---|
539 | |
---|
540 | |
---|
541 | |
---|
542 | # SHORT STARTING MESSAGE |
---|
543 | printf "\n*** $version " |
---|
544 | printf "\n will be executed. Please wait ..." |
---|
545 | |
---|
546 | |
---|
547 | |
---|
548 | # CHECK, IF CONFIGURATION FILE EXISTS |
---|
549 | if [[ ! -f $config_file ]] |
---|
550 | then |
---|
551 | printf "\n\n +++ configuration file: " |
---|
552 | printf "\n $config_file" |
---|
553 | printf "\n does not exist" |
---|
554 | locat=connect; exit |
---|
555 | fi |
---|
556 | |
---|
557 | |
---|
558 | # DETERMINE THE HOST-IDENTIFIER (localhost) FROM THE CONFIGURATION FILE |
---|
559 | line="" |
---|
560 | grep "%host_identifier" $config_file > tmp_mrun |
---|
561 | while read line |
---|
562 | do |
---|
563 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
564 | then |
---|
565 | HOSTNAME=`echo $line | cut -d" " -s -f2` |
---|
566 | host_identifier=`echo $line | cut -d" " -s -f3` |
---|
567 | if [[ $localhost_realname = $HOSTNAME ]] |
---|
568 | then |
---|
569 | localhost=$host_identifier |
---|
570 | break |
---|
571 | fi |
---|
572 | fi |
---|
573 | done < tmp_mrun |
---|
574 | |
---|
575 | if [[ "$localhost" = "" ]] |
---|
576 | then |
---|
577 | printf "\n\n +++ no host identifier found in configuration file \"$config_file\"" |
---|
578 | printf "\n for local host \"$localhost_realname\"." |
---|
579 | printf "\n Please add line" |
---|
580 | printf "\n \"\%host_identifier $localhost_realname <identifier>\"" |
---|
581 | printf "\n to the configuration file." |
---|
582 | locat=localhost; exit |
---|
583 | fi |
---|
584 | |
---|
585 | |
---|
586 | # SET HOST-SPECIFIC VARIABLES |
---|
587 | case $localhost_realname in |
---|
588 | (r1*|r2*|h01*|b01*) archive_system=tivoli;; |
---|
589 | (cs*) archive_system=ut;; |
---|
590 | esac |
---|
591 | |
---|
592 | |
---|
593 | # ??? THIS SHOULD BE DECRIBED IN THE MRUN DOCUMENTATION ??? |
---|
594 | # SET BASENAME OF THE INPUT-FILES TO THE GENERAL BASENAME (GIVEN BY OPTION -d), |
---|
595 | # IF IT HAS NOT BEEN SET BY THE USER DIFFERENTLY (USING OPTION -a) |
---|
596 | [[ "$afname" = "" ]] && afname=$fname |
---|
597 | |
---|
598 | |
---|
599 | # ADD RUN-FILE ACTIVATION STRINGS (GIVEN BY OPTION -r) TO THE |
---|
600 | # RESPECTIVE LISTS FOR ACTIVATING THE INPUT/OUTPUT FILE CONNECTION |
---|
601 | # STATEMENTS IN THE CONFIGURATION FILE |
---|
602 | if [[ "$run_mode" != "" ]] |
---|
603 | then |
---|
604 | input_list="$input_list $run_mode" |
---|
605 | output_list="$output_list $run_mode" |
---|
606 | fi |
---|
607 | |
---|
608 | |
---|
609 | # ??? is this (and the respective option -H) really required ??? |
---|
610 | # STORE HOSTNAME, FROM WHICH THE JOB IS STARTED, |
---|
611 | # BUT ONLY IF IT HASN'T BEEN ALREADY SET BY OPTION -H |
---|
612 | # (MRUN IS AUTOMATICALLY SETTING THIS OPTION IN THE MRUN-CALLS WITHIN |
---|
613 | # THOSE BATCH-JOBS, WHICH ARE CREATED BY MRUN ITSELF) |
---|
614 | if [[ "$fromhost" = "" ]] |
---|
615 | then |
---|
616 | fromhost=$localhost |
---|
617 | fi |
---|
618 | |
---|
619 | |
---|
620 | # CHECK, IF EXECUTION SHALL TO BE DONE ON THE REMOTE-MACHINE. |
---|
621 | # VALUE OF do_remote IS IMPORTANT FOR THE FILE CONNECTIONS. |
---|
622 | # IN CASE OF EXECUTION ON A REMOTE-MACHINE, A BATCH-JOB HAS |
---|
623 | # TO BE SUBMITTED (I.E. do_batch=true) |
---|
624 | if [[ -n $host && "$host" != $localhost ]] |
---|
625 | then |
---|
626 | do_batch=true |
---|
627 | do_remote=true |
---|
628 | case $host in |
---|
629 | (ibm|ibmh|ibmkisti|ibmku|ibms|nech|lcbullhh|lccrayb|lccrayh|lccrayf|lcflow|lckyoto|unics|lcxe6|lcxt5m|lck|lckiaps|lckordi|lckyuh|lckyut|lcsb) true;; |
---|
630 | (*) printf "\n" |
---|
631 | printf "\n +++ sorry: execution of batch jobs on remote host \"$host\"" |
---|
632 | printf "\n is not available" |
---|
633 | locat=nqs; (( iec = 0 )); exit;; |
---|
634 | esac |
---|
635 | else |
---|
636 | host=$localhost |
---|
637 | fi |
---|
638 | |
---|
639 | |
---|
640 | # EVALUATE ADDITIONAL CONDITIONS GIVEN BY OPTION -K |
---|
641 | if [[ -n $additional_conditions ]] |
---|
642 | then |
---|
643 | cond1=`echo $additional_conditions | cut -d" " -f1` |
---|
644 | cond2=`echo $additional_conditions | cut -d" " -s -f2` |
---|
645 | dummy=`echo $additional_conditions | cut -d" " -s -f3` |
---|
646 | if [[ -n $dummy ]] |
---|
647 | then |
---|
648 | printf "\n +++ more than 2 additional conditions given for Option \"-K\"" |
---|
649 | locat=options; exit |
---|
650 | fi |
---|
651 | block=_$cond1 |
---|
652 | [[ -n $cond2 ]] && block=${block}_$cond2 |
---|
653 | fi |
---|
654 | |
---|
655 | |
---|
656 | # EVALUATE MODEL COUPLING FEATURES (OPTION -Y) AND DETERMINE coupled_mode |
---|
657 | if [[ $run_coupled_model = true ]] |
---|
658 | then |
---|
659 | |
---|
660 | numprocs_atmos=`echo $coupled_dist | cut -d" " -s -f1` |
---|
661 | numprocs_ocean=`echo $coupled_dist | cut -d" " -s -f2` |
---|
662 | |
---|
663 | if (( $numprocs_ocean + $numprocs_atmos != $numprocs )) |
---|
664 | then |
---|
665 | |
---|
666 | printf "\n +++ number of processors does not fit to specification by \"-Y\"." |
---|
667 | printf "\n PEs (total) : $numprocs" |
---|
668 | printf "\n PEs (atmosphere): $numprocs_atmos" |
---|
669 | printf "\n PEs (ocean) : $numprocs_ocean" |
---|
670 | locat=coupling; exit |
---|
671 | |
---|
672 | fi |
---|
673 | |
---|
674 | |
---|
675 | # GET coupled_mode FROM THE CONFIG FILE |
---|
676 | line="" |
---|
677 | grep "%cpp_options.*-D__mpi2.*$host" $config_file > tmp_mrun |
---|
678 | while read line |
---|
679 | do |
---|
680 | echo line=\"$line\" |
---|
681 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" && $(echo $line | cut -d" " -s -f4) = $cond1 && $(echo $line | cut -d" " -s -f5) = $cond2 ]] |
---|
682 | then |
---|
683 | coupled_mode="mpi2" |
---|
684 | fi |
---|
685 | done < tmp_mrun |
---|
686 | |
---|
687 | fi |
---|
688 | |
---|
689 | # CHECK, IF FILE-ARCHIVING HAS FAILED IN PREVIOUS JOB (OF A JOB-CHAIN) |
---|
690 | if [[ -f ~/job_queue/ARCHIVE_ERROR_$fname ]] |
---|
691 | then |
---|
692 | if [[ $ignore_archive_error = false ]] |
---|
693 | then |
---|
694 | printf "\n +++ data archiving of previous run failed" |
---|
695 | printf "\n see directory \~/job_queue on remote machine" |
---|
696 | locat=archive; exit |
---|
697 | else |
---|
698 | printf "\n +++ warning: data archiving in a previous run failed" |
---|
699 | printf "\n MRUN continues, trying to get backup copy" |
---|
700 | fi |
---|
701 | fi |
---|
702 | |
---|
703 | |
---|
704 | # SAVE VALUES OF MRUN-OPTIONS SICHERN IN ORDER TO OVERWRITE |
---|
705 | # THOSE VALUES GIVEN IN THE CONFIGURATION-FILE |
---|
706 | mrun_memory=$memory |
---|
707 | mrun_group_number=$group_number |
---|
708 | mrun_cpumax=$cpumax |
---|
709 | mrun_numprocs=$numprocs |
---|
710 | |
---|
711 | |
---|
712 | # READ AND EVALUATE THE CONFIGURATION-FILE FROM WITHIN THIS SHELLSCRIPT |
---|
713 | # (OPTION -S). THE DEFAULT IS USING THE ROUTINE <<<< |
---|
714 | if [[ "$read_from_config" = false ]] |
---|
715 | then |
---|
716 | [[ $silent = false ]] && printf "\n Reading the configuration file... " |
---|
717 | |
---|
718 | # READ THE CONFIGURATION FILE LINE BY LINE |
---|
719 | while read zeile |
---|
720 | do |
---|
721 | [[ $silent = false ]] && printf "." |
---|
722 | |
---|
723 | |
---|
724 | # FIRST REPLACE ENVIRONMENT-VARIABLES BY THEIR RESPECTIVE VALUES |
---|
725 | eval zeile=\"$zeile\" |
---|
726 | |
---|
727 | |
---|
728 | # INTERPRET THE LINE |
---|
729 | if [[ "$(echo $zeile)" = "" ]] |
---|
730 | then |
---|
731 | # EMPTY LINE, NO ACTION |
---|
732 | continue |
---|
733 | |
---|
734 | elif [[ "$(echo $zeile | cut -c1)" = "#" ]] |
---|
735 | then |
---|
736 | |
---|
737 | # LINE IS A COMMENT LINE |
---|
738 | true |
---|
739 | |
---|
740 | elif [[ "$(echo $zeile | cut -c1)" = "%" ]] |
---|
741 | then |
---|
742 | |
---|
743 | # LINE DEFINES AN ENVIRONMENT-VARIABLE |
---|
744 | zeile=$(echo $zeile | cut -c2-) |
---|
745 | var=`echo $zeile | cut -d" " -f1` |
---|
746 | value=`echo $zeile | cut -d" " -s -f2` |
---|
747 | for_host=`echo $zeile | cut -d" " -s -f3` |
---|
748 | for_cond1=`echo $zeile | cut -d" " -s -f4` |
---|
749 | for_cond2=`echo $zeile | cut -d" " -s -f5` |
---|
750 | |
---|
751 | if [[ "$for_host" = "" || ( "$for_host" = $host && "$for_cond1" = "$cond1" && "$for_cond2" = "$cond2" ) || $(echo "$input_list$output_list"|grep -c "$for_host") != 0 ]] |
---|
752 | then |
---|
753 | |
---|
754 | # REPLACE ":" BY " " IN COMPILER- CPP- OR LINKER-OPTIONS, |
---|
755 | # "::" IS REPLACED BY ":". |
---|
756 | value=`echo $value | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` |
---|
757 | |
---|
758 | |
---|
759 | # VALUE FROM THE CONFIGURATION-FILE IS ASSIGNED TO THE |
---|
760 | # ENVIRONMENT-VARIABLE, BUT ONLY IF NO VALUE HAS BEEN ALREADY |
---|
761 | # ASSIGNED WITHIN THIS SCRIPT (E.G. BY SCRIPT-OPTIONS). |
---|
762 | # NON-ASSIGNED VARIABLES HAVE VALUE "" OR 0 (IN CASE OF INTEGER). |
---|
763 | # HENCE THE GENERAL RULE IS: SCRIPT-OPTION OVERWRITES THE |
---|
764 | # CONFIGURATION-FILE. |
---|
765 | if [[ "$(eval echo \$$var)" = "" || "$(eval echo \$$var)" = "0" ]] |
---|
766 | then |
---|
767 | eval $var=\$value |
---|
768 | |
---|
769 | # TERMINAL OUTPUT OF ENVIRONMENT-VARIABLES, IF TRACEBACK IS SWITCHED on |
---|
770 | if [[ $do_trace = true ]] |
---|
771 | then |
---|
772 | printf "\n*** ENVIRONMENT-VARIABLE $var = $value" |
---|
773 | fi |
---|
774 | fi |
---|
775 | |
---|
776 | # IF AN ENVIRONMENT-VARIABLE DETERMINES THE HOST, THEN EVALUATE IT IMMEDIATELY: |
---|
777 | # VALUE OF do-remote IS REQUIRED FOR THE FILE CONNECTIONS (COPY OF I/O FILES). |
---|
778 | # IF EXECUTION IS SCHEDULED FOR A REMOTE-MASCHINE, A BATCH-JOB |
---|
779 | # MUST HAVE TO BE STARTED |
---|
780 | if [[ $var = host ]] |
---|
781 | then |
---|
782 | if [[ -n $host && "$host" != $localhost ]] |
---|
783 | then |
---|
784 | do_batch=true |
---|
785 | do_remote=true |
---|
786 | case $host in |
---|
787 | (ibm|ibmh|ibmkisti|ibmku|ibms|lcbullhh|lccrayb|lccrayh|lccrayf|lcflow|lckyoto|nech|unics|lcxe6|lcxt5m|lck|lckiaps|lckordi|lckyuh|lckyut|lcsb) true;; |
---|
788 | (*) printf "\n +++ sorry: execution of batch jobs on remote host \"$host\"" |
---|
789 | printf "\n is not available" |
---|
790 | locat=nqs; exit;; |
---|
791 | esac |
---|
792 | else |
---|
793 | host=$localhost |
---|
794 | fi |
---|
795 | fi |
---|
796 | |
---|
797 | # USER-DEFINED ENVIRONMENT VARIABLES MUST BE EXPORTED, |
---|
798 | # BECAUSE THEY MAY BE REQUIRED IN OTHER SCRIPTS CALLED |
---|
799 | # BY MRUN (E.G. subjob) |
---|
800 | export $var |
---|
801 | fi |
---|
802 | |
---|
803 | |
---|
804 | |
---|
805 | |
---|
806 | elif [[ "$(echo $zeile | cut -c1-3)" = "EC:" ]] |
---|
807 | then |
---|
808 | |
---|
809 | # LINE DEFINES ERROR-COMMAND |
---|
810 | (( iec = iec + 1 )) |
---|
811 | zeile=$(echo $zeile | cut -c4-) |
---|
812 | err_command[$iec]="$zeile" |
---|
813 | |
---|
814 | elif [[ "$(echo $zeile | cut -c1-3)" = "IC:" ]] |
---|
815 | then |
---|
816 | |
---|
817 | # LINE DEFINES INPUT-COMMAND |
---|
818 | (( iic = iic + 1 )) |
---|
819 | zeile=$(echo $zeile | cut -c4-) |
---|
820 | in_command[$iic]="$zeile" |
---|
821 | |
---|
822 | elif [[ "$(echo $zeile | cut -c1-3)" = "OC:" ]] |
---|
823 | then |
---|
824 | |
---|
825 | # LINE DEFINES OUTPUT-COMMAND |
---|
826 | (( ioc = ioc + 1 )) |
---|
827 | zeile=$(echo $zeile | cut -c4-) |
---|
828 | out_command[$ioc]="$zeile" |
---|
829 | |
---|
830 | else |
---|
831 | |
---|
832 | # LINE DEFINES FILE CONNECTION. READ THE FILE ATTRIBUTES. |
---|
833 | # s2a: in/out - field |
---|
834 | # s2b: loc - field (optional) |
---|
835 | # s2c: tr/ar - field (optional) |
---|
836 | s1=`echo $zeile | cut -d" " -f1` |
---|
837 | s2=`echo $zeile | cut -d" " -s -f2` |
---|
838 | s2a=$(echo $s2 | cut -d":" -f1) |
---|
839 | if [[ $(echo $s2 | grep -c ":") = 0 ]] |
---|
840 | then |
---|
841 | s2b="" |
---|
842 | s2c="" |
---|
843 | else |
---|
844 | s2b=`echo $s2 | cut -d":" -f2 | sed 's/:/ /g'` |
---|
845 | s2c=`echo $s2 | cut -d":" -s -f3 | sed 's/:/ /g'` |
---|
846 | fi |
---|
847 | s3=`echo $zeile | cut -d" " -f3` |
---|
848 | s4=`echo $zeile | cut -d" " -s -f4` |
---|
849 | s5=`echo $zeile | cut -d" " -s -f5` |
---|
850 | s6=`echo $zeile | cut -d" " -s -f6` |
---|
851 | |
---|
852 | |
---|
853 | # STORE FILE CONNECTION, IF ACTIVATED BY ACTIVATION-STRING FROM |
---|
854 | # INPUT- OR OUTPUT-LIST. |
---|
855 | # VARIABLE S3 MAY CONTAIN A LIST OF ACTIVATION STRINGS (FIELD-SEPERATOR ":"). |
---|
856 | # IF EXECUTION IS SCHEDULED FOR A REMOTE-MACHINE AND THE FILE IS ONLY |
---|
857 | # LOCALLY REQUIRED ON THAT MACHINE (I.E. s2b = loc), THE FILE CONNECTION |
---|
858 | # IS NOT CHECKED AND STORED. |
---|
859 | IFSALT="$IFS"; IFS="$IFS:" |
---|
860 | if [[ "$s2a" = in && ! ( $do_remote = true && ( "$s2b" = loc || "$s2b" = locopt ) ) ]] |
---|
861 | then |
---|
862 | found=false |
---|
863 | for actual in $input_list |
---|
864 | do |
---|
865 | for formal in $s3 |
---|
866 | do |
---|
867 | [[ $actual = $formal || "$formal" = "-" ]] && found=true |
---|
868 | done |
---|
869 | done |
---|
870 | if [[ $found = true ]] |
---|
871 | then |
---|
872 | (( iin = iin + 1 )) |
---|
873 | localin[$iin]=$s1; transin[$iin]=$s2b; actionin[$iin]=$s2c; |
---|
874 | typein[$iin]=$s3; pathin[$iin]=$s4; endin[$iin]=$s5; |
---|
875 | extin[$iin]=$s6 |
---|
876 | fi |
---|
877 | elif [[ "$s2a" = out && ! ( $do_remote = true && "$s2b" = loc ) ]] |
---|
878 | then |
---|
879 | found=false |
---|
880 | for actual in $output_list |
---|
881 | do |
---|
882 | for formal in $s3 |
---|
883 | do |
---|
884 | [[ $actual = $formal || "$formal" = "-" ]] && found=true |
---|
885 | done |
---|
886 | done |
---|
887 | if [[ $found = true ]] |
---|
888 | then |
---|
889 | (( iout = iout + 1 )) |
---|
890 | localout[$iout]=$s1; actionout[$iout]=$s2c; typeout[$iout]=$s3; |
---|
891 | pathout[$iout]=$s4; endout[$iout]=$s5; extout[$iout]=$s6 |
---|
892 | fi |
---|
893 | elif [[ "$s2a" != in && "$s2a" != out ]] |
---|
894 | then |
---|
895 | printf "\n +++ I/O-attribute in configuration file $config_file has the invalid" |
---|
896 | printf "\n value \"$s2\". Only \"in\" and \"out\" are allowed!" |
---|
897 | locat=connect; exit |
---|
898 | fi |
---|
899 | IFS="$IFSALT" |
---|
900 | fi |
---|
901 | done < $config_file |
---|
902 | |
---|
903 | else |
---|
904 | |
---|
905 | # EVALUATE THE CONFIGURATION-FILE BY FORTRAN-PROGRAM |
---|
906 | [[ $silent = false ]] && printf "..." |
---|
907 | interpreted_config_file=.icf.$RANDOM |
---|
908 | |
---|
909 | |
---|
910 | |
---|
911 | # PROVIDE VALUES OF ENVIRONMENT-VARIABLE FOR interpret_config VIA NAMELIST-FILE |
---|
912 | cat > .mrun_environment << %%END%% |
---|
913 | &mrun_environment cond1 = '$cond1', cond2 = '$cond2', |
---|
914 | config_file = '$config_file', do_remote = '$do_remote', |
---|
915 | do_trace = '$do_trace', host = '$host', |
---|
916 | input_list = '$input_list', icf = '$interpreted_config_file', |
---|
917 | localhost = '$localhost', output_list = '$output_list' / |
---|
918 | |
---|
919 | %%END%% |
---|
920 | |
---|
921 | if [[ "$host" != $localhost ]] |
---|
922 | then |
---|
923 | |
---|
924 | # REMOTE JOB FROM LOCAL HOST: JUST TAKE THE FIRST EXECUTABLE FOUND |
---|
925 | interpret_config_executable=`ls -1 ${PALM_BIN}/interpret_config*.x 2>/dev/null` |
---|
926 | if [[ $? != 0 ]] |
---|
927 | then |
---|
928 | printf "\n\n +++ no interpret_config found" |
---|
929 | printf "\n run \"mbuild -u -h ...\" to generate utilities for this host" |
---|
930 | locat=interpret_config; exit |
---|
931 | fi |
---|
932 | interpret_config_executable=`echo $interpret_config_executable | cut -d" " -f1` |
---|
933 | $interpret_config_executable |
---|
934 | |
---|
935 | else |
---|
936 | |
---|
937 | # CHECK, IF THERE IS AN EXECUTABLE FOR THE BLOCK |
---|
938 | if [[ ! -f ${PALM_BIN}/interpret_config${block}.x ]] |
---|
939 | then |
---|
940 | printf "\n\n +++ no interpret_config found for given block \"$cond1 $cond2\"" |
---|
941 | printf "\n run \"mbuild -u -h ...\" to generate utilities for this block" |
---|
942 | locat=interpret_config; exit |
---|
943 | else |
---|
944 | interpret_config${block}.x |
---|
945 | fi |
---|
946 | |
---|
947 | fi |
---|
948 | rm .mrun_environment |
---|
949 | |
---|
950 | |
---|
951 | # EXECUTE SHELL-COMMANDS GENERATED BY interpret_config WITHIN THIS SHELL |
---|
952 | chmod u+x $interpreted_config_file |
---|
953 | export PATH=$PATH:. |
---|
954 | . $interpreted_config_file |
---|
955 | rm $interpreted_config_file |
---|
956 | |
---|
957 | fi |
---|
958 | |
---|
959 | |
---|
960 | # VALUES OF MRUN-OPTIONS OVERWRITE THOSE FROM THE CONFIGURATION-FILE |
---|
961 | [[ $mrun_memory != 0 ]] && memory=$mrun_memory |
---|
962 | [[ "$mrun_group_number" != "none" ]] && group_number=$mrun_group_number |
---|
963 | [[ $mrun_cpumax != 0 ]] && cpumax=$mrun_cpumax |
---|
964 | [[ "$mrun_numprocs" != "" ]] && numprocs=$mrun_numprocs |
---|
965 | [[ "$max_par_io_str" != "" ]] && maximum_parallel_io_streams=$max_par_io_str |
---|
966 | [[ "$mrun_tasks_per_node" != "" ]] && tasks_per_node=$mrun_tasks_per_node |
---|
967 | |
---|
968 | |
---|
969 | # ON THE LOCAL MACHINE, DETERMINE (FROM THE CONFIGURATION-FILE) THE PATH |
---|
970 | # FOR SOURCE-FILES TO BE COMPILED. |
---|
971 | # IN A BATCH-JOB, SOURCES (ROUTINES TO BE COMPILED) ARE COMPLETE ALREADY. |
---|
972 | # BEFORE MRUN IS CALLED IN THE JOB, SOURCES_COMPLETE = true IS ASSIGNED (SEE FURTHER BELOW). |
---|
973 | if [[ "$SOURCES_COMPLETE" = "" ]] |
---|
974 | then |
---|
975 | |
---|
976 | # FIRST CHECK, IF A GLOBAL SOURCE PATH (TO BE USED FOR ALL HOSTS) |
---|
977 | # HAS BEEN DEFINED |
---|
978 | source_path="" |
---|
979 | line="" |
---|
980 | grep "%source_path" $config_file > tmp_mrun |
---|
981 | while read line |
---|
982 | do |
---|
983 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
984 | then |
---|
985 | if [[ "$(echo $line | cut -d" " -f3)" = "" ]] |
---|
986 | then |
---|
987 | global_source_path=`echo $line | cut -d" " -f2` |
---|
988 | fi |
---|
989 | fi |
---|
990 | done < tmp_mrun |
---|
991 | |
---|
992 | line="" |
---|
993 | found=false |
---|
994 | grep " $localhost" $config_file | grep "%source_path" > tmp_mrun |
---|
995 | while read line |
---|
996 | do |
---|
997 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
998 | then |
---|
999 | if [[ $found = true ]] |
---|
1000 | then |
---|
1001 | printf "\n\n +++ more than one source path found in configuration file" |
---|
1002 | printf "\n for local host \"$localhost\" " |
---|
1003 | locat=source_path; exit |
---|
1004 | fi |
---|
1005 | source_path=`echo $line | cut -d" " -f2` |
---|
1006 | found=true |
---|
1007 | fi |
---|
1008 | done < tmp_mrun |
---|
1009 | rm tmp_mrun |
---|
1010 | |
---|
1011 | if [[ "$source_path" = "" ]] |
---|
1012 | then |
---|
1013 | if [[ "$global_source_path" != "" ]] |
---|
1014 | then |
---|
1015 | source_path=$global_source_path |
---|
1016 | else |
---|
1017 | printf "\n\n +++ no source path found in configuration file" |
---|
1018 | printf "\n for local host \"$localhost\" " |
---|
1019 | locat=source_path; exit |
---|
1020 | fi |
---|
1021 | fi |
---|
1022 | eval source_path=$source_path |
---|
1023 | |
---|
1024 | if [[ ! -d $source_path ]] |
---|
1025 | then |
---|
1026 | printf "\n\n +++ source path \"$source_path\" on local host" |
---|
1027 | printf "\n \"$localhost\" does not exist" |
---|
1028 | locat=source_path; exit |
---|
1029 | fi |
---|
1030 | |
---|
1031 | fi |
---|
1032 | |
---|
1033 | |
---|
1034 | # GET THE GLOBAL REVISION-NUMBER OF THE SVN-REPOSITORY |
---|
1035 | # (HANDED OVER TO RESTART-RUNS USING OPTION -G) |
---|
1036 | if [[ "$global_revision" = "" && $host != "ibmkisti" ]] |
---|
1037 | then |
---|
1038 | global_revision=`svnversion $source_path 2>/dev/null` |
---|
1039 | global_revision="Rev: $global_revision" |
---|
1040 | fi |
---|
1041 | |
---|
1042 | |
---|
1043 | # ??? das darf doch eigentlich garnicht passieren, weil optionen config-datei uebersteuern ??? |
---|
1044 | # CHECK AGAIN, IF EXECUTION SHALL BE DONE ON A REMOTE-HOST (BATCH-JOB). |
---|
1045 | # (HOST MAY HAVE CHANGED DUE TO SETTINGS IN THE CONFIGURATION-FILE) |
---|
1046 | if [[ -n $host && "$host" != $localhost ]] |
---|
1047 | then |
---|
1048 | do_batch=true |
---|
1049 | do_remote=true |
---|
1050 | case $host in |
---|
1051 | (ibm|ibmh|ibmkisti|ibmku|ibms|lcbullhh|lccrayb|lccrayh|lccrayf|lcflow|lckyoto|nech|unics|lcxe6|lcxt5m|lck|lckiaps|lckordi|lckyuh|lckyut|lcsb) true;; |
---|
1052 | (*) printf "\n" |
---|
1053 | printf "\n +++ sorry: execution of batch jobs on remote host \"$host\"" |
---|
1054 | printf "\n is not available" |
---|
1055 | locat=nqs; (( iec = 0 )); exit;; |
---|
1056 | esac |
---|
1057 | else |
---|
1058 | host=$localhost |
---|
1059 | fi |
---|
1060 | |
---|
1061 | |
---|
1062 | |
---|
1063 | # IN CASE OF PARALLEL EXECUTION, CHECK SOME SPECIFICATIONS CONCERNING PROCESSOR NUMBERS |
---|
1064 | if [[ "$cond1" = parallel || "$cond2" = parallel ]] |
---|
1065 | then |
---|
1066 | |
---|
1067 | # CHECK, IF NUMBER OF CORES TO BE USED HAS BEEN GIVEN |
---|
1068 | if [[ ! -n $numprocs ]] |
---|
1069 | then |
---|
1070 | printf "\n" |
---|
1071 | printf "\n +++ option \"-K parallel\" requires additional specification" |
---|
1072 | printf "\n of the number of processors to be used by" |
---|
1073 | printf "\n mrun-option \"-X\" or by environment-variable" |
---|
1074 | printf "\n \"numprocs\" in the configuration file" |
---|
1075 | locat=numprocs; (( iec = 0 )); exit |
---|
1076 | fi |
---|
1077 | |
---|
1078 | # CHECK, IF THE NUMBER OF CORES PER NODE HAS BEEN GIVEN UND IF IT IS AN |
---|
1079 | # INTEGRAL DIVISOR OF THE TOTAL NUMBER OF CORES GIVEN BY OPTION -X |
---|
1080 | if [[ "$tasks_per_node" = "" && $host != lcflow && $host != lcxt5m ]] |
---|
1081 | then |
---|
1082 | printf "\n" |
---|
1083 | printf "\n +++ option \"-T\" (tasks per node) is missing" |
---|
1084 | printf "\n set -T option or define tasks_per_node in the config file" |
---|
1085 | locat=tasks_per_node; (( iec = 0 )); exit |
---|
1086 | fi |
---|
1087 | |
---|
1088 | if (( numprocs < tasks_per_node )) |
---|
1089 | then |
---|
1090 | printf "\n" |
---|
1091 | printf "\n +++ tasks per node (-T) cannot exceed total number of processors (-X)" |
---|
1092 | printf "\n given values: -T $tasks_per_node -X $numprocs" |
---|
1093 | locat=tasks_per_node; (( iec = 0 )); exit |
---|
1094 | fi |
---|
1095 | |
---|
1096 | if [[ $host != lcflow && $host != lcxt5m ]] |
---|
1097 | then |
---|
1098 | (( nodes = numprocs / ( tasks_per_node * threads_per_task ) )) |
---|
1099 | (( ival = $tasks_per_node )) |
---|
1100 | (( pes = numprocs )) |
---|
1101 | (( ii = pes / ival )) |
---|
1102 | (( remaining_pes = pes - ii * ival )) |
---|
1103 | if (( remaining_pes > 0 )) |
---|
1104 | then |
---|
1105 | printf "\n" |
---|
1106 | printf "\n +++ WARNING: tasks per node (option \"-T\") is not an integral" |
---|
1107 | printf "\n divisor of the total number of processors (option \"-X\")" |
---|
1108 | printf "\n values of this mrun-call: \"-T $tasks_per_node\" \"-X $numprocs\"" |
---|
1109 | printf "\n One of the nodes is filled with $remaining_pes instead of $tasks_per_node tasks" |
---|
1110 | (( nodes = nodes + 1 )) |
---|
1111 | fi |
---|
1112 | fi |
---|
1113 | |
---|
1114 | |
---|
1115 | # SETTINGS FOR SUBJOB-COMMAND |
---|
1116 | OOPT="-O $threads_per_task" |
---|
1117 | |
---|
1118 | # SET THE TOTAL NUMBER OF NODES, REQUIRED FOR THE SUBJOB-COMMAND (SEE FURTHER BELOW) |
---|
1119 | if [[ "$tasks_per_node" != "" ]] |
---|
1120 | then |
---|
1121 | TOPT="-T $tasks_per_node" |
---|
1122 | fi |
---|
1123 | |
---|
1124 | # CHECK node_usage FOR ALLOWED VALUES AND SET DEFAULT VALUE, IF NECESSARY |
---|
1125 | if [[ $node_usage = default ]] |
---|
1126 | then |
---|
1127 | if [[ $host = ibms ]] |
---|
1128 | then |
---|
1129 | node_usage=shared |
---|
1130 | else |
---|
1131 | node_usage=not_shared |
---|
1132 | fi |
---|
1133 | fi |
---|
1134 | |
---|
1135 | if [[ $node_usage != shared && $node_usage != not_shared && $node_usage != singlejob && "$(echo $node_usage | cut -c1-3)" != "sla" ]] |
---|
1136 | then |
---|
1137 | printf "\n" |
---|
1138 | printf "\n +++ node usage (option \"-n\") is only allowed to be set" |
---|
1139 | printf "\n \"shared\" or \"not_shared\"" |
---|
1140 | locat=tasks_per_node; (( iec = 0 )); exit |
---|
1141 | fi |
---|
1142 | |
---|
1143 | fi |
---|
1144 | |
---|
1145 | # CHECK IF HOSTFILE EXISTS |
---|
1146 | if [[ -n $hostfile ]] |
---|
1147 | then |
---|
1148 | if [[ ! -f $hostfile ]] |
---|
1149 | then |
---|
1150 | printf "\n" |
---|
1151 | printf "\n +++ hostfile \"$hostfile\" does not exist" |
---|
1152 | locat=hostfile; exit |
---|
1153 | fi |
---|
1154 | fi |
---|
1155 | |
---|
1156 | |
---|
1157 | # SET DEFAULT VALUE FOR THE MAXIMUM NUMBER OF PARALLEL IO STREAMS |
---|
1158 | if [[ "$maximum_parallel_io_streams" = "" ]] |
---|
1159 | then |
---|
1160 | maximum_parallel_io_streams=$numprocs |
---|
1161 | fi |
---|
1162 | |
---|
1163 | |
---|
1164 | # SET PORT NUMBER OPTION FOR CALLS OF SSH/SCP, subjob AND batch_scp SCRIPTS |
---|
1165 | if [[ "$scp_port" != "" ]] |
---|
1166 | then |
---|
1167 | PORTOPT="-P $scp_port" |
---|
1168 | SSH_PORTOPT="-p $scp_port" |
---|
1169 | fi |
---|
1170 | |
---|
1171 | |
---|
1172 | # SET DEFAULT-QUEUE, IF NOT GIVEN |
---|
1173 | if [[ $queue = none ]] |
---|
1174 | then |
---|
1175 | case $host in |
---|
1176 | (ibmh) queue=cluster;; |
---|
1177 | (ibmkisti) queue=class.32plus;; |
---|
1178 | (lcbullhh) queue=compute;; |
---|
1179 | (lccrayb) queue=mpp1q;; |
---|
1180 | (lccrayh) queue=mpp1q;; |
---|
1181 | (lckiaps) queue=normal;; |
---|
1182 | (lckyoto) queue=ph;; |
---|
1183 | (lckyuh) queue=fx-single;; |
---|
1184 | (lckyut) queue=cx-single;; |
---|
1185 | (lctit) queue=S;; |
---|
1186 | (nech) queue=none;; |
---|
1187 | (unics) queue=unics;; |
---|
1188 | esac |
---|
1189 | fi |
---|
1190 | |
---|
1191 | |
---|
1192 | # GENERATE FULL FILENAMES OF INPUT-FILES, INCLUDING THEIR PATH |
---|
1193 | # CHECK, IF INPUT-FILES EXIST, AND DETERMINE HIGHEST CYCLE NUMBER (IF CYCLES EXIST) |
---|
1194 | (( i = 0 )) |
---|
1195 | while (( i < iin )) |
---|
1196 | do |
---|
1197 | (( i = i + 1 )) |
---|
1198 | (( maxcycle = 0 )) |
---|
1199 | |
---|
1200 | # GENERATE PATH AND FULL FILE NAME (then-BRANCH: FIXED FULL NAME IS GIVEN, I.E. THE |
---|
1201 | # FILE IDENTIFIER IS NOT PART OF THE FILENAME)) |
---|
1202 | if [[ "${actionin[$i]}" = di ]] |
---|
1203 | then |
---|
1204 | remotepathin[$i]=${pathin[$i]}/${endin[$i]} # EVALUATE REMOTE-PATH ON THE REMOTE |
---|
1205 | # HOST ONLY |
---|
1206 | eval filename=${pathin[$i]}/${endin[$i]} |
---|
1207 | else |
---|
1208 | remotepathin[$i]=${pathin[$i]}/${afname}${endin[$i]} # EVALUATE REMOTE-PATH ON THE REMOTE |
---|
1209 | # HOST ONLY |
---|
1210 | eval filename=${pathin[$i]}/${afname}${endin[$i]} |
---|
1211 | fi |
---|
1212 | eval pathname=${pathin[$i]} |
---|
1213 | |
---|
1214 | # CHECK IF FILE EXISTS |
---|
1215 | if [[ $(ls $filename* 2>&1 | grep -c "not found") = 1 || \ |
---|
1216 | $(ls $filename* 2>&1 | grep -c "nicht gefunden") = 1 || \ |
---|
1217 | $(ls $filename* 2>&1 | grep -c "No such file") = 1 || \ |
---|
1218 | $(ls $filename* 2>&1 | grep -c "does not exist") = 1 ]] |
---|
1219 | then |
---|
1220 | |
---|
1221 | # FILES WITH ATTRIBUTE locopt ARE OPTIONAL. NO ABORT, IF THEY DO NOT EXIST. |
---|
1222 | if [[ "${transin[$i]}" != "locopt" ]] |
---|
1223 | then |
---|
1224 | printf "\n\n +++ INPUT-file: " |
---|
1225 | if [[ "${extin[$i]}" = "" ]] |
---|
1226 | then |
---|
1227 | printf "\n $filename" |
---|
1228 | else |
---|
1229 | printf "\n $filename.${extin[$i]}" |
---|
1230 | fi |
---|
1231 | printf "\n does not exist\n" |
---|
1232 | locat=input; exit |
---|
1233 | else |
---|
1234 | transin[$i]="unavailable" |
---|
1235 | fi |
---|
1236 | else |
---|
1237 | |
---|
1238 | # DETERMINE THE FILE'S CYCLE NUMBER |
---|
1239 | ls -1 -d $filename > filelist 2>/dev/null |
---|
1240 | ls -1 -d $filename.* >> filelist 2>/dev/null |
---|
1241 | while read zeile |
---|
1242 | do |
---|
1243 | cycle=$(echo $zeile | cut -f2 -d".") |
---|
1244 | if [[ "$cycle" = "$zeile" ]] |
---|
1245 | then |
---|
1246 | (( icycle = 0 )) |
---|
1247 | elif [[ "$cycle" = "${extin[$i]}" ]] |
---|
1248 | then |
---|
1249 | (( icycle = 0 )) |
---|
1250 | else |
---|
1251 | (( icycle = $cycle )) |
---|
1252 | fi |
---|
1253 | if (( icycle > maxcycle )) |
---|
1254 | then |
---|
1255 | (( maxcycle = icycle )) |
---|
1256 | file_to_be_used=$zeile |
---|
1257 | fi |
---|
1258 | done <filelist |
---|
1259 | rm filelist |
---|
1260 | |
---|
1261 | # APPEND CYCLE NUMBER TO FILENAME |
---|
1262 | if (( maxcycle > 0 )) |
---|
1263 | then |
---|
1264 | if [[ "${extin[$i]}" != " " && "${extin[$i]}" != "" ]] |
---|
1265 | then |
---|
1266 | filename=${filename}.$maxcycle.${extin[$i]} |
---|
1267 | else |
---|
1268 | filename=${filename}.$maxcycle |
---|
1269 | fi |
---|
1270 | else |
---|
1271 | if [[ "${extin[$i]}" != " " && "${extin[$i]}" != "" ]] |
---|
1272 | then |
---|
1273 | filename=${filename}.${extin[$i]} |
---|
1274 | fi |
---|
1275 | fi |
---|
1276 | |
---|
1277 | # STORE FILENAME WITHOUT PATH BUT WITH CYCLE NUMBER, |
---|
1278 | # BECAUSE IT MIGHT BE REQUIRED LATER TO RESTORE THE FILE FROM AN ARCHIVE-SYSTEM |
---|
1279 | absnamein[$i]=$filename |
---|
1280 | if (( maxcycle > 0 )) |
---|
1281 | then |
---|
1282 | if [[ "${actionin[$i]}" = di ]] |
---|
1283 | then |
---|
1284 | frelin[$i]=${endin[$i]}.$maxcycle |
---|
1285 | else |
---|
1286 | frelin[$i]=${afname}${endin[$i]}.$maxcycle |
---|
1287 | fi |
---|
1288 | else |
---|
1289 | if [[ "${actionin[$i]}" = di ]] |
---|
1290 | then |
---|
1291 | frelin[$i]=${endin[$i]} |
---|
1292 | else |
---|
1293 | frelin[$i]=${afname}${endin[$i]} |
---|
1294 | fi |
---|
1295 | fi |
---|
1296 | |
---|
1297 | fi |
---|
1298 | done |
---|
1299 | |
---|
1300 | # GENERATE FULL FILENAMES OF OUTPUT-FILES (WITHOUT $ OR ~), |
---|
1301 | # CHECK, IF OUTPUT-FILES EXIST, AND DETERMINE HIGHEST CYCLE NUMBER (IF CYCLES EXIST), |
---|
1302 | # OR, IN CASE THAT FILE DOES NOT EXIST, CHECK, IF IT CAN BE CREATED |
---|
1303 | # THESE ACTIONS ARE NOT CARRIED OUT, IF FILES SHALL BE TRASFERRED FROM THE REMOTE TO |
---|
1304 | # THE LOCAL HOST (BECAUSE THEIR IS NO DIRECT ACCESS TO THE LOCAL DIRECTORIES FROM THE |
---|
1305 | # REMOTE HOST) |
---|
1306 | (( i = 0 )) |
---|
1307 | while (( i < iout )) |
---|
1308 | do |
---|
1309 | (( i = i + 1 )) |
---|
1310 | if [[ ! ( $fromhost != $localhost && ( "${actionout[$i]}" = tr || "${actionout[$i]}" = tra || "${actionout[$i]}" = trpe ) ) ]] |
---|
1311 | then |
---|
1312 | if [[ "${actionout[$i]}" = tr ]] |
---|
1313 | then |
---|
1314 | actionout[$i]="" |
---|
1315 | elif [[ "${actionout[$i]}" = trpe ]] |
---|
1316 | then |
---|
1317 | actionout[$i]=pe |
---|
1318 | elif [[ "${actionout[$i]}" = tra ]] |
---|
1319 | then |
---|
1320 | actionout[$i]=a |
---|
1321 | fi |
---|
1322 | (( maxcycle = 0 )) |
---|
1323 | eval filename=${pathout[$i]}/${fname}${endout[$i]} |
---|
1324 | eval catalogname=${pathout[$i]} |
---|
1325 | if [[ $(ls $filename* 2>&1 | grep -c "not found") = 1 || \ |
---|
1326 | $(ls $filename* 2>&1 | grep -c "nicht gefunden") = 1 || \ |
---|
1327 | $(ls $filename* 2>&1 | grep -c "No such file") = 1 || \ |
---|
1328 | $(ls $filename* 2>&1 | grep -c "does not exist") = 1 ]] |
---|
1329 | then |
---|
1330 | |
---|
1331 | # IF OUTPUT-FILE DOES NOT EXIST CHECK, IF IT CAN BE CREATED |
---|
1332 | if cat /dev/null > $filename |
---|
1333 | then |
---|
1334 | rm $filename |
---|
1335 | else |
---|
1336 | |
---|
1337 | # CHECK, IF THE DIRECTORY WHERE FILE SHALL BE COPIED TO EXISTS |
---|
1338 | # IF IT DOES NOT EXIST, TRY TO CREATE IT |
---|
1339 | if [[ ! -d $catalogname ]] |
---|
1340 | then |
---|
1341 | if mkdir -p $catalogname |
---|
1342 | then |
---|
1343 | printf "\n\n *** directory:" |
---|
1344 | printf "\n $catalogname" |
---|
1345 | printf "\n was created\n" |
---|
1346 | else |
---|
1347 | printf "\n\n +++ OUTPUT-file:" |
---|
1348 | printf "\n $filename" |
---|
1349 | printf "\n cannot be created, because directory does not exist" |
---|
1350 | printf "\n and cannot be created either" |
---|
1351 | printf "\n" |
---|
1352 | locat=output ; exit |
---|
1353 | fi 2>/dev/null |
---|
1354 | else |
---|
1355 | printf "\n\n +++ OUTPUT-file:" |
---|
1356 | printf "\n $filename" |
---|
1357 | printf "\n cannot be created, although directory exists" |
---|
1358 | printf "\n" |
---|
1359 | locat=output ; exit |
---|
1360 | fi |
---|
1361 | fi 2>/dev/null |
---|
1362 | else |
---|
1363 | |
---|
1364 | # DETERMINE THE CYCLE NUMBER |
---|
1365 | ls -1 -d $filename > filelist 2>/dev/null |
---|
1366 | ls -1 -d $filename.* >> filelist 2>/dev/null |
---|
1367 | while read zeile |
---|
1368 | do |
---|
1369 | cycle=$(echo $zeile | cut -f2 -d".") |
---|
1370 | if [[ "$cycle" = "$zeile" || "$cycle" = ${extout[$i]} ]] |
---|
1371 | then |
---|
1372 | (( icycle = 1 )) |
---|
1373 | else |
---|
1374 | (( icycle = $cycle + 1 )) |
---|
1375 | fi |
---|
1376 | if (( icycle > maxcycle )) |
---|
1377 | then |
---|
1378 | (( maxcycle = icycle )) |
---|
1379 | fi |
---|
1380 | done <filelist |
---|
1381 | rm filelist |
---|
1382 | fi |
---|
1383 | |
---|
1384 | # APPEND CYCLE NUMBER TO FILENAME AND CHECK, IF FILE CAN BE CREATED |
---|
1385 | # IN CASE OF FILE-APPEND, FILE MUST BE APPENDED TO THE ONE WITH HIGHEST CYCLE NUMBER |
---|
1386 | if [[ "${actionout[$i]}" != a ]] |
---|
1387 | then |
---|
1388 | if (( maxcycle > 0 )) |
---|
1389 | then |
---|
1390 | filename=${filename}.$maxcycle |
---|
1391 | if cat /dev/null > $filename |
---|
1392 | then |
---|
1393 | rm $filename |
---|
1394 | else |
---|
1395 | printf "\n +++ OUTPUT-file:" |
---|
1396 | printf "\n $filename" |
---|
1397 | printf "\n cannot be created" |
---|
1398 | locat=output ; exit |
---|
1399 | fi |
---|
1400 | fi |
---|
1401 | else |
---|
1402 | (( maxcycle = maxcycle - 1 )) |
---|
1403 | if (( maxcycle > 0 )) |
---|
1404 | then |
---|
1405 | filename=${filename}.$maxcycle |
---|
1406 | fi |
---|
1407 | fi |
---|
1408 | |
---|
1409 | # STORE FILENAME WITHOUT PATH BUT WITH CYCLE NUMBER, |
---|
1410 | # BECAUSE IT MIGHT BE REQUIRED LATER TO STORE THE FILE ON AN ARCHIVE-SYSTEM |
---|
1411 | # OR TO PUT THIS FILENAME ON FILE OUTPUT_FILE_CONNECTIONS |
---|
1412 | pathout[$i]=$filename |
---|
1413 | if (( maxcycle > 0 )) |
---|
1414 | then |
---|
1415 | frelout[$i]=${fname}${endout[$i]}.$maxcycle |
---|
1416 | else |
---|
1417 | frelout[$i]=${fname}${endout[$i]} |
---|
1418 | fi |
---|
1419 | |
---|
1420 | fi |
---|
1421 | done |
---|
1422 | |
---|
1423 | |
---|
1424 | # THE DVR-PACKAGE REQUIRES ITS OWN LIBRARY |
---|
1425 | if [[ $(echo $package_list | grep -c dvrp_graphics) != 0 ]] |
---|
1426 | then |
---|
1427 | if [[ "$dvr_inc" = "" ]] |
---|
1428 | then |
---|
1429 | printf "\n\n +++ no value for \"dvr_inc\" given in configuration file" |
---|
1430 | printf "\n This is required for the dvrp_graphics package.\n" |
---|
1431 | locat=dvr; exit |
---|
1432 | fi |
---|
1433 | if [[ "$dvr_lib" = "" ]] |
---|
1434 | then |
---|
1435 | printf "\n\n +++ no value for \"dvr_lib\" given in configuration file" |
---|
1436 | printf "\n This is required for the dvrp_graphics package.\n" |
---|
1437 | locat=dvr; exit |
---|
1438 | fi |
---|
1439 | fi |
---|
1440 | |
---|
1441 | |
---|
1442 | # CHECK, WETHER A MAIN PROGRAM OR AN EXECUTABLE HAVE BEEN DECLARED. |
---|
1443 | # EXECUTABLES DO NOT NEED TO BE COMPILED. |
---|
1444 | if [[ "$mainprog" = "" && "$executable" = "" ]] |
---|
1445 | then |
---|
1446 | printf "\n +++ neither main program nor executable defined" |
---|
1447 | locat=source; exit |
---|
1448 | elif [[ "$mainprog" != "" && "$executable" != "" ]] |
---|
1449 | then |
---|
1450 | printf "\n +++ main program as well as executable defined" |
---|
1451 | locat=source; exit |
---|
1452 | elif [[ "$mainprog" = "" && "$executable" != "" ]] |
---|
1453 | then |
---|
1454 | do_compile=false |
---|
1455 | fi |
---|
1456 | |
---|
1457 | |
---|
1458 | # CREATE SOURCE-DIRECTORY TO COLLECT ROUTINES TO BE COMPILED. |
---|
1459 | # LATER THE MRUN-SCRIPT AND CONFIGURATION-FILE WILL ALSO BE COPIED TO THIS DIRECTORY. |
---|
1460 | if [[ $restart_run != true && "$SOURCES_COMPLETE" = "" ]] |
---|
1461 | then |
---|
1462 | rm -rf SOURCES_FOR_RUN_$fname |
---|
1463 | mkdir SOURCES_FOR_RUN_$fname |
---|
1464 | fi |
---|
1465 | |
---|
1466 | |
---|
1467 | # COLLECT ALL ROUTINES TO BE COMPILED |
---|
1468 | # THIS IS NOT REQUIRED WITHIN BATCH-JOBS, BECAUSE ROUTINES HAVE ALREADY BEEN COLLECTED |
---|
1469 | # BY THE MRUN-CALL WHICH CREATED THE BATCH-JOB. |
---|
1470 | if [[ $do_compile = true && "$SOURCES_COMPLETE" = "" ]] |
---|
1471 | then |
---|
1472 | |
---|
1473 | [[ "$source_list" = LM ]] && source_list=LOCALLY_MODIFIED |
---|
1474 | |
---|
1475 | if [[ "$source_list" = LOCALLY_MODIFIED ]] |
---|
1476 | then |
---|
1477 | |
---|
1478 | # DETERMINE MODIFIED FILES OF THE SVN WORKING COPY |
---|
1479 | source_list="" |
---|
1480 | cd $source_path |
---|
1481 | |
---|
1482 | |
---|
1483 | # CHECK, IF DIRECTORY IS UNDER SVN CONTROL |
---|
1484 | if [[ ! -d .svn ]] |
---|
1485 | then |
---|
1486 | printf "\n\n +++ source directory" |
---|
1487 | printf "\n \"$source_path\" " |
---|
1488 | printf "\n is not under control of \"subversion\"." |
---|
1489 | printf "\n Please do not use mrun-option \"-s LOCALLY_MODIFIED\"\n" |
---|
1490 | fi |
---|
1491 | |
---|
1492 | |
---|
1493 | # LIST ALL MODIFIED SOURCE CODE FILES |
---|
1494 | Filenames="" |
---|
1495 | svn status > tmp_mrun |
---|
1496 | while read line |
---|
1497 | do |
---|
1498 | firstc=`echo $line | cut -c1` |
---|
1499 | if [[ $firstc = M || $firstc = "?" ]] |
---|
1500 | then |
---|
1501 | Name=`echo "$line" | cut -c8-` |
---|
1502 | extension=`echo $Name | cut -d. -f2` |
---|
1503 | if [[ "$extension" = f90 || "$extension" = F90 || "$extension" = f || "$extension" = F || "$extension" = c ]] |
---|
1504 | then |
---|
1505 | Filenames="$Filenames "$Name |
---|
1506 | fi |
---|
1507 | fi |
---|
1508 | done < tmp_mrun |
---|
1509 | |
---|
1510 | |
---|
1511 | # COPY FILES TO SOURCES_FOR_RUN_... |
---|
1512 | for dateiname in $Filenames |
---|
1513 | do |
---|
1514 | cp $dateiname $working_directory/SOURCES_FOR_RUN_$fname |
---|
1515 | source_list=$source_list"$dateiname " |
---|
1516 | done |
---|
1517 | |
---|
1518 | cd - > /dev/null |
---|
1519 | |
---|
1520 | |
---|
1521 | # COPY FILES GIVEN BY OPTION -s TO DIRECTORY SOURCES_FOR_RUN_... |
---|
1522 | # AUTOMATIC RESTART RUNS JUST ACCESS THE DIRECTORY CREATED BY THE INITIAL RUN |
---|
1523 | elif [[ "$source_list" != "" && $restart_run != true ]] |
---|
1524 | then |
---|
1525 | |
---|
1526 | cd $source_path |
---|
1527 | |
---|
1528 | for filename in $source_list |
---|
1529 | do |
---|
1530 | |
---|
1531 | # SOURCE CODE FILE IS NOT ALLOWED TO INCLUDE PATH |
---|
1532 | if [[ $(echo $filename | grep -c "/") != 0 ]] |
---|
1533 | then |
---|
1534 | printf "\n +++ source code file: $filename" |
---|
1535 | printf "\n must not contain (\"/\") " |
---|
1536 | locat=source; exit |
---|
1537 | fi |
---|
1538 | |
---|
1539 | if [[ ! -f $filename ]] |
---|
1540 | then |
---|
1541 | printf "\n +++ source code file: $filename" |
---|
1542 | printf "\n does not exist" |
---|
1543 | locat=source; exit |
---|
1544 | else |
---|
1545 | cp $filename $working_directory/SOURCES_FOR_RUN_$fname |
---|
1546 | fi |
---|
1547 | |
---|
1548 | done |
---|
1549 | |
---|
1550 | cd - > /dev/null |
---|
1551 | |
---|
1552 | fi |
---|
1553 | |
---|
1554 | |
---|
1555 | # CHECK, IF A MAIN PROGRAM EXISTS AND IF IT IS PART OF THE LIST OF FILES |
---|
1556 | # TO BE COMPILED. IF NOT, ADD IT TO THE LIST. |
---|
1557 | if [[ $restart_run != true ]] |
---|
1558 | then |
---|
1559 | |
---|
1560 | if [[ ! -f "$source_path/$mainprog" ]] |
---|
1561 | then |
---|
1562 | printf "\n\n +++ main program: $mainprog" |
---|
1563 | printf "\n does not exist in source directory" |
---|
1564 | printf "\n \"$source_path\"\n" |
---|
1565 | locat=source; exit |
---|
1566 | else |
---|
1567 | if [[ $(echo $source_list | grep -c $mainprog) = 0 ]] |
---|
1568 | then |
---|
1569 | cp $source_path/$mainprog SOURCES_FOR_RUN_$fname |
---|
1570 | source_list=${mainprog}" $source_list" |
---|
1571 | fi |
---|
1572 | fi |
---|
1573 | fi |
---|
1574 | |
---|
1575 | |
---|
1576 | # CHECK, IF MAKEFILE EXISTS AND COPY IT TO THE SOURCES_FOR_RUN... DIRECTORY |
---|
1577 | # NOT REQUIRED FOR RESTART RUNS, SOURCES_FOR_RUN... HAS BEEN CREATED BY THE INITIAL RUN |
---|
1578 | if [[ "$restart_run" != true ]] |
---|
1579 | then |
---|
1580 | [[ "$makefile" = "" ]] && makefile=$source_path/Makefile |
---|
1581 | if [[ ! -f $makefile ]] |
---|
1582 | then |
---|
1583 | printf "\n +++ file \"$makefile\" does not exist" |
---|
1584 | locat=make; exit |
---|
1585 | else |
---|
1586 | cp $makefile SOURCES_FOR_RUN_$fname/Makefile |
---|
1587 | fi |
---|
1588 | fi |
---|
1589 | |
---|
1590 | |
---|
1591 | # COPY FILES FROM OPTIONAL SOURCE PATH GIVEN IN THE CONFIGURATION FILE |
---|
1592 | if [[ $restart_run != true && "$add_source_path" != "" ]] |
---|
1593 | then |
---|
1594 | |
---|
1595 | # DOES THE DIRECTORY EXIST? |
---|
1596 | if [[ ! -d $add_source_path ]] |
---|
1597 | then |
---|
1598 | printf "\n\n *** INFORMATIVE: additional source code directory" |
---|
1599 | printf "\n \"$add_source_path\" " |
---|
1600 | printf "\n does not exist or is not a directory." |
---|
1601 | printf "\n No source code will be used from this directory!\n" |
---|
1602 | add_source_path="" |
---|
1603 | if [[ $silent == false ]] |
---|
1604 | then |
---|
1605 | sleep 3 |
---|
1606 | fi |
---|
1607 | else |
---|
1608 | |
---|
1609 | cd $add_source_path |
---|
1610 | found=false |
---|
1611 | |
---|
1612 | Names=$(ls -1 *.f90 2>&1) |
---|
1613 | [[ $(echo $Names | grep -c '*.f90') = 0 ]] && AddFilenames="$Names" |
---|
1614 | Names=$(ls -1 *.F90 2>&1) |
---|
1615 | [[ $(echo $Names | grep -c '*.F90') = 0 ]] && AddFilenames="$AddFilenames $Names" |
---|
1616 | Names=$(ls -1 *.F 2>&1) |
---|
1617 | [[ $(echo $Names | grep -c '*.F') = 0 ]] && AddFilenames="$AddFilenames $Names" |
---|
1618 | Names=$(ls -1 *.f 2>&1) |
---|
1619 | [[ $(echo $Names | grep -c '*.f') = 0 ]] && AddFilenames="$AddFilenames $Names" |
---|
1620 | Names=$(ls -1 *.c 2>&1) |
---|
1621 | [[ $(echo $Names | grep -c '*.c') = 0 ]] && AddFilenames="$AddFilenames $Names" |
---|
1622 | |
---|
1623 | cd - > /dev/null |
---|
1624 | cd SOURCES_FOR_RUN_$fname |
---|
1625 | |
---|
1626 | # COPY MAKEFILE IF EXISTING |
---|
1627 | if [[ -f $add_source_path/Makefile ]] |
---|
1628 | then |
---|
1629 | printf "\n\n *** user Makefile from directory" |
---|
1630 | printf "\n \"$add_source_path\" is used \n" |
---|
1631 | if [[ $silent == false ]] |
---|
1632 | then |
---|
1633 | sleep 1 |
---|
1634 | fi |
---|
1635 | cp $add_source_path/Makefile . |
---|
1636 | fi |
---|
1637 | |
---|
1638 | for dateiname in $AddFilenames |
---|
1639 | do |
---|
1640 | if [[ -f $dateiname ]] |
---|
1641 | then |
---|
1642 | printf "\n +++ source code file \"$dateiname\" found in additional" |
---|
1643 | printf "\n source code directory \"$add_source_path\" " |
---|
1644 | printf "\n but was also given with option \"-s\" which means that it should be taken" |
---|
1645 | printf "\n from directory \"$source_path\"." |
---|
1646 | locat=source; exit |
---|
1647 | fi |
---|
1648 | |
---|
1649 | cp $add_source_path/$dateiname . |
---|
1650 | source_list="$source_list $dateiname" |
---|
1651 | |
---|
1652 | # CHECK IF FILE IS CONTAINED IN MAKEFILE |
---|
1653 | if [[ $(grep -c $dateiname Makefile) = 0 ]] |
---|
1654 | then |
---|
1655 | printf "\n\n +++ user file \"$dateiname\" " |
---|
1656 | printf "\n is not listed in Makefile \n" |
---|
1657 | locat=source; exit |
---|
1658 | else |
---|
1659 | |
---|
1660 | if [[ $found = false ]] |
---|
1661 | then |
---|
1662 | found=true |
---|
1663 | printf "\n\n *** following user file(s) added to the" |
---|
1664 | printf " files to be translated:\n " |
---|
1665 | fi |
---|
1666 | printf "$dateiname " |
---|
1667 | if [[ $silent == false ]] |
---|
1668 | then |
---|
1669 | sleep 0.5 |
---|
1670 | fi |
---|
1671 | |
---|
1672 | fi |
---|
1673 | done |
---|
1674 | [[ $found = true ]] && printf "\n" |
---|
1675 | cd - > /dev/null |
---|
1676 | fi |
---|
1677 | fi |
---|
1678 | |
---|
1679 | |
---|
1680 | # ADD ALL ROUTINES BELONGING TO SOFTWARE PACKAGES (GIVEN BY OPTION -p) |
---|
1681 | # TO THE LIST OF FILES TO BE COMPILED |
---|
1682 | if [[ $restart_run != true && -n $package_list ]] |
---|
1683 | then |
---|
1684 | |
---|
1685 | cd $source_path |
---|
1686 | |
---|
1687 | for package in $package_list |
---|
1688 | do |
---|
1689 | |
---|
1690 | [[ $package = "dvrp_graphics+1PE" ]] && package=dvrp_graphics |
---|
1691 | |
---|
1692 | # DETERMINE FILES BELONGING TO THE PACKAGE |
---|
1693 | # ERROR MESSAGE ARE REDIRECTED TO /dev/null, BECAUSE WILDCARD (*) ALSO GIVES |
---|
1694 | # THE NAME OF THE DIRECTORY |
---|
1695 | package_source_list=`grep "defined( __$package " * 2>/dev/null | cut -f1 -d:` |
---|
1696 | |
---|
1697 | |
---|
1698 | # ADD THESE FILES TO THE LIST OF FILES TO BE COMPILED, |
---|
1699 | # IF THEY ARE NOT ALREADY PART OF THE LIST |
---|
1700 | for source_list_name in $package_source_list |
---|
1701 | do |
---|
1702 | if [[ $(echo $source_list | grep -c $source_list_name) = 0 ]] |
---|
1703 | then |
---|
1704 | |
---|
1705 | # ONLY TAKE FILES WITH VALID SUFFIX |
---|
1706 | ending=`echo $source_list_name | cut -f2 -d.` |
---|
1707 | if [[ "$ending" = f90 || "$ending" = F90 || "$ending" = f || "$ending" = F || "$ending" = c ]] |
---|
1708 | then |
---|
1709 | cp $source_list_name $working_directory/SOURCES_FOR_RUN_$fname |
---|
1710 | source_list="$source_list $source_list_name" |
---|
1711 | fi |
---|
1712 | fi |
---|
1713 | done |
---|
1714 | done |
---|
1715 | |
---|
1716 | cd - > /dev/null |
---|
1717 | fi |
---|
1718 | |
---|
1719 | fi # do_compile=true |
---|
1720 | |
---|
1721 | |
---|
1722 | # IF SOURCE CODE IS TO BE COMPILED, DO SOME MORE CHECKS |
---|
1723 | # AND SET PRE-PROCESSOR DIRECTIVES |
---|
1724 | if [[ $do_compile = true || $create_executable_for_batch = true ]] |
---|
1725 | then |
---|
1726 | |
---|
1727 | # SET PREPROCESSOR-DIRECTIVES TO SELECT OPERATING SYSTEM SPECIFIC CODE |
---|
1728 | if [[ $(echo $localhost | cut -c1-3) = ibm ]] |
---|
1729 | then |
---|
1730 | cpp_options="${cpp_options},-D__ibm=__ibm" |
---|
1731 | elif [[ $(echo $localhost | cut -c1-3) = nec ]] |
---|
1732 | then |
---|
1733 | cpp_options="$cpp_options -D__nec" |
---|
1734 | elif [[ $(echo $localhost | cut -c1-2) = lc ]] |
---|
1735 | then |
---|
1736 | cpp_options="$cpp_options -D__lc" |
---|
1737 | else |
---|
1738 | cpp_options="$cpp_options -D__$localhost" |
---|
1739 | fi |
---|
1740 | |
---|
1741 | # SET DIRECTIVES GIVEN BY OPTION -K (E.G. parallel) |
---|
1742 | if [[ $(echo $localhost | cut -c1-3) = ibm ]] |
---|
1743 | then |
---|
1744 | [[ -n $cond1 ]] && cpp_options="${cpp_options},-D__$cond1=__$cond1" |
---|
1745 | [[ -n $cond2 ]] && cpp_options="${cpp_options},-D__$cond2=__$cond2" |
---|
1746 | else |
---|
1747 | [[ -n $cond1 ]] && cpp_options="$cpp_options -D__$cond1" |
---|
1748 | [[ -n $cond2 ]] && cpp_options="$cpp_options -D__$cond2" |
---|
1749 | fi |
---|
1750 | |
---|
1751 | # SET DIRECTIVES FOR ACTIVATING SOFTWARE-PACKAGES (OPTION -p) |
---|
1752 | if [[ -n $package_list ]] |
---|
1753 | then |
---|
1754 | for package in $package_list |
---|
1755 | do |
---|
1756 | if [[ $(echo $localhost | cut -c1-3) = ibm ]] |
---|
1757 | then |
---|
1758 | if [[ $package != "dvrp_graphics+1PE" ]] |
---|
1759 | then |
---|
1760 | cpp_options="${cpp_options},-D__$package=__$package" |
---|
1761 | else |
---|
1762 | cpp_options="${cpp_options},-D__dvrp_graphics=__dvrp_graphics" |
---|
1763 | export use_seperate_pe_for_dvrp_output=true |
---|
1764 | fi |
---|
1765 | else |
---|
1766 | if [[ $package != "dvrp_graphics+1PE" ]] |
---|
1767 | then |
---|
1768 | cpp_options="$cpp_options -D__$package" |
---|
1769 | else |
---|
1770 | cpp_options="$cpp_options -D__dvrp_graphics" |
---|
1771 | export use_seperate_pe_for_dvrp_output=true |
---|
1772 | fi |
---|
1773 | fi |
---|
1774 | done |
---|
1775 | fi |
---|
1776 | |
---|
1777 | # SET DIRECTIVES GIVEN BY OPTION -D |
---|
1778 | if [[ -n $cpp_opts ]] |
---|
1779 | then |
---|
1780 | for popts in $cpp_opts |
---|
1781 | do |
---|
1782 | if [[ $(echo $localhost | cut -c1-3) = ibm ]] |
---|
1783 | then |
---|
1784 | cpp_options="${cpp_options},-D__$popts=__$popts" |
---|
1785 | else |
---|
1786 | cpp_options="$cpp_options -D__$popts" |
---|
1787 | fi |
---|
1788 | done |
---|
1789 | fi |
---|
1790 | |
---|
1791 | else |
---|
1792 | |
---|
1793 | |
---|
1794 | # FOR LOCAL RUNS CHECK AGAIN, IF EXECUTABLE EXISTS |
---|
1795 | if [[ $do_remote = false ]] |
---|
1796 | then |
---|
1797 | if [[ ! -f $executable ]] |
---|
1798 | then |
---|
1799 | printf "\n +++ executable file: $executable" |
---|
1800 | printf "\n does not exist" |
---|
1801 | locat=executable; exit |
---|
1802 | fi |
---|
1803 | fi |
---|
1804 | fi |
---|
1805 | |
---|
1806 | |
---|
1807 | # DETERMINE THE JOB MODE |
---|
1808 | if [[ $(echo $localhost | cut -c1-3) = ibm ]] |
---|
1809 | then |
---|
1810 | if [[ "$LOADLBATCH" = yes ]] |
---|
1811 | then |
---|
1812 | batch_job=.TRUE. |
---|
1813 | jobmo=BATCH |
---|
1814 | else |
---|
1815 | batch_job=.FALSE. |
---|
1816 | jobmo=INTERACTIVE |
---|
1817 | fi |
---|
1818 | else |
---|
1819 | if [[ "$ENVIRONMENT" = BATCH ]] |
---|
1820 | then |
---|
1821 | batch_job=.TRUE. |
---|
1822 | jobmo=BATCH |
---|
1823 | else |
---|
1824 | batch_job=.FALSE. |
---|
1825 | jobmo=INTERACTIVE |
---|
1826 | fi |
---|
1827 | fi |
---|
1828 | |
---|
1829 | # NO INTERACTIVE RUNS ALLOWED ON LCTIT |
---|
1830 | if [[ $host = lctit && $jobmo = INTERACTIVE && $do_batch = false ]] |
---|
1831 | then |
---|
1832 | printf "\n +++ no interactive runs allowed on host \"$host\" " |
---|
1833 | printf "\n please submit batch job using mrun option \"-b\" \n" |
---|
1834 | locat=normal; exit |
---|
1835 | fi |
---|
1836 | |
---|
1837 | |
---|
1838 | # CHECK, IF USER DEFINED A COMPILER |
---|
1839 | if [[ "$compiler_name" = "" ]] |
---|
1840 | then |
---|
1841 | |
---|
1842 | printf "\n +++ no compiler specified for \"$host $cond1 $cond2\"" |
---|
1843 | locat=compiler_name; exit |
---|
1844 | |
---|
1845 | fi |
---|
1846 | |
---|
1847 | |
---|
1848 | # DETERMINE THE NAME OF MRUN'S TEMPORARY WORKING DIRECTORY |
---|
1849 | |
---|
1850 | # ON HLRN-III, USE THE QUEUING NAME. OTHERWISE USE USERNAME AND RANDOM NUMBER |
---|
1851 | if [[ $do_batch = false && $(echo $host | cut -c1-6) = lccray ]] |
---|
1852 | then |
---|
1853 | kennung=$(checkjob $PBS_JOBID | grep Reservation | cut -d" " -s -f2 | cut -d"." -s -f2 | sed "s/['\"]//g") |
---|
1854 | if [[ "$kennung" = "" ]] |
---|
1855 | then |
---|
1856 | kennung=$RANDOM |
---|
1857 | fi |
---|
1858 | else |
---|
1859 | kennung=$RANDOM |
---|
1860 | fi |
---|
1861 | |
---|
1862 | if [[ "$tmp_user_catalog" = "" ]] |
---|
1863 | then |
---|
1864 | if [[ $localhost = ibmh ]] |
---|
1865 | then |
---|
1866 | tmp_user_catalog=$SCRATCH |
---|
1867 | elif [[ $localhost = nech ]] |
---|
1868 | then |
---|
1869 | tmp_user_catalog=$WRKSHR |
---|
1870 | else |
---|
1871 | tmp_user_catalog=/tmp |
---|
1872 | fi |
---|
1873 | fi |
---|
1874 | TEMPDIR=$tmp_user_catalog/${usern}.$kennung |
---|
1875 | |
---|
1876 | |
---|
1877 | # DETERMINE THE NAME OF THE DIRECTORY WHICH IS USED TO TEMPORARILY STORE DATA FOR RESTART RUNS |
---|
1878 | if [[ "$tmp_data_catalog" = "" ]] |
---|
1879 | then |
---|
1880 | if [[ $localhost = nech ]] |
---|
1881 | then |
---|
1882 | tmp_data_catalog=$WRKSHR/mrun_restart_data |
---|
1883 | else |
---|
1884 | tmp_data_catalog=/tmp/mrun_restart_data |
---|
1885 | fi |
---|
1886 | fi |
---|
1887 | |
---|
1888 | |
---|
1889 | # IN CASE OF LOCAL RUNS REPLACE ENVIRONMENT VARIABLES BY THEIR VALUES |
---|
1890 | if [[ $do_remote = false && $do_compile = true || $create_executable_for_batch = true ]] |
---|
1891 | then |
---|
1892 | eval fopts=\"$fopts\" |
---|
1893 | eval lopts=\"$lopts\" |
---|
1894 | fi |
---|
1895 | |
---|
1896 | |
---|
1897 | # DETERMINE COMPILE- AND LINK-OPTIONS |
---|
1898 | fopts="$fopts $netcdf_inc $fftw_inc $dvr_inc" |
---|
1899 | lopts="$lopts $netcdf_lib $fftw_lib $dvr_lib" |
---|
1900 | XOPT="-X $numprocs" |
---|
1901 | |
---|
1902 | |
---|
1903 | # CHECK THE CPU-LIMIT. IT MUST BE GIVEN FOR BATCH-JOBS AND IS COMMUNICATED TO THE |
---|
1904 | # EXECUTABLE VIA NAMELIST-PARAMETER cputime |
---|
1905 | done=false |
---|
1906 | while [[ $done = false ]] |
---|
1907 | do |
---|
1908 | cputime=$cpumax |
---|
1909 | if (( $cputime == 0 )) |
---|
1910 | then |
---|
1911 | if [[ $do_batch = true ]] |
---|
1912 | then |
---|
1913 | printf "\n +++ cpu-time is undefined" |
---|
1914 | printf "\n >>> Please type CPU-time in seconds as INTEGER:" |
---|
1915 | printf "\n >>> " |
---|
1916 | read cputime 1>/dev/null 2>&1 |
---|
1917 | else |
---|
1918 | cputime=10000000 # NO CPU LIMIT FOR INTERACTIVE RUNS |
---|
1919 | fi |
---|
1920 | else |
---|
1921 | done=true |
---|
1922 | fi |
---|
1923 | cpumax=$cputime |
---|
1924 | done |
---|
1925 | |
---|
1926 | (( minuten = cputime / 60 )) |
---|
1927 | (( sekunden = cputime - minuten * 60 )) |
---|
1928 | |
---|
1929 | |
---|
1930 | # CHECK THE MEMORY DEMAND |
---|
1931 | if [[ $do_batch = true ]] |
---|
1932 | then |
---|
1933 | done=false |
---|
1934 | while [[ $done = false ]] |
---|
1935 | do |
---|
1936 | if (( memory == 0 )) |
---|
1937 | then |
---|
1938 | printf "\n +++ memory demand is undefined" |
---|
1939 | printf "\n >>> Please type memory in MByte per process as INTEGER:" |
---|
1940 | printf "\n >>> " |
---|
1941 | read memory 1>/dev/null 2>&1 |
---|
1942 | else |
---|
1943 | done=true |
---|
1944 | fi |
---|
1945 | done |
---|
1946 | fi |
---|
1947 | |
---|
1948 | |
---|
1949 | # IN CASE OF REMOTE-JOBS CHECK, IF A USERNAME FOR THE REMOTE HOST IS GIVEN |
---|
1950 | if [[ $do_remote = true && -z $remote_username ]] |
---|
1951 | then |
---|
1952 | while [[ -z $remote_username ]] |
---|
1953 | do |
---|
1954 | printf "\n +++ username on remote host \"$host\" is undefined" |
---|
1955 | printf "\n >>> Please type username:" |
---|
1956 | printf "\n >>> " |
---|
1957 | read remote_username |
---|
1958 | done |
---|
1959 | mc="$mc -u$remote_username" |
---|
1960 | fi |
---|
1961 | |
---|
1962 | # CHECK FOR INITIAL COMMANDS AFTER LOGIN |
---|
1963 | if [[ "$login_init_cmd" != "" ]] |
---|
1964 | then |
---|
1965 | export init_cmds="${login_init_cmd};" |
---|
1966 | fi |
---|
1967 | |
---|
1968 | |
---|
1969 | # SET THE MODULE-LOAD COMMAD AND EXPORT IT FOR subjob |
---|
1970 | if [[ "$modules" != "" ]] |
---|
1971 | then |
---|
1972 | if [[ $host = lctit ]] |
---|
1973 | then |
---|
1974 | export module_calls=". $modules" |
---|
1975 | else |
---|
1976 | export module_calls="module load ${modules};" |
---|
1977 | fi |
---|
1978 | fi |
---|
1979 | |
---|
1980 | # OUTPUT OF THE MRUN-HEADER |
---|
1981 | calltime=$(date) |
---|
1982 | printf "\n" |
---|
1983 | printf "#------------------------------------------------------------------------# \n" |
---|
1984 | printf "| %-35s%35s | \n" "$version" "$calltime" |
---|
1985 | printf "| | \n" |
---|
1986 | spalte1="called on:"; spalte2=$localhost_realname |
---|
1987 | printf "| %-25s%-45s | \n" "$spalte1" "$spalte2" |
---|
1988 | if [[ $do_remote = true ]] |
---|
1989 | then |
---|
1990 | spalte1="execution on:"; spalte2="$host (username: $remote_username)" |
---|
1991 | else |
---|
1992 | spalte1="execution on:"; spalte2="$host ($localhost_realname)" |
---|
1993 | fi |
---|
1994 | printf "| %-25s%-45s | \n" "$spalte1" "$spalte2" |
---|
1995 | if [[ -n $numprocs ]] |
---|
1996 | then |
---|
1997 | if [[ $run_coupled_model = false ]] |
---|
1998 | then |
---|
1999 | spalte1="number of PEs:"; spalte2=$numprocs |
---|
2000 | else |
---|
2001 | spalte1="number of PEs:"; spalte2="$numprocs (atmosphere: $numprocs_atmos, ocean: $numprocs_ocean)" |
---|
2002 | fi |
---|
2003 | printf "| %-25s%-45s | \n" "$spalte1" "$spalte2" |
---|
2004 | fi |
---|
2005 | if [[ -n $tasks_per_node ]] |
---|
2006 | then |
---|
2007 | spalte1="tasks per node:"; spalte2="$tasks_per_node (number of nodes: $nodes)" |
---|
2008 | printf "| %-25s%-45s | \n" "$spalte1" "$spalte2" |
---|
2009 | if (( remaining_pes > 0 )) |
---|
2010 | then |
---|
2011 | spalte1=" "; spalte2="one of the nodes only filled with $remaining_pes tasks" |
---|
2012 | printf "| %-25s%-45s | \n" "$spalte1" "$spalte2" |
---|
2013 | fi |
---|
2014 | fi |
---|
2015 | if [[ $maximum_parallel_io_streams != $numprocs ]] |
---|
2016 | then |
---|
2017 | spalte1="max par io streams:"; spalte2="$maximum_parallel_io_streams" |
---|
2018 | printf "| %-25s%-45s | \n" "$spalte1" "$spalte2" |
---|
2019 | fi |
---|
2020 | if [[ $use_openmp = true ]] |
---|
2021 | then |
---|
2022 | spalte1="threads per task:"; spalte2="$threads_per_task" |
---|
2023 | printf "| %-25s%-45s | \n" "$spalte1" "$spalte2" |
---|
2024 | fi |
---|
2025 | printf "| | \n" |
---|
2026 | if [[ $do_compile = true ]] |
---|
2027 | then |
---|
2028 | if [[ "$mopts" != "" ]] |
---|
2029 | then |
---|
2030 | spalte1="make options:"; spalte2=$(echo "$mopts" | cut -c-45) |
---|
2031 | printf "| %-25s%-45s | \n" "$spalte1" "$spalte2" |
---|
2032 | zeile=$(echo "$mopts" | cut -c46-) |
---|
2033 | while [[ "$zeile" != "" ]] |
---|
2034 | do |
---|
2035 | spalte1="" |
---|
2036 | spalte2=$(echo "$zeile" | cut -c-45) |
---|
2037 | printf "| %-25s%-45s | \n" "$spalte1" "$spalte2" |
---|
2038 | zeile=$(echo "$zeile" | cut -c46-) |
---|
2039 | done |
---|
2040 | fi |
---|
2041 | |
---|
2042 | spalte1="cpp directives:"; spalte2=$(echo "$cpp_options" | cut -c-45) |
---|
2043 | printf "| %-25s%-45s | \n" "$spalte1" "$spalte2" |
---|
2044 | zeile=$(echo "$cpp_options" | cut -c46-) |
---|
2045 | while [[ "$zeile" != "" ]] |
---|
2046 | do |
---|
2047 | spalte1="" |
---|
2048 | spalte2=$(echo "$zeile" | cut -c-45) |
---|
2049 | printf "| %-25s%-45s | \n" "$spalte1" "$spalte2" |
---|
2050 | zeile=$(echo "$zeile" | cut -c46-) |
---|
2051 | done |
---|
2052 | |
---|
2053 | spalte1="compiler options:"; spalte2=$(echo "$fopts" | cut -c-45) |
---|
2054 | printf "| %-25s%-45s | \n" "$spalte1" "$spalte2" |
---|
2055 | zeile=$(echo "$fopts" | cut -c46-) |
---|
2056 | while [[ "$zeile" != "" ]] |
---|
2057 | do |
---|
2058 | spalte1="" |
---|
2059 | spalte2=$(echo "$zeile" | cut -c-45) |
---|
2060 | printf "| %-25s%-45s | \n" "$spalte1" "$spalte2" |
---|
2061 | zeile=$(echo "$zeile" | cut -c46-) |
---|
2062 | done |
---|
2063 | |
---|
2064 | spalte1="linker options:"; spalte2=$(echo "$lopts" | cut -c-45) |
---|
2065 | printf "| %-25s%-45s | \n" "$spalte1" "$spalte2" |
---|
2066 | zeile=$(echo "$lopts" | cut -c46-) |
---|
2067 | while [[ "$zeile" != "" ]] |
---|
2068 | do |
---|
2069 | spalte1="" |
---|
2070 | spalte2=$(echo "$zeile" | cut -c-45) |
---|
2071 | printf "| %-25s%-45s | \n" "$spalte1" "$spalte2" |
---|
2072 | zeile=$(echo "$zeile" | cut -c46-) |
---|
2073 | done |
---|
2074 | |
---|
2075 | spalte1="modules to be load:"; spalte2=$(echo "$modules" | cut -c-45) |
---|
2076 | printf "| %-25s%-45s | \n" "$spalte1" "$spalte2" |
---|
2077 | zeile=$(echo "$modules" | cut -c46-) |
---|
2078 | while [[ "$zeile" != "" ]] |
---|
2079 | do |
---|
2080 | spalte1="" |
---|
2081 | spalte2=$(echo "$zeile" | cut -c-45) |
---|
2082 | printf "| %-25s%-45s | \n" "$spalte1" "$spalte2" |
---|
2083 | zeile=$(echo "$zeile" | cut -c46-) |
---|
2084 | done |
---|
2085 | |
---|
2086 | spalte1="main program:"; spalte2=$mainprog |
---|
2087 | printf "| %-25s%-45s | \n" "$spalte1" "$spalte2" |
---|
2088 | else |
---|
2089 | spalte1=executable:; spalte2=$executable |
---|
2090 | printf "| %-25s%-45s | \n" "$spalte1" "$spalte2" |
---|
2091 | fi |
---|
2092 | printf "| | \n" |
---|
2093 | spalte1="base name of files:"; spalte2=$fname |
---|
2094 | printf "| %-25s%-45s | \n" "$spalte1" "$spalte2" |
---|
2095 | if [[ $fname != $afname ]] |
---|
2096 | then |
---|
2097 | spalte1="base name of input files:"; spalte2=$afname |
---|
2098 | printf "| %-25s%-45s | \n" "$spalte1" "$spalte2" |
---|
2099 | fi |
---|
2100 | spalte1="INPUT control list:"; spalte2=$(echo $input_list) |
---|
2101 | printf "| %-25s%-45s | \n" "$spalte1" "$spalte2" |
---|
2102 | spalte1="OUTPUT control list:"; spalte2=$(echo $output_list) |
---|
2103 | printf "| %-25s%-45s | \n" "$spalte1" "$spalte2" |
---|
2104 | |
---|
2105 | if [[ "$ocean_file_appendix" = true ]] |
---|
2106 | then |
---|
2107 | printf "| %-35s%-35s | \n" "suffix \"_O\" is added to local files" " " |
---|
2108 | fi |
---|
2109 | |
---|
2110 | if [[ $do_batch = true || "$LOADLBATCH" = yes ]] |
---|
2111 | then |
---|
2112 | spalte1="memory demand / PE":; spalte2="$memory MB" |
---|
2113 | printf "| %-25s%-45s | \n" "$spalte1" "$spalte2" |
---|
2114 | spalte1=CPU-time:; spalte2="$minuten:$sekunden" |
---|
2115 | printf "| %-25s%-45s | \n" "$spalte1" "$spalte2" |
---|
2116 | fi |
---|
2117 | |
---|
2118 | if [[ $do_compile = true ]] |
---|
2119 | then |
---|
2120 | printf "| | \n" |
---|
2121 | printf "| Files to be compiled: | \n" |
---|
2122 | zeile=$source_list |
---|
2123 | while [[ "$zeile" != "" ]] |
---|
2124 | do |
---|
2125 | linestart=$(echo $zeile | cut -c-70) |
---|
2126 | printf "| %-70s | \n" "$linestart" |
---|
2127 | zeile=$(echo "$zeile" | cut -c71-) |
---|
2128 | done |
---|
2129 | fi |
---|
2130 | printf "#------------------------------------------------------------------------#" |
---|
2131 | |
---|
2132 | |
---|
2133 | |
---|
2134 | # OUTPUT OF FILE CONNECTIONS IN CASE OF TRACEBACK |
---|
2135 | if [[ $do_trace = true ]] |
---|
2136 | then |
---|
2137 | (( i = 0 )) |
---|
2138 | while (( i < iin )) |
---|
2139 | do |
---|
2140 | (( i = i + 1 )) |
---|
2141 | if (( i == 1 )) |
---|
2142 | then |
---|
2143 | printf "\n\n >>> INPUT-file assignments:\n" |
---|
2144 | fi |
---|
2145 | printf "\n ${localin[$i]} : ${absnamein[$i]}" |
---|
2146 | done |
---|
2147 | (( i = 0 )) |
---|
2148 | while (( i < iout )) |
---|
2149 | do |
---|
2150 | (( i = i + 1 )) |
---|
2151 | if (( i == 1 )) |
---|
2152 | then |
---|
2153 | printf "\n\n >>> OUTPUT-file assignments:\n" |
---|
2154 | fi |
---|
2155 | printf "\n ${localout[$i]} : ${pathout[$i]}" |
---|
2156 | done |
---|
2157 | (( i = 0 )) |
---|
2158 | while (( i < iic )) |
---|
2159 | do |
---|
2160 | (( i = i + 1 )) |
---|
2161 | if (( i == 1 )) |
---|
2162 | then |
---|
2163 | printf "\n\n >>> INPUT-commands:\n" |
---|
2164 | fi |
---|
2165 | printf "\n ${in_command[$i]}" |
---|
2166 | done |
---|
2167 | (( i = 0 )) |
---|
2168 | while (( i < ioc )) |
---|
2169 | do |
---|
2170 | (( i = i + 1 )) |
---|
2171 | if (( i == 1 )) |
---|
2172 | then |
---|
2173 | printf "\n\n >>> OUTPUT-commands:\n" |
---|
2174 | fi |
---|
2175 | printf "\n ${out_command[$i]}" |
---|
2176 | done |
---|
2177 | fi |
---|
2178 | |
---|
2179 | # QUERY FOR CONTINUE (ON LOCAL MACHINES ONLY) |
---|
2180 | if [[ $remotecall = false && $silent = false && $jobmo != BATCH ]] |
---|
2181 | then |
---|
2182 | antwort=dummy |
---|
2183 | printf "\n\n" |
---|
2184 | printf " >>> everything o.k. (y/n) ? " |
---|
2185 | while read antwort |
---|
2186 | do |
---|
2187 | if [[ "$antwort" != y && "$antwort" != Y && "$antwort" != n && "$antwort" != N ]] |
---|
2188 | then |
---|
2189 | printf " >>> everything o.k. (y/n) ? " |
---|
2190 | else |
---|
2191 | break |
---|
2192 | fi |
---|
2193 | done |
---|
2194 | if [[ $antwort = n || $antwort = N ]] |
---|
2195 | then |
---|
2196 | locat=user_abort; (( iec = 0 )); exit |
---|
2197 | fi |
---|
2198 | if [[ $do_batch = true ]] |
---|
2199 | then |
---|
2200 | printf " >>> batch-job will be created and submitted" |
---|
2201 | else |
---|
2202 | printf " >>> MRUN will now continue to execute on this machine" |
---|
2203 | fi |
---|
2204 | fi |
---|
2205 | |
---|
2206 | |
---|
2207 | # DETERMINE PATH FOR MAKE DEPOSITORY |
---|
2208 | if [[ $do_batch = false || $create_executable_for_batch = true ]] |
---|
2209 | then |
---|
2210 | |
---|
2211 | line="" |
---|
2212 | grep "%depository_path" $config_file > tmp_mrun |
---|
2213 | while read line |
---|
2214 | do |
---|
2215 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
2216 | then |
---|
2217 | if [[ "$(echo $line | cut -d" " -s -f3)" = "" ]] |
---|
2218 | then |
---|
2219 | global_depository_path=`echo $line | cut -d" " -s -f2` |
---|
2220 | fi |
---|
2221 | fi |
---|
2222 | done < tmp_mrun |
---|
2223 | |
---|
2224 | line="" |
---|
2225 | grep " $localhost" $config_file | grep "%depository_path" > tmp_mrun |
---|
2226 | while read line |
---|
2227 | do |
---|
2228 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
2229 | then |
---|
2230 | if [[ "$(echo $line | cut -d" " -s -f4)" = "$cond1" && "$(echo $line | cut -d" " -s -f5)" = "$cond2" ]] |
---|
2231 | then |
---|
2232 | local_depository_path=`echo $line | cut -d" " -s -f2` |
---|
2233 | fi |
---|
2234 | fi |
---|
2235 | done < tmp_mrun |
---|
2236 | |
---|
2237 | if [[ "$local_depository_path" = "" ]] |
---|
2238 | then |
---|
2239 | if [[ "$global_depository_path" != "" ]] |
---|
2240 | then |
---|
2241 | local_depository_path=$global_depository_path |
---|
2242 | else |
---|
2243 | printf "\n\n +++ no depository path found in configuration file" |
---|
2244 | printf "\n for local host \"$localhost\" " |
---|
2245 | printf "\n please set \"\%depository_path\" in configuration file\n" |
---|
2246 | locat=config_file; exit |
---|
2247 | fi |
---|
2248 | fi |
---|
2249 | eval local_depository_path=$local_depository_path |
---|
2250 | [[ "$cond1" != "" ]] && local_depository_path=${local_depository_path}_$cond1 |
---|
2251 | [[ "$cond2" != "" ]] && local_depository_path=${local_depository_path}_$cond2 |
---|
2252 | |
---|
2253 | |
---|
2254 | basename=`echo $mainprog | cut -f1 -d"."` |
---|
2255 | eval make_depository=${local_depository_path}/${basename}_current_version.tar |
---|
2256 | if [[ ! -f $make_depository ]] |
---|
2257 | then |
---|
2258 | printf "\n" |
---|
2259 | printf "\n *** WARNING: make depository \"$make_depository\" not found" |
---|
2260 | printf "\n \"make\" will fail, if the Makefile or other source files are missing\n" |
---|
2261 | fi |
---|
2262 | |
---|
2263 | fi |
---|
2264 | |
---|
2265 | |
---|
2266 | # NOW PERFORM THOSE ACTIONS REQUIRED TO EXECUTE THE PROGRAM (PALM) ON THIS MACHINE |
---|
2267 | # (COMPILING/LINKING, EXECUTING, COPYING I/O FILES) |
---|
2268 | if [[ $do_batch = false ]] |
---|
2269 | then |
---|
2270 | |
---|
2271 | |
---|
2272 | # CREATE THE TEMPORARY WORKING DIRECTORY |
---|
2273 | mkdir -p $TEMPDIR |
---|
2274 | chmod go+rx $TEMPDIR |
---|
2275 | tmpcreate=true |
---|
2276 | |
---|
2277 | |
---|
2278 | # COPY EITHER THE COMPLETE SOURCE CODE FILES TO BE COMPILED OR THE EXECUTABLE |
---|
2279 | # INTO THE TEMPORARY WORKING DIRECTORY |
---|
2280 | if [[ $do_compile = true ]] |
---|
2281 | then |
---|
2282 | |
---|
2283 | # ON NEC, COMPILATION IS DONE ON HOST CROSS VIA CROSS COMPILING |
---|
2284 | # CREATE A TEMPORARY DIRECTORY ON THAT MACHINE (HOME MOUNTED VIA NFS) |
---|
2285 | if [[ $localhost = nech ]] |
---|
2286 | then |
---|
2287 | TEMPDIR_COMPILE=$HOME/work/${usern}.$kennung |
---|
2288 | if mkdir -p $TEMPDIR_COMPILE |
---|
2289 | then |
---|
2290 | printf "\n *** \"$TEMPDIR_COMPILE\" " |
---|
2291 | printf "\n is generated as temporary directory for cross compiling\n" |
---|
2292 | else |
---|
2293 | printf "\n +++ creating directory \"$TEMPDIR_COMPILE\" " |
---|
2294 | printf "\n needed for cross compilation failed" |
---|
2295 | locat=compile |
---|
2296 | exit |
---|
2297 | fi |
---|
2298 | else |
---|
2299 | TEMPDIR_COMPILE=$TEMPDIR |
---|
2300 | fi |
---|
2301 | |
---|
2302 | cp $make_depository $TEMPDIR_COMPILE |
---|
2303 | cd $TEMPDIR_COMPILE |
---|
2304 | tar -xf $make_depository > /dev/null 2>&1 |
---|
2305 | cd - > /dev/null |
---|
2306 | |
---|
2307 | # DUE TO UNKNOWN REASONS, COPY WITH cp COMMAND CREATES CORRUPT |
---|
2308 | # FILES ON CRAY XC30 SYSTEMS (HLRN III), rsync IS USED INSTEAD |
---|
2309 | if [[ $(echo $host | cut -c1-6) = lccray ]] |
---|
2310 | then |
---|
2311 | rsync -av -t SOURCES_FOR_RUN_$fname/* $TEMPDIR_COMPILE > /dev/null |
---|
2312 | else |
---|
2313 | cp SOURCES_FOR_RUN_$fname/* $TEMPDIR_COMPILE > /dev/null |
---|
2314 | fi |
---|
2315 | |
---|
2316 | else |
---|
2317 | |
---|
2318 | cp $executable ${TEMPDIR}/a.out |
---|
2319 | |
---|
2320 | fi |
---|
2321 | |
---|
2322 | |
---|
2323 | # CHANGE TO THE TEMPORARY WORKING DIRECTORY |
---|
2324 | cd $TEMPDIR |
---|
2325 | printf "\n *** changed to temporary directory: $TEMPDIR" |
---|
2326 | |
---|
2327 | |
---|
2328 | # THE FOLLOWING IS REQUIRED FPR AVS-OUTPUT WITH PALM ??? REMOVE ??? |
---|
2329 | # WRITE INFORMATIONS ABOUT THE OUTPUT-FILE CONNECTIONS TO A TEMPORARY FILE |
---|
2330 | # THIS FILE CAN LATER BE READ FROM USER-DEFINED CODE TO DETERMINE THE |
---|
2331 | # RELATION BETWEEN THE LOCAL TEMPORARY AND PERMANENT FILE NAMES |
---|
2332 | (( i = 0 )) |
---|
2333 | while (( i < iout )) |
---|
2334 | do |
---|
2335 | (( i = i + 1 )) |
---|
2336 | if [[ "${actionout[$i]}" = tr || "${actionout[$i]}" = tra || "${actionout[$i]}" = trpe ]] |
---|
2337 | then |
---|
2338 | printf "${localout[$i]} ${actionout[$i]}\n${pathout[$i]}\n${localhost}_${fname}${endout[$i]}\n" >> OUTPUT_FILE_CONNECTIONS |
---|
2339 | else |
---|
2340 | printf "${localout[$i]} ${actionout[$i]}\n${pathout[$i]}\n${frelout[$i]}\n" >> OUTPUT_FILE_CONNECTIONS |
---|
2341 | fi |
---|
2342 | done |
---|
2343 | |
---|
2344 | |
---|
2345 | # IF REQUIRED, START WITH COMPILING |
---|
2346 | if [[ $do_compile = true ]] |
---|
2347 | then |
---|
2348 | |
---|
2349 | |
---|
2350 | if [[ -f a.out ]] |
---|
2351 | then |
---|
2352 | |
---|
2353 | # EXECUTABLE WAS CREATED DURING INTERACTIVE CALL OF MRUN |
---|
2354 | printf "\n\n\n *** executable a.out found" |
---|
2355 | printf "\n no compilation required \n" |
---|
2356 | |
---|
2357 | else |
---|
2358 | |
---|
2359 | # COMPILING WITH MAKE (ON NEC COMPILER IS CALLED ON HOST CROSS) |
---|
2360 | printf "\n\n\n *** compilation starts \n$dashes\n" |
---|
2361 | printf " *** compilation with make using following options:\n" |
---|
2362 | printf " make depository: $make_depository" |
---|
2363 | if [[ "$mopts" != "" ]] |
---|
2364 | then |
---|
2365 | printf " make options: $mopts\n" |
---|
2366 | fi |
---|
2367 | printf " compilername: $compiler_name\n" |
---|
2368 | printf " compiler options: $fopts\n" |
---|
2369 | printf " preprocessor directives: $cpp_options \n" |
---|
2370 | printf " linker options: $lopts \n" |
---|
2371 | if [[ "$modules" != "" ]] |
---|
2372 | then |
---|
2373 | printf " modules to be load: $modules \n" |
---|
2374 | fi |
---|
2375 | printf " source code files: $source_list \n" |
---|
2376 | |
---|
2377 | if [[ $localhost = nech ]] |
---|
2378 | then |
---|
2379 | ssh $SSH_PORTOPT 136.172.44.192 -l $usern "$init_cmds $module_calls cd \$HOME/work/${usern}.$kennung; sxmake $mopts -f Makefile PROG=a.out F90=$compiler_name COPT=\"$cpp_options\" F90FLAGS=\"$fopts\" LDFLAGS=\"$lopts\" " |
---|
2380 | cp $TEMPDIR_COMPILE/a.out . |
---|
2381 | [[ $? != 0 ]] && compile_error=true |
---|
2382 | rm -rf $TEMPDIR_COMPILE |
---|
2383 | elif [[ $localhost = ibmh ]] |
---|
2384 | then |
---|
2385 | printf " compiler is called via ssh on \"plogin1\" \n" |
---|
2386 | ssh $SSH_PORTOPT plogin1 -l $usern "$init_cmds export PATH=/sw/ibm/xlf/13.1.0.8/usr/bin:$PATH; $module_calls cd $TEMPDIR; make $mopts -f Makefile PROG=a.out F90=$compiler_name COPT=\"$cpp_options\" F90FLAGS=\"$fopts\" LDFLAGS=\"$lopts\" " |
---|
2387 | [[ ! -f a.out ]] && compile_error=true |
---|
2388 | continue # STATUS=1, IF a.out EXISTS |
---|
2389 | elif [[ $localhost = lcflow ]] |
---|
2390 | then |
---|
2391 | printf " compiler is called via ssh on \"flow\" \n" |
---|
2392 | /usr/bin/ssh $SSH_PORTOPT flow02.hpc.uni-oldenburg.de -l $usern "$init_cmds $module_calls cd $TEMPDIR; make $mopts -f Makefile PROG=a.out F90=$compiler_name COPT=\"$cpp_options\" F90FLAGS=\"$fopts\" LDFLAGS=\"$lopts\" " |
---|
2393 | check_for_file=`/usr/bin/ssh $SSH_PORTOPT flow02.hpc.uni-oldenburg.de -l $usern "ls $TEMPDIR/a.out 2> /dev/null"` |
---|
2394 | [[ "$check_for_file" = "" ]] && compile_error=true |
---|
2395 | continue # STATUS=1, IF a.out EXISTS |
---|
2396 | elif [[ $localhost = lcbullhh || $localhost = lccrayb || $localhost = lccrayf || $localhost = lccrayh ]] |
---|
2397 | then |
---|
2398 | make $mopts -f Makefile PROG=a.out F90=$compiler_name COPT="$cpp_options" F90FLAGS="$fopts" LDFLAGS="$lopts" |
---|
2399 | else |
---|
2400 | [[ "$init_cmds" != "" ]] && eval $init_cmds |
---|
2401 | [[ "$module_calls" != "" ]] && eval $module_calls |
---|
2402 | make $mopts -f Makefile PROG=a.out F90=$compiler_name COPT="$cpp_options" F90FLAGS="$fopts" LDFLAGS="$lopts" |
---|
2403 | fi |
---|
2404 | |
---|
2405 | if [[ $? != 0 || "$compile_error" = true || "$module_compile_error" = true ]] |
---|
2406 | then |
---|
2407 | printf "\n +++ error occured while compiling or linking" |
---|
2408 | locat=compile |
---|
2409 | |
---|
2410 | exit |
---|
2411 | else |
---|
2412 | printf "$dashes\n *** compilation finished \n" |
---|
2413 | fi |
---|
2414 | |
---|
2415 | fi |
---|
2416 | |
---|
2417 | fi |
---|
2418 | |
---|
2419 | |
---|
2420 | # PROVIDE THE INPUT FILES |
---|
2421 | # LOOP OVER ALL ACTIVATED FILES (LISTED IN THE CONFIGURATION FILE) |
---|
2422 | (( i = 0 )) |
---|
2423 | while (( i < iin )) |
---|
2424 | do |
---|
2425 | (( i = i + 1 )) |
---|
2426 | if (( i == 1 )) |
---|
2427 | then |
---|
2428 | printf "\n\n *** providing INPUT-files:\n$dashes" |
---|
2429 | fi |
---|
2430 | |
---|
2431 | |
---|
2432 | # SKIP OPTIONAL FILES, IF THEY DO NOT EXIST |
---|
2433 | if [[ "${transin[$i]}" = unavailable ]] |
---|
2434 | then |
---|
2435 | if [[ "${extin[$i]}" = "" || "${extin[$i]}" = " " ]] |
---|
2436 | then |
---|
2437 | printf "\n *** INFORMATIVE: input file \"${pathin[$i]}/${afname}${endin[$i]}\" " |
---|
2438 | printf "\n is not available!" |
---|
2439 | else |
---|
2440 | printf "\n *** INFORMATIVE: input file \"${pathin[$i]}/${afname}${endin[$i]}.${extin[$i]}\" " |
---|
2441 | printf "\n is not available!" |
---|
2442 | fi |
---|
2443 | continue |
---|
2444 | fi |
---|
2445 | |
---|
2446 | # CHECK FOR SINGLE FILE (SERIAL RUN) OR DIRECTORY (ONE FILE PER CORE FOR PARELLEL EXECUTION) |
---|
2447 | files_for_pes=false; datentyp=file |
---|
2448 | if [[ "${actionin[$i]}" = pe && -n $numprocs ]] |
---|
2449 | then |
---|
2450 | files_for_pes=true; datentyp=directory |
---|
2451 | actionin[$i]="" |
---|
2452 | elif [[ "${actionin[$i]}" = pe && ! -n $numprocs ]] |
---|
2453 | then |
---|
2454 | actionin[$i]="" |
---|
2455 | elif [[ "${actionin[$i]}" = arpe && -n $numprocs ]] |
---|
2456 | then |
---|
2457 | files_for_pes=true; datentyp=directory |
---|
2458 | actionin[$i]="ar" |
---|
2459 | elif [[ "${actionin[$i]}" = arpe && ! -n $numprocs ]] |
---|
2460 | then |
---|
2461 | actionin[$i]="ar" |
---|
2462 | elif [[ "${actionin[$i]}" = flpe && -n $numprocs ]] |
---|
2463 | then |
---|
2464 | files_for_pes=true; datentyp=directory |
---|
2465 | actionin[$i]="fl" |
---|
2466 | elif [[ "${actionin[$i]}" = flpe && ! -n $numprocs ]] |
---|
2467 | then |
---|
2468 | actionin[$i]="fl" |
---|
2469 | fi |
---|
2470 | |
---|
2471 | if [[ $files_for_pes = true ]] |
---|
2472 | then |
---|
2473 | printf "\n >>> INPUT: ${absnamein[$i]}/.... to ${localin[$i]}" |
---|
2474 | else |
---|
2475 | printf "\n >>> INPUT: ${absnamein[$i]} to ${localin[$i]}" |
---|
2476 | fi |
---|
2477 | |
---|
2478 | # INPUT-FILE FOR A RESTART RUN. |
---|
2479 | # CHECK, IF THIS FILE STILL EXISTS ON THE TEMPORARY DATA DIRECTORY. |
---|
2480 | # IF NOT, TRY TO GET IT FROM THE ARCHIVE SYSTEM |
---|
2481 | if [[ "${actionin[$i]}" = fl ]] |
---|
2482 | then |
---|
2483 | printf "\n $datentyp will be fetched from temporary directory \"${tmp_data_catalog}\" !" |
---|
2484 | if [[ $files_for_pes = false ]] |
---|
2485 | then |
---|
2486 | if [[ -f "$tmp_data_catalog/${frelin[$i]}" ]] |
---|
2487 | then |
---|
2488 | ln $tmp_data_catalog/${frelin[$i]} ${localin[$i]} |
---|
2489 | got_tmp[$i]=true |
---|
2490 | elif [[ -f "$WORK/${frelin[$i]}" && $ignore_archive_error = true ]] |
---|
2491 | then |
---|
2492 | printf "\n +++ $datentyp not found in \"$tmp_data_catalog\" !" |
---|
2493 | printf "\n *** trying to use backup copy in \"$WORK\" " |
---|
2494 | cp $WORK/${frelin[$i]} ${localin[$i]} |
---|
2495 | else |
---|
2496 | printf "\n +++ $datentyp not found in \"$tmp_data_catalog\" " |
---|
2497 | printf "\n or \"$tmp_data_catalog\" does not exist!" |
---|
2498 | printf "\n *** trying to get copy from archive" |
---|
2499 | actionin[$i]=ar |
---|
2500 | fi |
---|
2501 | else |
---|
2502 | if [[ -d "$tmp_data_catalog/${frelin[$i]}" ]] |
---|
2503 | then |
---|
2504 | mkdir ${localin[$i]} |
---|
2505 | cd $tmp_data_catalog/${frelin[$i]} |
---|
2506 | for file in $(ls *) |
---|
2507 | do |
---|
2508 | ln $file $TEMPDIR/${localin[$i]} |
---|
2509 | done |
---|
2510 | cd $TEMPDIR |
---|
2511 | got_tmp[$i]=true |
---|
2512 | elif [[ -d "$WORK/${frelin[$i]}" && $ignore_archive_error = true ]] |
---|
2513 | then |
---|
2514 | printf "\n +++ $datentyp not found in \"$tmp_data_catalog\" !" |
---|
2515 | printf "\n *** trying to use backup copy in \"$WORK\" " |
---|
2516 | cp -r $WORK/${frelin[$i]} ${localin[$i]} |
---|
2517 | else |
---|
2518 | printf "\n +++ $datentyp not found in \"$tmp_data_catalog\" " |
---|
2519 | printf "\n or \"$tmp_data_catalog\" does not exist!" |
---|
2520 | printf "\n *** trying to get copy from archive" |
---|
2521 | actionin[$i]=ar |
---|
2522 | fi |
---|
2523 | fi |
---|
2524 | fi |
---|
2525 | |
---|
2526 | |
---|
2527 | # FILE IS STORED ON THE ARCHIVE SYSTEM |
---|
2528 | if [[ "${actionin[$i]}" = ar ]] |
---|
2529 | then |
---|
2530 | |
---|
2531 | if [[ $files_for_pes = false ]] |
---|
2532 | then |
---|
2533 | printf "\n file will be restored from archive-system ($archive_system)!" |
---|
2534 | else |
---|
2535 | printf "\n directory will be restored from archive-system ($archive_system)!" |
---|
2536 | fi |
---|
2537 | |
---|
2538 | file_restored=false |
---|
2539 | |
---|
2540 | if [[ $archive_system = asterix ]] |
---|
2541 | then |
---|
2542 | do_stagein=true |
---|
2543 | (( stagein_anz = 0 )) |
---|
2544 | while [[ $do_stagein = true ]] |
---|
2545 | do |
---|
2546 | if [[ $files_for_pes = false ]] |
---|
2547 | then |
---|
2548 | stagein -O ${frelin[$i]} > STAGEIN_OUTPUT |
---|
2549 | else |
---|
2550 | stagein -t -O ${frelin[$i]} > STAGEIN_OUTPUT |
---|
2551 | fi |
---|
2552 | cat STAGEIN_OUTPUT |
---|
2553 | if [[ $(grep -c "st.msg:i24" STAGEIN_OUTPUT) != 0 ]] |
---|
2554 | then |
---|
2555 | file_restored=true |
---|
2556 | do_stagein=false |
---|
2557 | else |
---|
2558 | (( stagein_anz = stagein_anz + 1 )) |
---|
2559 | if (( stagein_anz == 10 )) |
---|
2560 | then |
---|
2561 | printf "\n +++ stagein stoped after 10 tries" |
---|
2562 | locat=stage |
---|
2563 | exit |
---|
2564 | fi |
---|
2565 | printf "\n +++ restoring from archive failed, trying again:" |
---|
2566 | sleep 900 |
---|
2567 | fi |
---|
2568 | done |
---|
2569 | elif [[ $archive_system = DMF ]] |
---|
2570 | then |
---|
2571 | if [[ $files_for_pes = false ]] |
---|
2572 | then |
---|
2573 | printf "\n +++ restoring of single files impossible with $archive_system !\n" |
---|
2574 | locat=DMF |
---|
2575 | exit |
---|
2576 | else |
---|
2577 | find $ARCHIVE/${frelin[$i]} -type m -print | dmget |
---|
2578 | cp -r $ARCHIVE/${frelin[$i]} $PWD |
---|
2579 | file_restored=true |
---|
2580 | fi |
---|
2581 | elif [[ $archive_system = tivoli ]] |
---|
2582 | then |
---|
2583 | if [[ $files_for_pes = false ]] |
---|
2584 | then |
---|
2585 | ssh $SSH_PORTOPT $usern@bicedata.hlrn.de "cp $PERM/${frelin[$i]} $PWD" |
---|
2586 | else |
---|
2587 | (( inode = 0 )) |
---|
2588 | while (( inode < nodes )) |
---|
2589 | do |
---|
2590 | ssh $SSH_PORTOPT $usern@bicedata.hlrn.de "cd $PWD; tar xf $PERM/${frelin[$i]}/${frelin[$i]}.node_$inode.tar" |
---|
2591 | (( inode = inode + 1 )) |
---|
2592 | done |
---|
2593 | fi |
---|
2594 | file_restored=true |
---|
2595 | elif [[ $archive_system = ut ]] |
---|
2596 | then |
---|
2597 | if [[ $files_for_pes = false ]] |
---|
2598 | then |
---|
2599 | cp $UT/${frelin[$i]} . |
---|
2600 | else |
---|
2601 | (( inode = 0 )) |
---|
2602 | while (( inode < nodes )) |
---|
2603 | do |
---|
2604 | tar xf $UT/${frelin[$i]}/${frelin[$i]}.node_$inode.tar |
---|
2605 | (( inode = inode + 1 )) |
---|
2606 | done |
---|
2607 | fi |
---|
2608 | file_restored=true |
---|
2609 | else |
---|
2610 | printf "\n +++ archive_system=\"$archive_system\" restore impossible!" |
---|
2611 | locat=rearchive |
---|
2612 | exit |
---|
2613 | fi |
---|
2614 | |
---|
2615 | if [[ $file_restored = true ]] |
---|
2616 | then |
---|
2617 | |
---|
2618 | # PUT FILE ON THE TEMPORARY DATA DIRECTORY TOO. |
---|
2619 | # THIS WILL MAKE FILE ACCESS EASIER FOR LATER RUNS |
---|
2620 | [[ ! -d $tmp_data_catalog ]] && mkdir -p $tmp_data_catalog; chmod g+rx $tmp_data_catalog |
---|
2621 | if [[ $files_for_pes = false ]] |
---|
2622 | then |
---|
2623 | ln -f ${frelin[$i]} $tmp_data_catalog/${frelin[$i]} |
---|
2624 | else |
---|
2625 | mkdir $tmp_data_catalog/${frelin[$i]} |
---|
2626 | ln -f ${frelin[$i]}/* $tmp_data_catalog/${frelin[$i]} |
---|
2627 | fi |
---|
2628 | got_tmp[$i]=true |
---|
2629 | |
---|
2630 | # PROVIDE THE FILE UNDER ITS LOCAL NAME |
---|
2631 | mv ${frelin[$i]} ${localin[$i]} |
---|
2632 | |
---|
2633 | fi |
---|
2634 | fi |
---|
2635 | |
---|
2636 | |
---|
2637 | # FILE IS STORED IN THE RESPECTIVE DIRECTORY GIVEN IN THE CONFIGURATION FILE |
---|
2638 | if [[ "${actionin[$i]}" = "" || "${actionin[$i]}" = "di" || "${actionin[$i]}" = "npe" ]] |
---|
2639 | then |
---|
2640 | |
---|
2641 | if [[ "${actionin[$i]}" = "npe" && -n $numprocs ]] |
---|
2642 | then |
---|
2643 | |
---|
2644 | # FILE COPIES ARE PROVIDED FOR ALL CORES |
---|
2645 | # EACH FILE GETS A UNIQUE FILENAME WITH A FOUR DIGIT NUMBER |
---|
2646 | printf "\n file will be provided for $numprocs processors" |
---|
2647 | mkdir ${localin[$i]} |
---|
2648 | ival=$numprocs |
---|
2649 | (( ii = 0 )) |
---|
2650 | while (( ii <= ival-1 )) |
---|
2651 | do |
---|
2652 | if (( ii < 10 )) |
---|
2653 | then |
---|
2654 | cp ${absnamein[$i]} ${localin[$i]}/_000$ii |
---|
2655 | elif (( ii < 100 )) |
---|
2656 | then |
---|
2657 | cp ${absnamein[$i]} ${localin[$i]}/_00$ii |
---|
2658 | elif (( ii < 1000 )) |
---|
2659 | then |
---|
2660 | cp ${absnamein[$i]} ${localin[$i]}/_0$ii |
---|
2661 | else |
---|
2662 | cp ${absnamein[$i]} ${localin[$i]}/_$ii |
---|
2663 | fi |
---|
2664 | (( ii = ii + 1 )) |
---|
2665 | done |
---|
2666 | |
---|
2667 | else |
---|
2668 | |
---|
2669 | if [[ $files_for_pes = true ]] |
---|
2670 | then |
---|
2671 | |
---|
2672 | # PROVIDE FILES FOR EACH CORE |
---|
2673 | # FIRST CREATE THE LOCAL DIRECTORY, THEN COPY FILES |
---|
2674 | # FROM THE PERMANENT DIRECTORY BY LINKING THEM TO THE LOCAL ONE |
---|
2675 | printf "\n providing $numprocs files for the respective processors" |
---|
2676 | mkdir ${localin[$i]} |
---|
2677 | if [[ $link_local_input = true ]] |
---|
2678 | then |
---|
2679 | printf " using ln -f\n" |
---|
2680 | cd ${absnamein[$i]} |
---|
2681 | for file in $(ls *) |
---|
2682 | do |
---|
2683 | ln -f $file ${localin[$i]} |
---|
2684 | done |
---|
2685 | cd $TEMPDIR |
---|
2686 | fi |
---|
2687 | |
---|
2688 | # IF "ln -f" FAILED OR IF "$link_local_input = false" DO A NORMAL "cp -r" |
---|
2689 | if [[ ! -f "${localin[$i]}/_0000" ]] |
---|
2690 | then |
---|
2691 | if [[ $link_local_input = true ]] |
---|
2692 | then |
---|
2693 | printf " ln failed for .../_0000, using cp...\n" |
---|
2694 | fi |
---|
2695 | cp -r ${absnamein[$i]}/* ${localin[$i]} |
---|
2696 | fi |
---|
2697 | |
---|
2698 | else |
---|
2699 | |
---|
2700 | # PROVIDE FILE FOR RUNS ON A SINGLE CORE |
---|
2701 | if [[ $link_local_input = true ]] |
---|
2702 | then |
---|
2703 | printf " using ln -f\n" |
---|
2704 | ln -f ${absnamein[$i]} ${localin[$i]} |
---|
2705 | fi |
---|
2706 | # If "ln -f" fails of if "$link_local_input = false" do a normal "cp" |
---|
2707 | if [[ ! -f "${localin[$i]}" ]] |
---|
2708 | then |
---|
2709 | if [[ $link_local_input = true ]] |
---|
2710 | then |
---|
2711 | printf " ln failed, using cp...\n" |
---|
2712 | fi |
---|
2713 | cp ${absnamein[$i]} ${localin[$i]} |
---|
2714 | fi |
---|
2715 | fi |
---|
2716 | fi |
---|
2717 | fi |
---|
2718 | |
---|
2719 | done |
---|
2720 | if (( i != 0 )) |
---|
2721 | then |
---|
2722 | printf "\n$dashes\n *** all INPUT-files provided \n" |
---|
2723 | fi |
---|
2724 | |
---|
2725 | |
---|
2726 | # EXECUTE INPUT-COMMANDS GIVEN IN THE CONFIGURATION FILE |
---|
2727 | (( i = 0 )) |
---|
2728 | while (( i < iic )) |
---|
2729 | do |
---|
2730 | (( i = i + 1 )) |
---|
2731 | if (( i == 1 )) |
---|
2732 | then |
---|
2733 | printf "\n\n *** execution of INPUT-commands:\n$dashes" |
---|
2734 | fi |
---|
2735 | printf "\n >>> ${in_command[$i]}" |
---|
2736 | eval ${in_command[$i]} |
---|
2737 | if (( i == iic )) |
---|
2738 | then |
---|
2739 | printf "\n$dashes\n" |
---|
2740 | fi |
---|
2741 | done |
---|
2742 | |
---|
2743 | |
---|
2744 | # SET THE REMAINING CPU-TIME |
---|
2745 | cpurest=${cpumax}. |
---|
2746 | |
---|
2747 | |
---|
2748 | # START DVR STREAMING SERVER |
---|
2749 | if [[ $(echo $package_list | grep -c dvrp_graphics) != 0 ]] |
---|
2750 | then |
---|
2751 | if [[ "$dvr_server" != "" ]] |
---|
2752 | then |
---|
2753 | |
---|
2754 | printf "\n\n *** preparing the dvr streaming server configuration file" |
---|
2755 | |
---|
2756 | # CHECK, IF A DVR SERVER IS ALREADY RUNNING |
---|
2757 | running_dvrserver_id=`echo $(ps -edaf | grep .dvrserver.config | grep -v grep) | cut -d" " -f2` |
---|
2758 | if [[ "$running_dvrserver_id" != "" ]] |
---|
2759 | then |
---|
2760 | |
---|
2761 | printf "\n\n +++ WARNING: A dvr server with id=$running_dvrserver_id is already running!" |
---|
2762 | printf "\n This server is used instead starting a new one!" |
---|
2763 | printf "\n If required, script \"process_dvr_output\" has to be run manually." |
---|
2764 | |
---|
2765 | else |
---|
2766 | |
---|
2767 | # COPY CONFIGURATION FILE FOR STREAMING SERVER FROM REPOSITORY TO HERE |
---|
2768 | if [[ -f ${PALM_BIN}/.dvrserver.config ]] |
---|
2769 | then |
---|
2770 | cp ${PALM_BIN}/.dvrserver.config . |
---|
2771 | |
---|
2772 | # ENTERING THE BASEDIR, UID AND GID INTO THIS FILE |
---|
2773 | user_id=`id -u` |
---|
2774 | group_id=`id -g` |
---|
2775 | |
---|
2776 | # "&" IS REQUIRED AS A SEPERATOR, BECAUSE TEMPDIR CONTAINS "/" |
---|
2777 | sed "s&<replace by dvr data directory>&${TEMPDIR}&g" .dvrserver.config > .dvrserver.1 |
---|
2778 | sed "s/<replace by user id>/$user_id/g" .dvrserver.1 > .dvrserver.2 |
---|
2779 | sed "s/<replace by group id>/$group_id/g" .dvrserver.2 > .dvrserver.3 |
---|
2780 | mv .dvrserver.3 .dvrserver.config |
---|
2781 | rm .dvrserver.1 .dvrserver.2 |
---|
2782 | |
---|
2783 | # START DVR SERVER IN BACKGROUND, GET HIS ID AND PRINT ON TERMINAL |
---|
2784 | $dvr_server .dvrserver.config >> DVR_LOGFILE 2>&1 & |
---|
2785 | dvrserver_id=`echo $(ps -edaf | grep .dvrserver.config) | cut -d" " -f2` |
---|
2786 | printf "\n *** streaming server with id=$dvrserver_id is started in background" |
---|
2787 | local_dvrserver_running=.TRUE. |
---|
2788 | else |
---|
2789 | printf "\n +++ missing file \".dvrserver.config\" in directory:" |
---|
2790 | printf "\n \"$PALM_BIN\" " |
---|
2791 | locat=dvr |
---|
2792 | exit |
---|
2793 | fi |
---|
2794 | |
---|
2795 | fi |
---|
2796 | |
---|
2797 | else |
---|
2798 | printf "\n\n --- INFORMATIVE: no dvr streaming server will be started" |
---|
2799 | fi |
---|
2800 | fi |
---|
2801 | |
---|
2802 | |
---|
2803 | # CREATE THE NAMELIST-FILE WITH VALUES OF ENVIRONMENT-VARIABLES REQUIRED BY PALM |
---|
2804 | # (FILE ENVPAR WILL BE READ BY PALM) |
---|
2805 | cat > ENVPAR << %%END%% |
---|
2806 | &envpar run_identifier = '$fname', host = '$localhost', |
---|
2807 | write_binary = '$write_binary', tasks_per_node = $tasks_per_node, |
---|
2808 | maximum_parallel_io_streams = $maximum_parallel_io_streams, |
---|
2809 | maximum_cpu_time_allowed = ${cpumax}., |
---|
2810 | revision = '$global_revision', |
---|
2811 | local_dvrserver_running = $local_dvrserver_running, |
---|
2812 | batch_job = $batch_job / |
---|
2813 | |
---|
2814 | %%END%% |
---|
2815 | |
---|
2816 | |
---|
2817 | # STARTING THE EXECUTABLE |
---|
2818 | printf "\n\n *** execution starts in directory\n \"`pwd`\"\n$dashes\n" |
---|
2819 | PATH=$PATH:$TEMPDIR |
---|
2820 | |
---|
2821 | |
---|
2822 | if [[ $execute_command != "none" ]] |
---|
2823 | then |
---|
2824 | |
---|
2825 | printf "\n +++ branch still not realized" |
---|
2826 | locat=execution |
---|
2827 | exit |
---|
2828 | |
---|
2829 | else |
---|
2830 | |
---|
2831 | # MPI DEBUG OPTION (ARGUMENT CHECKING, SLOWS DOWN EXECUTION DUE TO INCREASED LATENCY) |
---|
2832 | if [[ "$mpi_debug" = true ]] |
---|
2833 | then |
---|
2834 | export MPI_CHECK_ARGS=1 |
---|
2835 | printf "\n +++ MPI_CHECK_ARGS=$MPI_CHECK_ARGS" |
---|
2836 | fi |
---|
2837 | |
---|
2838 | if [[ "$totalview" = true ]] |
---|
2839 | then |
---|
2840 | printf "\n *** totalview debugger will be used" |
---|
2841 | tv_opt="-tv" |
---|
2842 | else |
---|
2843 | tv_opt="" |
---|
2844 | fi |
---|
2845 | |
---|
2846 | if [[ "$cond1" = debug || "$cond2" = debug ]] |
---|
2847 | then |
---|
2848 | |
---|
2849 | #Interactive ALLINEA DEBUG seesion |
---|
2850 | if [[ "$ENVIRONMENT" != BATCH ]] |
---|
2851 | then |
---|
2852 | if [[ $host = lccrayb || $host = lccrayh ]] |
---|
2853 | then |
---|
2854 | if [[ "$allinea" = true ]] |
---|
2855 | then |
---|
2856 | echo "--- aprun -n $ii -N $tasks_per_node a.out < runfile_atmos" |
---|
2857 | |
---|
2858 | ddt aprun -n $ii -N $tasks_per_node a.out |
---|
2859 | wait |
---|
2860 | fi |
---|
2861 | fi |
---|
2862 | fi |
---|
2863 | |
---|
2864 | if [[ $localhost = ibmh ]] |
---|
2865 | then |
---|
2866 | |
---|
2867 | # SETUP THE IBM MPI ENVIRONMENT |
---|
2868 | export MP_SHARED_MEMORY=yes |
---|
2869 | export AIXTHREADS_SCOPE=S |
---|
2870 | export OMP_NUM_THREADS=$threads_per_task |
---|
2871 | export AUTHSTATE=files |
---|
2872 | export XLFRTEOPTS="nlwidth=132:err_recovery=no" # RECORD-LENGTH OF NAMELIST-OUTPUT |
---|
2873 | |
---|
2874 | # FOLLOWING OPTIONS ARE MANDATORY FOR TOTALVIEW |
---|
2875 | export MP_ADAPTER_USE=shared |
---|
2876 | export MP_CPU_USE=multiple |
---|
2877 | export MP_TIMEOUT=1200 |
---|
2878 | |
---|
2879 | unset MP_TASK_AFFINITY |
---|
2880 | |
---|
2881 | if [[ "$LOADLBATCH" = yes ]] |
---|
2882 | then |
---|
2883 | totalview poe a.out |
---|
2884 | else |
---|
2885 | echo totalview poe -a a.out -procs $numprocs -rmpool 0 -nodes 1 |
---|
2886 | export TVDSVRLAUNCHCMD=ssh |
---|
2887 | totalview poe -a a.out -procs $numprocs -rmpool 0 -nodes 1 |
---|
2888 | fi |
---|
2889 | |
---|
2890 | fi # END DEBUG MODE |
---|
2891 | |
---|
2892 | else |
---|
2893 | |
---|
2894 | # NORMAL EXECUTION |
---|
2895 | if [[ -n $numprocs ]] |
---|
2896 | then |
---|
2897 | |
---|
2898 | # RUNNING THE PROGRAM ON PARALLEL MACHINES |
---|
2899 | if [[ $(echo $host | cut -c1-3) = ibm ]] |
---|
2900 | then |
---|
2901 | |
---|
2902 | # SETUP THE IBM MPI ENVIRONMENT |
---|
2903 | if [[ $host != ibmh && $host != ibmkisti ]] |
---|
2904 | then |
---|
2905 | export MP_SHARED_MEMORY=yes |
---|
2906 | export AIXTHREAD_SCOPE=S |
---|
2907 | export OMP_NUM_THREADS=$threads_per_task |
---|
2908 | export XLSMPOPTS="spins=0:yields=0:stack=20000000" |
---|
2909 | export AUTHSTATE=files |
---|
2910 | export XLFRTEOPTS="nlwidth=132:err_recovery=no" # RECORD-LENGTH OF NAMELIST-OUTPUT |
---|
2911 | # export MP_PRINTENV=yes |
---|
2912 | |
---|
2913 | # TUNING-VARIABLES TO IMPROVE COMMUNICATION SPEED |
---|
2914 | # DO NOT SHOW SIGNIFICANT EFFECTS (SEP 04, FEDERATION-SWITCH) |
---|
2915 | export MP_WAIT_MODE=poll |
---|
2916 | [[ $node_usage = not_shared ]] && export MP_SINGLE_THREAD=yes |
---|
2917 | fi |
---|
2918 | |
---|
2919 | if [[ $host = ibmkisti ]] |
---|
2920 | then |
---|
2921 | export LANG=en_US |
---|
2922 | export MP_SHARED_MEMORY=yes |
---|
2923 | if [[ $threads_per_task = 1 ]] |
---|
2924 | then |
---|
2925 | export MP_SINGLE_THREAD=yes |
---|
2926 | export MEMORY_AFFINITY=MCM |
---|
2927 | else |
---|
2928 | export OMP_NUM_THREADS=$threads_per_task |
---|
2929 | fi |
---|
2930 | fi |
---|
2931 | |
---|
2932 | if [[ "$LOADLBATCH" = yes ]] |
---|
2933 | then |
---|
2934 | printf "\n--- Control: OMP_NUM_THREADS = \"$OMP_NUM_THREADS\" \n" |
---|
2935 | if [[ "$cond1" = hpmcount || "$cond2" = hpmcount ]] |
---|
2936 | then |
---|
2937 | /opt/optibm/HPM_2_4_1/bin/hpmcount a.out |
---|
2938 | else |
---|
2939 | if [[ $run_coupled_model = false ]] |
---|
2940 | then |
---|
2941 | if [[ "$ocean_file_appendix" = true ]] |
---|
2942 | then |
---|
2943 | echo "precursor_ocean" > runfile_atmos |
---|
2944 | else |
---|
2945 | echo "precursor_atmos" > runfile_atmos |
---|
2946 | fi |
---|
2947 | else |
---|
2948 | (( iia = $numprocs_atmos / $threads_per_task )) |
---|
2949 | (( iio = $numprocs_ocean / $threads_per_task )) |
---|
2950 | printf "\n coupled run ($iia atmosphere, $iio ocean)" |
---|
2951 | printf "\n using $coupled_mode coupling" |
---|
2952 | printf "\n\n" |
---|
2953 | echo "coupled_run $iia $iio" > runfile_atmos |
---|
2954 | fi |
---|
2955 | poe ./a.out < runfile_atmos |
---|
2956 | fi |
---|
2957 | else |
---|
2958 | if [[ $localhost = ibmh || $localhost = ibms ]] |
---|
2959 | then |
---|
2960 | poe a.out -procs $numprocs -nodes 1 -rmpool 0 |
---|
2961 | elif [[ $localhost = ibmkisti || $localhost = ibmku ]] |
---|
2962 | then |
---|
2963 | if [[ -f $hostfile ]] |
---|
2964 | then |
---|
2965 | cp $hostfile hostfile |
---|
2966 | else |
---|
2967 | (( ii = 1 )) |
---|
2968 | while (( ii <= $numprocs )) |
---|
2969 | do |
---|
2970 | echo $localhost_realname >> hostfile |
---|
2971 | (( ii = ii + 1 )) |
---|
2972 | done |
---|
2973 | fi |
---|
2974 | export MP_HOSTFILE=hostfile |
---|
2975 | if [[ $run_coupled_model = false ]] |
---|
2976 | then |
---|
2977 | if [[ "$ocean_file_appendix" = true ]] |
---|
2978 | then |
---|
2979 | echo "precursor_ocean" > runfile_atmos |
---|
2980 | else |
---|
2981 | echo "precursor_atmos" > runfile_atmos |
---|
2982 | fi |
---|
2983 | else |
---|
2984 | (( iia = $numprocs_atmos / $threads_per_task )) |
---|
2985 | (( iio = $numprocs_ocean / $threads_per_task )) |
---|
2986 | printf "\n coupled run ($iia atmosphere, $iio ocean)" |
---|
2987 | printf "\n using $coupled_mode coupling" |
---|
2988 | printf "\n\n" |
---|
2989 | echo "coupled_run $iia $iio" > runfile_atmos |
---|
2990 | fi |
---|
2991 | |
---|
2992 | poe ./a.out -procs $numprocs < runfile_atmos |
---|
2993 | |
---|
2994 | else |
---|
2995 | if [[ "$host_file" = "" ]] |
---|
2996 | then |
---|
2997 | printf "\n +++ no hostfile given in configuration file" |
---|
2998 | locat=config_file |
---|
2999 | exit |
---|
3000 | else |
---|
3001 | eval host_file=$host_file |
---|
3002 | fi |
---|
3003 | export MP_HOSTFILE=$host_file |
---|
3004 | poe a.out -procs $numprocs -tasks_per_node $numprocs |
---|
3005 | fi |
---|
3006 | fi |
---|
3007 | |
---|
3008 | elif [[ $host = nech ]] # running on NEC machines |
---|
3009 | then |
---|
3010 | |
---|
3011 | (( ii = nodes )) |
---|
3012 | if [[ $ii = 1 ]] |
---|
3013 | then |
---|
3014 | export F_ERRCNT=0 # acceptable number of errors before program is stopped |
---|
3015 | export MPIPROGINF=YES |
---|
3016 | # export F_TRACE=YES|FMT1|FMT2 # output of ftrace informations to job protocol |
---|
3017 | echo "*** execution on single node with mpirun" |
---|
3018 | mpirun -np $numprocs ./a.out |
---|
3019 | else |
---|
3020 | (( i = 0 )) |
---|
3021 | while (( i < ii )) |
---|
3022 | do |
---|
3023 | echo "-h $i -p $tasks_per_node -e ./mpi_exec_shell" >> multinode_config |
---|
3024 | (( i = i + 1 )) |
---|
3025 | done |
---|
3026 | |
---|
3027 | echo "#!/bin/sh" > mpi_exec_shell |
---|
3028 | echo " " >> mpi_exec_shell |
---|
3029 | echo "set -u" >> mpi_exec_shell |
---|
3030 | echo "F_ERRCNT=0" >> mpi_exec_shell |
---|
3031 | echo "MPIPROGINV=YES" >> mpi_exec_shell |
---|
3032 | echo "OMP_NUM_THREADS=$threads_per_task" >> mpi_exec_shell |
---|
3033 | echo "cpurest=$cpurest" >> mpi_exec_shell |
---|
3034 | echo "fname=$fname" >> mpi_exec_shell |
---|
3035 | echo "localhost=$localhost" >> mpi_exec_shell |
---|
3036 | echo "return_address=$return_address" >> mpi_exec_shell |
---|
3037 | echo "return_username=$return_username" >> mpi_exec_shell |
---|
3038 | echo "tasks_per_node=$tasks_per_node" >> mpi_exec_shell |
---|
3039 | echo "write_binary=$write_binary" >> mpi_exec_shell |
---|
3040 | echo "use_seperate_pe_for_dvrp_output=$use_seperate_pe_for_dvrp_output" >> mpi_exec_shell |
---|
3041 | echo " " >> mpi_exec_shell |
---|
3042 | echo "export F_ERRCNT" >> mpi_exec_shell |
---|
3043 | echo "export MPIPROGINV" >> mpi_exec_shell |
---|
3044 | echo "export OMP_NUM_THREADS" >> mpi_exec_shell |
---|
3045 | echo "export cpurest" >> mpi_exec_shell |
---|
3046 | echo "export fname" >> mpi_exec_shell |
---|
3047 | echo "export localhost" >> mpi_exec_shell |
---|
3048 | echo "export return_address" >> mpi_exec_shell |
---|
3049 | echo "export return_username" >> mpi_exec_shell |
---|
3050 | echo "export tasks_per_node" >> mpi_exec_shell |
---|
3051 | echo "export write_binary" >> mpi_exec_shell |
---|
3052 | echo "export use_seperate_pe_for_dvrp_output" >> mpi_exec_shell |
---|
3053 | echo " " >> mpi_exec_shell |
---|
3054 | echo "exec ./a.out" >> mpi_exec_shell |
---|
3055 | |
---|
3056 | chmod u+x mpi_exec_shell |
---|
3057 | export MPIPROGINF=YES |
---|
3058 | mpirun -f multinode_config & |
---|
3059 | wait |
---|
3060 | |
---|
3061 | fi |
---|
3062 | |
---|
3063 | elif [[ $(echo $host | cut -c1-2) = lc && $host != lckyoto && $host != lctit ]] |
---|
3064 | then |
---|
3065 | |
---|
3066 | # COPY HOSTFILE FROM SOURCE DIRECTORY OR CREATE IT, IF IT |
---|
3067 | # DOES NOT EXIST |
---|
3068 | if [[ $host != lcbullhh && $host != lccrayb && $host != lccrayf && $host != lccrayh && $host != lckyuh && $host != lckyut ]] |
---|
3069 | then |
---|
3070 | if [[ -f $hostfile ]] |
---|
3071 | then |
---|
3072 | cp $hostfile hostfile |
---|
3073 | (( ii = $numprocs / $threads_per_task )) |
---|
3074 | [[ $ii = 0 ]] && (( ii = 1 )) |
---|
3075 | else |
---|
3076 | (( ii = 1 )) |
---|
3077 | while (( ii <= $numprocs / $threads_per_task )) |
---|
3078 | do |
---|
3079 | echo $localhost_realname >> hostfile |
---|
3080 | (( ii = ii + 1 )) |
---|
3081 | done |
---|
3082 | if (( $numprocs / $threads_per_task == 0 )) |
---|
3083 | then |
---|
3084 | echo $localhost_realname >> hostfile |
---|
3085 | fi |
---|
3086 | fi |
---|
3087 | eval zeile=\"`head -n $ii hostfile`\" |
---|
3088 | printf "\n *** running on: $zeile" |
---|
3089 | fi |
---|
3090 | |
---|
3091 | (( ii = $numprocs / $threads_per_task )) |
---|
3092 | [[ $ii = 0 ]] && (( ii = 1 )) |
---|
3093 | export OMP_NUM_THREADS=$threads_per_task |
---|
3094 | |
---|
3095 | if [[ $threads_per_task != 1 ]] |
---|
3096 | then |
---|
3097 | # INCREASE STACK SIZE TO UNLIMITED, BECAUSE OTHERWISE LARGE RUNS |
---|
3098 | # MAY ABORT |
---|
3099 | ulimit -s unlimited |
---|
3100 | printf "\n threads per task: $threads_per_task stacksize: unlimited" |
---|
3101 | fi |
---|
3102 | if [[ $run_coupled_model = false ]] |
---|
3103 | then |
---|
3104 | if [[ "$ocean_file_appendix" = true ]] |
---|
3105 | then |
---|
3106 | echo "precursor_ocean" > runfile_atmos |
---|
3107 | else |
---|
3108 | echo "precursor_atmos" > runfile_atmos |
---|
3109 | fi |
---|
3110 | printf "\n\n" |
---|
3111 | |
---|
3112 | if [[ $host = lccrayb || $host = lccrayh ]] |
---|
3113 | then |
---|
3114 | echo "--- aprun -n $ii -N $tasks_per_node a.out < runfile_atmos" |
---|
3115 | aprun -n $ii -N $tasks_per_node a.out < runfile_atmos |
---|
3116 | elif [[ $host = lcbullhh ]] |
---|
3117 | then |
---|
3118 | export OMPI_MCA_pml=cm |
---|
3119 | export OMPI_MCA_mtl=mxm |
---|
3120 | export OMPI_MCA_coll=^ghc |
---|
3121 | export OMPI_MCA_mtl_mxm_np=0 |
---|
3122 | export MXM_RDMA_PORTS=mlx5_0:1 |
---|
3123 | export MXM_LOG_LEVEL=ERROR |
---|
3124 | export OMP_NUM_THREADS=$threads_per_task |
---|
3125 | export KMP_AFFINITY=verbose,granularity=core,compact,1 |
---|
3126 | export KMP_STACKSIZE=64m |
---|
3127 | |
---|
3128 | srun --nodes=$nodes --ntasks-per-node=$tasks_per_node ./a.out < runfile_atmos |
---|
3129 | |
---|
3130 | elif [[ $host = lccrayf ]] |
---|
3131 | then |
---|
3132 | aprun -j1 -n $ii -N $tasks_per_node -m ${memory}M a.out < runfile_atmos |
---|
3133 | elif [[ $host = lcxe6 || $host = lcxt5m ]] |
---|
3134 | then |
---|
3135 | aprun -n $ii -N $tasks_per_node a.out < runfile_atmos |
---|
3136 | elif [[ $host = lcflow ]] |
---|
3137 | then |
---|
3138 | mpirun -np $ii a.out < runfile_atmos |
---|
3139 | elif [[ $host = lcsb ]] |
---|
3140 | then |
---|
3141 | mpirun_rsh -hostfile $PBS_NODEFILE -np `cat $PBS_NODEFILE | wc -l` a.out < runfile_atmos |
---|
3142 | elif [[ $host = lckiaps ]] |
---|
3143 | then |
---|
3144 | mpirun -np $ii -f $PBS_NODEFILE a.out < runfile_atmos |
---|
3145 | elif [[ $host = lckyu* ]] |
---|
3146 | then |
---|
3147 | mpiexec -n $ii --stdin runfile_atmos ./a.out |
---|
3148 | else |
---|
3149 | mpiexec -machinefile hostfile -n $ii a.out < runfile_atmos |
---|
3150 | fi |
---|
3151 | |
---|
3152 | else |
---|
3153 | |
---|
3154 | # CURRENTLY THERE IS NO FULL MPI-2 SUPPORT ON ICE AND XT4 |
---|
3155 | (( iia = $numprocs_atmos / $threads_per_task )) |
---|
3156 | (( iio = $numprocs_ocean / $threads_per_task )) |
---|
3157 | printf "\n coupled run ($iia atmosphere, $iio ocean)" |
---|
3158 | printf "\n using $coupled_mode coupling" |
---|
3159 | printf "\n\n" |
---|
3160 | |
---|
3161 | if [[ $coupled_mode = "mpi2" ]] |
---|
3162 | then |
---|
3163 | echo "atmosphere_to_ocean $iia $iio" > runfile_atmos |
---|
3164 | echo "ocean_to_atmosphere $iia $iio" > runfile_ocean |
---|
3165 | |
---|
3166 | if [[ $host = lccrayf || $host = lcxe6 || $host = lcxt5m ]] |
---|
3167 | then |
---|
3168 | |
---|
3169 | aprun -n $iia -N $tasks_per_node a.out < runfile_atmos & |
---|
3170 | aprun -n $iio -N $tasks_per_node a.out < runfile_ocean & |
---|
3171 | |
---|
3172 | else |
---|
3173 | # WORKAROUND BECAUSE mpiexec WITH -env option IS NOT AVAILABLE ON SOME SYSTEMS |
---|
3174 | mpiexec -machinefile hostfile -n $iia a.out < runfile_atmos & |
---|
3175 | mpiexec -machinefile hostfile -n $iio a.out < runfile_ocean & |
---|
3176 | # mpiexec -machinefile hostfile -n $iia -env coupling_mode atmosphere_to_ocean a.out & |
---|
3177 | # mpiexec -machinefile hostfile -n $iio -env coupling_mode ocean_to_atmosphere a.out & |
---|
3178 | fi |
---|
3179 | wait |
---|
3180 | |
---|
3181 | else |
---|
3182 | |
---|
3183 | echo "coupled_run $iia $iio" > runfile_atmos |
---|
3184 | |
---|
3185 | if [[ $host = lccrayf || $host = lcxe6 || $host = lcxt5m ]] |
---|
3186 | then |
---|
3187 | |
---|
3188 | aprun -n $ii -N $tasks_per_node a.out < runfile_atmos |
---|
3189 | |
---|
3190 | elif [[ $host = lck || $host = lckordi ]] |
---|
3191 | then |
---|
3192 | |
---|
3193 | mpiexec -n $ii ./a.out < runfile_atmos & |
---|
3194 | |
---|
3195 | elif [[ $host = lckyu* ]] |
---|
3196 | then |
---|
3197 | |
---|
3198 | mpiexec -n $ii --stdin runfile_atmos ./a.out |
---|
3199 | |
---|
3200 | elif [[ $host = lcmuk ]] |
---|
3201 | then |
---|
3202 | |
---|
3203 | mpiexec -machinefile hostfile -n $ii a.out < runfile_atmos |
---|
3204 | |
---|
3205 | fi |
---|
3206 | wait |
---|
3207 | fi |
---|
3208 | |
---|
3209 | fi |
---|
3210 | |
---|
3211 | elif [[ $host = lckyoto ]] |
---|
3212 | then |
---|
3213 | set -xv |
---|
3214 | export P4_RSHCOMMAND=plesh |
---|
3215 | echo " P4_RSHCOMMAND = $P4_RSHCOMMAND" |
---|
3216 | if [[ "$ENVIRONMENT" = BATCH ]] |
---|
3217 | then |
---|
3218 | if [[ "$cond2" = fujitsu ]] |
---|
3219 | then |
---|
3220 | mpiexec -n $numprocs ./a.out # for fujitsu-compiler |
---|
3221 | elif [[ "cond2" = pgi ]] |
---|
3222 | then |
---|
3223 | mpirun -np $numprocs -machinefile ${QSUB_NODEINF} ./a.out |
---|
3224 | else |
---|
3225 | mpirun_rsh -np $numprocs -hostfile ${QSUB_NODEINF} MV2_USE_SRQ=0 ./a.out || /bin/true |
---|
3226 | fi |
---|
3227 | else |
---|
3228 | if [[ "$cond2" = "" ]] |
---|
3229 | then |
---|
3230 | mpiruni_rsh -np $numprocs ./a.out # for intel |
---|
3231 | else |
---|
3232 | mpirun -np $numprocs ./a.out |
---|
3233 | fi |
---|
3234 | fi |
---|
3235 | set +xv |
---|
3236 | |
---|
3237 | elif [[ $host = lctit ]] |
---|
3238 | then |
---|
3239 | export OMP_NUM_THREADS=$threads_per_task |
---|
3240 | echo "OMP_NUM_THREADS=$OMP_NUM_THREADS" |
---|
3241 | if [[ "$threads_per_task" != 1 ]] |
---|
3242 | then |
---|
3243 | export MV2_ENABLE_AFFINITY=0 |
---|
3244 | fi |
---|
3245 | echo "----- PBS_NODEFILE content:" |
---|
3246 | cat $PBS_NODEFILE |
---|
3247 | echo "-----" |
---|
3248 | (( ii = $numprocs / $threads_per_task )) |
---|
3249 | echo "mpirun -np $ii -hostfile $PBS_NODEFILE ./a.out" |
---|
3250 | mpirun -np $ii -hostfile $PBS_NODEFILE ./a.out |
---|
3251 | |
---|
3252 | else |
---|
3253 | mpprun -n $numprocs a.out |
---|
3254 | fi |
---|
3255 | else |
---|
3256 | a.out |
---|
3257 | fi |
---|
3258 | |
---|
3259 | fi # end normal (non-debug) execution |
---|
3260 | |
---|
3261 | fi # end explicit execute_command or host-specific execute actions |
---|
3262 | |
---|
3263 | if [[ $? != 0 ]] |
---|
3264 | then |
---|
3265 | |
---|
3266 | # ABORT IN CASE OF RUNTIME ERRORS |
---|
3267 | printf "\n +++ runtime error occured" |
---|
3268 | locat=execution |
---|
3269 | exit |
---|
3270 | |
---|
3271 | else |
---|
3272 | |
---|
3273 | printf "\n$dashes\n *** execution finished \n" |
---|
3274 | |
---|
3275 | # STOP THE DVR STREAMING SERVER AND PROCESS THE DVR OUTPUT IN ORDER |
---|
3276 | # TO CREAT DVRS- AND HTML-FILES CONTAINING ALL STREAMS |
---|
3277 | if [[ "$dvrserver_id" != "" ]] |
---|
3278 | then |
---|
3279 | kill $dvrserver_id |
---|
3280 | printf "\n *** dvr server with id=$dvrserver_id has been stopped" |
---|
3281 | |
---|
3282 | # IF THERE IS A DIRECTORY, DATA HAVE BEEN OUTPUT BY THE |
---|
3283 | # STREAMING SERVER. OTHERWISE, USER HAS CHOSEN dvrp_output=local |
---|
3284 | if [[ -d DATA_DVR ]] |
---|
3285 | then |
---|
3286 | |
---|
3287 | # ADD THE CURRENT DVR CONFIGURATION FILE TO THE DVR OUTPUT |
---|
3288 | # DIRECTORY |
---|
3289 | cp .dvrserver.config DATA_DVR |
---|
3290 | |
---|
3291 | # PROCESS THE DVR OUTPUT (OPTION -s FOR GENERATING |
---|
3292 | # SEQUENCE MODE DATA TOO) |
---|
3293 | process_dvr_output -d DATA_DVR -f $fname -s |
---|
3294 | |
---|
3295 | else |
---|
3296 | |
---|
3297 | # PROCESS THE LOCAL OUTPUT |
---|
3298 | process_dvr_output -l -d DATA_DVR -f $fname |
---|
3299 | |
---|
3300 | fi |
---|
3301 | |
---|
3302 | elif [[ $(echo $package_list | grep -c dvrp_graphics) != 0 ]] |
---|
3303 | then |
---|
3304 | |
---|
3305 | # PROCESS DVR OUTPUT GENERATD IN LOCAL MODE (dvrp_output=local) |
---|
3306 | process_dvr_output -l -d DATA_DVR -f $fname |
---|
3307 | |
---|
3308 | fi |
---|
3309 | fi |
---|
3310 | |
---|
3311 | |
---|
3312 | |
---|
3313 | # CALL OF combine_plot_fields IN ORDER TO MERGE SINGLE FILES WRITTEN |
---|
3314 | # BY EACH CORE INTO ONE FILE |
---|
3315 | if [[ ! -f ${PALM_BIN}/combine_plot_fields${block}.x ]] |
---|
3316 | then |
---|
3317 | printf "\n\n\n +++ WARNING: no combine_plot_fields found for given block \"$cond1 $cond2\"" |
---|
3318 | printf "\n 2d- and/or 3d-data may be incomplete!" |
---|
3319 | printf "\n Run \"mbuild -u -h $localhost\" to generate utilities for this block.\n" |
---|
3320 | elif [[ "$combine_plot_fields" == true ]] |
---|
3321 | then |
---|
3322 | if [[ $localhost = lccrayh || $localhost = lccrayb ]] |
---|
3323 | then |
---|
3324 | printf "\n\n\n *** post-processing: now executing \"aprun -n 1 -N 1 combine_plot_fields${block}.x\" ..." |
---|
3325 | aprun -n 1 -N 1 combine_plot_fields${block}.x |
---|
3326 | else |
---|
3327 | printf "\n\n\n *** post-processing: now executing \"combine_plot_fields${block}.x\" ..." |
---|
3328 | combine_plot_fields${block}.x |
---|
3329 | fi |
---|
3330 | else |
---|
3331 | |
---|
3332 | # TEMPORARY SOLUTION TO SKIP combine_plot_fields. THIS IS REQUIRED IN CASE OF HUGE AMOUNT OF |
---|
3333 | # DATA OUTPUT. TO DO: EXTEND THIS BRANCH BY CREATING A BATCH JOB for combine_plot_fields. |
---|
3334 | # ??? koennen wir das streichen ??? |
---|
3335 | printf "\n\n\n *** post-processing: skipping combine_plot_fields (-Z option set) ..." |
---|
3336 | fi |
---|
3337 | |
---|
3338 | |
---|
3339 | |
---|
3340 | # EXECUTE OUTPUT-COMMANDS GIVEN IN THE CONFIGURATION FILE |
---|
3341 | (( i = 0 )) |
---|
3342 | while (( i < ioc )) |
---|
3343 | do |
---|
3344 | (( i = i + 1 )) |
---|
3345 | if (( i == 1 )) |
---|
3346 | then |
---|
3347 | printf "\n\n *** execution of OUTPUT-commands:\n$dashes" |
---|
3348 | fi |
---|
3349 | printf "\n >>> ${out_command[$i]}" |
---|
3350 | eval ${out_command[$i]} |
---|
3351 | if (( i == ioc )) |
---|
3352 | then |
---|
3353 | printf "\n$dashes\n" |
---|
3354 | fi |
---|
3355 | done |
---|
3356 | |
---|
3357 | |
---|
3358 | # IN TRACE-MODE PRINT CONTENTS OF THE CURRENT (TEMPORARY) WORKING DIRECTORY |
---|
3359 | if [[ $do_trace = true ]] |
---|
3360 | then |
---|
3361 | printf "\n\n" |
---|
3362 | ls -al |
---|
3363 | fi |
---|
3364 | |
---|
3365 | |
---|
3366 | |
---|
3367 | # COPY LOCAL OUTPUT-FILES TO THEIR PERMANENT DESTINATIONS |
---|
3368 | (( i = 0 )) |
---|
3369 | while (( i < iout )) |
---|
3370 | do |
---|
3371 | (( i = i + 1 )) |
---|
3372 | if (( i == 1 )) |
---|
3373 | then |
---|
3374 | printf "\n\n *** saving OUTPUT-files:\n$dashes" |
---|
3375 | fi |
---|
3376 | |
---|
3377 | # CHECK FOR SINGLE FILE (SERIAL RUN) OR DIRECTORY (ONE FILE PER CORE FOR PARELLEL EXECUTION) |
---|
3378 | files_for_pes=false; filetyp=file |
---|
3379 | if [[ "${actionout[$i]}" = pe && -n $numprocs ]] |
---|
3380 | then |
---|
3381 | files_for_pes=true; filetyp=directory |
---|
3382 | actionout[$i]="" |
---|
3383 | elif [[ "${actionout[$i]}" = pe && ! -n $numprocs ]] |
---|
3384 | then |
---|
3385 | actionout[$i]="" |
---|
3386 | elif [[ "${actionout[$i]}" = arpe && -n $numprocs ]] |
---|
3387 | then |
---|
3388 | files_for_pes=true; filetyp=directory |
---|
3389 | actionout[$i]="ar" |
---|
3390 | elif [[ "${actionout[$i]}" = arpe && ! -n $numprocs ]] |
---|
3391 | then |
---|
3392 | actionout[$i]="ar" |
---|
3393 | elif [[ "${actionout[$i]}" = flpe && -n $numprocs ]] |
---|
3394 | then |
---|
3395 | files_for_pes=true; filetyp=directory |
---|
3396 | actionout[$i]="fl" |
---|
3397 | elif [[ "${actionout[$i]}" = flpe && ! -n $numprocs ]] |
---|
3398 | then |
---|
3399 | actionout[$i]="fl" |
---|
3400 | elif [[ "${actionout[$i]}" = trpe && -n $numprocs ]] |
---|
3401 | then |
---|
3402 | files_for_pes=true; filetyp=directory |
---|
3403 | actionout[$i]="tr" |
---|
3404 | elif [[ "${actionout[$i]}" = trpe && ! -n $numprocs ]] |
---|
3405 | then |
---|
3406 | actionout[$i]="tr" |
---|
3407 | fi |
---|
3408 | |
---|
3409 | if [[ ! -f ${localout[$i]} && $files_for_pes = false ]] |
---|
3410 | then |
---|
3411 | printf "\n +++ temporary OUTPUT-file ${localout[$i]} does not exist\n" |
---|
3412 | elif [[ ! -d ${localout[$i]} && $files_for_pes = true ]] |
---|
3413 | then |
---|
3414 | printf "\n +++ temporary OUTPUT-file ${localout[$i]}/.... does not exist\n" |
---|
3415 | else |
---|
3416 | |
---|
3417 | |
---|
3418 | # COPY VIA SCP TO LOCAL HOST (ALWAYS IN BINARY MODE USING batch_scp option -m) |
---|
3419 | # IF TARGET DIRECTORY DOES NOT EXISTS, TRY TO CREATE IT |
---|
3420 | if [[ "${actionout[$i]}" = tr ]] |
---|
3421 | then |
---|
3422 | if [[ $localhost != $fromhost ]] |
---|
3423 | then |
---|
3424 | if [[ $files_for_pes = false ]] |
---|
3425 | then |
---|
3426 | cps="" |
---|
3427 | cst="" |
---|
3428 | else |
---|
3429 | cps=-c |
---|
3430 | cst="/" |
---|
3431 | fi |
---|
3432 | if [[ $localhost = nech ]] |
---|
3433 | then |
---|
3434 | |
---|
3435 | # TRANSFER IN SEPERATE JOB |
---|
3436 | # FIRST COPY FILE TO TEMPORY DATA DIRECTORY |
---|
3437 | [[ ! -d $tmp_data_catalog/TRANSFER ]] && mkdir -p $tmp_data_catalog/TRANSFER |
---|
3438 | file_to_transfer=${fname}_${localout[$i]}_to_transfer_$kennung |
---|
3439 | if [[ $files_for_pes = false ]] |
---|
3440 | then |
---|
3441 | ln -f ${localout[$i]} $tmp_data_catalog/TRANSFER/$file_to_transfer |
---|
3442 | else |
---|
3443 | mkdir $tmp_data_catalog/TRANSFER/$file_to_transfer |
---|
3444 | ln ${localout[$i]}/* $tmp_data_catalog/TRANSFER/$file_to_transfer |
---|
3445 | fi |
---|
3446 | |
---|
3447 | echo "set -x" > transfer_${localout[$i]} |
---|
3448 | echo "cd $tmp_data_catalog/TRANSFER" >> transfer_${localout[$i]} |
---|
3449 | |
---|
3450 | printf "\n >>> OUTPUT: ${localout[$i]}$cst by SCP in seperate job to" |
---|
3451 | printf "\n ${pathout[$i]}/${localhost}_${fname}${endout[$i]}$cst" |
---|
3452 | printf "\n or higher cycle\n" |
---|
3453 | echo "batch_scp $PORTOPT $cps -b -m -u $return_username $return_address $file_to_transfer \"${pathout[$i]}\" ${localhost}_${fname}${endout[$i]} ${extout[$i]}" >> transfer_${localout[$i]} |
---|
3454 | |
---|
3455 | echo "[[ \$? = 0 ]] && rm $file_to_transfer" >> transfer_${localout[$i]} |
---|
3456 | |
---|
3457 | if [[ $localhost = nech ]] |
---|
3458 | then |
---|
3459 | subjob -d -c /pf/b/$usern/job_queue -v -q pp -X 0 -m 1000 -t 900 $PORTOPT transfer_${localout[$i]} |
---|
3460 | else |
---|
3461 | if [[ "$LOGNAME" = b323013 ]] |
---|
3462 | then |
---|
3463 | subjob -v -q c1 -X 0 -m 1000 -t 900 -c $job_catalog $PORTOPT transfer_${localout[$i]} |
---|
3464 | else |
---|
3465 | subjob -d -v -q c1 -X 0 -m 1000 -t 900 -c $job_catalog $PORTOPT transfer_${localout[$i]} |
---|
3466 | fi |
---|
3467 | fi |
---|
3468 | |
---|
3469 | else |
---|
3470 | |
---|
3471 | # TRANSFER WITHIN THIS JOB |
---|
3472 | transfer_failed=false |
---|
3473 | printf "\n >>> OUTPUT: ${localout[$i]}$cst by SCP to" |
---|
3474 | printf "\n ${pathout[$i]}/${localhost}_${fname}${endout[$i]}$cst\n" |
---|
3475 | if [[ $localhost = lccrayb ]] |
---|
3476 | then |
---|
3477 | ssh $usern@blogin1 ". \\$HOME/.profile; cd $TEMPDIR; batch_scp $PORTOPT $cps -b -m -u $return_username $return_address ${localout[$i]} \"${pathout[$i]}\" ${localhost}_${fname}${endout[$i]} ${extout[$i]}" |
---|
3478 | elif [[ $localhost = lccrayh ]] |
---|
3479 | then |
---|
3480 | ssh $usern@hlogin1 ". \\$HOME/.profile; cd $TEMPDIR; batch_scp $PORTOPT $cps -b -m -u $return_username $return_address ${localout[$i]} \"${pathout[$i]}\" ${localhost}_${fname}${endout[$i]} ${extout[$i]}" |
---|
3481 | elif [[ $localhost = lcbullhh ]] |
---|
3482 | then |
---|
3483 | ssh $usern@mlogin101 ". \\$HOME/.profile; cd $TEMPDIR; batch_scp $PORTOPT $cps -b -m -u $return_username $return_address ${localout[$i]} \"${pathout[$i]}\" ${localhost}_${fname}${endout[$i]} ${extout[$i]}" |
---|
3484 | elif [[ $localhost = lcxe6 ]] |
---|
3485 | then |
---|
3486 | ssh $usern@hexagon ". \\$HOME/.profile; cd $TEMPDIR; batch_scp $PORTOPT $cps -b -m -u $return_username $return_address ${localout[$i]} \"${pathout[$i]}\" ${localhost}_${fname}${endout[$i]} ${extout[$i]}" |
---|
3487 | else |
---|
3488 | batch_scp $PORTOPT $cps -b -m -u $return_username $return_address ${localout[$i]} "${pathout[$i]}" ${localhost}_${fname}${endout[$i]} ${extout[$i]} |
---|
3489 | fi |
---|
3490 | [[ $? != 0 ]] && transfer_failed=true |
---|
3491 | |
---|
3492 | # IF TRANSFER FAILED, CREATE BACKUP COPY ON THIS MACHINE |
---|
3493 | if [[ $transfer_failed = true ]] |
---|
3494 | then |
---|
3495 | printf " +++ transfer failed. Trying to save a copy on this host under:\n" |
---|
3496 | printf " ${pathout[$i]}/${localhost}_${fname}${endout[$i]}_$kennung\n" |
---|
3497 | |
---|
3498 | # FIRST CHECK, IF DIRECTORY EXISTS, AND CREATE IT, IF NECESSARY |
---|
3499 | eval local_catalog=${pathout[$i]} |
---|
3500 | if [[ ! -d $local_catalog ]] |
---|
3501 | then |
---|
3502 | printf " *** local directory does not exist. Trying to create:\n" |
---|
3503 | printf " $local_catalog \n" |
---|
3504 | mkdir -p $local_catalog |
---|
3505 | fi |
---|
3506 | eval cp ${localout[$i]} ${pathout[$i]}/${localhost}_${fname}${endout[$i]}_$kennung |
---|
3507 | transfer_problems=true |
---|
3508 | fi |
---|
3509 | fi |
---|
3510 | else |
---|
3511 | |
---|
3512 | # UNSET actionout. DUE TO THIS SETTING, FILE WILL LATER JUST BE COPIED ON THIS MACHINE |
---|
3513 | actionout[$i]="" |
---|
3514 | fi |
---|
3515 | fi |
---|
3516 | |
---|
3517 | |
---|
3518 | # APPEND VIA SCP TO LOCAL HOST (ALWAYS IN BINARY MODE USING batch_scp option -m) |
---|
3519 | # IF TARGET DIRECTORY DOES NOT EXISTS, TRY TO CREATE IT |
---|
3520 | if [[ "${actionout[$i]}" = tra ]] |
---|
3521 | then |
---|
3522 | if [[ $localhost != $fromhost ]] |
---|
3523 | then |
---|
3524 | if [[ $localhost = ibmh || $localhost = nech ]] |
---|
3525 | then |
---|
3526 | |
---|
3527 | # TRANSFER IN SEPERATE JOB |
---|
3528 | # FIRST COPY FILE TO TEMPORY DATA DIRECTORY |
---|
3529 | [[ ! -d $tmp_data_catalog/TRANSFER ]] && mkdir -p $tmp_data_catalog/TRANSFER |
---|
3530 | file_to_transfer=${fname}_${localout[$i]}_to_transfer_$kennung |
---|
3531 | ln -f ${localout[$i]} $tmp_data_catalog/TRANSFER/$file_to_transfer |
---|
3532 | |
---|
3533 | echo "set -x" > transfer_${localout[$i]} |
---|
3534 | echo "cd $tmp_data_catalog/TRANSFER" >> transfer_${localout[$i]} |
---|
3535 | |
---|
3536 | printf "\n >>> OUTPUT: ${localout[$i]} append by SCP in seperate job to" |
---|
3537 | printf "\n ${pathout[$i]}/${localhost}_${fname}${endout[$i]}" |
---|
3538 | printf "\n or higher cycle\n" |
---|
3539 | echo "batch_scp $PORTOPT -A -b -m -u $return_username $return_address $file_to_transfer \"${pathout[$i]}\" ${localhost}_${fname}${endout[$i]} ${extout[$i]}" >> transfer_${localout[$i]} |
---|
3540 | |
---|
3541 | echo "[[ \$? = 0 ]] && rm $file_to_transfer" >> transfer_${localout[$i]} |
---|
3542 | |
---|
3543 | if [[ $localhost = nech ]] |
---|
3544 | then |
---|
3545 | subjob -d -c /pf/b/$usern/job_queue -v -q pp -X 0 -m 1000 -t 900 $PORTOPT transfer_${localout[$i]} |
---|
3546 | else |
---|
3547 | if [[ $LOGNAME = b323013 ]] |
---|
3548 | then |
---|
3549 | subjob -v -q c1 -X 0 -m 1000 -t 900 -c $job_catalog $PORTOPT transfer_${localout[$i]} |
---|
3550 | else |
---|
3551 | subjob -d -v -q c1 -X 0 -m 1000 -t 900 -c $job_catalog $PORTOPT transfer_${localout[$i]} |
---|
3552 | fi |
---|
3553 | fi |
---|
3554 | |
---|
3555 | else |
---|
3556 | |
---|
3557 | # TRANSFER WITHIN THIS JOB |
---|
3558 | transfer_failed=false |
---|
3559 | printf "\n >>> OUTPUT: ${localout[$i]} append by SCP to" |
---|
3560 | printf "\n ${pathout[$i]}/${localhost}_${fname}${endout[$i]}\n" |
---|
3561 | if [[ $localhost = lccrayb ]] |
---|
3562 | then |
---|
3563 | ssh $usern@blogin1 ". \\$HOME/.profile; cd $TEMPDIR; batch_scp $PORTOPT -A -b -m -u $return_username $return_address ${localout[$i]} \"${pathout[$i]}\" ${localhost}_${fname}${endout[$i]} ${extout[$i]}" |
---|
3564 | elif [[ $localhost = lccrayh ]] |
---|
3565 | then |
---|
3566 | ssh $usern@hlogin1 ". \\$HOME/.profile; cd $TEMPDIR; batch_scp $PORTOPT -A -b -m -u $return_username $return_address ${localout[$i]} \"${pathout[$i]}\" ${localhost}_${fname}${endout[$i]} ${extout[$i]}" |
---|
3567 | elif [[ $localhost = lcxe6 ]] |
---|
3568 | then |
---|
3569 | ssh $usern@hexagon ". \\$HOME/.profile; cd $TEMPDIR; batch_scp $PORTOPT -A -b -m -u $return_username $return_address ${localout[$i]} \"${pathout[$i]}\" ${localhost}_${fname}${endout[$i]} ${extout[$i]}" |
---|
3570 | else |
---|
3571 | batch_scp $PORTOPT -A -b -m -u $return_username $return_address ${localout[$i]} "${pathout[$i]}" ${localhost}_${fname}${endout[$i]} ${extout[$i]} |
---|
3572 | fi |
---|
3573 | [[ $? != 0 ]] && transfer_failed=true |
---|
3574 | |
---|
3575 | # IF TRANSFER FAILED, CREATE BACKUP COPY ON THIS MACHINE |
---|
3576 | if [[ $transfer_failed = true ]] |
---|
3577 | then |
---|
3578 | printf " +++ transfer failed. Trying to save a copy on this host under:\n" |
---|
3579 | printf " ${pathout[$i]}/${localhost}_${fname}${endout[$i]}_$kennung\n" |
---|
3580 | |
---|
3581 | # FIRST CHECK, IF DIRECTORY EXISTS, AND CREATE IT, IF NECESSARY |
---|
3582 | eval local_catalog=${pathout[$i]} |
---|
3583 | if [[ ! -d $local_catalog ]] |
---|
3584 | then |
---|
3585 | printf " *** local directory does not exist. Trying to create:\n" |
---|
3586 | printf " $local_catalog \n" |
---|
3587 | mkdir -p $local_catalog |
---|
3588 | fi |
---|
3589 | |
---|
3590 | eval cp ${localout[$i]} ${pathout[$i]}/${localhost}_${fname}${endout[$i]}_$kennung |
---|
3591 | transfer_problems=true |
---|
3592 | fi |
---|
3593 | fi |
---|
3594 | else |
---|
3595 | |
---|
3596 | # RESET actionout. DUE TO THIS SETTING, FILE WILL LATER JUST BE APPENDED ON THIS MACHINE |
---|
3597 | actionout[$i]=a |
---|
3598 | fi |
---|
3599 | fi |
---|
3600 | |
---|
3601 | |
---|
3602 | # OUTPUT-FILE FOR A RESTART-RUN. |
---|
3603 | # FILE IS MOVED TO THE TEMPORARY DATA DIRECTORY USING link COMMAND. |
---|
3604 | # OPTION -f IS USED TO OVERWRITE EXISTING FILES. |
---|
3605 | # AS LAST ACTION, ARCHIVING IS INITIATED. |
---|
3606 | if [[ "${actionout[$i]}" = fl ]] |
---|
3607 | then |
---|
3608 | [[ ! -d $tmp_data_catalog ]] && mkdir -p $tmp_data_catalog |
---|
3609 | chmod g+rx $tmp_data_catalog |
---|
3610 | if [[ $files_for_pes = false ]] |
---|
3611 | then |
---|
3612 | printf "\n >>> OUTPUT: ${localout[$i]} to" |
---|
3613 | printf "\n $tmp_data_catalog/${frelout[$i]} (temporary data catalog)\n" |
---|
3614 | ln -f ${localout[$i]} $tmp_data_catalog/${frelout[$i]} |
---|
3615 | else |
---|
3616 | printf "\n >>> OUTPUT: ${localout[$i]}/.... to" |
---|
3617 | printf "\n $tmp_data_catalog/${frelout[$i]} (temporary data catalog)\n" |
---|
3618 | mkdir $tmp_data_catalog/${frelout[$i]} |
---|
3619 | cd ${localout[$i]} |
---|
3620 | for file in $(ls *) |
---|
3621 | do |
---|
3622 | ln -f $file $tmp_data_catalog/${frelout[$i]} |
---|
3623 | done |
---|
3624 | cd $TEMPDIR |
---|
3625 | fi |
---|
3626 | |
---|
3627 | |
---|
3628 | # CREATE AND SUBMIT ARCHIVING-JOB |
---|
3629 | if [[ $store_on_archive_system = true ]] |
---|
3630 | then |
---|
3631 | |
---|
3632 | if [[ $archive_system = asterix ]] |
---|
3633 | then |
---|
3634 | echo "cd $tmp_data_catalog" >> archive_${frelout[$i]} |
---|
3635 | if [[ $files_for_pes = false ]] |
---|
3636 | then |
---|
3637 | echo "stageout ${frelout[$i]} > STAGE_OUTPUT${i}_$kennung" >> archive_${frelout[$i]} |
---|
3638 | else |
---|
3639 | echo "stageout -t ${frelout[$i]} > STAGE_OUTPUT${i}_$kennung" >> archive_${frelout[$i]} |
---|
3640 | fi |
---|
3641 | echo "cat STAGE_OUTPUT${i}_$kennung" >> archive_${frelout[$i]} |
---|
3642 | echo "if [[ \$(grep -c \"st.msg:150\" STAGE_OUTPUT${i}_$kennung) != 0 ]]" >> archive_${frelout[$i]} |
---|
3643 | echo "then" >> archive_${frelout[$i]} |
---|
3644 | echo " do_stageout=false" >> archive_${frelout[$i]} |
---|
3645 | echo "else" >> archive_${frelout[$i]} |
---|
3646 | echo " echo \" +++ $filetyp ${frelout[$i]} could not be stored on archive-system\" " >> archive_${frelout[$i]} |
---|
3647 | echo " cat /dev/null > ~/job_queue/ARCHIVE_ERROR_$fname" >> archive_${frelout[$i]} |
---|
3648 | echo " cat STAGE_OUTPUT${i}_$kennung > ~/job_queue/archive_${frelout[$i]}_error" >> archive_${frelout[$i]} |
---|
3649 | echo " echo \" *** $filetyp ${frelout[$i]} will be copied to \$WORK as backup\" " >> archive_${frelout[$i]} |
---|
3650 | if [[ $files_for_pes = false ]] |
---|
3651 | then |
---|
3652 | echo " cp ${frelout[$i]} \$WORK" >> archive_${frelout[$i]} |
---|
3653 | else |
---|
3654 | echo " cp -r ${frelout[$i]} \$WORK/${frelout[$i]}" >> archive_${frelout[$i]} |
---|
3655 | fi |
---|
3656 | echo " echo \" *** $filetyp ${frelout[$i]} saved\" " >> archive_${frelout[$i]} |
---|
3657 | echo "fi" >> archive_${frelout[$i]} |
---|
3658 | echo "rm STAGE_OUTPUT${i}_$kennung" >> archive_${frelout[$i]} |
---|
3659 | elif [[ $archive_system = DMF ]] |
---|
3660 | then |
---|
3661 | echo "cd $tmp_data_catalog" >> archive_${frelout[$i]} |
---|
3662 | if [[ $files_for_pes = false ]] |
---|
3663 | then |
---|
3664 | printf "\n +++ archiving of single files impossible with $archive_system !\n" |
---|
3665 | locat=DMF |
---|
3666 | exit |
---|
3667 | else |
---|
3668 | # ??? nicht benötigte Archiv-Systeme entfernen ??? |
---|
3669 | # FUER RECHNER IN JUELICH. DORT KOENNTEN AUCH |
---|
3670 | # EINZELNE DATEIEN GESICHERT WERDEN (SPAETER KORR.) |
---|
3671 | echo "rm -rf \$ARCHIVE/${frelout[$i]}" >> archive_${frelout[$i]} |
---|
3672 | echo "cp -r ${frelout[$i]} \$ARCHIVE" >> archive_${frelout[$i]} |
---|
3673 | fi |
---|
3674 | elif [[ $archive_system = tivoli ]] |
---|
3675 | then |
---|
3676 | echo "cd $tmp_data_catalog" >> archive_${frelout[$i]} |
---|
3677 | if [[ $files_for_pes = false ]] |
---|
3678 | then |
---|
3679 | # REMOVE EXISTING OLD FILES FROM THE ARCHIVE |
---|
3680 | echo "set -x" >> archive_${frelout[$i]} |
---|
3681 | echo "rm -rf \$PERM/${frelout[$i]}" >> archive_${frelout[$i]} |
---|
3682 | echo "cp ${frelout[$i]} \$PERM/${frelout[$i]}" >> archive_${frelout[$i]} |
---|
3683 | else |
---|
3684 | |
---|
3685 | echo "set -x" >> archive_${frelout[$i]} |
---|
3686 | echo "rm -rf \$PERM/${frelout[$i]}/*" >> archive_${frelout[$i]} |
---|
3687 | echo "[[ ! -d \$PERM/${frelout[$i]} ]] && mkdir $PERM/${frelout[$i]}" >> archive_${frelout[$i]} |
---|
3688 | cd $tmp_data_catalog |
---|
3689 | all_files=`ls -1 ${frelout[$i]}/*` |
---|
3690 | cd - > /dev/null |
---|
3691 | (( inode = 0 )) |
---|
3692 | (( tp1 = tasks_per_node + 1 )) |
---|
3693 | while (( inode < nodes )) |
---|
3694 | do |
---|
3695 | files=`echo $all_files | cut -d" " -f1-$tasks_per_node` |
---|
3696 | all_files=`echo $all_files | cut -d" " -f$tp1-` |
---|
3697 | echo "tar cvf \$PERM/${frelout[$i]}/${frelout[$i]}.node_$inode.tar $files" >> archive_${frelout[$i]} |
---|
3698 | (( inode = inode + 1 )) |
---|
3699 | done |
---|
3700 | fi |
---|
3701 | elif [[ $archive_system = ut ]] |
---|
3702 | then |
---|
3703 | echo "cd $tmp_data_catalog" >> archive_${frelout[$i]} |
---|
3704 | if [[ $files_for_pes = false ]] |
---|
3705 | then |
---|
3706 | # REMOVE EXISTING OLD FILES FROM THE ARCHIVE |
---|
3707 | echo "set -x" >> archive_${frelout[$i]} |
---|
3708 | echo "rm -rf \$UT/${frelout[$i]}" >> archive_${frelout[$i]} |
---|
3709 | echo "cp ${frelout[$i]} \$UT/${frelout[$i]}" >> archive_${frelout[$i]} |
---|
3710 | else |
---|
3711 | |
---|
3712 | echo "set -x" >> archive_${frelout[$i]} |
---|
3713 | echo "rm -rf \$UT/${frelout[$i]}/*" >> archive_${frelout[$i]} |
---|
3714 | echo "[[ ! -d \$UT/${frelout[$i]} ]] && mkdir $UT/${frelout[$i]}" >> archive_${frelout[$i]} |
---|
3715 | cd $tmp_data_catalog |
---|
3716 | all_files=`ls -1 ${frelout[$i]}/*` |
---|
3717 | cd - > /dev/null |
---|
3718 | (( inode = 0 )) |
---|
3719 | (( tp1 = tasks_per_node + 1 )) |
---|
3720 | while (( inode < nodes )) |
---|
3721 | do |
---|
3722 | files=`echo $all_files | cut -d" " -f1-$tasks_per_node` |
---|
3723 | all_files=`echo $all_files | cut -d" " -f$tp1-` |
---|
3724 | echo "tar cvf \$UT/${frelout[$i]}/${frelout[$i]}.node_$inode.tar $files" >> archive_${frelout[$i]} |
---|
3725 | (( inode = inode + 1 )) |
---|
3726 | done |
---|
3727 | fi |
---|
3728 | elif [[ $archive_system = none ]] |
---|
3729 | then |
---|
3730 | printf " +++ archiving on $localhost not available!\n" |
---|
3731 | fi |
---|
3732 | |
---|
3733 | if [[ $archive_system != none ]] |
---|
3734 | then |
---|
3735 | if [[ $localhost = nech ]] |
---|
3736 | then |
---|
3737 | subjob -d -c /pf/b/$usern/job_queue -v -q pp -X 0 -m 1000 -t 7200 $PORTOPT archive_${frelout[$i]} |
---|
3738 | fi |
---|
3739 | printf " Archiving of $tmp_data_catalog/${frelout[$i]} initiated (batch job submitted)\n" |
---|
3740 | fi |
---|
3741 | else |
---|
3742 | printf " +++ caution: option -A is switched off. No archiving on $archive_system!\n" |
---|
3743 | fi |
---|
3744 | |
---|
3745 | |
---|
3746 | # CREATE AN EMPTY DIRECTORY IN THE USERS PERMANENT DIRECTORY, |
---|
3747 | # IN ORDER TO NOTE THE RESPECTIVE CYCLE NUMBER ON THE ARCHIVE SYSTEM |
---|
3748 | # RESTART-JOBS ARE USING THESE EMPTY-DIRECTORIES TO GET THE CURRENT HIGHEST |
---|
3749 | # CYCLE NUMBER ON THE ARCHIVE SYSTEM (IN CASE THAT INFORMATIONS ARE DIFFICULT TO |
---|
3750 | # TO ACCESS FROM THE ARCHIVE-SYSTEM DIRECTLY)) |
---|
3751 | if [[ $files_for_pes = false ]] |
---|
3752 | then |
---|
3753 | cat /dev/null > ${pathout[$i]} |
---|
3754 | else |
---|
3755 | mkdir -p ${pathout[$i]} |
---|
3756 | fi |
---|
3757 | |
---|
3758 | fi |
---|
3759 | |
---|
3760 | |
---|
3761 | # COPY FROM THIS HOST TO THE ARCHIVE-SYSTEM |
---|
3762 | # IF ANY ARCHIVING FAILS, AN ERROR-FLAG-FILE IS SET |
---|
3763 | # THIS FILE REMAINS TO BE SET, EVEN IF ARCHIVING OF FURTHER FILES IS SUCCESSFULL |
---|
3764 | if [[ "${actionout[$i]}" = ar ]] |
---|
3765 | then |
---|
3766 | if [[ $files_for_pes = false ]] |
---|
3767 | then |
---|
3768 | printf "\n >>> OUTPUT: ${localout[$i]} to" |
---|
3769 | printf "\n ${pathout[$i]}" |
---|
3770 | printf "\n File will be copied to archive-system ($archive_system) !\n" |
---|
3771 | else |
---|
3772 | printf "\n >>> OUTPUT: ${localout[$i]}/_.... to" |
---|
3773 | printf "\n ${pathout[$i]}" |
---|
3774 | printf "\n Directory will be copied to archive-system ($archive_system) !\n" |
---|
3775 | fi |
---|
3776 | mv ${localout[$i]} ${frelout[$i]} |
---|
3777 | |
---|
3778 | file_saved=false |
---|
3779 | |
---|
3780 | if [[ $archive_system = asterix ]] |
---|
3781 | then |
---|
3782 | do_stageout=true |
---|
3783 | (( stageout_anz = 0 )) |
---|
3784 | while [[ $do_stageout = true ]] |
---|
3785 | do |
---|
3786 | if [[ $files_for_pes = false ]] |
---|
3787 | then |
---|
3788 | stageout ${frelout[$i]} > STAGE_OUTPUT |
---|
3789 | else |
---|
3790 | stageout -t ${frelout[$i]} > STAGE_OUTPUT |
---|
3791 | fi |
---|
3792 | cat STAGE_OUTPUT |
---|
3793 | if [[ $(grep -c "st.msg:150" STAGE_OUTPUT) != 0 ]] |
---|
3794 | then |
---|
3795 | file_saved=true |
---|
3796 | do_stageout=false |
---|
3797 | else |
---|
3798 | if [[ $files_for_pes = false ]] |
---|
3799 | then |
---|
3800 | printf "\n +++ file ${frelout[$i]} could not be saved on archive-system" |
---|
3801 | else |
---|
3802 | printf "\n +++ directory ${frelout[$i]} could not be saved on archive-system" |
---|
3803 | fi |
---|
3804 | (( stageout_anz = stageout_anz + 1 )) |
---|
3805 | if (( stageout_anz == 10 )) |
---|
3806 | then |
---|
3807 | printf "\n +++ stoped after 10 unsuccessful tries!" |
---|
3808 | archive_save=false |
---|
3809 | do_stageout=false |
---|
3810 | else |
---|
3811 | printf "\n *** new try to store on archive after 15 min:" |
---|
3812 | sleep 900 |
---|
3813 | fi |
---|
3814 | fi |
---|
3815 | done |
---|
3816 | elif [[ $archive_system = DMF ]] |
---|
3817 | then |
---|
3818 | if [[ $files_for_pes = false ]] |
---|
3819 | then |
---|
3820 | printf "\n +++ archiving of single files impossible on $archive_system!\n" |
---|
3821 | locat=DMF |
---|
3822 | exit |
---|
3823 | else |
---|
3824 | rm -rf $ARCHIVE/${frelout[$i]} |
---|
3825 | cp -r ${frelout[$i]} $ARCHIVE |
---|
3826 | fi |
---|
3827 | file_saved=true |
---|
3828 | elif [[ $archive_system = tivoli ]] |
---|
3829 | then |
---|
3830 | # ARCHIVING ONLY POSSIBLE VIA BATCH-JOB |
---|
3831 | # IN THE MEANTIME, FILE IS STORED IN THE TEMPORARY DATA DIRECTORY, |
---|
3832 | # BECAUSE MRUN'S CURRENT TEMPORARY WORKING DIRECTORY MAY ALREADY BE DELETED |
---|
3833 | # WHEN THE ARCHIVE-JOB IS EXECUTED |
---|
3834 | [[ ! -d $tmp_data_catalog ]] && mkdir -p $tmp_data_catalog |
---|
3835 | chmod g+rx $tmp_data_catalog |
---|
3836 | if [[ $files_for_pes = false ]] |
---|
3837 | then |
---|
3838 | ln -f ${frelout[$i]} $tmp_data_catalog/${frelout[$i]} |
---|
3839 | else |
---|
3840 | mkdir $tmp_data_catalog/${frelout[$i]} |
---|
3841 | ln -f ${frelout[$i]}/* $tmp_data_catalog/${frelout[$i]} |
---|
3842 | fi |
---|
3843 | |
---|
3844 | # GENERATE AND SUBMIT BATCH-JOB |
---|
3845 | # FILE HAS TO BE DELETED FROM THE TEMPORARY DATA DIRECTORY |
---|
3846 | # DELETE OLD EXISTING FILES FROM THE ARCHIVE |
---|
3847 | echo "cd $tmp_data_catalog" > archive_${frelout[$i]} |
---|
3848 | if [[ $files_for_pes = false ]] |
---|
3849 | then |
---|
3850 | echo "rm -rf \$PERM/${frelout[$i]}" >> archive_${frelout[$i]} |
---|
3851 | echo "cp ${frelout[$i]} \$PERM/${frelout[$i]}" >> archive_${frelout[$i]} |
---|
3852 | echo "rm -rf ${frelout[$i]}" >> archive_${frelout[$i]} |
---|
3853 | else |
---|
3854 | echo "rm -rf \$PERM/${frelout[$i]}.tar" >> archive_${frelout[$i]} |
---|
3855 | echo "tar cvf \$PERM/${frelout[$i]}.tar ${frelout[$i]}" >> archive_${frelout[$i]} |
---|
3856 | echo "rm -rf ${frelout[$i]}" >> archive_${frelout[$i]} |
---|
3857 | fi |
---|
3858 | |
---|
3859 | subjob -v -d -q cdata -X 0 -m 1000 -t 43200 -c $job_catalog $PORTOPT archive_${frelout[$i]} |
---|
3860 | printf " Archiving of $tmp_data_catalog/${frelout[$i]} initiated (batch job submitted)\n" |
---|
3861 | file_saved=true |
---|
3862 | |
---|
3863 | elif [[ $archive_system = ut ]] |
---|
3864 | then |
---|
3865 | # ARCHIVING ONLY POSSIBLE VIA BATCH-JOB |
---|
3866 | # IN THE MEANTIME, FILE IS STORED IN THE TEMPORARY DATA DIRECTORY, |
---|
3867 | # BECAUSE MRUN'S CURRENT TEMPORARY WORKING DIRECTORY MAY ALREADY BE DELETED |
---|
3868 | # WHEN THE ARCHIVE-JOB IS EXECUTED |
---|
3869 | [[ ! -d $tmp_data_catalog ]] && mkdir -p $tmp_data_catalog |
---|
3870 | chmod g+rx $tmp_data_catalog |
---|
3871 | if [[ $files_for_pes = false ]] |
---|
3872 | then |
---|
3873 | ln -f ${frelout[$i]} $tmp_data_catalog/${frelout[$i]} |
---|
3874 | else |
---|
3875 | mkdir $tmp_data_catalog/${frelout[$i]} |
---|
3876 | ln -f ${frelout[$i]}/* $tmp_data_catalog/${frelout[$i]} |
---|
3877 | fi |
---|
3878 | |
---|
3879 | # GENERATE AND SUBMIT BATCH-JOB |
---|
3880 | # FILE HAS TO BE DELETED FROM THE TEMPORARY DATA DIRECTORY |
---|
3881 | # DELETE OLD EXISTING FILES FROM THE ARCHIVE |
---|
3882 | echo "cd $tmp_data_catalog" > archive_${frelout[$i]} |
---|
3883 | if [[ $files_for_pes = false ]] |
---|
3884 | then |
---|
3885 | echo "rm -rf \$UT/${frelout[$i]}" >> archive_${frelout[$i]} |
---|
3886 | echo "cp ${frelout[$i]} \$UT/${frelout[$i]}" >> archive_${frelout[$i]} |
---|
3887 | echo "rm -rf ${frelout[$i]}" >> archive_${frelout[$i]} |
---|
3888 | else |
---|
3889 | echo "rm -rf \$UT/${frelout[$i]}.tar" >> archive_${frelout[$i]} |
---|
3890 | echo "tar cvf \$UT/${frelout[$i]}.tar ${frelout[$i]}" >> archive_${frelout[$i]} |
---|
3891 | echo "rm -rf ${frelout[$i]}" >> archive_${frelout[$i]} |
---|
3892 | fi |
---|
3893 | |
---|
3894 | subjob -v -c /pf/b/$usern/job_queue -d -q pp -X 0 -m 1000 -t 7200 $PORTOPT archive_${frelout[$i]} |
---|
3895 | printf " Archiving of $tmp_data_catalog/${frelout[$i]} initiated (batch job submitted)\n" |
---|
3896 | file_saved=true |
---|
3897 | |
---|
3898 | else |
---|
3899 | printf "\n +++ archive_system=\"$archive_system\" archiving impossible!" |
---|
3900 | archive_save=false |
---|
3901 | fi |
---|
3902 | |
---|
3903 | # CREATE EMPTY FLAG-FILE OR -DIRECTORY |
---|
3904 | # IN ORDER TO NOTE THE RESPECTIVE CYCLE NUMBER ON THE ARCHIVE SYSTEM |
---|
3905 | # RESTART-JOBS ARE USING THESE EMPTY-DIRECTORIES TO GET THE CURRENT HIGHEST |
---|
3906 | # CYCLE NUMBER ON THE ARCHIVE SYSTEM (IN CASE THAT INFORMATIONS ARE DIFFICULT TO |
---|
3907 | # TO ACCESS FROM THE ARCHIVE-SYSTEM DIRECTLY)) |
---|
3908 | if [[ $file_saved = true ]] |
---|
3909 | then |
---|
3910 | if [[ $files_for_pes = false ]] |
---|
3911 | then |
---|
3912 | cat /dev/null > ${pathout[$i]} |
---|
3913 | else |
---|
3914 | mkdir -p ${pathout[$i]} |
---|
3915 | fi |
---|
3916 | fi |
---|
3917 | |
---|
3918 | fi |
---|
3919 | |
---|
3920 | # APPEND ON THIS MACHINE |
---|
3921 | if [[ "${actionout[$i]}" = "a" ]] |
---|
3922 | then |
---|
3923 | if [[ "${extout[$i]}" != " " && "${extout[$i]}" != "" ]] |
---|
3924 | then |
---|
3925 | printf "\n >>> OUTPUT: ${localout[$i]} append to ${pathout[$i]}.${extout[$i]}\n" |
---|
3926 | cat ${localout[$i]} >> ${pathout[$i]}.${extout[$i]} |
---|
3927 | else |
---|
3928 | printf "\n >>> OUTPUT: ${localout[$i]} append to ${pathout[$i]}\n" |
---|
3929 | cat ${localout[$i]} >> ${pathout[$i]} |
---|
3930 | fi |
---|
3931 | fi |
---|
3932 | |
---|
3933 | # COPY ON THIS MACHINE |
---|
3934 | # COPY HAS TO BE USED, BECAUSE MOVE DOES NOT WORK IF FILE-ORIGIN AND TARGET ARE |
---|
3935 | # ON DIFFERENT FILE-SYSTEMS |
---|
3936 | if [[ "${actionout[$i]}" = "" && $files_for_pes = false ]] |
---|
3937 | then |
---|
3938 | |
---|
3939 | # COPY IN CASE OF RUNS ON SINGLE CORES |
---|
3940 | if [[ "${extout[$i]}" != " " && "${extout[$i]}" != "" ]] |
---|
3941 | then |
---|
3942 | printf "\n >>> OUTPUT: ${localout[$i]} to ${pathout[$i]}.${extout[$i]}\n" |
---|
3943 | if [[ $link_local_output = true ]] |
---|
3944 | then |
---|
3945 | printf " using ln -f\n" |
---|
3946 | ln -f ${localout[$i]} ${pathout[$i]}.${extout[$i]} |
---|
3947 | fi |
---|
3948 | # If "ln -f" fails of if "$link_local_output = false" do a normal "cp" |
---|
3949 | if [[ ! -f "${pathout[$i]}.${extout[$i]}" ]] |
---|
3950 | then |
---|
3951 | if [[ $link_local_output = true ]] |
---|
3952 | then |
---|
3953 | printf " ln failed, using cp...\n" |
---|
3954 | fi |
---|
3955 | cp ${localout[$i]} ${pathout[$i]}.${extout[$i]} |
---|
3956 | fi |
---|
3957 | else |
---|
3958 | printf "\n >>> OUTPUT: ${localout[$i]} to ${pathout[$i]}\n" |
---|
3959 | if [[ $link_local_output = true ]] |
---|
3960 | then |
---|
3961 | printf " using ln -f\n" |
---|
3962 | ln -f ${localout[$i]} ${pathout[$i]} |
---|
3963 | fi |
---|
3964 | # If "ln -f" fails of if "$link_local_output = false" do a normal "cp" |
---|
3965 | if [[ ! -f "${pathout[$i]}" ]] |
---|
3966 | then |
---|
3967 | if [[ $link_local_output = true ]] |
---|
3968 | then |
---|
3969 | printf " ln failed, using cp...\n" |
---|
3970 | fi |
---|
3971 | cp ${localout[$i]} ${pathout[$i]} |
---|
3972 | fi |
---|
3973 | fi |
---|
3974 | |
---|
3975 | elif [[ "${actionout[$i]}" = "" && $files_for_pes = true ]] |
---|
3976 | then |
---|
3977 | |
---|
3978 | # FILES FROM THE DIFFERENT CORES ARE MOVED WITH ln-COMMAND TO THE PERMANENT DIRECTORY |
---|
3979 | # AS A FIRST STEP, THE PERMANENT DIRECTORY IS CREATED |
---|
3980 | printf "\n >>> OUTPUT: ${localout[$i]}/_.... to ${pathout[$i]}\n" |
---|
3981 | if [[ $link_local_output = true ]] |
---|
3982 | then |
---|
3983 | printf " using ln -f\n" |
---|
3984 | mkdir ${pathout[$i]} |
---|
3985 | cd ${localout[$i]} |
---|
3986 | for file in $(ls *) |
---|
3987 | do |
---|
3988 | ln -f $file ${pathout[$i]} |
---|
3989 | done |
---|
3990 | cd $TEMPDIR |
---|
3991 | fi |
---|
3992 | |
---|
3993 | # IF "ln -f" HAS FAILED OR IF "$link_local_output = false" DO A NORMAL COPY "cp -r" |
---|
3994 | if [[ ! -f "${pathout[$i]}/_0000" ]] |
---|
3995 | then |
---|
3996 | if [[ $link_local_output = true ]] |
---|
3997 | then |
---|
3998 | printf " ln failed for .../_0000, using cp...\n" |
---|
3999 | fi |
---|
4000 | cp -r ${localout[$i]} ${pathout[$i]} |
---|
4001 | fi |
---|
4002 | |
---|
4003 | fi |
---|
4004 | fi |
---|
4005 | done |
---|
4006 | if (( i != 0 )) |
---|
4007 | then |
---|
4008 | if [[ $transfer_problems = true ]] |
---|
4009 | then |
---|
4010 | printf "\n$dashes\n *** OUTPUT-files saved" |
---|
4011 | printf "\n +++ WARNING: some data transfers failed! \n" |
---|
4012 | else |
---|
4013 | printf "\n$dashes\n *** all OUTPUT-files saved \n" |
---|
4014 | fi |
---|
4015 | fi |
---|
4016 | |
---|
4017 | |
---|
4018 | # IF REQUIRED, START A RESTART-JOB |
---|
4019 | # FILE CONTINUE_RUN MUST HAVE BEEN CREATED BY THE EXECUTABLE (PALM) |
---|
4020 | if [[ -f CONTINUE_RUN ]] |
---|
4021 | then |
---|
4022 | |
---|
4023 | if [[ $archive_save = true ]] |
---|
4024 | then |
---|
4025 | |
---|
4026 | # ADD RESTART-OPTIONS TO THE MRUN-CALL (IF THEY ARE NOT USED ALREADY): |
---|
4027 | # -C TELLS MRUN THAT IT IS A RESTART-RUN |
---|
4028 | # -v SILENT MODE WITHOUT INTERACTIVE QUERIES |
---|
4029 | # -n BATCH-MODE (IMPORTANT ONLY IN CASE OF BATCH JOBS ON THE LOCAL MACHINE) |
---|
4030 | [[ $(echo $mc | grep -c "\-C") = 0 ]] && mc="$mc -C" |
---|
4031 | [[ $(echo $mc | grep -c "\-v") = 0 ]] && mc="$mc -v" |
---|
4032 | [[ $(echo $mc | grep -c "\-b") = 0 ]] && mc="$mc -b" |
---|
4033 | if [[ $(echo $mc | grep -c "#") != 0 ]] |
---|
4034 | then |
---|
4035 | mc=`echo $mc | sed 's/#/f/g'` |
---|
4036 | fi |
---|
4037 | |
---|
4038 | |
---|
4039 | # START THE RESTART-JOB |
---|
4040 | printf "\n\n *** initiating restart-run on \"$return_address\" using command:\n" |
---|
4041 | echo " $mc" |
---|
4042 | printf "\n$dashes\n" |
---|
4043 | if [[ $localhost != $fromhost ]] |
---|
4044 | then |
---|
4045 | |
---|
4046 | if [[ $localhost = lcbullhh || $localhost = lccrayb || $localhost = lccrayh || $localhost = nech || $localhost = ibmh || $localhost = ibmkisti || $localhost = ibmku || $localhost = ibms || $localhost = lcflow || $localhost = lckyu* || $localhost = lcxe6 ]] |
---|
4047 | then |
---|
4048 | echo "*** ssh will be used to initiate restart-runs!" |
---|
4049 | echo " return_address=\"$return_address\" " |
---|
4050 | echo " return_username=\"$return_username\" " |
---|
4051 | if [[ $(echo $return_address | grep -c "130.75.105") = 1 ]] |
---|
4052 | then |
---|
4053 | if [[ $localhost = ibmh ]] |
---|
4054 | then |
---|
4055 | ssh $SSH_PORTOPT $usern@136.172.40.15 "ssh $SSH_PORTOPT $return_address -l $return_username \". \\\$HOME/.profile; module load intel-compiler hdf5 netcdf; PATH=\\\$PATH:$LOCAL_MRUN_PATH;export PALM_BIN=$LOCAL_MRUN_PATH;cd $LOCAL_PWD; $mc\" " |
---|
4056 | elif [[ $localhost = lcbullhh ]] |
---|
4057 | then |
---|
4058 | ssh $SSH_PORTOPT $usern@mlogin101 "ssh $SSH_PORTOPT $return_address -l $return_username \". \\\$HOME/.profile; module load intel-compiler hdf5 netcdf; PATH=\\\$PATH:$LOCAL_MRUN_PATH;export PALM_BIN=$LOCAL_MRUN_PATH;cd $LOCAL_PWD; $mc\" " |
---|
4059 | elif [[ $localhost = lccrayb ]] |
---|
4060 | then |
---|
4061 | ssh $usern@blogin1 "ssh $SSH_PORTOPT $return_address -l $return_username \". \\\$HOME/.profile; module load intel-compiler hdf5 netcdf; PATH=\\\$PATH:$LOCAL_MRUN_PATH; export PALM_BIN=$LOCAL_MRUN_PATH;cd $LOCAL_PWD; $mc\" " |
---|
4062 | elif [[ $localhost = lccrayh ]] |
---|
4063 | then |
---|
4064 | ssh $usern@hlogin1 "ssh $SSH_PORTOPT $return_address -l $return_username \". \\\$HOME/.profile; module load intel-compiler hdf5 netcdf; PATH=\\\$PATH:$LOCAL_MRUN_PATH; export PALM_BIN=$LOCAL_MRUN_PATH;cd $LOCAL_PWD; $mc\" " |
---|
4065 | elif [[ $localhost = lcxe6 ]] |
---|
4066 | then |
---|
4067 | ssh $usern@hexagon "ssh $SSH_PORTOPT $return_address -l $return_username \". \\\$HOME/.profile; module load intel-compiler hdf5 netcdf; PATH=\\\$PATH:$LOCAL_MRUN_PATH; export PALM_BIN=$LOCAL_MRUN_PATH;cd $LOCAL_PWD; $mc\" " |
---|
4068 | else |
---|
4069 | ssh $SSH_PORTOPT $return_address -l $return_username ". \\\$HOME/.profile; module load intel-compiler hdf5 netcdf; PATH=\$PATH:$LOCAL_MRUN_PATH;export PALM_BIN=$LOCAL_MRUN_PATH;cd $LOCAL_PWD; $mc " |
---|
4070 | fi |
---|
4071 | else |
---|
4072 | if [[ $localhost = ibmkisti ]] |
---|
4073 | then |
---|
4074 | ssh $SSH_PORTOPT $usern@gaiad "ssh $SSH_PORTOPT $return_address -l $return_username \"PATH=\\\$PATH:$LOCAL_MRUN_PATH;export PALM_BIN=$LOCAL_MRUN_PATH;cd $LOCAL_PWD; $mc\" " |
---|
4075 | elif [[ $localhost = lcflow ]] |
---|
4076 | then |
---|
4077 | /usr/bin/ssh $SSH_PORTOPT $return_address -l $return_username "PATH=\$PATH:$LOCAL_MRUN_PATH;export PALM_BIN=$LOCAL_MRUN_PATH;cd $LOCAL_PWD; $mc " |
---|
4078 | elif [[ $localhost = lccrayb ]] |
---|
4079 | then |
---|
4080 | ssh $usern@blogin1 "ssh $SSH_PORTOPT $return_address -l $return_username \"PATH=\\\$PATH:$LOCAL_MRUN_PATH;export PALM_BIN=$LOCAL_MRUN_PATH;cd $LOCAL_PWD; $mc\" " |
---|
4081 | elif [[ $localhost = lccrayh ]] |
---|
4082 | then |
---|
4083 | ssh $usern@hlogin1 "ssh $SSH_PORTOPT $return_address -l $return_username \"PATH=\\\$PATH:$LOCAL_MRUN_PATH;export PALM_BIN=$LOCAL_MRUN_PATH;cd $LOCAL_PWD; $mc\" " |
---|
4084 | else |
---|
4085 | ssh $SSH_PORTOPT $return_address -l $return_username "PATH=\$PATH:$LOCAL_MRUN_PATH;export PALM_BIN=$LOCAL_MRUN_PATH;cd $LOCAL_PWD; $mc " |
---|
4086 | fi |
---|
4087 | fi |
---|
4088 | else |
---|
4089 | printf "\n +++ no restart mechanism available for host \"$localhost\" " |
---|
4090 | locat=restart; exit |
---|
4091 | fi |
---|
4092 | |
---|
4093 | # WAIT TO ALLOW THE RESTART-JOB TO BE QUEUED, BEFORE THE CURRENT JOB IS FINISHED |
---|
4094 | if [[ $queue = special1q ]] |
---|
4095 | then |
---|
4096 | sleep 120 |
---|
4097 | else |
---|
4098 | sleep 30 |
---|
4099 | fi |
---|
4100 | |
---|
4101 | else |
---|
4102 | |
---|
4103 | # JOBS RUNNING (AND STARTED) ON THE LOCAL MACHINE CAN DIRECTLY CALL MRUN (WITHOUT |
---|
4104 | # USING SSH) |
---|
4105 | cd $LOCAL_PWD |
---|
4106 | if [[ $localhost = lckyuh ]] |
---|
4107 | then |
---|
4108 | printf "\n +++ WARNING: no restart mechanism available for host \"$localhost\" " |
---|
4109 | printf "\n please restart job manually using command:\n" |
---|
4110 | printf "\n \"$mc\" " |
---|
4111 | else |
---|
4112 | eval $mc # THE ' MUST BE EVALUATED |
---|
4113 | fi |
---|
4114 | cd - > /dev/null |
---|
4115 | fi |
---|
4116 | if [[ $localhost = lckyuh ]] |
---|
4117 | then |
---|
4118 | printf "\n$dashes\n *** restart-run to be initiated manually\n" |
---|
4119 | else |
---|
4120 | printf "\n$dashes\n *** restart-run initiated \n" |
---|
4121 | fi |
---|
4122 | |
---|
4123 | |
---|
4124 | # DELETE INPUT-(RESTART)FILES, WHICH HAVE BEEN FETCHED FROM THE TEMPORARY DATA |
---|
4125 | # DIRECTORY, BACAUSE THEY ARE NOT REQUIRED BY THE RESTART-JOB. |
---|
4126 | # THIS IS DONE IN ORDER TO AVOID EXCEEDING DISC QUOTAS OR DISC SPACE (RESTART-FILES |
---|
4127 | # MAY BE VERY HUGE) |
---|
4128 | (( i = 0 )) |
---|
4129 | while (( i < iin )) |
---|
4130 | do |
---|
4131 | (( i = i + 1 )) |
---|
4132 | if [[ "${got_tmp[$i]}" = true && $keep_data_from_previous_run = false ]] |
---|
4133 | then |
---|
4134 | rm -r $tmp_data_catalog/${frelin[$i]} |
---|
4135 | fi |
---|
4136 | done |
---|
4137 | |
---|
4138 | else |
---|
4139 | |
---|
4140 | printf "\n +++ no restart-run possible, since errors occured" |
---|
4141 | printf "\n during the archive process" |
---|
4142 | fi |
---|
4143 | |
---|
4144 | fi |
---|
4145 | |
---|
4146 | |
---|
4147 | |
---|
4148 | # SEND EMAIL NOTIFICATION ABOUT THE FINISHED RUN |
---|
4149 | if [[ "$email_notification" != "none" ]] |
---|
4150 | then |
---|
4151 | |
---|
4152 | if [[ $localhost != $fromhost ]] |
---|
4153 | then |
---|
4154 | if [[ -f CONTINUE_RUN ]] |
---|
4155 | then |
---|
4156 | echo "PALM restart run necessary" > email_text |
---|
4157 | echo "description header of actual run:" >> email_text |
---|
4158 | cat CONTINUE_RUN >> email_text |
---|
4159 | echo "mrun-command to restart:" >> email_text |
---|
4160 | echo "$mc" >> email_text |
---|
4161 | else |
---|
4162 | echo "PALM run with base filename \"$fname\" on host \"$localhost\" finished" > email_text |
---|
4163 | fi |
---|
4164 | mail $email_notification < email_text |
---|
4165 | printf "\n *** email notification sent to \"$email_notification\" " |
---|
4166 | fi |
---|
4167 | fi |
---|
4168 | |
---|
4169 | |
---|
4170 | |
---|
4171 | # ALL ACTIONS FINISHED, TEMPORARY WORKING-DIRECTORY CAN BE DELETED |
---|
4172 | cd $HOME |
---|
4173 | [[ $delete_temporary_catalog = true ]] && rm -rf $TEMPDIR |
---|
4174 | |
---|
4175 | else |
---|
4176 | |
---|
4177 | # PREPARING ACTIONS, |
---|
4178 | # IF A BATCH-JOB IS TO BE GENERATED AND STARTED ON A REMOTE-MACHINE GERECHNET |
---|
4179 | |
---|
4180 | # BUILD THE MRUN-COMMAND TO BE CALLED IN THE BATCH-JOB ON THE REMOTE-MACHINE |
---|
4181 | mrun_com="$mrun_script_name -a $afname -c $config_file -d $fname -h $host -H $fromhost -m $memory -t $cpumax -q $queue -R $return_address -U $return_username -u $remote_username" |
---|
4182 | [[ "$cpp_opts" != "" ]] && mrun_com=${mrun_com}" -D \"$cpp_opts\"" |
---|
4183 | [[ "$global_revision" != "" ]] && mrun_com=${mrun_com}" -G \"$global_revision\"" |
---|
4184 | [[ $group_number != none ]] && mrun_com=${mrun_com}" -g $group_number" |
---|
4185 | [[ $do_compile = true ]] && mrun_com=${mrun_com}" -s \"$source_list\"" |
---|
4186 | [[ "$input_list" != "" ]] && mrun_com=${mrun_com}" -i \"$input_list\"" |
---|
4187 | [[ $ignore_archive_error = true ]] && mrun_com=${mrun_com}" -I" |
---|
4188 | [[ $keep_data_from_previous_run = true ]] && mrun_com=${mrun_com}" -k" |
---|
4189 | [[ "$additional_conditions" != "" ]] && mrun_com=${mrun_com}" -K \"$additional_conditions\"" |
---|
4190 | [[ "$output_list" != "" ]] && mrun_com=${mrun_com}" -o \"$output_list\"" |
---|
4191 | [[ "$read_from_config" = false ]] && mrun_com=${mrun_com}" -S" |
---|
4192 | [[ $do_trace = true ]] && mrun_com=${mrun_com}" -x" |
---|
4193 | [[ "$numprocs" != "" ]] && mrun_com=${mrun_com}" -X $numprocs" |
---|
4194 | if [[ $use_openmp = true ]] |
---|
4195 | then |
---|
4196 | mrun_com=${mrun_com}" -O $threads_per_task" |
---|
4197 | fi |
---|
4198 | [[ "$tasks_per_node" != "" ]] && mrun_com=${mrun_com}" -T $tasks_per_node" |
---|
4199 | [[ $store_on_archive_system = true ]] && mrun_com=${mrun_com}" -A" |
---|
4200 | [[ $package_list != "" ]] && mrun_com=${mrun_com}" -p \"$package_list\"" |
---|
4201 | [[ $return_password != "" ]] && mrun_com=${mrun_com}" -P $return_password" |
---|
4202 | [[ $delete_temporary_catalog = false ]] && mrun_com=${mrun_com}" -B" |
---|
4203 | [[ $node_usage != default && "$(echo $node_usage | cut -c1-3)" != "sla" && $node_usage != novice ]] && mrun_com=${mrun_com}" -n $node_usage" |
---|
4204 | [[ "$ocean_file_appendix" = true ]] && mrun_com=${mrun_com}" -y" |
---|
4205 | [[ $run_coupled_model = true ]] && mrun_com=${mrun_com}" -Y \"$coupled_dist\"" |
---|
4206 | [[ "$check_namelist_files" = false ]] && mrun_com=${mrun_com}" -z" |
---|
4207 | [[ "$combine_plot_fields" = false ]] && mrun_com=${mrun_com}" -Z" |
---|
4208 | [[ "$max_par_io_str" != "" ]] && mrun_com=${mrun_com}" -w $max_par_io_str" |
---|
4209 | if [[ $do_remote = true ]] |
---|
4210 | then |
---|
4211 | printf "\n>>>> MRUN-command on execution host:\n>>>> $mrun_com \n" |
---|
4212 | fi |
---|
4213 | |
---|
4214 | |
---|
4215 | # CREATE EXECUTABLE FOR BATCH JOB |
---|
4216 | if [[ $create_executable_for_batch = true && $restart_run != true ]] |
---|
4217 | then |
---|
4218 | |
---|
4219 | printf "\n *** creating the executable for batch job\n" |
---|
4220 | |
---|
4221 | # METHOD ONLY WORKS FOR BATCH JOBS ON LOCAL HOSTS |
---|
4222 | if [[ $host != $localhost ]] |
---|
4223 | then |
---|
4224 | printf "\n +++ creation of executables is only allowed for batch jobs on local hosts." |
---|
4225 | printf "\n Please set create_executable_for_batch = false in the config-file.\n" |
---|
4226 | locat=create_executable; exit |
---|
4227 | fi |
---|
4228 | |
---|
4229 | mkdir $working_directory/SOURCES_FOR_RUN_${fname}/TMPDIR_FOR_CREATING_EXECUTABLE |
---|
4230 | cd $working_directory/SOURCES_FOR_RUN_${fname}/TMPDIR_FOR_CREATING_EXECUTABLE |
---|
4231 | |
---|
4232 | cp $make_depository . |
---|
4233 | tar -xf $make_depository > /dev/null 2>&1 |
---|
4234 | cp ../* . > /dev/null 2>&1 |
---|
4235 | |
---|
4236 | make $mopts -f Makefile PROG=a.out F90=$compiler_name COPT="$cpp_options" F90FLAGS="$fopts" LDFLAGS="$lopts" |
---|
4237 | |
---|
4238 | if [[ $? != 0 || "$compile_error" = true || "$module_compile_error" = true ]] |
---|
4239 | then |
---|
4240 | printf "\n +++ error occured while compiling or linking" |
---|
4241 | locat=compile |
---|
4242 | exit |
---|
4243 | fi |
---|
4244 | |
---|
4245 | mv a.out .. |
---|
4246 | cd - > /dev/null 2>&1 |
---|
4247 | rm -rf $working_directory/SOURCES_FOR_RUN_${fname}/TMPDIR_FOR_CREATING_EXECUTABLE |
---|
4248 | |
---|
4249 | printf " *** executable created in \"$working_directory/SOURCES_FOR_RUN_${fname}\"\n " |
---|
4250 | |
---|
4251 | fi |
---|
4252 | |
---|
4253 | |
---|
4254 | # BUILD THE JOB-SCRIPTS ON FILE jobfile |
---|
4255 | jobfile=jobfile.$RANDOM |
---|
4256 | |
---|
4257 | |
---|
4258 | # CREATE TEMPORARY DIRECTORY AND SWITCH TO IT |
---|
4259 | echo "mkdir $TEMPDIR" >> $jobfile |
---|
4260 | echo "cd $TEMPDIR" >> $jobfile |
---|
4261 | |
---|
4262 | |
---|
4263 | # ACTIVATE ERROR-TRACEBACK |
---|
4264 | if [[ $do_trace = true ]] |
---|
4265 | then |
---|
4266 | echo "set -x" >> $jobfile |
---|
4267 | else |
---|
4268 | echo "set +vx" >> $jobfile |
---|
4269 | fi |
---|
4270 | |
---|
4271 | |
---|
4272 | # INITIALIZE THE ENVIRONMENT AND LOAD MODULES |
---|
4273 | if [[ "$init_cmds" != "" ]] |
---|
4274 | then |
---|
4275 | echo "$init_cmds" >> $jobfile |
---|
4276 | fi |
---|
4277 | if [[ "$module_calls" != "" ]] |
---|
4278 | then |
---|
4279 | echo "$module_calls" >> $jobfile |
---|
4280 | fi |
---|
4281 | |
---|
4282 | |
---|
4283 | # PROVIDE SOURCE-CODE FILES, MRUN-SCRIPT AND CONFIGURATION-FILE FOR THE JOB |
---|
4284 | # then-CLAUSE: FILES ARE COLLECTED IN THE SOURCES_FOR_RUN_... DIRECTORY ON THE LOCAL HOST, |
---|
4285 | # WHICH IS THEN FETCHED FROM THE BATCH-JOB BY USING cp/scp |
---|
4286 | # THE SOURCE-CODE FILES ALREADY EXIST IN THIS DIRECTORY |
---|
4287 | # else-CLAUSE: FILE-CONTENTS ARE PUT INTO THE JOB-FILE AS HERE-DOCUMENTS |
---|
4288 | # THIS MAY CREATE A QUITE LARGE JOB-FILE, WHICH CAN CAUSE PROBLEMS WITH SOME |
---|
4289 | # QUEUEING-SYSTEMS |
---|
4290 | if [[ $host = ibmkisti || $host = lcbullhh || $host = lccrayb || $host = lccrayf || $host = lccrayh ]] |
---|
4291 | then |
---|
4292 | |
---|
4293 | # COPY CONFIGURATION-FILE AND MRUN-SCRIPT INTO THE SOURCES_FOR_RUN... DIRECTORY |
---|
4294 | if [[ $restart_run != true ]] |
---|
4295 | then |
---|
4296 | cp $config_file $working_directory/SOURCES_FOR_RUN_$fname |
---|
4297 | cp ${PALM_BIN}/$mrun_script_name $working_directory/SOURCES_FOR_RUN_$fname |
---|
4298 | fi |
---|
4299 | |
---|
4300 | # COPY THE SOURCES_FOR_RUN... DIRECTORY FROM THE LOCAL HOST TO THE JOB VIA scp |
---|
4301 | # (then-CLAUSE: JOBS ON THE LOCAL HOST CAN JUST USE cp) |
---|
4302 | echo "set -x" >> $jobfile |
---|
4303 | if [[ $host = $localhost ]] |
---|
4304 | then |
---|
4305 | # DUE TO UNKNOWN REASONS, COPY WITH cp COMMAND CREATES CORRUPT |
---|
4306 | # FILES ON CRAY XC30 SYSTEMS (CSC HELSINKI), rsync IS USED INSTEAD |
---|
4307 | if [[ $(echo $host | cut -c1-6) = lccray ]] |
---|
4308 | then |
---|
4309 | echo "rsync -av -t $working_directory/SOURCES_FOR_RUN_$fname ." >> $jobfile |
---|
4310 | else |
---|
4311 | echo "cp -r $working_directory/SOURCES_FOR_RUN_$fname ." >> $jobfile |
---|
4312 | fi |
---|
4313 | |
---|
4314 | else |
---|
4315 | if [[ $host = ibmkisti ]] |
---|
4316 | then |
---|
4317 | # ON KISTI'S IBM FIREWALL IS ONLY OPENED ON INTERACTIVE NODE |
---|
4318 | echo "localdir=\`pwd\`" >> $jobfile |
---|
4319 | echo "ssh $SSH_PORTOPT $remote_username@gaiad \"cd \$localdir; scp $PORTOPT -r $return_username@$return_address:$working_directory/SOURCES_FOR_RUN_$fname .\" " >> $jobfile |
---|
4320 | elif [[ $host = lcbullhh ]] |
---|
4321 | then |
---|
4322 | echo "localdir=\`pwd\`" >> $jobfile |
---|
4323 | echo "ssh $SSH_PORTOPT $remote_username@mlogin101 \"cd \$localdir; scp $PORTOPT -r $return_username@$return_address:$working_directory/SOURCES_FOR_RUN_$fname .\" " >> $jobfile |
---|
4324 | |
---|
4325 | elif [[ $host = lccrayb ]] |
---|
4326 | then |
---|
4327 | echo "localdir=\`pwd\`" >> $jobfile |
---|
4328 | echo "ssh $SSH_PORTOPT $remote_username@blogin1 \"cd \$localdir; scp $PORTOPT -r $return_username@$return_address:$working_directory/SOURCES_FOR_RUN_$fname .\" " >> $jobfile |
---|
4329 | elif [[ $host = lccrayh ]] |
---|
4330 | then |
---|
4331 | echo "localdir=\`pwd\`" >> $jobfile |
---|
4332 | echo "ssh $SSH_PORTOPT $remote_username@hlogin1 \"cd \$localdir; scp $PORTOPT -r $return_username@$return_address:$working_directory/SOURCES_FOR_RUN_$fname .\" " >> $jobfile |
---|
4333 | |
---|
4334 | else |
---|
4335 | echo "scp $PORTOPT -r $return_username@$return_address:$working_directory/SOURCES_FOR_RUN_$fname ." >> $jobfile |
---|
4336 | fi |
---|
4337 | fi |
---|
4338 | echo "export SOURCES_COMPLETE=true" >> $jobfile |
---|
4339 | |
---|
4340 | # MOVE MRUN-SCRIPT AND CONFIGURATION-FILE FROM THE SOURCES_FOR_RUN... DIRECTORY TO THE |
---|
4341 | # WORKING DIRECTORY OF THE JOB |
---|
4342 | echo "mv SOURCES_FOR_RUN_$fname/$config_file . " >> $jobfile |
---|
4343 | echo "mv SOURCES_FOR_RUN_$fname/$mrun_script_name . " >> $jobfile |
---|
4344 | echo "chmod u+rwx $mrun_script_name" >> $jobfile |
---|
4345 | echo "execute_mrun=true" >> $jobfile |
---|
4346 | echo " " >> $jobfile |
---|
4347 | |
---|
4348 | else |
---|
4349 | |
---|
4350 | # PROVIDE SOURCE-CODE FILES AND MAKEFILE AS HERE DOCUMENT |
---|
4351 | if [[ $do_compile = true ]] |
---|
4352 | then |
---|
4353 | |
---|
4354 | source_catalog=SOURCES_FOR_RUN_$fname |
---|
4355 | |
---|
4356 | # CREATE SOURCES_FOR_RUN... DIRECTORY TO STORE THE SOURCE CODE FILES AND THE MAKEFILE |
---|
4357 | echo "mkdir SOURCES_FOR_RUN_$fname" >> $jobfile |
---|
4358 | echo "export SOURCES_COMPLETE=true" >> $jobfile |
---|
4359 | echo "cd SOURCES_FOR_RUN_$fname" >> $jobfile |
---|
4360 | |
---|
4361 | for filename in $source_list |
---|
4362 | do |
---|
4363 | # BACKSLASH IS USED FOR MASKING |
---|
4364 | echo "cat > $filename << \"%END%\"" >> $jobfile |
---|
4365 | cat $source_catalog/$filename >> $jobfile |
---|
4366 | echo " " >> $jobfile |
---|
4367 | echo "%END%" >> $jobfile |
---|
4368 | echo " " >> $jobfile |
---|
4369 | done |
---|
4370 | |
---|
4371 | # BACKSLASH IS USED FOR MASKING |
---|
4372 | echo "cat > Makefile << \"%END%\"" >> $jobfile |
---|
4373 | cat $source_catalog/Makefile >> $jobfile |
---|
4374 | echo " " >> $jobfile |
---|
4375 | echo "%END%" >> $jobfile |
---|
4376 | echo " " >> $jobfile |
---|
4377 | |
---|
4378 | echo "cd - > /dev/null" >> $jobfile |
---|
4379 | |
---|
4380 | fi |
---|
4381 | |
---|
4382 | |
---|
4383 | # PROVIDE THE CONFIGURATION-FILE AS HERE-DOCUMENT |
---|
4384 | # BACKSLASH IS USED FOR MASKING |
---|
4385 | # LINES WITH #$ IN THE CONFIGURATION-FILE, COMING FROM THE SVN KEYWORD SUBSTITUTION, |
---|
4386 | # ARE REMOVED FROM THE FILE IN ORDER TO AVOID PROBLEMS WITH THE SGE BATCH SYSTEM |
---|
4387 | echo "cat > $config_file << \"%END%\"" >> $jobfile |
---|
4388 | if [[ $host = lckyuh ]] |
---|
4389 | then |
---|
4390 | # NO CROSS-COMPILER ON COMPUTE NODE |
---|
4391 | sed 's/frtpx/frt/g' $config_file >> $jobfile |
---|
4392 | else |
---|
4393 | sed 's/#$.*//g' $config_file >> $jobfile |
---|
4394 | fi |
---|
4395 | echo "%END%" >> $jobfile |
---|
4396 | echo " " >> $jobfile |
---|
4397 | |
---|
4398 | |
---|
4399 | # PROVIDE THE MRUN-SCRIPTS AS HERE-DOCUMENT |
---|
4400 | # BACKSLASH IS USED FOR MASKING |
---|
4401 | echo "cat > $mrun_script_name <<\"%END%\"" >> $jobfile |
---|
4402 | if [[ $host = lckyuh ]] |
---|
4403 | then |
---|
4404 | sed 's/\/bin\/ksh/\/bin\/bash/g' ${PALM_BIN}/$mrun_script_name >> $jobfile |
---|
4405 | else |
---|
4406 | cat ${PALM_BIN}/$mrun_script_name >> $jobfile |
---|
4407 | fi |
---|
4408 | echo "%END%" >> $jobfile |
---|
4409 | echo "chmod u+x $mrun_script_name" >> $jobfile |
---|
4410 | echo "execute_mrun=true" >> $jobfile |
---|
4411 | echo " " >> $jobfile |
---|
4412 | |
---|
4413 | fi |
---|
4414 | |
---|
4415 | |
---|
4416 | # GET REQUIRED INPUT-FILES BY SCP OR BY SENDING THEM WITH THE JOB AS HERE-DOCUMENT |
---|
4417 | # PUT THESE FILES INTO THE USER'S RESPECTIVE PERMANENT DIRECTORIES ON THE REMOTE-HOST |
---|
4418 | # IF THE DIRECTORIES DO NOT EXIST, TRY TO CREATE THEM |
---|
4419 | if [[ $do_remote = true ]] |
---|
4420 | then |
---|
4421 | (( i = 0 )) |
---|
4422 | while (( i < iin )) |
---|
4423 | do |
---|
4424 | (( i = i + 1 )) |
---|
4425 | echo "[[ ! -d ${pathin[$i]} ]] && mkdir -p ${pathin[$i]}" >> $jobfile |
---|
4426 | if [[ "${transin[$i]}" = job ]] |
---|
4427 | then |
---|
4428 | echo "cat > ${remotepathin[$i]} <<\"%END%\"" >> $jobfile |
---|
4429 | eval cat ${pathin[$i]}/${frelin[$i]} >> $jobfile |
---|
4430 | echo " " >> $jobfile |
---|
4431 | echo "%END%" >> $jobfile |
---|
4432 | else |
---|
4433 | echo "batch_scp $PORTOPT -b -o -g -s -u $return_username $return_address ${remotepathin[$i]} \"${pathin[$i]}\" ${frelin[$i]}" >> $jobfile |
---|
4434 | fi |
---|
4435 | |
---|
4436 | # CHECK, IF FILE COULD BE CREATED |
---|
4437 | echo "if [[ \$? = 1 ]]" >> $jobfile |
---|
4438 | echo "then" >> $jobfile |
---|
4439 | echo " echo \" \" " >> $jobfile |
---|
4440 | echo " echo \"+++ file ${remotepathin[$i]} could not be created\" " >> $jobfile |
---|
4441 | echo " echo \" please check, if directory exists on $host!\" " >> $jobfile |
---|
4442 | echo " echo \"+++ MRUN will not be continued\" " >> $jobfile |
---|
4443 | echo " execute_mrun=false" >> $jobfile |
---|
4444 | echo "fi" >> $jobfile |
---|
4445 | done |
---|
4446 | fi |
---|
4447 | |
---|
4448 | # PROVIDE NAME OF THE CURRENT WORKING-DIRECTORY ON THE LOCAL MACHINE (FROM WHERE THE JOB IS |
---|
4449 | # STARTED) BY SETTING AN ENVIRONMENT-VARIABLE. THIS INFORMATION IS USED IN THE JOB BY MRUN |
---|
4450 | # IN CASE THAT RESTART-RUNS HAVE TO BE GENERATED |
---|
4451 | echo "LOCAL_PWD=$working_directory" >> $jobfile |
---|
4452 | echo "export LOCAL_PWD" >> $jobfile |
---|
4453 | |
---|
4454 | # PROVIDE THE PATH OF THE LOCAL MRUN-SCRIPT FOR THE SAME REASON |
---|
4455 | echo "LOCAL_MRUN_PATH=$PALM_BIN" >> $jobfile |
---|
4456 | echo "export LOCAL_MRUN_PATH" >> $jobfile |
---|
4457 | |
---|
4458 | # lcflow ALSO REQUIRES TO PROVIDE PATH FOR THE PALM-SCRIPTS |
---|
4459 | # if [[ $host = lcflow || $localhost = lcflow ]] |
---|
4460 | # then |
---|
4461 | echo "export PALM_BIN=$PALM_BIN" | sed -e 's:'$HOME':$HOME:' >> $jobfile |
---|
4462 | echo "export PATH=\$PATH:\$PALM_BIN" >> $jobfile |
---|
4463 | # fi |
---|
4464 | |
---|
4465 | # CALL MRUN WITHIN THE JOB (SETTING QUEUE IS A WORKAROUND FOR ibmkisti) |
---|
4466 | # AS FINAL ACTION, REMOVE THE TEMPORARY DIRECTORY CREATED AT THE BEGINNING OF THE JOB |
---|
4467 | echo "set -x" >> $jobfile |
---|
4468 | echo "queue=$queue" >> $jobfile |
---|
4469 | echo "[[ \$execute_mrun = true ]] && ./$mrun_com" >> $jobfile |
---|
4470 | echo 'ls -al; echo `pwd`' >> $jobfile |
---|
4471 | echo "cd \$HOME" >> $jobfile |
---|
4472 | echo "rm -rf $TEMPDIR" >> $jobfile |
---|
4473 | |
---|
4474 | |
---|
4475 | |
---|
4476 | |
---|
4477 | # START THE JOB USING SUBJOB-COMMAND |
---|
4478 | if [[ $silent = false ]] |
---|
4479 | then |
---|
4480 | printf "\n " |
---|
4481 | else |
---|
4482 | printf "\n\n" |
---|
4483 | fi |
---|
4484 | |
---|
4485 | subjob $job_on_file -h $host -u $remote_username -g $group_number -q $queue -m $memory -N $node_usage -t $cpumax $XOPT $TOPT $OOPT -n $fname -v -c $job_catalog -e $email_notification $PORTOPT $jobfile |
---|
4486 | rm -rf $jobfile |
---|
4487 | |
---|
4488 | |
---|
4489 | fi # END OF REMOTE-PART |
---|