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