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