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