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