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