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