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 | # |
---|
25 | # |
---|
26 | # Former revisions: |
---|
27 | # ----------------- |
---|
28 | # $Id: mrun 1290 2014-03-04 07:17:03Z raasch $ |
---|
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: 1290 $" |
---|
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 | # END DEBUG MODE |
---|
3236 | else |
---|
3237 | |
---|
3238 | # NORMAL EXECUTION |
---|
3239 | if [[ -n $numprocs ]] |
---|
3240 | then |
---|
3241 | |
---|
3242 | # RUNNING THE PROGRAM ON PARALLEL MACHINES |
---|
3243 | if [[ $(echo $host | cut -c1-3) = ibm ]] |
---|
3244 | then |
---|
3245 | |
---|
3246 | # SETUP THE IBM MPI ENVIRONMENT |
---|
3247 | if [[ $host != ibmh && $host != ibmkisti ]] |
---|
3248 | then |
---|
3249 | export MP_SHARED_MEMORY=yes |
---|
3250 | export AIXTHREAD_SCOPE=S |
---|
3251 | export OMP_NUM_THREADS=$threads_per_task |
---|
3252 | export XLSMPOPTS="spins=0:yields=0:stack=20000000" |
---|
3253 | export AUTHSTATE=files |
---|
3254 | export XLFRTEOPTS="nlwidth=132:err_recovery=no" # RECORD-LENGTH OF NAMELIST-OUTPUT |
---|
3255 | # export MP_PRINTENV=yes |
---|
3256 | |
---|
3257 | # TUNING-VARIABLES TO IMPROVE COMMUNICATION SPEED |
---|
3258 | # DO NOT SHOW SIGNIFICANT EFFECTS (SEP 04, FEDERATION-SWITCH) |
---|
3259 | export MP_WAIT_MODE=poll |
---|
3260 | [[ $node_usage = not_shared ]] && export MP_SINGLE_THREAD=yes |
---|
3261 | fi |
---|
3262 | |
---|
3263 | if [[ $host = ibmkisti ]] |
---|
3264 | then |
---|
3265 | export LANG=en_US |
---|
3266 | export MP_SHARED_MEMORY=yes |
---|
3267 | if [[ $threads_per_task = 1 ]] |
---|
3268 | then |
---|
3269 | export MP_SINGLE_THREAD=yes |
---|
3270 | export MEMORY_AFFINITY=MCM |
---|
3271 | else |
---|
3272 | export OMP_NUM_THREADS=$threads_per_task |
---|
3273 | fi |
---|
3274 | fi |
---|
3275 | |
---|
3276 | if [[ "$LOADLBATCH" = yes ]] |
---|
3277 | then |
---|
3278 | printf "\n--- Control: OMP_NUM_THREADS = \"$OMP_NUM_THREADS\" \n" |
---|
3279 | if [[ "$cond1" = hpmcount || "$cond2" = hpmcount ]] |
---|
3280 | then |
---|
3281 | /opt/optibm/HPM_2_4_1/bin/hpmcount a.out $ROPTS |
---|
3282 | else |
---|
3283 | if [[ $run_coupled_model = false ]] |
---|
3284 | then |
---|
3285 | if [[ "$ocean_file_appendix" = true ]] |
---|
3286 | then |
---|
3287 | echo "precursor_ocean" > runfile_atmos |
---|
3288 | else |
---|
3289 | echo "precursor_atmos" > runfile_atmos |
---|
3290 | fi |
---|
3291 | else |
---|
3292 | (( iia = $numprocs_atmos / $threads_per_task )) |
---|
3293 | (( iio = $numprocs_ocean / $threads_per_task )) |
---|
3294 | printf "\n coupled run ($iia atmosphere, $iio ocean)" |
---|
3295 | printf "\n using $coupled_mode coupling" |
---|
3296 | printf "\n\n" |
---|
3297 | echo "coupled_run $iia $iio" > runfile_atmos |
---|
3298 | fi |
---|
3299 | poe ./a.out $ROPTS < runfile_atmos |
---|
3300 | fi |
---|
3301 | else |
---|
3302 | if [[ $localhost = ibmh || $localhost = ibms ]] |
---|
3303 | then |
---|
3304 | poe a.out -procs $numprocs -nodes 1 -rmpool 0 $ROPTS |
---|
3305 | elif [[ $localhost = ibmkisti || $localhost = ibmku ]] |
---|
3306 | then |
---|
3307 | if [[ -f $hostfile ]] |
---|
3308 | then |
---|
3309 | cp $hostfile hostfile |
---|
3310 | else |
---|
3311 | (( ii = 1 )) |
---|
3312 | while (( ii <= $numprocs )) |
---|
3313 | do |
---|
3314 | echo $localhost_realname >> hostfile |
---|
3315 | (( ii = ii + 1 )) |
---|
3316 | done |
---|
3317 | fi |
---|
3318 | export MP_HOSTFILE=hostfile |
---|
3319 | if [[ $run_coupled_model = false ]] |
---|
3320 | then |
---|
3321 | if [[ "$ocean_file_appendix" = true ]] |
---|
3322 | then |
---|
3323 | echo "precursor_ocean" > runfile_atmos |
---|
3324 | else |
---|
3325 | echo "precursor_atmos" > runfile_atmos |
---|
3326 | fi |
---|
3327 | else |
---|
3328 | (( iia = $numprocs_atmos / $threads_per_task )) |
---|
3329 | (( iio = $numprocs_ocean / $threads_per_task )) |
---|
3330 | printf "\n coupled run ($iia atmosphere, $iio ocean)" |
---|
3331 | printf "\n using $coupled_mode coupling" |
---|
3332 | printf "\n\n" |
---|
3333 | echo "coupled_run $iia $iio" > runfile_atmos |
---|
3334 | fi |
---|
3335 | |
---|
3336 | poe ./a.out -procs $numprocs $ROPTS < runfile_atmos |
---|
3337 | |
---|
3338 | else |
---|
3339 | if [[ "$host_file" = "" ]] |
---|
3340 | then |
---|
3341 | printf "\n +++ no hostfile given in configuration file" |
---|
3342 | locat=config_file |
---|
3343 | exit |
---|
3344 | else |
---|
3345 | eval host_file=$host_file |
---|
3346 | fi |
---|
3347 | export MP_HOSTFILE=$host_file |
---|
3348 | poe a.out -procs $numprocs -tasks_per_node $numprocs $ROPTS |
---|
3349 | fi |
---|
3350 | fi |
---|
3351 | elif [[ $host = nech ]] |
---|
3352 | then |
---|
3353 | (( ii = nodes )) |
---|
3354 | if [[ $ii = 1 ]] |
---|
3355 | then |
---|
3356 | export F_ERRCNT=0 # acceptable number of errors before program is stopped |
---|
3357 | export MPIPROGINF=YES |
---|
3358 | # export F_TRACE=YES|FMT1|FMT2 # output of ftrace informations to job protocol |
---|
3359 | echo "*** execution on single node with mpirun" |
---|
3360 | mpirun -np $numprocs ./a.out $ROPTS |
---|
3361 | else |
---|
3362 | (( i = 0 )) |
---|
3363 | while (( i < ii )) |
---|
3364 | do |
---|
3365 | echo "-h $i -p $tasks_per_node -e ./mpi_exec_shell" >> multinode_config |
---|
3366 | (( i = i + 1 )) |
---|
3367 | done |
---|
3368 | |
---|
3369 | echo "#!/bin/sh" > mpi_exec_shell |
---|
3370 | echo " " >> mpi_exec_shell |
---|
3371 | echo "set -u" >> mpi_exec_shell |
---|
3372 | echo "F_ERRCNT=0" >> mpi_exec_shell |
---|
3373 | echo "MPIPROGINV=YES" >> mpi_exec_shell |
---|
3374 | echo "OMP_NUM_THREADS=$threads_per_task" >> mpi_exec_shell |
---|
3375 | echo "cpurest=$cpurest" >> mpi_exec_shell |
---|
3376 | echo "fname=$fname" >> mpi_exec_shell |
---|
3377 | echo "localhost=$localhost" >> mpi_exec_shell |
---|
3378 | echo "return_addres=$return_addres" >> mpi_exec_shell |
---|
3379 | echo "return_username=$return_username" >> mpi_exec_shell |
---|
3380 | echo "tasks_per_node=$tasks_per_node" >> mpi_exec_shell |
---|
3381 | echo "write_binary=$write_binary" >> mpi_exec_shell |
---|
3382 | echo "use_seperate_pe_for_dvrp_output=$use_seperate_pe_for_dvrp_output" >> mpi_exec_shell |
---|
3383 | echo " " >> mpi_exec_shell |
---|
3384 | echo "export F_ERRCNT" >> mpi_exec_shell |
---|
3385 | echo "export MPIPROGINV" >> mpi_exec_shell |
---|
3386 | echo "export OMP_NUM_THREADS" >> mpi_exec_shell |
---|
3387 | echo "export cpurest" >> mpi_exec_shell |
---|
3388 | echo "export fname" >> mpi_exec_shell |
---|
3389 | echo "export localhost" >> mpi_exec_shell |
---|
3390 | echo "export return_addres" >> mpi_exec_shell |
---|
3391 | echo "export return_username" >> mpi_exec_shell |
---|
3392 | echo "export tasks_per_node" >> mpi_exec_shell |
---|
3393 | echo "export write_binary" >> mpi_exec_shell |
---|
3394 | echo "export use_seperate_pe_for_dvrp_output" >> mpi_exec_shell |
---|
3395 | echo " " >> mpi_exec_shell |
---|
3396 | echo "exec ./a.out" >> mpi_exec_shell |
---|
3397 | |
---|
3398 | chmod u+x mpi_exec_shell |
---|
3399 | export MPIPROGINF=YES |
---|
3400 | mpirun -f multinode_config & |
---|
3401 | wait |
---|
3402 | |
---|
3403 | fi |
---|
3404 | elif [[ $(echo $host | cut -c1-2) = lc && $host != lckyoto && $host != lctit ]] |
---|
3405 | then |
---|
3406 | |
---|
3407 | # COPY HOSTFILE FROM SOURCE DIRECTORY OR CREATE IT, IF IT |
---|
3408 | # DOES NOT EXIST |
---|
3409 | if [[ $host != lccrayb &&$host != lccrayf && $host != lccrayh && $host != lckyuh && $host != lckyut ]] |
---|
3410 | then |
---|
3411 | if [[ -f $hostfile ]] |
---|
3412 | then |
---|
3413 | cp $hostfile hostfile |
---|
3414 | (( ii = $numprocs / $threads_per_task )) |
---|
3415 | else |
---|
3416 | (( ii = 1 )) |
---|
3417 | while (( ii <= $numprocs / $threads_per_task )) |
---|
3418 | do |
---|
3419 | echo $localhost_realname >> hostfile |
---|
3420 | (( ii = ii + 1 )) |
---|
3421 | done |
---|
3422 | fi |
---|
3423 | eval zeile=\"`head -n $ii hostfile`\" |
---|
3424 | printf "\n *** running on: $zeile" |
---|
3425 | fi |
---|
3426 | |
---|
3427 | (( ii = $numprocs / $threads_per_task )) |
---|
3428 | export OMP_NUM_THREADS=$threads_per_task |
---|
3429 | |
---|
3430 | if [[ $threads_per_task != 1 ]] |
---|
3431 | then |
---|
3432 | # INCREASE STACK SIZE TO UNLIMITED, BECAUSE OTHERWISE LARGE RUNS |
---|
3433 | # MAY ABORT |
---|
3434 | ulimit -Ss unlimited |
---|
3435 | printf "\n threads per task: $threads_per_task stacksize: unlimited" |
---|
3436 | fi |
---|
3437 | if [[ $run_coupled_model = false ]] |
---|
3438 | then |
---|
3439 | if [[ "$ocean_file_appendix" = true ]] |
---|
3440 | then |
---|
3441 | echo "precursor_ocean" > runfile_atmos |
---|
3442 | else |
---|
3443 | echo "precursor_atmos" > runfile_atmos |
---|
3444 | fi |
---|
3445 | printf "\n\n" |
---|
3446 | |
---|
3447 | if [[ $host = lccrayb || $host = lccrayh ]] |
---|
3448 | then |
---|
3449 | echo "--- aprun -n $ii -N $tasks_per_node a.out $ROPTS < runfile_atmos" |
---|
3450 | aprun -n $ii -N $tasks_per_node a.out $ROPTS < runfile_atmos |
---|
3451 | # aprun -n $ii -ss -r2 -j1 a.out $ROPTS < runfile_atmos |
---|
3452 | elif [[ $host = lccrayf ]] |
---|
3453 | then |
---|
3454 | aprun -n $ii -N $tasks_per_node -m ${memory}M a.out $ROPTS < runfile_atmos |
---|
3455 | elif [[ $host = lcxe6 || $host = lcxt5m ]] |
---|
3456 | then |
---|
3457 | aprun -n $ii -N $tasks_per_node a.out $ROPTS < runfile_atmos |
---|
3458 | elif [[ $host = lcflow ]] |
---|
3459 | then |
---|
3460 | mpirun -bootstrap sge -np $ii -env I_MPI_FABRICS shm:ofa a.out < runfile_atmos $ROPTS |
---|
3461 | elif [[ $host = lcsb ]] |
---|
3462 | then |
---|
3463 | mpirun_rsh -hostfile $PBS_NODEFILE -np `cat $PBS_NODEFILE | wc -l` a.out < runfile_atmos $ROPTS |
---|
3464 | elif [[ $host = lckiaps ]] |
---|
3465 | then |
---|
3466 | mpirun -np $ii -f $PBS_NODEFILE a.out < runfile_atmos $ROPTS |
---|
3467 | elif [[ $host = lckyu* ]] |
---|
3468 | then |
---|
3469 | mpiexec -n $ii --stdin runfile_atmos ./a.out $ROPTS |
---|
3470 | else |
---|
3471 | mpiexec -machinefile hostfile -n $ii a.out < runfile_atmos $ROPTS |
---|
3472 | fi |
---|
3473 | else |
---|
3474 | |
---|
3475 | # CURRENTLY THERE IS NO FULL MPI-2 SUPPORT ON ICE AND XT4 |
---|
3476 | (( iia = $numprocs_atmos / $threads_per_task )) |
---|
3477 | (( iio = $numprocs_ocean / $threads_per_task )) |
---|
3478 | printf "\n coupled run ($iia atmosphere, $iio ocean)" |
---|
3479 | printf "\n using $coupled_mode coupling" |
---|
3480 | printf "\n\n" |
---|
3481 | |
---|
3482 | if [[ $coupled_mode = "mpi2" ]] |
---|
3483 | then |
---|
3484 | echo "atmosphere_to_ocean $iia $iio" > runfile_atmos |
---|
3485 | echo "ocean_to_atmosphere $iia $iio" > runfile_ocean |
---|
3486 | |
---|
3487 | if [[ $host = lccrayf || $host = lcxe6 || $host = lcxt5m ]] |
---|
3488 | then |
---|
3489 | |
---|
3490 | aprun -n $iia -N $tasks_per_node a.out < runfile_atmos $ROPTS & |
---|
3491 | aprun -n $iio -N $tasks_per_node a.out < runfile_ocean $ROPTS & |
---|
3492 | |
---|
3493 | else |
---|
3494 | # WORKAROUND BECAUSE mpiexec WITH -env option IS NOT AVAILABLE ON SOME SYSTEMS |
---|
3495 | mpiexec -machinefile hostfile -n $iia a.out $ROPTS < runfile_atmos & |
---|
3496 | mpiexec -machinefile hostfile -n $iio a.out $ROPTS < runfile_ocean & |
---|
3497 | # mpiexec -machinefile hostfile -n $iia -env coupling_mode atmosphere_to_ocean a.out $ROPTS & |
---|
3498 | # mpiexec -machinefile hostfile -n $iio -env coupling_mode ocean_to_atmosphere a.out $ROPTS & |
---|
3499 | fi |
---|
3500 | wait |
---|
3501 | |
---|
3502 | else |
---|
3503 | |
---|
3504 | echo "coupled_run $iia $iio" > runfile_atmos |
---|
3505 | |
---|
3506 | if [[ $host = lccrayf || $host = lcxe6 || $host = lcxt5m ]] |
---|
3507 | then |
---|
3508 | |
---|
3509 | aprun -n $ii -N $tasks_per_node a.out < runfile_atmos $ROPTS |
---|
3510 | |
---|
3511 | elif [[ $host = lck || $host = lckordi ]] |
---|
3512 | then |
---|
3513 | |
---|
3514 | mpiexec -n $ii ./a.out $ROPTS < runfile_atmos & |
---|
3515 | |
---|
3516 | elif [[ $host = lckyu* ]] |
---|
3517 | then |
---|
3518 | |
---|
3519 | mpiexec -n $ii --stdin runfile_atmos ./a.out $ROPTS |
---|
3520 | |
---|
3521 | fi |
---|
3522 | wait |
---|
3523 | fi |
---|
3524 | |
---|
3525 | fi |
---|
3526 | |
---|
3527 | elif [[ $host = lckyoto ]] |
---|
3528 | then |
---|
3529 | set -xv |
---|
3530 | export P4_RSHCOMMAND=plesh |
---|
3531 | echo " P4_RSHCOMMAND = $P4_RSHCOMMAND" |
---|
3532 | if [[ "$ENVIRONMENT" = BATCH ]] |
---|
3533 | then |
---|
3534 | if [[ "$cond2" = fujitsu ]] |
---|
3535 | then |
---|
3536 | mpiexec -n $numprocs ./a.out $ROPTS # for fujitsu-compiler |
---|
3537 | elif [[ "cond2" = pgi ]] |
---|
3538 | then |
---|
3539 | mpirun -np $numprocs -machinefile ${QSUB_NODEINF} ./a.out $ROPTS |
---|
3540 | else |
---|
3541 | mpirun_rsh -np $numprocs -hostfile ${QSUB_NODEINF} MV2_USE_SRQ=0 ./a.out ${ROPTS} || /bin/true |
---|
3542 | fi |
---|
3543 | else |
---|
3544 | if [[ "$cond2" = "" ]] |
---|
3545 | then |
---|
3546 | mpiruni_rsh -np $numprocs ./a.out $ROPTS # for intel |
---|
3547 | else |
---|
3548 | mpirun -np $numprocs ./a.out $ROPTS |
---|
3549 | fi |
---|
3550 | fi |
---|
3551 | set +xv |
---|
3552 | |
---|
3553 | elif [[ $host = lctit ]] |
---|
3554 | then |
---|
3555 | export OMP_NUM_THREADS=$threads_per_task |
---|
3556 | echo "OMP_NUM_THREADS=$OMP_NUM_THREADS" |
---|
3557 | if [[ "$threads_per_task" != 1 ]] |
---|
3558 | then |
---|
3559 | export MV2_ENABLE_AFFINITY=0 |
---|
3560 | fi |
---|
3561 | echo "----- PBS_NODEFILE content:" |
---|
3562 | cat $PBS_NODEFILE |
---|
3563 | echo "-----" |
---|
3564 | (( ii = $numprocs / $threads_per_task )) |
---|
3565 | echo "mpirun -np $ii -hostfile $PBS_NODEFILE ./a.out $ROPTS" |
---|
3566 | mpirun -np $ii -hostfile $PBS_NODEFILE ./a.out $ROPTS |
---|
3567 | else |
---|
3568 | mpprun -n $numprocs a.out $ROPTS |
---|
3569 | fi |
---|
3570 | else |
---|
3571 | a.out $ROPTS |
---|
3572 | fi |
---|
3573 | fi |
---|
3574 | |
---|
3575 | if [[ $? != 0 ]] |
---|
3576 | then |
---|
3577 | |
---|
3578 | # ABORT IN CASE OF RUNTIME ERRORS |
---|
3579 | printf "\n +++ runtime error occured" |
---|
3580 | locat=execution |
---|
3581 | exit |
---|
3582 | |
---|
3583 | else |
---|
3584 | |
---|
3585 | printf "\n$dashes\n *** execution finished \n" |
---|
3586 | |
---|
3587 | # STOP THE DVR STREAMING SERVER AND PROCESS THE DVR OUTPUT IN ORDER |
---|
3588 | # TO CREAT DVRS- AND HTML-FILES CONTAINING ALL STREAMS |
---|
3589 | if [[ "$dvrserver_id" != "" ]] |
---|
3590 | then |
---|
3591 | kill $dvrserver_id |
---|
3592 | printf "\n *** dvr server with id=$dvrserver_id has been stopped" |
---|
3593 | |
---|
3594 | # IF THERE IS A DIRECTORY, DATA HAVE BEEN OUTPUT BY THE |
---|
3595 | # STREAMING SERVER. OTHERWISE, USER HAS CHOSEN dvrp_output=local |
---|
3596 | if [[ -d DATA_DVR ]] |
---|
3597 | then |
---|
3598 | |
---|
3599 | # ADD THE CURRENT DVR CONFIGURATION FILE TO THE DVR OUTPUT |
---|
3600 | # DIRECTORY |
---|
3601 | cp .dvrserver.config DATA_DVR |
---|
3602 | |
---|
3603 | # PROCESS THE DVR OUTPUT (OPTION -s FOR GENERATING |
---|
3604 | # SEQUENCE MODE DATA TOO) |
---|
3605 | process_dvr_output -d DATA_DVR -f $fname -s |
---|
3606 | |
---|
3607 | else |
---|
3608 | |
---|
3609 | # PROCESS THE LOCAL OUTPUT |
---|
3610 | process_dvr_output -l -d DATA_DVR -f $fname |
---|
3611 | |
---|
3612 | fi |
---|
3613 | |
---|
3614 | elif [[ $(echo $package_list | grep -c dvrp_graphics) != 0 ]] |
---|
3615 | then |
---|
3616 | |
---|
3617 | # PROCESS DVR OUTPUT GENERATD IN LOCAL MODE (dvrp_output=local) |
---|
3618 | process_dvr_output -l -d DATA_DVR -f $fname |
---|
3619 | |
---|
3620 | fi |
---|
3621 | fi |
---|
3622 | |
---|
3623 | |
---|
3624 | |
---|
3625 | # CALL OF combine_plot_fields IN ORDER TO MERGE SINGLE FILES WRITTEN |
---|
3626 | # BY EACH CORE INTO ONE FILE |
---|
3627 | if [[ ! -f ${PALM_BIN}/combine_plot_fields${block}.x ]] |
---|
3628 | then |
---|
3629 | printf "\n\n\n +++ WARNING: no combine_plot_fields found for given block \"$cond1 $cond2\"" |
---|
3630 | printf "\n 2d- and/or 3d-data may be incomplete!" |
---|
3631 | printf "\n Run \"mbuild -u -h $localhost\" to generate utilities for this block.\n" |
---|
3632 | elif [[ "$combine_plot_fields" == true ]] |
---|
3633 | then |
---|
3634 | if [[ $localhost = lccrayh || $localhost = lccrayb ]] |
---|
3635 | then |
---|
3636 | printf "\n\n\n *** post-processing: now executing \"aprun -n 1 -N 1 combine_plot_fields${block}.x\" ..." |
---|
3637 | aprun -n 1 -N 1 combine_plot_fields${block}.x #$ROPTS < runfile_atmos |
---|
3638 | else |
---|
3639 | printf "\n\n\n *** post-processing: now executing \"combine_plot_fields${block}.x\" ..." |
---|
3640 | combine_plot_fields${block}.x |
---|
3641 | fi |
---|
3642 | else |
---|
3643 | |
---|
3644 | # TEMPORARY SOLUTION TO SKIP combine_plot_fields. THIS IS REQUIRED IN CASE OF HUGE AMOUNT OF |
---|
3645 | # DATA OUTPUT. TO DO: EXTEND THIS BRANCH BY CREATING A BATCH JOB for combine_plot_fields. |
---|
3646 | # ??? koennen wir das streichen ??? |
---|
3647 | printf "\n\n\n *** post-processing: skipping combine_plot_fields (-Z option set) ..." |
---|
3648 | fi |
---|
3649 | |
---|
3650 | |
---|
3651 | |
---|
3652 | # EXECUTE OUTPUT-COMMANDS GIVEN IN THE CONFIGURATION FILE |
---|
3653 | (( i = 0 )) |
---|
3654 | while (( i < ioc )) |
---|
3655 | do |
---|
3656 | (( i = i + 1 )) |
---|
3657 | if (( i == 1 )) |
---|
3658 | then |
---|
3659 | printf "\n\n *** execution of OUTPUT-commands:\n$dashes" |
---|
3660 | fi |
---|
3661 | printf "\n >>> ${out_command[$i]}" |
---|
3662 | eval ${out_command[$i]} |
---|
3663 | if (( i == ioc )) |
---|
3664 | then |
---|
3665 | printf "\n$dashes\n" |
---|
3666 | fi |
---|
3667 | done |
---|
3668 | |
---|
3669 | |
---|
3670 | # IN TRACE-MODE PRINT CONTENTS OF THE CURRENT (TEMPORARY) WORKING DIRECTORY |
---|
3671 | if [[ $do_trace = true ]] |
---|
3672 | then |
---|
3673 | printf "\n\n" |
---|
3674 | ls -al |
---|
3675 | fi |
---|
3676 | |
---|
3677 | |
---|
3678 | |
---|
3679 | # COPY LOCAL OUTPUT-FILES TO THEIR PERMANENT DESTINATIONS |
---|
3680 | (( i = 0 )) |
---|
3681 | while (( i < iout )) |
---|
3682 | do |
---|
3683 | (( i = i + 1 )) |
---|
3684 | if (( i == 1 )) |
---|
3685 | then |
---|
3686 | printf "\n\n *** saving OUTPUT-files:\n$dashes" |
---|
3687 | fi |
---|
3688 | |
---|
3689 | # CHECK FOR SINGLE FILE (SERIAL RUN) OR DIRECTORY (ONE FILE PER CORE FOR PARELLEL EXECUTION) |
---|
3690 | files_for_pes=false; filetyp=file |
---|
3691 | if [[ "${actionout[$i]}" = pe && -n $numprocs ]] |
---|
3692 | then |
---|
3693 | files_for_pes=true; filetyp=directory |
---|
3694 | actionout[$i]="" |
---|
3695 | elif [[ "${actionout[$i]}" = pe && ! -n $numprocs ]] |
---|
3696 | then |
---|
3697 | actionout[$i]="" |
---|
3698 | elif [[ "${actionout[$i]}" = arpe && -n $numprocs ]] |
---|
3699 | then |
---|
3700 | files_for_pes=true; filetyp=directory |
---|
3701 | actionout[$i]="ar" |
---|
3702 | elif [[ "${actionout[$i]}" = arpe && ! -n $numprocs ]] |
---|
3703 | then |
---|
3704 | actionout[$i]="ar" |
---|
3705 | elif [[ "${actionout[$i]}" = flpe && -n $numprocs ]] |
---|
3706 | then |
---|
3707 | files_for_pes=true; filetyp=directory |
---|
3708 | actionout[$i]="fl" |
---|
3709 | elif [[ "${actionout[$i]}" = flpe && ! -n $numprocs ]] |
---|
3710 | then |
---|
3711 | actionout[$i]="fl" |
---|
3712 | elif [[ "${actionout[$i]}" = trpe && -n $numprocs ]] |
---|
3713 | then |
---|
3714 | files_for_pes=true; filetyp=directory |
---|
3715 | actionout[$i]="tr" |
---|
3716 | elif [[ "${actionout[$i]}" = trpe && ! -n $numprocs ]] |
---|
3717 | then |
---|
3718 | actionout[$i]="tr" |
---|
3719 | fi |
---|
3720 | |
---|
3721 | if [[ ! -f ${localout[$i]} && $files_for_pes = false ]] |
---|
3722 | then |
---|
3723 | printf "\n +++ temporary OUTPUT-file ${localout[$i]} does not exist\n" |
---|
3724 | elif [[ ! -d ${localout[$i]} && $files_for_pes = true ]] |
---|
3725 | then |
---|
3726 | printf "\n +++ temporary OUTPUT-file ${localout[$i]}/.... does not exist\n" |
---|
3727 | else |
---|
3728 | |
---|
3729 | |
---|
3730 | # COPY VIA SCP TO LOCAL HOST (ALWAYS IN BINARY MODE USING batch_scp option -m) |
---|
3731 | # IF TARGET DIRECTORY DOES NOT EXISTS, TRY TO CREATE IT |
---|
3732 | if [[ "${actionout[$i]}" = tr ]] |
---|
3733 | then |
---|
3734 | if [[ $localhost != $fromhost ]] |
---|
3735 | then |
---|
3736 | if [[ $files_for_pes = false ]] |
---|
3737 | then |
---|
3738 | cps="" |
---|
3739 | cst="" |
---|
3740 | else |
---|
3741 | cps=-c |
---|
3742 | cst="/" |
---|
3743 | fi |
---|
3744 | if [[ $localhost = nech ]] |
---|
3745 | then |
---|
3746 | |
---|
3747 | # TRANSFER IN SEPERATE JOB |
---|
3748 | # FIRST COPY FILE TO TEMPORY DATA DIRECTORY |
---|
3749 | [[ ! -d $tmp_data_catalog/TRANSFER ]] && mkdir -p $tmp_data_catalog/TRANSFER |
---|
3750 | file_to_transfer=${fname}_${localout[$i]}_to_transfer_$kennung |
---|
3751 | if [[ $files_for_pes = false ]] |
---|
3752 | then |
---|
3753 | ln -f ${localout[$i]} $tmp_data_catalog/TRANSFER/$file_to_transfer |
---|
3754 | else |
---|
3755 | mkdir $tmp_data_catalog/TRANSFER/$file_to_transfer |
---|
3756 | ln ${localout[$i]}/* $tmp_data_catalog/TRANSFER/$file_to_transfer |
---|
3757 | fi |
---|
3758 | |
---|
3759 | echo "set -x" > transfer_${localout[$i]} |
---|
3760 | echo "cd $tmp_data_catalog/TRANSFER" >> transfer_${localout[$i]} |
---|
3761 | |
---|
3762 | printf "\n >>> OUTPUT: ${localout[$i]}$cst by SCP in seperate job to" |
---|
3763 | printf "\n ${pathout[$i]}/${localhost}_${fname}${endout[$i]}$cst" |
---|
3764 | printf "\n or higher cycle\n" |
---|
3765 | 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]} |
---|
3766 | |
---|
3767 | echo "[[ \$? = 0 ]] && rm $file_to_transfer" >> transfer_${localout[$i]} |
---|
3768 | |
---|
3769 | if [[ $localhost = nech ]] |
---|
3770 | then |
---|
3771 | subjob -d -c /pf/b/$usern/job_queue -v -q pp -X 0 -m 1000 -t 900 $PORTOPT transfer_${localout[$i]} |
---|
3772 | else |
---|
3773 | if [[ "$LOGNAME" = b323013 ]] |
---|
3774 | then |
---|
3775 | subjob -v -q c1 -X 0 -m 1000 -t 900 -c $job_catalog $PORTOPT transfer_${localout[$i]} |
---|
3776 | else |
---|
3777 | subjob -d -v -q c1 -X 0 -m 1000 -t 900 -c $job_catalog $PORTOPT transfer_${localout[$i]} |
---|
3778 | fi |
---|
3779 | fi |
---|
3780 | |
---|
3781 | else |
---|
3782 | |
---|
3783 | # TRANSFER WITHIN THIS JOB |
---|
3784 | transfer_failed=false |
---|
3785 | printf "\n >>> OUTPUT: ${localout[$i]}$cst by SCP to" |
---|
3786 | printf "\n ${pathout[$i]}/${localhost}_${fname}${endout[$i]}$cst\n" |
---|
3787 | if [[ $localhost = lccrayb ]] |
---|
3788 | then |
---|
3789 | 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]}" |
---|
3790 | elif [[ $localhost = lccrayh ]] |
---|
3791 | then |
---|
3792 | 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]}" |
---|
3793 | else |
---|
3794 | batch_scp $PORTOPT $cps -b -m -u $return_username $return_addres ${localout[$i]} "${pathout[$i]}" ${localhost}_${fname}${endout[$i]} ${extout[$i]} |
---|
3795 | fi |
---|
3796 | [[ $? != 0 ]] && transfer_failed=true |
---|
3797 | |
---|
3798 | # IF TRANSFER FAILED, CREATE BACKUP COPY ON THIS MACHINE |
---|
3799 | if [[ $transfer_failed = true ]] |
---|
3800 | then |
---|
3801 | printf " +++ transfer failed. Trying to save a copy on this host under:\n" |
---|
3802 | printf " ${pathout[$i]}/${localhost}_${fname}${endout[$i]}_$kennung\n" |
---|
3803 | |
---|
3804 | # FIRST CHECK, IF DIRECTORY EXISTS, AND CREATE IT, IF NECESSARY |
---|
3805 | eval local_catalog=${pathout[$i]} |
---|
3806 | if [[ ! -d $local_catalog ]] |
---|
3807 | then |
---|
3808 | printf " *** local directory does not exist. Trying to create:\n" |
---|
3809 | printf " $local_catalog \n" |
---|
3810 | mkdir -p $local_catalog |
---|
3811 | fi |
---|
3812 | eval cp ${localout[$i]} ${pathout[$i]}/${localhost}_${fname}${endout[$i]}_$kennung |
---|
3813 | transfer_problems=true |
---|
3814 | fi |
---|
3815 | fi |
---|
3816 | else |
---|
3817 | |
---|
3818 | # UNSET actionout. DUE TO THIS SETTING, FILE WILL LATER JUST BE COPIED ON THIS MACHINE |
---|
3819 | actionout[$i]="" |
---|
3820 | fi |
---|
3821 | fi |
---|
3822 | |
---|
3823 | |
---|
3824 | # APPEND VIA SCP TO LOCAL HOST (ALWAYS IN BINARY MODE USING batch_scp option -m) |
---|
3825 | # IF TARGET DIRECTORY DOES NOT EXISTS, TRY TO CREATE IT |
---|
3826 | if [[ "${actionout[$i]}" = tra ]] |
---|
3827 | then |
---|
3828 | if [[ $localhost != $fromhost ]] |
---|
3829 | then |
---|
3830 | if [[ $localhost = ibmh || $localhost = nech ]] |
---|
3831 | then |
---|
3832 | |
---|
3833 | # TRANSFER IN SEPERATE JOB |
---|
3834 | # FIRST COPY FILE TO TEMPORY DATA DIRECTORY |
---|
3835 | [[ ! -d $tmp_data_catalog/TRANSFER ]] && mkdir -p $tmp_data_catalog/TRANSFER |
---|
3836 | file_to_transfer=${fname}_${localout[$i]}_to_transfer_$kennung |
---|
3837 | ln -f ${localout[$i]} $tmp_data_catalog/TRANSFER/$file_to_transfer |
---|
3838 | |
---|
3839 | echo "set -x" > transfer_${localout[$i]} |
---|
3840 | echo "cd $tmp_data_catalog/TRANSFER" >> transfer_${localout[$i]} |
---|
3841 | |
---|
3842 | printf "\n >>> OUTPUT: ${localout[$i]} append by SCP in seperate job to" |
---|
3843 | printf "\n ${pathout[$i]}/${localhost}_${fname}${endout[$i]}" |
---|
3844 | printf "\n or higher cycle\n" |
---|
3845 | 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]} |
---|
3846 | |
---|
3847 | echo "[[ \$? = 0 ]] && rm $file_to_transfer" >> transfer_${localout[$i]} |
---|
3848 | |
---|
3849 | if [[ $localhost = nech ]] |
---|
3850 | then |
---|
3851 | subjob -d -c /pf/b/$usern/job_queue -v -q pp -X 0 -m 1000 -t 900 $PORTOPT transfer_${localout[$i]} |
---|
3852 | else |
---|
3853 | if [[ $LOGNAME = b323013 ]] |
---|
3854 | then |
---|
3855 | subjob -v -q c1 -X 0 -m 1000 -t 900 -c $job_catalog $PORTOPT transfer_${localout[$i]} |
---|
3856 | else |
---|
3857 | subjob -d -v -q c1 -X 0 -m 1000 -t 900 -c $job_catalog $PORTOPT transfer_${localout[$i]} |
---|
3858 | fi |
---|
3859 | fi |
---|
3860 | |
---|
3861 | else |
---|
3862 | |
---|
3863 | # TRANSFER WITHIN THIS JOB |
---|
3864 | transfer_failed=false |
---|
3865 | printf "\n >>> OUTPUT: ${localout[$i]} append by SCP to" |
---|
3866 | printf "\n ${pathout[$i]}/${localhost}_${fname}${endout[$i]}\n" |
---|
3867 | if [[ $localhost = lccrayb ]] |
---|
3868 | then |
---|
3869 | 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]}" |
---|
3870 | elif [[ $localhost = lccrayh ]] |
---|
3871 | then |
---|
3872 | 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]}" |
---|
3873 | else |
---|
3874 | batch_scp $PORTOPT -A -b -m -u $return_username $return_addres ${localout[$i]} "${pathout[$i]}" ${localhost}_${fname}${endout[$i]} ${extout[$i]} |
---|
3875 | fi |
---|
3876 | [[ $? != 0 ]] && transfer_failed=true |
---|
3877 | |
---|
3878 | # IF TRANSFER FAILED, CREATE BACKUP COPY ON THIS MACHINE |
---|
3879 | if [[ $transfer_failed = true ]] |
---|
3880 | then |
---|
3881 | printf " +++ transfer failed. Trying to save a copy on this host under:\n" |
---|
3882 | printf " ${pathout[$i]}/${localhost}_${fname}${endout[$i]}_$kennung\n" |
---|
3883 | |
---|
3884 | # FIRST CHECK, IF DIRECTORY EXISTS, AND CREATE IT, IF NECESSARY |
---|
3885 | eval local_catalog=${pathout[$i]} |
---|
3886 | if [[ ! -d $local_catalog ]] |
---|
3887 | then |
---|
3888 | printf " *** local directory does not exist. Trying to create:\n" |
---|
3889 | printf " $local_catalog \n" |
---|
3890 | mkdir -p $local_catalog |
---|
3891 | fi |
---|
3892 | |
---|
3893 | eval cp ${localout[$i]} ${pathout[$i]}/${localhost}_${fname}${endout[$i]}_$kennung |
---|
3894 | transfer_problems=true |
---|
3895 | fi |
---|
3896 | fi |
---|
3897 | else |
---|
3898 | |
---|
3899 | # RESET actionout. DUE TO THIS SETTING, FILE WILL LATER JUST BE APPENDED ON THIS MACHINE |
---|
3900 | actionout[$i]=a |
---|
3901 | fi |
---|
3902 | fi |
---|
3903 | |
---|
3904 | |
---|
3905 | # OUTPUT-FILE FOR A RESTART-RUN. |
---|
3906 | # FILE IS MOVED TO THE TEMPORARY DATA DIRECTORY USING link COMMAND. |
---|
3907 | # OPTION -f IS USED TO OVERWRITE EXISTING FILES. |
---|
3908 | # AS LAST ACTION, ARCHIVING IS INITIATED. |
---|
3909 | if [[ "${actionout[$i]}" = fl ]] |
---|
3910 | then |
---|
3911 | [[ ! -d $tmp_data_catalog ]] && mkdir -p $tmp_data_catalog |
---|
3912 | chmod g+rx $tmp_data_catalog |
---|
3913 | if [[ $files_for_pes = false ]] |
---|
3914 | then |
---|
3915 | printf "\n >>> OUTPUT: ${localout[$i]} to" |
---|
3916 | printf "\n $tmp_data_catalog/${frelout[$i]} (temporary data catalog)\n" |
---|
3917 | ln -f ${localout[$i]} $tmp_data_catalog/${frelout[$i]} |
---|
3918 | else |
---|
3919 | printf "\n >>> OUTPUT: ${localout[$i]}/.... to" |
---|
3920 | printf "\n $tmp_data_catalog/${frelout[$i]} (temporary data catalog)\n" |
---|
3921 | mkdir $tmp_data_catalog/${frelout[$i]} |
---|
3922 | cd ${localout[$i]} |
---|
3923 | for file in $(ls *) |
---|
3924 | do |
---|
3925 | ln -f $file $tmp_data_catalog/${frelout[$i]} |
---|
3926 | done |
---|
3927 | cd $TEMPDIR |
---|
3928 | fi |
---|
3929 | |
---|
3930 | |
---|
3931 | # CREATE AND SUBMIT ARCHIVING-JOB |
---|
3932 | if [[ $store_on_archive_system = true ]] |
---|
3933 | then |
---|
3934 | |
---|
3935 | if [[ $archive_system = asterix ]] |
---|
3936 | then |
---|
3937 | echo "cd $tmp_data_catalog" >> archive_${frelout[$i]} |
---|
3938 | if [[ $files_for_pes = false ]] |
---|
3939 | then |
---|
3940 | echo "stageout ${frelout[$i]} > STAGE_OUTPUT${i}_$kennung" >> archive_${frelout[$i]} |
---|
3941 | else |
---|
3942 | echo "stageout -t ${frelout[$i]} > STAGE_OUTPUT${i}_$kennung" >> archive_${frelout[$i]} |
---|
3943 | fi |
---|
3944 | echo "cat STAGE_OUTPUT${i}_$kennung" >> archive_${frelout[$i]} |
---|
3945 | echo "if [[ \$(grep -c \"st.msg:150\" STAGE_OUTPUT${i}_$kennung) != 0 ]]" >> archive_${frelout[$i]} |
---|
3946 | echo "then" >> archive_${frelout[$i]} |
---|
3947 | echo " do_stageout=false" >> archive_${frelout[$i]} |
---|
3948 | echo "else" >> archive_${frelout[$i]} |
---|
3949 | echo " echo \" +++ $filetyp ${frelout[$i]} could not be stored on archive-system\" " >> archive_${frelout[$i]} |
---|
3950 | echo " cat /dev/null > ~/job_queue/ARCHIVE_ERROR_$fname" >> archive_${frelout[$i]} |
---|
3951 | echo " cat STAGE_OUTPUT${i}_$kennung > ~/job_queue/archive_${frelout[$i]}_error" >> archive_${frelout[$i]} |
---|
3952 | echo " echo \" *** $filetyp ${frelout[$i]} will be copied to \$WORK as backup\" " >> archive_${frelout[$i]} |
---|
3953 | if [[ $files_for_pes = false ]] |
---|
3954 | then |
---|
3955 | echo " cp ${frelout[$i]} \$WORK" >> archive_${frelout[$i]} |
---|
3956 | else |
---|
3957 | echo " cp -r ${frelout[$i]} \$WORK/${frelout[$i]}" >> archive_${frelout[$i]} |
---|
3958 | fi |
---|
3959 | echo " echo \" *** $filetyp ${frelout[$i]} saved\" " >> archive_${frelout[$i]} |
---|
3960 | echo "fi" >> archive_${frelout[$i]} |
---|
3961 | echo "rm STAGE_OUTPUT${i}_$kennung" >> archive_${frelout[$i]} |
---|
3962 | elif [[ $archive_system = DMF ]] |
---|
3963 | then |
---|
3964 | echo "cd $tmp_data_catalog" >> archive_${frelout[$i]} |
---|
3965 | if [[ $files_for_pes = false ]] |
---|
3966 | then |
---|
3967 | printf "\n +++ archiving of single files impossible with $archive_system !\n" |
---|
3968 | locat=DMF |
---|
3969 | exit |
---|
3970 | else |
---|
3971 | # ??? nicht benötigte Archiv-Systeme entfernen ??? |
---|
3972 | # FUER RECHNER IN JUELICH. DORT KOENNTEN AUCH |
---|
3973 | # EINZELNE DATEIEN GESICHERT WERDEN (SPAETER KORR.) |
---|
3974 | echo "rm -rf \$ARCHIVE/${frelout[$i]}" >> archive_${frelout[$i]} |
---|
3975 | echo "cp -r ${frelout[$i]} \$ARCHIVE" >> archive_${frelout[$i]} |
---|
3976 | fi |
---|
3977 | elif [[ $archive_system = tivoli ]] |
---|
3978 | then |
---|
3979 | echo "cd $tmp_data_catalog" >> archive_${frelout[$i]} |
---|
3980 | if [[ $files_for_pes = false ]] |
---|
3981 | then |
---|
3982 | # REMOVE EXISTING OLD FILES FROM THE ARCHIVE |
---|
3983 | echo "set -x" >> archive_${frelout[$i]} |
---|
3984 | echo "rm -rf \$PERM/${frelout[$i]}" >> archive_${frelout[$i]} |
---|
3985 | echo "cp ${frelout[$i]} \$PERM/${frelout[$i]}" >> archive_${frelout[$i]} |
---|
3986 | else |
---|
3987 | |
---|
3988 | echo "set -x" >> archive_${frelout[$i]} |
---|
3989 | echo "rm -rf \$PERM/${frelout[$i]}/*" >> archive_${frelout[$i]} |
---|
3990 | echo "[[ ! -d \$PERM/${frelout[$i]} ]] && mkdir $PERM/${frelout[$i]}" >> archive_${frelout[$i]} |
---|
3991 | cd $tmp_data_catalog |
---|
3992 | all_files=`ls -1 ${frelout[$i]}/*` |
---|
3993 | cd - > /dev/null |
---|
3994 | (( inode = 0 )) |
---|
3995 | (( tp1 = tasks_per_node + 1 )) |
---|
3996 | while (( inode < nodes )) |
---|
3997 | do |
---|
3998 | files=`echo $all_files | cut -d" " -f1-$tasks_per_node` |
---|
3999 | all_files=`echo $all_files | cut -d" " -f$tp1-` |
---|
4000 | echo "tar cvf \$PERM/${frelout[$i]}/${frelout[$i]}.node_$inode.tar $files" >> archive_${frelout[$i]} |
---|
4001 | (( inode = inode + 1 )) |
---|
4002 | done |
---|
4003 | fi |
---|
4004 | elif [[ $archive_system = ut ]] |
---|
4005 | then |
---|
4006 | echo "cd $tmp_data_catalog" >> archive_${frelout[$i]} |
---|
4007 | if [[ $files_for_pes = false ]] |
---|
4008 | then |
---|
4009 | # REMOVE EXISTING OLD FILES FROM THE ARCHIVE |
---|
4010 | echo "set -x" >> archive_${frelout[$i]} |
---|
4011 | echo "rm -rf \$UT/${frelout[$i]}" >> archive_${frelout[$i]} |
---|
4012 | echo "cp ${frelout[$i]} \$UT/${frelout[$i]}" >> archive_${frelout[$i]} |
---|
4013 | else |
---|
4014 | |
---|
4015 | echo "set -x" >> archive_${frelout[$i]} |
---|
4016 | echo "rm -rf \$UT/${frelout[$i]}/*" >> archive_${frelout[$i]} |
---|
4017 | echo "[[ ! -d \$UT/${frelout[$i]} ]] && mkdir $UT/${frelout[$i]}" >> archive_${frelout[$i]} |
---|
4018 | cd $tmp_data_catalog |
---|
4019 | all_files=`ls -1 ${frelout[$i]}/*` |
---|
4020 | cd - > /dev/null |
---|
4021 | (( inode = 0 )) |
---|
4022 | (( tp1 = tasks_per_node + 1 )) |
---|
4023 | while (( inode < nodes )) |
---|
4024 | do |
---|
4025 | files=`echo $all_files | cut -d" " -f1-$tasks_per_node` |
---|
4026 | all_files=`echo $all_files | cut -d" " -f$tp1-` |
---|
4027 | echo "tar cvf \$UT/${frelout[$i]}/${frelout[$i]}.node_$inode.tar $files" >> archive_${frelout[$i]} |
---|
4028 | (( inode = inode + 1 )) |
---|
4029 | done |
---|
4030 | fi |
---|
4031 | elif [[ $archive_system = none ]] |
---|
4032 | then |
---|
4033 | printf " +++ archiving on $localhost not available!\n" |
---|
4034 | fi |
---|
4035 | |
---|
4036 | if [[ $archive_system != none ]] |
---|
4037 | then |
---|
4038 | if [[ $localhost = nech ]] |
---|
4039 | then |
---|
4040 | subjob -d -c /pf/b/$usern/job_queue -v -q pp -X 0 -m 1000 -t 7200 $PORTOPT archive_${frelout[$i]} |
---|
4041 | fi |
---|
4042 | printf " Archiving of $tmp_data_catalog/${frelout[$i]} initiated (batch job submitted)\n" |
---|
4043 | fi |
---|
4044 | else |
---|
4045 | printf " +++ caution: option -A is switched off. No archiving on $archive_system!\n" |
---|
4046 | fi |
---|
4047 | |
---|
4048 | |
---|
4049 | # CREATE AN EMPTY DIRECTORY IN THE USERS PERMANENT DIRECTORY, |
---|
4050 | # IN ORDER TO NOTE THE RESPECTIVE CYCLE NUMBER ON THE ARCHIVE SYSTEM |
---|
4051 | # RESTART-JOBS ARE USING THESE EMPTY-DIRECTORIES TO GET THE CURRENT HIGHEST |
---|
4052 | # CYCLE NUMBER ON THE ARCHIVE SYSTEM (IN CASE THAT INFORMATIONS ARE DIFFICULT TO |
---|
4053 | # TO ACCESS FROM THE ARCHIVE-SYSTEM DIRECTLY)) |
---|
4054 | if [[ $files_for_pes = false ]] |
---|
4055 | then |
---|
4056 | cat /dev/null > ${pathout[$i]} |
---|
4057 | else |
---|
4058 | mkdir -p ${pathout[$i]} |
---|
4059 | fi |
---|
4060 | |
---|
4061 | fi |
---|
4062 | |
---|
4063 | |
---|
4064 | # COPY FROM THIS HOST TO THE ARCHIVE-SYSTEM |
---|
4065 | # IF ANY ARCHIVING FAILS, AN ERROR-FLAG-FILE IS SET |
---|
4066 | # THIS FILE REMAINS TO BE SET, EVEN IF ARCHIVING OF FURTHER FILES IS SUCCESSFULL |
---|
4067 | if [[ "${actionout[$i]}" = ar ]] |
---|
4068 | then |
---|
4069 | if [[ $files_for_pes = false ]] |
---|
4070 | then |
---|
4071 | printf "\n >>> OUTPUT: ${localout[$i]} to" |
---|
4072 | printf "\n ${pathout[$i]}" |
---|
4073 | printf "\n File will be copied to archive-system ($archive_system) !\n" |
---|
4074 | else |
---|
4075 | printf "\n >>> OUTPUT: ${localout[$i]}/_.... to" |
---|
4076 | printf "\n ${pathout[$i]}" |
---|
4077 | printf "\n Directory will be copied to archive-system ($archive_system) !\n" |
---|
4078 | fi |
---|
4079 | mv ${localout[$i]} ${frelout[$i]} |
---|
4080 | |
---|
4081 | file_saved=false |
---|
4082 | |
---|
4083 | if [[ $archive_system = asterix ]] |
---|
4084 | then |
---|
4085 | do_stageout=true |
---|
4086 | (( stageout_anz = 0 )) |
---|
4087 | while [[ $do_stageout = true ]] |
---|
4088 | do |
---|
4089 | if [[ $files_for_pes = false ]] |
---|
4090 | then |
---|
4091 | stageout ${frelout[$i]} > STAGE_OUTPUT |
---|
4092 | else |
---|
4093 | stageout -t ${frelout[$i]} > STAGE_OUTPUT |
---|
4094 | fi |
---|
4095 | cat STAGE_OUTPUT |
---|
4096 | if [[ $(grep -c "st.msg:150" STAGE_OUTPUT) != 0 ]] |
---|
4097 | then |
---|
4098 | file_saved=true |
---|
4099 | do_stageout=false |
---|
4100 | else |
---|
4101 | if [[ $files_for_pes = false ]] |
---|
4102 | then |
---|
4103 | printf "\n +++ file ${frelout[$i]} could not be saved on archive-system" |
---|
4104 | else |
---|
4105 | printf "\n +++ directory ${frelout[$i]} could not be saved on archive-system" |
---|
4106 | fi |
---|
4107 | (( stageout_anz = stageout_anz + 1 )) |
---|
4108 | if (( stageout_anz == 10 )) |
---|
4109 | then |
---|
4110 | printf "\n +++ stoped after 10 unsuccessful tries!" |
---|
4111 | archive_save=false |
---|
4112 | do_stageout=false |
---|
4113 | else |
---|
4114 | printf "\n *** new try to store on archive after 15 min:" |
---|
4115 | sleep 900 |
---|
4116 | fi |
---|
4117 | fi |
---|
4118 | done |
---|
4119 | elif [[ $archive_system = DMF ]] |
---|
4120 | then |
---|
4121 | if [[ $files_for_pes = false ]] |
---|
4122 | then |
---|
4123 | printf "\n +++ archiving of single files impossible on $archive_system!\n" |
---|
4124 | locat=DMF |
---|
4125 | exit |
---|
4126 | else |
---|
4127 | rm -rf $ARCHIVE/${frelout[$i]} |
---|
4128 | cp -r ${frelout[$i]} $ARCHIVE |
---|
4129 | fi |
---|
4130 | file_saved=true |
---|
4131 | elif [[ $archive_system = tivoli ]] |
---|
4132 | then |
---|
4133 | # ARCHIVING ONLY POSSIBLE VIA BATCH-JOB |
---|
4134 | # IN THE MEANTIME, FILE IS STORED IN THE TEMPORARY DATA DIRECTORY, |
---|
4135 | # BECAUSE MRUN'S CURRENT TEMPORARY WORKING DIRECTORY MAY ALREADY BE DELETED |
---|
4136 | # WHEN THE ARCHIVE-JOB IS EXECUTED |
---|
4137 | [[ ! -d $tmp_data_catalog ]] && mkdir -p $tmp_data_catalog |
---|
4138 | chmod g+rx $tmp_data_catalog |
---|
4139 | if [[ $files_for_pes = false ]] |
---|
4140 | then |
---|
4141 | ln -f ${frelout[$i]} $tmp_data_catalog/${frelout[$i]} |
---|
4142 | else |
---|
4143 | mkdir $tmp_data_catalog/${frelout[$i]} |
---|
4144 | ln -f ${frelout[$i]}/* $tmp_data_catalog/${frelout[$i]} |
---|
4145 | fi |
---|
4146 | |
---|
4147 | # GENERATE AND SUBMIT BATCH-JOB |
---|
4148 | # FILE HAS TO BE DELETED FROM THE TEMPORARY DATA DIRECTORY |
---|
4149 | # DELETE OLD EXISTING FILES FROM THE ARCHIVE |
---|
4150 | echo "cd $tmp_data_catalog" > archive_${frelout[$i]} |
---|
4151 | if [[ $files_for_pes = false ]] |
---|
4152 | then |
---|
4153 | echo "rm -rf \$PERM/${frelout[$i]}" >> archive_${frelout[$i]} |
---|
4154 | echo "cp ${frelout[$i]} \$PERM/${frelout[$i]}" >> archive_${frelout[$i]} |
---|
4155 | echo "rm -rf ${frelout[$i]}" >> archive_${frelout[$i]} |
---|
4156 | else |
---|
4157 | echo "rm -rf \$PERM/${frelout[$i]}.tar" >> archive_${frelout[$i]} |
---|
4158 | echo "tar cvf \$PERM/${frelout[$i]}.tar ${frelout[$i]}" >> archive_${frelout[$i]} |
---|
4159 | echo "rm -rf ${frelout[$i]}" >> archive_${frelout[$i]} |
---|
4160 | fi |
---|
4161 | |
---|
4162 | subjob -v -d -q cdata -X 0 -m 1000 -t 43200 -c $job_catalog $PORTOPT archive_${frelout[$i]} |
---|
4163 | printf " Archiving of $tmp_data_catalog/${frelout[$i]} initiated (batch job submitted)\n" |
---|
4164 | file_saved=true |
---|
4165 | |
---|
4166 | elif [[ $archive_system = ut ]] |
---|
4167 | then |
---|
4168 | # ARCHIVING ONLY POSSIBLE VIA BATCH-JOB |
---|
4169 | # IN THE MEANTIME, FILE IS STORED IN THE TEMPORARY DATA DIRECTORY, |
---|
4170 | # BECAUSE MRUN'S CURRENT TEMPORARY WORKING DIRECTORY MAY ALREADY BE DELETED |
---|
4171 | # WHEN THE ARCHIVE-JOB IS EXECUTED |
---|
4172 | [[ ! -d $tmp_data_catalog ]] && mkdir -p $tmp_data_catalog |
---|
4173 | chmod g+rx $tmp_data_catalog |
---|
4174 | if [[ $files_for_pes = false ]] |
---|
4175 | then |
---|
4176 | ln -f ${frelout[$i]} $tmp_data_catalog/${frelout[$i]} |
---|
4177 | else |
---|
4178 | mkdir $tmp_data_catalog/${frelout[$i]} |
---|
4179 | ln -f ${frelout[$i]}/* $tmp_data_catalog/${frelout[$i]} |
---|
4180 | fi |
---|
4181 | |
---|
4182 | # GENERATE AND SUBMIT BATCH-JOB |
---|
4183 | # FILE HAS TO BE DELETED FROM THE TEMPORARY DATA DIRECTORY |
---|
4184 | # DELETE OLD EXISTING FILES FROM THE ARCHIVE |
---|
4185 | echo "cd $tmp_data_catalog" > archive_${frelout[$i]} |
---|
4186 | if [[ $files_for_pes = false ]] |
---|
4187 | then |
---|
4188 | echo "rm -rf \$UT/${frelout[$i]}" >> archive_${frelout[$i]} |
---|
4189 | echo "cp ${frelout[$i]} \$UT/${frelout[$i]}" >> archive_${frelout[$i]} |
---|
4190 | echo "rm -rf ${frelout[$i]}" >> archive_${frelout[$i]} |
---|
4191 | else |
---|
4192 | echo "rm -rf \$UT/${frelout[$i]}.tar" >> archive_${frelout[$i]} |
---|
4193 | echo "tar cvf \$UT/${frelout[$i]}.tar ${frelout[$i]}" >> archive_${frelout[$i]} |
---|
4194 | echo "rm -rf ${frelout[$i]}" >> archive_${frelout[$i]} |
---|
4195 | fi |
---|
4196 | |
---|
4197 | subjob -v -c /pf/b/$usern/job_queue -d -q pp -X 0 -m 1000 -t 7200 $PORTOPT archive_${frelout[$i]} |
---|
4198 | printf " Archiving of $tmp_data_catalog/${frelout[$i]} initiated (batch job submitted)\n" |
---|
4199 | file_saved=true |
---|
4200 | |
---|
4201 | else |
---|
4202 | printf "\n +++ archive_system=\"$archive_system\" archiving impossible!" |
---|
4203 | archive_save=false |
---|
4204 | fi |
---|
4205 | |
---|
4206 | # CREATE EMPTY FLAG-FILE OR -DIRECTORY |
---|
4207 | # IN ORDER TO NOTE THE RESPECTIVE CYCLE NUMBER ON THE ARCHIVE SYSTEM |
---|
4208 | # RESTART-JOBS ARE USING THESE EMPTY-DIRECTORIES TO GET THE CURRENT HIGHEST |
---|
4209 | # CYCLE NUMBER ON THE ARCHIVE SYSTEM (IN CASE THAT INFORMATIONS ARE DIFFICULT TO |
---|
4210 | # TO ACCESS FROM THE ARCHIVE-SYSTEM DIRECTLY)) |
---|
4211 | if [[ $file_saved = true ]] |
---|
4212 | then |
---|
4213 | if [[ $files_for_pes = false ]] |
---|
4214 | then |
---|
4215 | cat /dev/null > ${pathout[$i]} |
---|
4216 | else |
---|
4217 | mkdir -p ${pathout[$i]} |
---|
4218 | fi |
---|
4219 | fi |
---|
4220 | |
---|
4221 | fi |
---|
4222 | |
---|
4223 | # APPEND ON THIS MACHINE |
---|
4224 | if [[ "${actionout[$i]}" = "a" ]] |
---|
4225 | then |
---|
4226 | if [[ "${extout[$i]}" != " " && "${extout[$i]}" != "" ]] |
---|
4227 | then |
---|
4228 | printf "\n >>> OUTPUT: ${localout[$i]} append to ${pathout[$i]}.${extout[$i]}\n" |
---|
4229 | cat ${localout[$i]} >> ${pathout[$i]}.${extout[$i]} |
---|
4230 | else |
---|
4231 | printf "\n >>> OUTPUT: ${localout[$i]} append to ${pathout[$i]}\n" |
---|
4232 | cat ${localout[$i]} >> ${pathout[$i]} |
---|
4233 | fi |
---|
4234 | fi |
---|
4235 | |
---|
4236 | # COPY ON THIS MACHINE |
---|
4237 | # COPY HAS TO BE USED, BECAUSE MOVE DOES NOT WORK IF FILE-ORIGIN AND TARGET ARE |
---|
4238 | # ON DIFFERENT FILE-SYSTEMS |
---|
4239 | if [[ "${actionout[$i]}" = "" && $files_for_pes = false ]] |
---|
4240 | then |
---|
4241 | |
---|
4242 | # COPY IN CASE OF RUNS ON SINGLE CORES |
---|
4243 | if [[ "${extout[$i]}" != " " && "${extout[$i]}" != "" ]] |
---|
4244 | then |
---|
4245 | printf "\n >>> OUTPUT: ${localout[$i]} to ${pathout[$i]}.${extout[$i]}\n" |
---|
4246 | if [[ $link_local_output = true ]] |
---|
4247 | then |
---|
4248 | printf " using ln -f\n" |
---|
4249 | ln -f ${localout[$i]} ${pathout[$i]}.${extout[$i]} |
---|
4250 | fi |
---|
4251 | # If "ln -f" fails of if "$link_local_output = false" do a normal "cp" |
---|
4252 | if [[ ! -f "${pathout[$i]}.${extout[$i]}" ]] |
---|
4253 | then |
---|
4254 | if [[ $link_local_output = true ]] |
---|
4255 | then |
---|
4256 | printf " ln failed, using cp...\n" |
---|
4257 | fi |
---|
4258 | cp ${localout[$i]} ${pathout[$i]}.${extout[$i]} |
---|
4259 | fi |
---|
4260 | else |
---|
4261 | printf "\n >>> OUTPUT: ${localout[$i]} to ${pathout[$i]}\n" |
---|
4262 | if [[ $link_local_output = true ]] |
---|
4263 | then |
---|
4264 | printf " using ln -f\n" |
---|
4265 | ln -f ${localout[$i]} ${pathout[$i]} |
---|
4266 | fi |
---|
4267 | # If "ln -f" fails of if "$link_local_output = false" do a normal "cp" |
---|
4268 | if [[ ! -f "${pathout[$i]}" ]] |
---|
4269 | then |
---|
4270 | if [[ $link_local_output = true ]] |
---|
4271 | then |
---|
4272 | printf " ln failed, using cp...\n" |
---|
4273 | fi |
---|
4274 | cp ${localout[$i]} ${pathout[$i]} |
---|
4275 | fi |
---|
4276 | fi |
---|
4277 | |
---|
4278 | elif [[ "${actionout[$i]}" = "" && $files_for_pes = true ]] |
---|
4279 | then |
---|
4280 | |
---|
4281 | # FILES FROM THE DIFFERENT CORES ARE MOVED WITH ln-COMMAND TO THE PERMANENT DIRECTORY |
---|
4282 | # AS A FIRST STEP, THE PERMANENT DIRECTORY IS CREATED |
---|
4283 | printf "\n >>> OUTPUT: ${localout[$i]}/_.... to ${pathout[$i]}\n" |
---|
4284 | if [[ $link_local_output = true ]] |
---|
4285 | then |
---|
4286 | printf " using ln -f\n" |
---|
4287 | mkdir ${pathout[$i]} |
---|
4288 | cd ${localout[$i]} |
---|
4289 | for file in $(ls *) |
---|
4290 | do |
---|
4291 | ln -f $file ${pathout[$i]} |
---|
4292 | done |
---|
4293 | cd $TEMPDIR |
---|
4294 | fi |
---|
4295 | |
---|
4296 | # IF "ln -f" HAS FAILED OR IF "$link_local_output = false" DO A NORMAL COPY "cp -r" |
---|
4297 | if [[ ! -f "${pathout[$i]}/_0000" ]] |
---|
4298 | then |
---|
4299 | if [[ $link_local_output = true ]] |
---|
4300 | then |
---|
4301 | printf " ln failed for .../_0000, using cp...\n" |
---|
4302 | fi |
---|
4303 | cp -r ${localout[$i]} ${pathout[$i]} |
---|
4304 | fi |
---|
4305 | |
---|
4306 | fi |
---|
4307 | fi |
---|
4308 | done |
---|
4309 | if (( i != 0 )) |
---|
4310 | then |
---|
4311 | if [[ $transfer_problems = true ]] |
---|
4312 | then |
---|
4313 | printf "\n$dashes\n *** OUTPUT-files saved" |
---|
4314 | printf "\n +++ WARNING: some data transfers failed! \n" |
---|
4315 | else |
---|
4316 | printf "\n$dashes\n *** all OUTPUT-files saved \n" |
---|
4317 | fi |
---|
4318 | fi |
---|
4319 | |
---|
4320 | |
---|
4321 | # IF REQUIRED, START A RESTART-JOB |
---|
4322 | # FILE CONTINUE_RUN MUST HAVE BEEN CREATED BY THE EXECUTABLE (PALM) |
---|
4323 | if [[ -f CONTINUE_RUN ]] |
---|
4324 | then |
---|
4325 | |
---|
4326 | if [[ $archive_save = true ]] |
---|
4327 | then |
---|
4328 | |
---|
4329 | # ADD RESTART-OPTIONS TO THE MRUN-CALL (IF THEY ARE NOT USED ALREADY): |
---|
4330 | # -C TELLS MRUN THAT IT IS A RESTART-RUN |
---|
4331 | # -v SILENT MODE WITHOUT INTERACTIVE QUERIES |
---|
4332 | # -n BATCH-MODE (IMPORTANT ONLY IN CASE OF BATCH JOBS ON THE LOCAL MACHINE) |
---|
4333 | [[ $(echo $mc | grep -c "\-C") = 0 ]] && mc="$mc -C" |
---|
4334 | [[ $(echo $mc | grep -c "\-v") = 0 ]] && mc="$mc -v" |
---|
4335 | [[ $(echo $mc | grep -c "\-b") = 0 ]] && mc="$mc -b" |
---|
4336 | if [[ $(echo $mc | grep -c "#") != 0 ]] |
---|
4337 | then |
---|
4338 | mc=`echo $mc | sed 's/#/f/g'` |
---|
4339 | fi |
---|
4340 | |
---|
4341 | |
---|
4342 | # START THE RESTART-JOB |
---|
4343 | printf "\n\n *** initiating restart-run on \"$return_addres\" using command:\n" |
---|
4344 | echo " $mc" |
---|
4345 | printf "\n$dashes\n" |
---|
4346 | if [[ $localhost != $fromhost ]] |
---|
4347 | then |
---|
4348 | |
---|
4349 | if [[ $localhost = lccrayh || $localhost = nech || $localhost = ibmh || $localhost = ibmkisti || $localhost = ibmku || $localhost = ibms || $localhost = lcflow || $localhost = lckyu* ]] |
---|
4350 | then |
---|
4351 | echo "*** ssh will be used to initiate restart-runs!" |
---|
4352 | echo " return_addres=\"$return_addres\" " |
---|
4353 | echo " return_username=\"$return_username\" " |
---|
4354 | if [[ $(echo $return_addres | grep -c "130.75.105") = 1 ]] |
---|
4355 | then |
---|
4356 | if [[ $localhost = ibmh ]] |
---|
4357 | then |
---|
4358 | 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\" " |
---|
4359 | elif [[ $localhost = lccrayb ]] |
---|
4360 | then |
---|
4361 | 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\" " |
---|
4362 | elif [[ $localhost = lccrayh ]] |
---|
4363 | then |
---|
4364 | 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\" " |
---|
4365 | |
---|
4366 | else |
---|
4367 | ssh $SSH_PORTOPT $return_addres -l $return_username "PATH=\$PATH:$LOCAL_MRUN_PATH;. /muksoft/packages/intel/bin/compilervars.sh intel64;export PALM_BIN=$LOCAL_MRUN_PATH;cd $LOCAL_PWD; $mc " |
---|
4368 | fi |
---|
4369 | else |
---|
4370 | if [[ $localhost = ibmkisti ]] |
---|
4371 | then |
---|
4372 | 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\" " |
---|
4373 | elif [[ $localhost = lcflow ]] |
---|
4374 | then |
---|
4375 | /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 " |
---|
4376 | elif [[ $localhost = lccrayb ]] |
---|
4377 | then |
---|
4378 | 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\" " |
---|
4379 | elif [[ $localhost = lccrayh ]] |
---|
4380 | then |
---|
4381 | 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\" " |
---|
4382 | else |
---|
4383 | ssh $SSH_PORTOPT $return_addres -l $return_username "PATH=\$PATH:$LOCAL_MRUN_PATH;export PALM_BIN=$LOCAL_MRUN_PATH;cd $LOCAL_PWD; $mc " |
---|
4384 | fi |
---|
4385 | fi |
---|
4386 | else |
---|
4387 | printf "\n +++ no restart mechanism available for host \"$localhost\" " |
---|
4388 | locat=restart; exit |
---|
4389 | fi |
---|
4390 | |
---|
4391 | # WAIT TO ALLOW THE RESTART-JOB TO BE QUEUED, BEFORE THE CURRENT JOB IS FINISHED |
---|
4392 | if [[ $queue = special1q ]] |
---|
4393 | then |
---|
4394 | sleep 120 |
---|
4395 | else |
---|
4396 | sleep 30 |
---|
4397 | fi |
---|
4398 | |
---|
4399 | else |
---|
4400 | |
---|
4401 | # JOBS RUNNING (AND STARTED) ON THE LOCAL MACHINE CAN DIRECTLY CALL MRUN (WITHOUT |
---|
4402 | # USING SSH) |
---|
4403 | cd $LOCAL_PWD |
---|
4404 | if [[ $localhost = lckyuh ]] |
---|
4405 | then |
---|
4406 | printf "\n +++ WARNING: no restart mechanism available for host \"$localhost\" " |
---|
4407 | printf "\n please restart job manually using command:\n" |
---|
4408 | printf "\n \"$mc\" " |
---|
4409 | else |
---|
4410 | eval $mc # THE ' MUST BE EVALUATED |
---|
4411 | fi |
---|
4412 | cd - > /dev/null |
---|
4413 | fi |
---|
4414 | if [[ $localhost = lckyuh ]] |
---|
4415 | then |
---|
4416 | printf "\n$dashes\n *** restart-run to be initiated manually\n" |
---|
4417 | else |
---|
4418 | printf "\n$dashes\n *** restart-run initiated \n" |
---|
4419 | fi |
---|
4420 | |
---|
4421 | |
---|
4422 | # DELETE INPUT-(RESTART)FILES, WHICH HAVE BEEN FETCHED FROM THE TEMPORARY DATA |
---|
4423 | # DIRECTORY, BACAUSE THEY ARE NOT REQUIRED BY THE RESTART-JOB. |
---|
4424 | # THIS IS DONE IN ORDER TO AVOID EXCEEDING DISC QUOTAS OR DISC SPACE (RESTART-FILES |
---|
4425 | # MAY BE VERY HUGE) |
---|
4426 | (( i = 0 )) |
---|
4427 | while (( i < iin )) |
---|
4428 | do |
---|
4429 | (( i = i + 1 )) |
---|
4430 | if [[ "${got_tmp[$i]}" = true && $keep_data_from_previous_run = false ]] |
---|
4431 | then |
---|
4432 | rm -r $tmp_data_catalog/${frelin[$i]} |
---|
4433 | fi |
---|
4434 | done |
---|
4435 | |
---|
4436 | else |
---|
4437 | |
---|
4438 | printf "\n +++ no restart-run possible, since errors occured" |
---|
4439 | printf "\n during the archive process" |
---|
4440 | fi |
---|
4441 | |
---|
4442 | fi |
---|
4443 | |
---|
4444 | |
---|
4445 | |
---|
4446 | # SEND EMAIL NOTIFICATION ABOUT THE FINISHED RUN |
---|
4447 | if [[ "$email_notification" != "none" ]] |
---|
4448 | then |
---|
4449 | |
---|
4450 | if [[ $localhost != $fromhost ]] |
---|
4451 | then |
---|
4452 | if [[ -f CONTINUE_RUN ]] |
---|
4453 | then |
---|
4454 | echo "PALM restart run necessary" > email_text |
---|
4455 | echo "description header of actual run:" >> email_text |
---|
4456 | cat CONTINUE_RUN >> email_text |
---|
4457 | echo "mrun-command to restart:" >> email_text |
---|
4458 | echo "$mc" >> email_text |
---|
4459 | else |
---|
4460 | echo "PALM run with base filename \"$fname\" on host \"$localhost\" finished" > email_text |
---|
4461 | fi |
---|
4462 | mail $email_notification < email_text |
---|
4463 | printf "\n *** email notification sent to \"$email_notification\" " |
---|
4464 | fi |
---|
4465 | fi |
---|
4466 | |
---|
4467 | |
---|
4468 | |
---|
4469 | # ALL ACTIONS FINISHED, TEMPORARY WORKING-DIRECTORY CAN BE DELETED |
---|
4470 | cd $HOME |
---|
4471 | [[ $delete_temporary_catalog = true ]] && rm -rf $TEMPDIR |
---|
4472 | |
---|
4473 | else |
---|
4474 | |
---|
4475 | |
---|
4476 | # PREPARING ACTIONS, |
---|
4477 | # IF A BATCH-JOB IS TO BE GENERATED AND STARTED ON A REMOTE-MACHINE GERECHNET |
---|
4478 | |
---|
4479 | # BUILD THE MRUN-COMMAND TO BE CALLED IN THE BATCH-JOB ON THE REMOTE-MACHINE |
---|
4480 | 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" |
---|
4481 | [[ "$cpp_opts" != "" ]] && mrun_com=${mrun_com}" -D \"$cpp_opts\"" |
---|
4482 | [[ "$global_revision" != "" ]] && mrun_com=${mrun_com}" -G \"$global_revision\"" |
---|
4483 | [[ $group_number != none ]] && mrun_com=${mrun_com}" -g $group_number" |
---|
4484 | [[ $do_compile = true ]] && mrun_com=${mrun_com}" -s \"$source_list\"" |
---|
4485 | [[ "$input_list" != "" ]] && mrun_com=${mrun_com}" -i \"$input_list\"" |
---|
4486 | [[ $ignore_archive_error = true ]] && mrun_com=${mrun_com}" -I" |
---|
4487 | [[ $keep_data_from_previous_run = true ]] && mrun_com=${mrun_com}" -k" |
---|
4488 | [[ "$additional_conditions" != "" ]] && mrun_com=${mrun_com}" -K \"$additional_conditions\"" |
---|
4489 | [[ "$output_list" != "" ]] && mrun_com=${mrun_com}" -o \"$output_list\"" |
---|
4490 | [[ "$read_from_config" = false ]] && mrun_com=${mrun_com}" -S" |
---|
4491 | [[ $do_trace = true ]] && mrun_com=${mrun_com}" -x" |
---|
4492 | [[ "$numprocs" != "" ]] && mrun_com=${mrun_com}" -X $numprocs" |
---|
4493 | if [[ $use_openmp = true ]] |
---|
4494 | then |
---|
4495 | mrun_com=${mrun_com}" -O $threads_per_task" |
---|
4496 | fi |
---|
4497 | [[ "$tasks_per_node" != "" ]] && mrun_com=${mrun_com}" -T $tasks_per_node" |
---|
4498 | [[ $store_on_archive_system = true ]] && mrun_com=${mrun_com}" -A" |
---|
4499 | [[ $package_list != "" ]] && mrun_com=${mrun_com}" -p \"$package_list\"" |
---|
4500 | [[ $return_password != "" ]] && mrun_com=${mrun_com}" -P $return_password" |
---|
4501 | [[ $delete_temporary_catalog = false ]] && mrun_com=${mrun_com}" -B" |
---|
4502 | [[ $node_usage != default && "$(echo $node_usage | cut -c1-3)" != "sla" && $node_usage != novice ]] && mrun_com=${mrun_com}" -n $node_usage" |
---|
4503 | [[ "$ocean_file_appendix" = true ]] && mrun_com=${mrun_com}" -y" |
---|
4504 | [[ $run_coupled_model = true ]] && mrun_com=${mrun_com}" -Y \"$coupled_dist\"" |
---|
4505 | [[ "$check_namelist_files" = false ]] && mrun_com=${mrun_com}" -z" |
---|
4506 | [[ "$combine_plot_fields" = false ]] && mrun_com=${mrun_com}" -Z" |
---|
4507 | [[ "$max_par_io_str" != "" ]] && mrun_com=${mrun_com}" -w $max_par_io_str" |
---|
4508 | if [[ $do_remote = true ]] |
---|
4509 | then |
---|
4510 | printf "\n>>>> MRUN-command on execution host:\n>>>> $mrun_com \n" |
---|
4511 | fi |
---|
4512 | |
---|
4513 | |
---|
4514 | # CREATE EXECUTABLE FOR BATCH JOB |
---|
4515 | if [[ $create_executable_for_batch = true && $restart_run != true ]] |
---|
4516 | then |
---|
4517 | |
---|
4518 | printf "\n *** creating the executable for batch job\n" |
---|
4519 | |
---|
4520 | # METHOD ONLY WORKS FOR BATCH JOBS ON LOCAL HOSTS |
---|
4521 | if [[ $host != $localhost ]] |
---|
4522 | then |
---|
4523 | printf "\n +++ creation of executables is only allowed for batch jobs on local hosts." |
---|
4524 | printf "\n Please set create_executable_for_batch = false in the config-file.\n" |
---|
4525 | locat=create_executable; exit |
---|
4526 | fi |
---|
4527 | |
---|
4528 | mkdir $working_directory/SOURCES_FOR_RUN_${fname}/TMPDIR_FOR_CREATING_EXECUTABLE |
---|
4529 | cd $working_directory/SOURCES_FOR_RUN_${fname}/TMPDIR_FOR_CREATING_EXECUTABLE |
---|
4530 | |
---|
4531 | cp $make_depository . |
---|
4532 | tar -xf $make_depository > /dev/null 2>&1 |
---|
4533 | cp ../* . > /dev/null 2>&1 |
---|
4534 | |
---|
4535 | make $mopts -f Makefile PROG=a.out F90=$compiler_name COPT="$cpp_options" F90FLAGS="$fopts" LDFLAGS="$lopts" |
---|
4536 | |
---|
4537 | if [[ $? != 0 || "$compile_error" = true || "$module_compile_error" = true ]] |
---|
4538 | then |
---|
4539 | printf "\n +++ error occured while compiling or linking" |
---|
4540 | locat=compile |
---|
4541 | exit |
---|
4542 | fi |
---|
4543 | |
---|
4544 | mv a.out .. |
---|
4545 | cd - > /dev/null 2>&1 |
---|
4546 | rm -rf $working_directory/SOURCES_FOR_RUN_${fname}/TMPDIR_FOR_CREATING_EXECUTABLE |
---|
4547 | |
---|
4548 | printf " *** executable created in \"$working_directory/SOURCES_FOR_RUN_${fname}\"\n " |
---|
4549 | |
---|
4550 | fi |
---|
4551 | |
---|
4552 | |
---|
4553 | # BUILD THE JOB-SCRIPTS ON FILE jobfile |
---|
4554 | jobfile=jobfile.$RANDOM |
---|
4555 | |
---|
4556 | |
---|
4557 | # CREATE TEMPORARY DIRECTORY AND SWITCH TO IT |
---|
4558 | echo "mkdir $TEMPDIR" >> $jobfile |
---|
4559 | echo "cd $TEMPDIR" >> $jobfile |
---|
4560 | |
---|
4561 | |
---|
4562 | # ACTIVATE ERROR-TRACEBACK |
---|
4563 | if [[ $do_trace = true ]] |
---|
4564 | then |
---|
4565 | echo "set -x" >> $jobfile |
---|
4566 | else |
---|
4567 | echo "set +vx" >> $jobfile |
---|
4568 | fi |
---|
4569 | |
---|
4570 | |
---|
4571 | # INITIALIZE THE ENVIRONMENT AND LOAD MODULES |
---|
4572 | if [[ "$init_cmds" != "" ]] |
---|
4573 | then |
---|
4574 | echo "$init_cmds" >> $jobfile |
---|
4575 | fi |
---|
4576 | if [[ "$module_calls" != "" ]] |
---|
4577 | then |
---|
4578 | echo "$module_calls" >> $jobfile |
---|
4579 | fi |
---|
4580 | |
---|
4581 | |
---|
4582 | # PROVIDE SOURCE-CODE FILES, MRUN-SCRIPT AND CONFIGURATION-FILE FOR THE JOB |
---|
4583 | # then-CLAUSE: FILES ARE COLLECTED IN THE SOURCES_FOR_RUN_... DIRECTORY ON THE LOCAL HOST, |
---|
4584 | # WHICH IS THEN FETCHED FROM THE BATCH-JOB BY USING cp/scp |
---|
4585 | # THE SOURCE-CODE FILES ALREADY EXIST IN THIS DIRECTORY |
---|
4586 | # else-CLAUSE: FILE-CONTENTS ARE PUT INTO THE JOB-FILE AS HERE-DOCUMENTS |
---|
4587 | # THIS MAY CREATE A QUITE LARGE JOB-FILE, WHICH CAN CAUSE PROBLEMS WITH SOME |
---|
4588 | # QUEUEING-SYSTEMS |
---|
4589 | if [[ $host = ibmkisti || $host = lccrayb || $host = lccrayf || $host = lccrayh ]] |
---|
4590 | then |
---|
4591 | |
---|
4592 | # COPY CONFIGURATION-FILE AND MRUN-SCRIPT INTO THE SOURCES_FOR_RUN... DIRECTORY |
---|
4593 | if [[ $restart_run != true ]] |
---|
4594 | then |
---|
4595 | cp $config_file $working_directory/SOURCES_FOR_RUN_$fname |
---|
4596 | cp ${PALM_BIN}/$mrun_script_name $working_directory/SOURCES_FOR_RUN_$fname |
---|
4597 | fi |
---|
4598 | |
---|
4599 | # COPY THE SOURCES_FOR_RUN... DIRECTORY FROM THE LOCAL HOST TO THE JOB VIA scp |
---|
4600 | # (then-CLAUSE: JOBS ON THE LOCAL HOST CAN JUST USE cp) |
---|
4601 | echo "set -x" >> $jobfile |
---|
4602 | if [[ $host = $localhost ]] |
---|
4603 | then |
---|
4604 | |
---|
4605 | # DUE TO UNKNOWN REASONS, COPY WITH cp COMMAND CREATES CORRUPT |
---|
4606 | # FILES ON CRAY XC30 SYSTEMS (CSC HELSINKI), rsync IS USED INSTEAD |
---|
4607 | if [[ $(echo $host | cut -c1-6) = lccray ]] |
---|
4608 | then |
---|
4609 | echo "rsync -av -t $working_directory/SOURCES_FOR_RUN_$fname ." >> $jobfile |
---|
4610 | else |
---|
4611 | echo "cp -r $working_directory/SOURCES_FOR_RUN_$fname ." >> $jobfile |
---|
4612 | fi |
---|
4613 | |
---|
4614 | else |
---|
4615 | if [[ $host = ibmkisti ]] |
---|
4616 | then |
---|
4617 | # ON KISTI'S IBM FIREWALL IS ONLY OPENED ON INTERACTIVE NODE |
---|
4618 | echo "localdir=\`pwd\`" >> $jobfile |
---|
4619 | echo "ssh $SSH_PORTOPT $remote_username@gaiad \"cd \$localdir; scp $PORTOPT -r $return_username@$return_addres:$working_directory/SOURCES_FOR_RUN_$fname .\" " >> $jobfile |
---|
4620 | elif [[ $host = lccrayb ]] |
---|
4621 | then |
---|
4622 | echo "localdir=\`pwd\`" >> $jobfile |
---|
4623 | echo "ssh $SSH_PORTOPT $remote_username@blogin1 \"cd \$localdir; scp $PORTOPT -r $return_username@$return_addres:$working_directory/SOURCES_FOR_RUN_$fname .\" " >> $jobfile |
---|
4624 | elif [[ $host = lccrayh ]] |
---|
4625 | then |
---|
4626 | echo "localdir=\`pwd\`" >> $jobfile |
---|
4627 | echo "ssh $SSH_PORTOPT $remote_username@hlogin1 \"cd \$localdir; scp $PORTOPT -r $return_username@$return_addres:$working_directory/SOURCES_FOR_RUN_$fname .\" " >> $jobfile |
---|
4628 | |
---|
4629 | else |
---|
4630 | echo "scp $PORTOPT -r $return_username@$return_addres:$working_directory/SOURCES_FOR_RUN_$fname ." >> $jobfile |
---|
4631 | fi |
---|
4632 | fi |
---|
4633 | echo "export SOURCES_COMPLETE=true" >> $jobfile |
---|
4634 | |
---|
4635 | # MOVE MRUN-SCRIPT AND CONFIGURATION-FILE FROM THE SOURCES_FOR_RUN... DIRECTORY TO THE |
---|
4636 | # WORKING DIRECTORY OF THE JOB |
---|
4637 | echo "mv SOURCES_FOR_RUN_$fname/$config_file . " >> $jobfile |
---|
4638 | echo "mv SOURCES_FOR_RUN_$fname/$mrun_script_name . " >> $jobfile |
---|
4639 | echo "chmod u+rwx $mrun_script_name" >> $jobfile |
---|
4640 | echo "execute_mrun=true" >> $jobfile |
---|
4641 | echo " " >> $jobfile |
---|
4642 | |
---|
4643 | else |
---|
4644 | |
---|
4645 | # PROVIDE SOURCE-CODE FILES AND MAKEFILE AS HERE DOCUMENT |
---|
4646 | if [[ $do_compile = true ]] |
---|
4647 | then |
---|
4648 | |
---|
4649 | source_catalog=SOURCES_FOR_RUN_$fname |
---|
4650 | |
---|
4651 | # CREATE SOURCES_FOR_RUN... DIRECTORY TO STORE THE SOURCE CODE FILES AND THE MAKEFILE |
---|
4652 | echo "mkdir SOURCES_FOR_RUN_$fname" >> $jobfile |
---|
4653 | echo "export SOURCES_COMPLETE=true" >> $jobfile |
---|
4654 | echo "cd SOURCES_FOR_RUN_$fname" >> $jobfile |
---|
4655 | |
---|
4656 | for filename in $source_list |
---|
4657 | do |
---|
4658 | # BACKSLASH IS USED FOR MASKING |
---|
4659 | echo "cat > $filename << \"%END%\"" >> $jobfile |
---|
4660 | cat $source_catalog/$filename >> $jobfile |
---|
4661 | echo " " >> $jobfile |
---|
4662 | echo "%END%" >> $jobfile |
---|
4663 | echo " " >> $jobfile |
---|
4664 | done |
---|
4665 | |
---|
4666 | # BACKSLASH IS USED FOR MASKING |
---|
4667 | echo "cat > Makefile << \"%END%\"" >> $jobfile |
---|
4668 | cat $source_catalog/Makefile >> $jobfile |
---|
4669 | echo " " >> $jobfile |
---|
4670 | echo "%END%" >> $jobfile |
---|
4671 | echo " " >> $jobfile |
---|
4672 | |
---|
4673 | echo "cd - > /dev/null" >> $jobfile |
---|
4674 | |
---|
4675 | fi |
---|
4676 | |
---|
4677 | |
---|
4678 | # PROVIDE THE CONFIGURATION-FILE AS HERE-DOCUMENT |
---|
4679 | # BACKSLASH IS USED FOR MASKING |
---|
4680 | # LINES WITH #$ IN THE CONFIGURATION-FILE, COMING FROM THE SVN KEYWORD SUBSTITUTION, |
---|
4681 | # ARE REMOVED FROM THE FILE IN ORDER TO AVOID PROBLEMS WITH THE SGE BATCH SYSTEM |
---|
4682 | echo "cat > $config_file << \"%END%\"" >> $jobfile |
---|
4683 | if [[ $host = lckyuh ]] |
---|
4684 | then |
---|
4685 | # NO CROSS-COMPILER ON COMPUTE NODE |
---|
4686 | sed 's/frtpx/frt/g' $config_file >> $jobfile |
---|
4687 | else |
---|
4688 | sed 's/#$.*//g' $config_file >> $jobfile |
---|
4689 | fi |
---|
4690 | echo "%END%" >> $jobfile |
---|
4691 | echo " " >> $jobfile |
---|
4692 | |
---|
4693 | |
---|
4694 | # PROVIDE THE MRUN-SCRIPTS AS HERE-DOCUMENT |
---|
4695 | # BACKSLASH IS USED FOR MASKING |
---|
4696 | echo "cat > $mrun_script_name <<\"%END%\"" >> $jobfile |
---|
4697 | if [[ $host = lckyuh ]] |
---|
4698 | then |
---|
4699 | sed 's/\/bin\/ksh/\/bin\/bash/g' ${PALM_BIN}/$mrun_script_name >> $jobfile |
---|
4700 | else |
---|
4701 | cat ${PALM_BIN}/$mrun_script_name >> $jobfile |
---|
4702 | fi |
---|
4703 | echo "%END%" >> $jobfile |
---|
4704 | echo "chmod u+x $mrun_script_name" >> $jobfile |
---|
4705 | echo "execute_mrun=true" >> $jobfile |
---|
4706 | echo " " >> $jobfile |
---|
4707 | |
---|
4708 | fi |
---|
4709 | |
---|
4710 | |
---|
4711 | # GET REQUIRED INPUT-FILES BY SCP OR BY SENDING THEM WITH THE JOB AS HERE-DOCUMENT |
---|
4712 | # PUT THESE FILES INTO THE USER'S RESPECTIVE PERMANENT DIRECTORIES ON THE REMOTE-HOST |
---|
4713 | # IF THE DIRECTORIES DO NOT EXIST, TRY TO CREATE THEM |
---|
4714 | if [[ $do_remote = true ]] |
---|
4715 | then |
---|
4716 | (( i = 0 )) |
---|
4717 | while (( i < iin )) |
---|
4718 | do |
---|
4719 | (( i = i + 1 )) |
---|
4720 | echo "[[ ! -d ${pathin[$i]} ]] && mkdir -p ${pathin[$i]}" >> $jobfile |
---|
4721 | if [[ "${transin[$i]}" = job ]] |
---|
4722 | then |
---|
4723 | echo "cat > ${remotepathin[$i]} <<\"%END%\"" >> $jobfile |
---|
4724 | eval cat ${pathin[$i]}/${frelin[$i]} >> $jobfile |
---|
4725 | echo " " >> $jobfile |
---|
4726 | echo "%END%" >> $jobfile |
---|
4727 | else |
---|
4728 | echo "batch_scp $PORTOPT -b -o -g -s -u $return_username $return_addres ${remotepathin[$i]} \"${pathin[$i]}\" ${frelin[$i]}" >> $jobfile |
---|
4729 | fi |
---|
4730 | |
---|
4731 | # CHECK, IF FILE COULD BE CREATED |
---|
4732 | echo "if [[ \$? = 1 ]]" >> $jobfile |
---|
4733 | echo "then" >> $jobfile |
---|
4734 | echo " echo \" \" " >> $jobfile |
---|
4735 | echo " echo \"+++ file ${remotepathin[$i]} could not be created\" " >> $jobfile |
---|
4736 | echo " echo \" please check, if directory exists on $host!\" " >> $jobfile |
---|
4737 | echo " echo \"+++ MRUN will not be continued\" " >> $jobfile |
---|
4738 | echo " execute_mrun=false" >> $jobfile |
---|
4739 | echo "fi" >> $jobfile |
---|
4740 | done |
---|
4741 | fi |
---|
4742 | |
---|
4743 | # PROVIDE NAME OF THE CURRENT WORKING-DIRECTORY ON THE LOCAL MACHINE (FROM WHERE THE JOB IS |
---|
4744 | # STARTED) BY SETTING AN ENVIRONMENT-VARIABLE. THIS INFORMATION IS USED IN THE JOB BY MRUN |
---|
4745 | # IN CASE THAT RESTART-RUNS HAVE TO BE GENERATED |
---|
4746 | echo "LOCAL_PWD=$working_directory" >> $jobfile |
---|
4747 | echo "export LOCAL_PWD" >> $jobfile |
---|
4748 | |
---|
4749 | # PROVIDE THE PATH OF THE LOCAL MRUN-SCRIPT FOR THE SAME REASON |
---|
4750 | echo "LOCAL_MRUN_PATH=$PALM_BIN" >> $jobfile |
---|
4751 | echo "export LOCAL_MRUN_PATH" >> $jobfile |
---|
4752 | |
---|
4753 | # lcflow ALSO REQUIRES TO PROVIDE PATH FOR THE PALM-SCRIPTS |
---|
4754 | if [[ $host = lcflow || $localhost = lcflow ]] |
---|
4755 | then |
---|
4756 | echo "export PALM_BIN=$PALM_BIN" | sed -e 's:'$HOME':$HOME:' >> $jobfile |
---|
4757 | echo "export PATH=\$PATH:\$PALM_BIN" >> $jobfile |
---|
4758 | fi |
---|
4759 | |
---|
4760 | # CALL MRUN WITHIN THE JOB (SETTING QUEUE IS A WORKAROUND FOR ibmkisti) |
---|
4761 | # AS FINAL ACTION, REMOVE THE TEMPORARY DIRECTORY CREATED AT THE BEGINNING OF THE JOB |
---|
4762 | echo "set -x" >> $jobfile |
---|
4763 | echo "queue=$queue" >> $jobfile |
---|
4764 | echo "[[ \$execute_mrun = true ]] && ./$mrun_com" >> $jobfile |
---|
4765 | echo 'ls -al; echo `pwd`' >> $jobfile |
---|
4766 | echo "cd \$HOME" >> $jobfile |
---|
4767 | echo "rm -rf $TEMPDIR" >> $jobfile |
---|
4768 | |
---|
4769 | |
---|
4770 | |
---|
4771 | |
---|
4772 | # START THE JOB USING SUBJOB-COMMAND |
---|
4773 | if [[ $silent = false ]] |
---|
4774 | then |
---|
4775 | printf "\n " |
---|
4776 | else |
---|
4777 | printf "\n\n" |
---|
4778 | fi |
---|
4779 | |
---|
4780 | 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 |
---|
4781 | rm -rf $jobfile |
---|
4782 | |
---|
4783 | |
---|
4784 | fi # END OF REMOTE-PART |
---|