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