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