1 | #!/bin/bash |
---|
2 | |
---|
3 | # palmrun - 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 2017 Leibniz Universitaet Hannover |
---|
20 | #--------------------------------------------------------------------------------# |
---|
21 | # |
---|
22 | # Current revisions: |
---|
23 | # ------------------ |
---|
24 | # initial revision |
---|
25 | # |
---|
26 | # Former revisions: |
---|
27 | # ----------------- |
---|
28 | # $Id: palmrun 2380 2017-09-01 08:33:46Z raasch $ |
---|
29 | # |
---|
30 | # |
---|
31 | #--------------------------------------------------------------------------------# |
---|
32 | # palmrun - script for running PALM jobs on local and remote hosts |
---|
33 | #--------------------------------------------------------------------------------# |
---|
34 | |
---|
35 | |
---|
36 | |
---|
37 | # DECLARATION OF VARIABLES AND THEIR DEFAULT VALUES |
---|
38 | |
---|
39 | set +o allexport # SUPPRESS EXPORT OF ALL VARIABLES, SINCE IN THE PAST THIS |
---|
40 | # LEAD TO PROBLEMS IN ROUTINES CALLED BY PALMRUN |
---|
41 | # (TOO MANY ARGUMENTS - PROBLEM) |
---|
42 | set +o noclobber # EXISTING FILES ARE ALLOWED TO BE OVERWRITTEN |
---|
43 | |
---|
44 | typeset -i ibd=0 ibdt=0 iec=0 iic=0 iin=0 ioc=0 iout=0 |
---|
45 | typeset -x -i memory=0 # HAS TO BE EXPORTED HERE, OTHERWISE AN UNKNOWN SIDE |
---|
46 | # SIDE EFFECT MAY CAUSE DATA LOSS WHEN GETOPTS IS READING THE |
---|
47 | # SCRIPT-OPTION ARGUMENTS |
---|
48 | typeset -i cores cputime cpu_hours cpu_minutes cpu_seconds i ii iia iii iio |
---|
49 | typeset -i icycle inode ival maxcycle mpi_tasks |
---|
50 | typeset -i nodes remaining_cores run_number tasks_per_node threads_per_task |
---|
51 | |
---|
52 | activation_string_list="" |
---|
53 | AddFilenames="" |
---|
54 | add_source_path="" |
---|
55 | combine_plot_fields=true |
---|
56 | compiler_name="" |
---|
57 | compiler_name_ser="" |
---|
58 | compiler_options="" |
---|
59 | config_file="" |
---|
60 | cores="" |
---|
61 | cores_atmos=0 |
---|
62 | cores_ocean=0 |
---|
63 | coupled_dist="" |
---|
64 | cpp_options="" |
---|
65 | cpumax=0 |
---|
66 | create_jobfile_only=false |
---|
67 | delete_temporary_catalog=true |
---|
68 | create_batch_job=false |
---|
69 | create_remote_batch_job=false |
---|
70 | dashes=" ----------------------------------------------------------------------------" |
---|
71 | defaultqueue="" |
---|
72 | do_compile=true |
---|
73 | do_trace=false |
---|
74 | executable="" |
---|
75 | execute_command="" |
---|
76 | execution_error=false |
---|
77 | fileconnection_file=.palm.iofiles |
---|
78 | fname=test |
---|
79 | global_revision="" |
---|
80 | host="default" |
---|
81 | hostfile="" |
---|
82 | hp="" |
---|
83 | job_directory="" |
---|
84 | keep_data_from_previous_run=false |
---|
85 | link_local_input=false |
---|
86 | link_local_output=false |
---|
87 | loader_options="" |
---|
88 | locat=normal |
---|
89 | makefile="" |
---|
90 | max_par_io_str="" |
---|
91 | prc=$0 |
---|
92 | while [[ $(echo $prc | grep -c "/") != 0 ]] |
---|
93 | do |
---|
94 | prc=`echo $prc | cut -f2- -d"/"` |
---|
95 | done |
---|
96 | module_calls="" |
---|
97 | palmrun_script_name=$prc |
---|
98 | openmp=false |
---|
99 | queue=none |
---|
100 | restart_run=false |
---|
101 | return_address="" |
---|
102 | remote_username="" |
---|
103 | running_in_batch_mode=false |
---|
104 | run_coupled_model=false |
---|
105 | run_id="" |
---|
106 | silent=false |
---|
107 | source_list="" |
---|
108 | source_path="" |
---|
109 | tasks_per_node="" |
---|
110 | threads_per_task=1 |
---|
111 | tmpcreate=false |
---|
112 | tmp_data_catalog="" |
---|
113 | transfer_problems=false |
---|
114 | use_openmp=false |
---|
115 | version="palmrun 0.9 Rev$Rev: 2303 $" |
---|
116 | working_directory=`pwd` |
---|
117 | write_binary="" |
---|
118 | TOPT="" |
---|
119 | |
---|
120 | |
---|
121 | # ERROR HANDLING IN CASE OF EXIT |
---|
122 | trap 'rm -rf $working_directory/tmp_mrun |
---|
123 | if [[ $locat != normal && $locat != control_c ]] |
---|
124 | then |
---|
125 | |
---|
126 | # CARRY OUT ERROR-COMMANDS GIVEN IN THE CONFIGURATION FILE (EC:) |
---|
127 | (( i = 0 )) |
---|
128 | while (( i < iec )) |
---|
129 | do |
---|
130 | (( i = i + 1 )) |
---|
131 | printf "\n *** Execution of ERROR-command:\n" |
---|
132 | printf " >>> ${err_command[$i]}\n" |
---|
133 | eval ${err_command[$i]} |
---|
134 | done |
---|
135 | if [[ $tmpcreate = true ]] |
---|
136 | then |
---|
137 | [[ $delete_temporary_catalog = true ]] && rm -rf $TEMPDIR |
---|
138 | fi |
---|
139 | printf "\n\n+++ palmrun killed \n\n" |
---|
140 | elif [[ $locat != control_c ]] |
---|
141 | then |
---|
142 | printf "\n\n --> palmrun finished\n\n" |
---|
143 | if [[ $running_on_remote = true ]] |
---|
144 | then |
---|
145 | printf " Bye, bye $remote_username !!\n\n" |
---|
146 | else |
---|
147 | printf " Bye, bye $local_username !!\n\n" |
---|
148 | fi |
---|
149 | fi' exit |
---|
150 | |
---|
151 | |
---|
152 | # ACTIONS IN CASE OF TERMINAL-BREAK (CONTROL-C): |
---|
153 | trap 'rm -rf $working_directory/tmp_mrun |
---|
154 | [[ $tmpcreate = true ]] && (cd; rm -rf $TEMPDIR) |
---|
155 | printf "\n+++ palmrun killed by \"^C\" \n\n" |
---|
156 | locat=control_c |
---|
157 | exit |
---|
158 | ' 2 |
---|
159 | |
---|
160 | |
---|
161 | # CHECK IF THE PATH FOR THE PALM BINARIES (SCRIPTS+UTILITY-PROGRAMS) HAS |
---|
162 | # BEEN SET |
---|
163 | if [[ "$PALM_BIN" = "" ]] |
---|
164 | then |
---|
165 | printf "\n +++ environment variable PALM_BIN has not been set" |
---|
166 | printf "\n please set it to the directory where the PALM scripts are located" |
---|
167 | locat=palm_bin; exit |
---|
168 | fi |
---|
169 | export PATH=$PALM_BIN:$PATH |
---|
170 | |
---|
171 | |
---|
172 | |
---|
173 | # READ SHELLSCRIPT-OPTIONS AND REBUILD THE PALMRUN-COMMAND STRING (prc), |
---|
174 | # WHICH WILL BE USED TO START RESTART-JOBS |
---|
175 | while getopts :a:bBc:Cd:FG:h:jkm:M:O:q:r:R:s:t:T:u:U:vw:xX:yY:Z option |
---|
176 | do |
---|
177 | case $option in |
---|
178 | (a) activation_string_list=$OPTARG; prc="$prc -a'$OPTARG'";; |
---|
179 | (b) create_batch_job=true; prc="$prc -b";; |
---|
180 | (B) delete_temporary_catalog=false; prc="$prc -B";; |
---|
181 | (c) config_file=$OPTARG; prc="$prc -c$OPTARG";; |
---|
182 | (C) restart_run=true; prc="$prc -C";; |
---|
183 | (d) fname=$OPTARG; prc="$prc -d$OPTARG";; |
---|
184 | (F) create_jobfile_only=true;; |
---|
185 | (G) global_revision=$OPTARG; prc="$prc -G'$OPTARG'";; |
---|
186 | (h) host=$OPTARG; prc="$prc -h$OPTARG";; |
---|
187 | (j) running_in_batch_mode=true;; |
---|
188 | (k) keep_data_from_previous_run=true; prc="$prc -k";; |
---|
189 | (m) memory=$OPTARG; prc="$prc -m$OPTARG";; |
---|
190 | (M) makefile=$OPTARG; prc="$prc -M$OPTARG";; |
---|
191 | (O) use_openmp=true; threads_per_task=$OPTARG; prc="$prc -O$OPTARG";; |
---|
192 | (q) queue=$OPTARG; prc="$prc -q$OPTARG";; |
---|
193 | (r) run_id=$OPTARG;; |
---|
194 | (R) return_address=$OPTARG;; |
---|
195 | (s) source_list=$OPTARG;; |
---|
196 | (t) cpumax=$OPTARG; prc="$prc -t$OPTARG";; |
---|
197 | (T) palmrun_tasks_per_node=$OPTARG; prc="$prc -T$OPTARG";; |
---|
198 | (u) remote_username=$OPTARG; prc="$prc -u$OPTARG";; |
---|
199 | (U) return_username=$OPTARG; prc="$prc -U$OPTARG";; |
---|
200 | (v) silent=true; prc="$prc -v";; |
---|
201 | (w) max_par_io_str=$OPTARG; prc="$prc -w$OPTARG";; |
---|
202 | (x) do_trace=true;set -x; prc="$prc -x";; |
---|
203 | (X) cores=$OPTARG; prc="$prc -X$OPTARG";; |
---|
204 | (y) ocean_file_appendix=true; prc="$prc -y";; |
---|
205 | (Y) run_coupled_model=true; coupled_dist=$OPTARG; prc="$prc -Y'$OPTARG'";; |
---|
206 | (Z) combine_plot_fields=false; prc="$prc -Z";; |
---|
207 | (\?) printf "\n +++ unknown option $OPTARG \n" |
---|
208 | printf "\n --> type \"$0 ?\" for available options \n" |
---|
209 | locat=parameter;exit;; |
---|
210 | esac |
---|
211 | done |
---|
212 | |
---|
213 | |
---|
214 | # SKIP GIVEN OPTIONS TO READ POSITIONAL PARAMETER, IF GIVEN |
---|
215 | # CURRENTLY ONLY PARAMETER ? (TO OUTPUT A SHORT COMMAND INFO) IS ALLOWED |
---|
216 | (( to_shift = $OPTIND - 1 )) |
---|
217 | shift $to_shift |
---|
218 | |
---|
219 | # PRINT SHORT DESCRIPTION OF PALMRUN OPTIONS |
---|
220 | if [[ "$1" = "?" ]] |
---|
221 | then |
---|
222 | (printf "\n *** Description of available palmrun options:\n" |
---|
223 | printf "\n Option Description Default-Value" |
---|
224 | printf "\n -a activation string list \"\" " |
---|
225 | printf "\n -b batch-job on local machine ---" |
---|
226 | printf "\n -B do not delete temporary directory at end ---" |
---|
227 | printf "\n -c configuration file .mrun.config" |
---|
228 | printf "\n -d base name of files attached to program test" |
---|
229 | printf "\n -F create batch job file only ---" |
---|
230 | printf "\n -h execution host \"default\" " |
---|
231 | printf "\n -k keep data from previous run" |
---|
232 | printf "\n -K additional conditions for controling" |
---|
233 | printf "\n usage of conditional code and" |
---|
234 | printf "\n env-variables in configuration file \"\" " |
---|
235 | printf "\n -m memory demand in MB (batch-jobs) 0 MB" |
---|
236 | printf "\n -M Makefile name Makefile" |
---|
237 | printf "\n -O threads per openMP task ---" |
---|
238 | printf "\n -q queue \"$queue\" " |
---|
239 | printf "\n -r run control list (combines -i -o) \"\" " |
---|
240 | printf "\n -s filenames of routines to be compiled \"\" " |
---|
241 | printf "\n must end with .f, .f90, .F, or .c !" |
---|
242 | printf "\n use \"..\" for more than one file and wildcards" |
---|
243 | printf "\n -s LM compiles all locally modified files" |
---|
244 | printf "\n -t allowed cpu-time in seconds (batch) 0" |
---|
245 | printf "\n -T tasks per node depending on -h" |
---|
246 | printf "\n -u username on remote machine \"\" " |
---|
247 | printf "\n -v no prompt for confirmation ---" |
---|
248 | printf "\n -w maximum parallel io streams as given by -X" |
---|
249 | printf "\n -x tracing of palmrun for debug purposes ---" |
---|
250 | printf "\n -X # of processors (on parallel machines) 1" |
---|
251 | printf "\n -y add appendix \"_O\" to all local output" |
---|
252 | printf "\n files (ocean precursor runs followed by" |
---|
253 | printf "\n coupled atmosphere-ocean runs) ---" |
---|
254 | printf "\n -Y run coupled model, \"#1 #2\" with" |
---|
255 | printf "\n #1 atmosphere and #2 ocean processors \"#/2 #/2\" depending on -X" |
---|
256 | printf "\n -Z skip combine_plot_fields at the end of " |
---|
257 | printf "\n the simulation ---" |
---|
258 | printf "\n " |
---|
259 | printf "\n Possible values of positional parameter <modus>:" |
---|
260 | printf "\n \"?\" - this outline \n\n") | more |
---|
261 | exit |
---|
262 | elif [[ "$1" != "" ]] |
---|
263 | then |
---|
264 | printf "\n +++ positional parameter $1 unknown \n" |
---|
265 | locat=parameter; exit |
---|
266 | fi |
---|
267 | |
---|
268 | |
---|
269 | |
---|
270 | # SHORT STARTING MESSAGE |
---|
271 | printf "\n*** $version " |
---|
272 | printf "\n will be executed. Please wait ..." |
---|
273 | |
---|
274 | |
---|
275 | # BUILD THE CONFIGURATION-FILE NAME |
---|
276 | if [[ "$config_file" = "" ]] |
---|
277 | then |
---|
278 | config_file=.palm.config.$host |
---|
279 | fi |
---|
280 | |
---|
281 | |
---|
282 | # CHECK, IF CONFIGURATION FILE EXISTS |
---|
283 | if [[ ! -f $config_file ]] |
---|
284 | then |
---|
285 | printf "\n\n +++ configuration file: " |
---|
286 | printf "\n $config_file" |
---|
287 | printf "\n does not exist" |
---|
288 | locat=connect; exit |
---|
289 | fi |
---|
290 | |
---|
291 | |
---|
292 | # CHECK, IF FILE CONNECTION FILE EXISTS |
---|
293 | if [[ ! -f $fileconnection_file ]] |
---|
294 | then |
---|
295 | printf "\n\n +++ file connection file: " |
---|
296 | printf "\n $fileconnection_file" |
---|
297 | printf "\n does not exist" |
---|
298 | locat=connect; exit |
---|
299 | fi |
---|
300 | |
---|
301 | |
---|
302 | # READ AND EVALUATE THE CONFIGURATION-FILE |
---|
303 | [[ $silent = false ]] && printf "\n\n Reading the configuration file... " |
---|
304 | |
---|
305 | # READ VARIABLE SETTINGS FROM CONFIG FILE LINE BY LINE |
---|
306 | while read line |
---|
307 | do |
---|
308 | |
---|
309 | # FIRST REPLACE ENVIRONMENT-VARIABLES BY THEIR RESPECTIVE VALUES |
---|
310 | eval line=\"$line\" |
---|
311 | |
---|
312 | |
---|
313 | # INTERPRET THE LINE |
---|
314 | if [[ "$(echo $line)" = "" ]] |
---|
315 | then |
---|
316 | |
---|
317 | # EMPTY LINE, NO ACTION |
---|
318 | continue |
---|
319 | |
---|
320 | elif [[ "$(echo $line | cut -c1)" = "#" ]] |
---|
321 | then |
---|
322 | |
---|
323 | # LINE IS A COMMENT LINE |
---|
324 | continue |
---|
325 | |
---|
326 | elif [[ "$(echo $line | cut -c1)" = "%" ]] |
---|
327 | then |
---|
328 | |
---|
329 | # LINE DEFINES AN ENVIRONMENT-VARIABLE |
---|
330 | var=`echo $line | cut -d" " -s -f1 | cut -c2-` |
---|
331 | value=`echo $line | cut -d" " -s -f2-` |
---|
332 | |
---|
333 | |
---|
334 | # VALUE FROM THE CONFIGURATION-FILE IS ASSIGNED TO THE |
---|
335 | # ENVIRONMENT-VARIABLE, BUT ONLY IF NO VALUE HAS BEEN ALREADY |
---|
336 | # ASSIGNED WITHIN THIS SCRIPT (E.G. BY SCRIPT-OPTIONS). |
---|
337 | # NON-ASSIGNED VARIABLES HAVE VALUE "" OR 0 (IN CASE OF INTEGER). |
---|
338 | # HENCE THE GENERAL RULE IS: SCRIPT-OPTION OVERWRITES THE |
---|
339 | # CONFIGURATION-FILE. |
---|
340 | if [[ "$(eval echo \$$var)" = "" || "$(eval echo \$$var)" = "0" ]] |
---|
341 | then |
---|
342 | eval export $var="\$value" |
---|
343 | |
---|
344 | # TERMINAL OUTPUT OF ENVIRONMENT-VARIABLES, IF TRACEBACK IS SWITCHED on |
---|
345 | if [[ $do_trace = true ]] |
---|
346 | then |
---|
347 | printf "\n*** ENVIRONMENT-VARIABLE $var = $value" |
---|
348 | fi |
---|
349 | fi |
---|
350 | |
---|
351 | elif [[ "$(echo $line | cut -c1-3)" = "BD:" ]] |
---|
352 | then |
---|
353 | |
---|
354 | # LINE DEFINES BATCH-DIRECTIVE |
---|
355 | (( ibd = ibd + 1 )) |
---|
356 | line=$(echo $line | cut -c4-) |
---|
357 | batch_directive[$ibd]="$line" |
---|
358 | |
---|
359 | elif [[ "$(echo $line | cut -c1-4)" = "BDT:" ]] |
---|
360 | then |
---|
361 | |
---|
362 | # LINE DEFINES BATCH-DIRECTIVE FOR SENDING BACK THE JOBFILE FROM A |
---|
363 | # REMOTE TO A LOCAL HOST |
---|
364 | (( ibdt = ibdt + 1 )) |
---|
365 | line=$(echo $line | cut -c5-) |
---|
366 | batch_directive_transfer[$ibdt]="$line" |
---|
367 | |
---|
368 | elif [[ "$(echo $line | cut -c1-3)" = "EC:" ]] |
---|
369 | then |
---|
370 | |
---|
371 | # LINE DEFINES ERROR-COMMAND |
---|
372 | (( iec = iec + 1 )) |
---|
373 | line=$(echo $line | cut -c4-) |
---|
374 | err_command[$iec]="$line" |
---|
375 | |
---|
376 | elif [[ "$(echo $line | cut -c1-3)" = "IC:" ]] |
---|
377 | then |
---|
378 | |
---|
379 | # LINE DEFINES INPUT-COMMAND |
---|
380 | (( iic = iic + 1 )) |
---|
381 | line=$(echo $line | cut -c4-) |
---|
382 | in_command[$iic]="$line" |
---|
383 | |
---|
384 | elif [[ "$(echo $line | cut -c1-3)" = "OC:" ]] |
---|
385 | then |
---|
386 | |
---|
387 | # LINE DEFINES OUTPUT-COMMAND |
---|
388 | (( ioc = ioc + 1 )) |
---|
389 | line=$(echo $line | cut -c4-) |
---|
390 | out_command[$ioc]="$line" |
---|
391 | |
---|
392 | else |
---|
393 | |
---|
394 | # SKIP ALL OTHER LINES |
---|
395 | continue |
---|
396 | |
---|
397 | fi |
---|
398 | |
---|
399 | done < $config_file |
---|
400 | |
---|
401 | |
---|
402 | # CHECK SETTING OF REQUIRED PARAMETERS |
---|
403 | if [[ "$compiler_name" = "" ]] |
---|
404 | then |
---|
405 | printf "\n +++ no compiler name found in $config_file" |
---|
406 | printf "\n Please add line \"compiler_name ...\" to that file." |
---|
407 | locat=config_file; exit |
---|
408 | fi |
---|
409 | if [[ "$compiler_name_ser" = "" ]] |
---|
410 | then |
---|
411 | printf "\n +++ no compiler name for non-paralle compilation found in $config_file" |
---|
412 | printf "\n Please add line \"compiler_name_ser ...\" to that file." |
---|
413 | locat=config_file; exit |
---|
414 | fi |
---|
415 | if [[ "$compiler_options" = "" ]] |
---|
416 | then |
---|
417 | printf "\n +++ no compiler options found in $config_file" |
---|
418 | printf "\n Please add line \"compiler_options ...\" to that file." |
---|
419 | locat=config_file; exit |
---|
420 | fi |
---|
421 | if [[ "$loader_options" = "" ]] |
---|
422 | then |
---|
423 | printf "\n +++ no loader options found in $config_file" |
---|
424 | printf "\n Please add line \"loader_options ...\" to that file." |
---|
425 | locat=config_file; exit |
---|
426 | fi |
---|
427 | if [[ "$execute_command" = "" ]] |
---|
428 | then |
---|
429 | printf "\n +++ no execute command found in $config_file" |
---|
430 | printf "\n Please add line \"execute_command ...\" to that file." |
---|
431 | locat=config_file; exit |
---|
432 | fi |
---|
433 | |
---|
434 | if [[ "$hostfile" != "" ]] |
---|
435 | then |
---|
436 | if [[ $hostfile != auto && ! -f $hostfile ]] |
---|
437 | then |
---|
438 | printf "\n +++ no hostfile \"$hostfile\" found" |
---|
439 | printf "\n Please check line \"hostfile ...\" in $config_file" |
---|
440 | locat=config_file; exit |
---|
441 | fi |
---|
442 | fi |
---|
443 | |
---|
444 | if [[ "$write_binary" = "" ]] |
---|
445 | then |
---|
446 | write_binary=false |
---|
447 | fi |
---|
448 | |
---|
449 | # DETERMINE THE CALL STATUS |
---|
450 | if [[ "$return_address" != "" ]] |
---|
451 | then |
---|
452 | |
---|
453 | # I AM RUNNING ON A REMOTE HOST, WHICH ALSO MEANS THAT I AM RUNNING IN |
---|
454 | # BATCH MODE AND ... |
---|
455 | running_on_remote=true |
---|
456 | host_name=$remote_hostname |
---|
457 | |
---|
458 | else |
---|
459 | |
---|
460 | # I HAVE BEEN CALLED INTERACTIVELY ON THIS HOST |
---|
461 | if [[ "$remote_ip" != "" ]] |
---|
462 | then |
---|
463 | |
---|
464 | # I HAVE TO CREATE A BATCH JOB TO RUN PALM ON THE REMOTE HOST |
---|
465 | create_remote_batch_job=true |
---|
466 | |
---|
467 | fi |
---|
468 | host_name=$local_hostname |
---|
469 | running_on_remote=false |
---|
470 | fi |
---|
471 | |
---|
472 | |
---|
473 | |
---|
474 | # READ AND EVALUATE THE I/O-FILE LIST |
---|
475 | [[ $silent = false ]] && printf "\n Reading the I/O files... " |
---|
476 | |
---|
477 | # READ THE FILE CONNECTION FILE LINE BY LINE |
---|
478 | while read line |
---|
479 | do |
---|
480 | |
---|
481 | # FIRST REPLACE ENVIRONMENT-VARIABLES BY THEIR RESPECTIVE VALUES |
---|
482 | eval line=\"$line\" |
---|
483 | |
---|
484 | |
---|
485 | # INTERPRET THE LINE |
---|
486 | if [[ "$(echo $line)" = "" ]] |
---|
487 | then |
---|
488 | # EMPTY LINE, NO ACTION |
---|
489 | continue |
---|
490 | |
---|
491 | elif [[ "$(echo $line | cut -c1)" = "#" ]] |
---|
492 | then |
---|
493 | |
---|
494 | # LINE IS A COMMENT LINE |
---|
495 | true |
---|
496 | |
---|
497 | else |
---|
498 | |
---|
499 | # LINE DEFINES FILE CONNECTION. READ THE FILE ATTRIBUTES. |
---|
500 | # s2a: in/out - field |
---|
501 | # s2b: loc - field (optional) |
---|
502 | # s2c: tr/ar - field (optional) |
---|
503 | s1=`echo $line | cut -d" " -f1` |
---|
504 | s2=`echo $line | cut -d" " -s -f2` |
---|
505 | s2a=$(echo $s2 | cut -d":" -f1) |
---|
506 | if [[ $(echo $s2 | grep -c ":") = 0 ]] |
---|
507 | then |
---|
508 | s2b="" |
---|
509 | s2c="" |
---|
510 | else |
---|
511 | s2b=`echo $s2 | cut -d":" -f2 | sed 's/:/ /g'` |
---|
512 | s2c=`echo $s2 | cut -d":" -s -f3 | sed 's/:/ /g'` |
---|
513 | fi |
---|
514 | s3=`echo $line | cut -d" " -f3` |
---|
515 | s4=`echo $line | cut -d" " -s -f4` |
---|
516 | s5=`echo $line | cut -d" " -s -f5` |
---|
517 | s6=`echo $line | cut -d" " -s -f6` |
---|
518 | |
---|
519 | |
---|
520 | # STORE FILE CONNECTION, IF ACTIVATED BY ACTIVATION-STRING FROM |
---|
521 | # INPUT- OR OUTPUT-LIST. |
---|
522 | # VARIABLE S3 MAY CONTAIN A LIST OF ACTIVATION STRINGS (FIELD-SEPERATOR ":"). |
---|
523 | # IF EXECUTION IS SCHEDULED FOR A REMOTE-MACHINE AND THE FILE IS ONLY |
---|
524 | # LOCALLY REQUIRED ON THAT MACHINE (I.E. s2b = loc), THE FILE CONNECTION |
---|
525 | # IS NOT CHECKED AND STORED. |
---|
526 | IFSALT="$IFS"; IFS="$IFS:" |
---|
527 | if [[ "$s2a" = in && ! ( $create_remote_batch_job = true && ( "$s2b" = loc || "$s2b" = locopt ) ) ]] |
---|
528 | then |
---|
529 | found=false |
---|
530 | for actual in $activation_string_list |
---|
531 | do |
---|
532 | for formal in $s3 |
---|
533 | do |
---|
534 | [[ $actual = $formal || "$formal" = "-" ]] && found=true |
---|
535 | done |
---|
536 | done |
---|
537 | if [[ $found = true ]] |
---|
538 | then |
---|
539 | (( iin = iin + 1 )) |
---|
540 | localin[$iin]=$s1; transin[$iin]=$s2b; actionin[$iin]=$s2c; |
---|
541 | typein[$iin]=$s3; pathin[$iin]=$s4; endin[$iin]=$s5; |
---|
542 | extin[$iin]=$s6 |
---|
543 | fi |
---|
544 | elif [[ "$s2a" = out && ! ( $create_remote_batch_job = true && "$s2b" = loc ) ]] |
---|
545 | then |
---|
546 | found=false |
---|
547 | for actual in $activation_string_list |
---|
548 | do |
---|
549 | for formal in $s3 |
---|
550 | do |
---|
551 | [[ $actual = $formal || "$formal" = "-" ]] && found=true |
---|
552 | done |
---|
553 | done |
---|
554 | if [[ $found = true ]] |
---|
555 | then |
---|
556 | (( iout = iout + 1 )) |
---|
557 | localout[$iout]=$s1; actionout[$iout]=$s2c; typeout[$iout]=$s3; |
---|
558 | pathout[$iout]=$s4; endout[$iout]=$s5; extout[$iout]=$s6 |
---|
559 | fi |
---|
560 | elif [[ "$s2a" != in && "$s2a" != out ]] |
---|
561 | then |
---|
562 | printf "\n +++ I/O-attribute in configuration file $config_file has the invalid" |
---|
563 | printf "\n value \"$s2\". Only \"in\" and \"out\" are allowed!" |
---|
564 | locat=connect; exit |
---|
565 | fi |
---|
566 | IFS="$IFSALT" |
---|
567 | fi |
---|
568 | |
---|
569 | done < $fileconnection_file |
---|
570 | |
---|
571 | |
---|
572 | |
---|
573 | # EVALUATE MODEL COUPLING FEATURES (OPTION -Y) |
---|
574 | if [[ $run_coupled_model = true ]] |
---|
575 | then |
---|
576 | |
---|
577 | cores_atmos=`echo $coupled_dist | cut -d" " -s -f1` |
---|
578 | cores_ocean=`echo $coupled_dist | cut -d" " -s -f2` |
---|
579 | |
---|
580 | if (( $cores_ocean + $cores_atmos != $cores )) |
---|
581 | then |
---|
582 | |
---|
583 | printf "\n +++ number of processors does not fit to specification by \"-Y\"." |
---|
584 | printf "\n PEs (total) : $cores" |
---|
585 | printf "\n PEs (atmosphere): $cores_atmos" |
---|
586 | printf "\n PEs (ocean) : $cores_ocean" |
---|
587 | locat=coupling; exit |
---|
588 | |
---|
589 | fi |
---|
590 | |
---|
591 | fi |
---|
592 | |
---|
593 | |
---|
594 | # SAVE VALUES OF PALMRUN-OPTIONS IN ORDER TO OVERWRITE |
---|
595 | # THOSE VALUES GIVEN IN THE CONFIGURATION-FILE |
---|
596 | palmrun_memory=$memory |
---|
597 | palmrun_cpumax=$cpumax |
---|
598 | palmrun_cores=$cores |
---|
599 | |
---|
600 | |
---|
601 | # VALUES OF PALMRUN-OPTIONS OVERWRITE THOSE FROM THE CONFIGURATION-FILE |
---|
602 | [[ $palmrun_memory != 0 ]] && memory=$palmrun_memory |
---|
603 | [[ $palmrun_cpumax != 0 ]] && cpumax=$palmrun_cpumax |
---|
604 | [[ "$palmrun_cores" != "" ]] && cores=$palmrun_cores |
---|
605 | [[ "$max_par_io_str" != "" ]] && maximum_parallel_io_streams=$max_par_io_str |
---|
606 | [[ "$palmrun_tasks_per_node" != "" ]] && tasks_per_node=$palmrun_tasks_per_node |
---|
607 | |
---|
608 | |
---|
609 | |
---|
610 | # IF I AM IN BATCH MODE, CHECK IF EXECUTABLE AND OTHER REQUIRED FILES |
---|
611 | # HAVE BEEN GENERATED BY PALMBUILD AND STORED IN THE SOURCES_FOR_RUN_... |
---|
612 | # FOLDER |
---|
613 | if [[ $running_in_batch_mode = true ]] |
---|
614 | then |
---|
615 | |
---|
616 | if [[ ! -d ${tmp_user_catalog}/SOURCES_FOR_RUN_$fname ]] |
---|
617 | then |
---|
618 | printf "\n +++ directory ${tmp_user_catalog}/SOURCES_FOR_RUN_$fname is missing" |
---|
619 | printf "\n Please check the output of the palmrun-call" |
---|
620 | printf "\n that you did on your local host." |
---|
621 | locat=SOURCES_FOR_RUN; exit |
---|
622 | fi |
---|
623 | |
---|
624 | else |
---|
625 | |
---|
626 | # CREATE THE SOURCES_FOR_RUN_... FOLDER, BUT NOT IF I AM PART OF AN |
---|
627 | # AUTOMATIC RESTART RUN |
---|
628 | # AUTOMATIC RESTART RUNS JUST ACCESS THE DIRECTORY CREATED BY THE INITIAL RUN |
---|
629 | if [[ $restart_run = false ]] |
---|
630 | then |
---|
631 | |
---|
632 | # COLLECT FILES TO BE COMPILED IN THE SOURCES_FOR_RUN_... FOLDER ON |
---|
633 | # THE LOCAL HOST |
---|
634 | if [[ ! -d $source_path ]] |
---|
635 | then |
---|
636 | printf "\n\n +++ source path \"$source_path\" on local host" |
---|
637 | printf "\n \"$(hostname)\" does not exist" |
---|
638 | locat=source_path; exit |
---|
639 | fi |
---|
640 | |
---|
641 | rm -rf SOURCES_FOR_RUN_$fname |
---|
642 | mkdir SOURCES_FOR_RUN_$fname |
---|
643 | |
---|
644 | if [[ "$source_list" = LM ]] |
---|
645 | then |
---|
646 | |
---|
647 | # DETERMINE MODIFIED FILES OF THE SVN WORKING COPY |
---|
648 | source_list="" |
---|
649 | cd $source_path |
---|
650 | |
---|
651 | |
---|
652 | # CHECK, IF DIRECTORY IS UNDER SVN CONTROL |
---|
653 | if [[ ! -d .svn ]] |
---|
654 | then |
---|
655 | printf "\n\n +++ source directory" |
---|
656 | printf "\n \"$source_path\" " |
---|
657 | printf "\n is not under control of \"subversion\"." |
---|
658 | printf "\n Please do not use palmmrun-option \"-s LM\"\n" |
---|
659 | fi |
---|
660 | |
---|
661 | |
---|
662 | # LIST ALL MODIFIED SOURCE CODE FILES |
---|
663 | Filenames="" |
---|
664 | svn status > tmp_mrun |
---|
665 | while read line |
---|
666 | do |
---|
667 | firstc=`echo $line | cut -c1` |
---|
668 | if [[ $firstc = M || $firstc = "?" ]] |
---|
669 | then |
---|
670 | Name=`echo "$line" | cut -c8-` |
---|
671 | extension=`echo $Name | cut -d. -f2` |
---|
672 | if [[ "$extension" = f90 || "$extension" = F90 || "$extension" = f || "$extension" = F || "$extension" = c ]] |
---|
673 | then |
---|
674 | Filenames="$Filenames "$Name |
---|
675 | fi |
---|
676 | fi |
---|
677 | done < tmp_mrun |
---|
678 | |
---|
679 | |
---|
680 | # COPY FILES TO SOURCES_FOR_RUN_... |
---|
681 | for filename in $Filenames |
---|
682 | do |
---|
683 | cp $filename $working_directory/SOURCES_FOR_RUN_$fname |
---|
684 | source_list=$source_list"$filename " |
---|
685 | done |
---|
686 | |
---|
687 | cd - > /dev/null |
---|
688 | |
---|
689 | |
---|
690 | # COPY FILES GIVEN BY OPTION -s TO DIRECTORY SOURCES_FOR_RUN_... |
---|
691 | elif [[ "$source_list" != "" ]] |
---|
692 | then |
---|
693 | |
---|
694 | cd $source_path |
---|
695 | |
---|
696 | for filename in $source_list |
---|
697 | do |
---|
698 | |
---|
699 | # SOURCE CODE FILE IS NOT ALLOWED TO INCLUDE PATH |
---|
700 | if [[ $(echo $filename | grep -c "/") != 0 ]] |
---|
701 | then |
---|
702 | printf "\n +++ source code file: $filename" |
---|
703 | printf "\n must not contain (\"/\") " |
---|
704 | locat=source; exit |
---|
705 | fi |
---|
706 | |
---|
707 | if [[ ! -f $filename ]] |
---|
708 | then |
---|
709 | printf "\n +++ source code file: $filename" |
---|
710 | printf "\n does not exist" |
---|
711 | locat=source; exit |
---|
712 | else |
---|
713 | cp $filename $working_directory/SOURCES_FOR_RUN_$fname |
---|
714 | fi |
---|
715 | |
---|
716 | done |
---|
717 | |
---|
718 | cd - > /dev/null |
---|
719 | |
---|
720 | fi |
---|
721 | |
---|
722 | # CHECK, IF MAKEFILE EXISTS AND COPY IT TO THE SOURCES_FOR_RUN... DIRECTORY |
---|
723 | [[ "$makefile" = "" ]] && makefile=$source_path/Makefile |
---|
724 | if [[ ! -f $makefile ]] |
---|
725 | then |
---|
726 | printf "\n +++ file \"$makefile\" does not exist" |
---|
727 | locat=make; exit |
---|
728 | else |
---|
729 | cp $makefile SOURCES_FOR_RUN_$fname/Makefile |
---|
730 | fi |
---|
731 | |
---|
732 | |
---|
733 | # COPY FILES FROM OPTIONAL SOURCE PATH GIVEN IN THE CONFIGURATION FILE |
---|
734 | if [[ "$add_source_path" != "" ]] |
---|
735 | then |
---|
736 | |
---|
737 | # DOES THE DIRECTORY EXIST? |
---|
738 | if [[ ! -d $add_source_path ]] |
---|
739 | then |
---|
740 | |
---|
741 | printf "\n\n *** INFORMATIVE: additional source code directory" |
---|
742 | printf "\n \"$add_source_path\" " |
---|
743 | printf "\n does not exist or is not a directory." |
---|
744 | printf "\n No source code will be used from this directory!\n" |
---|
745 | add_source_path="" |
---|
746 | if [[ $silent == false ]] |
---|
747 | then |
---|
748 | sleep 2 |
---|
749 | fi |
---|
750 | |
---|
751 | else |
---|
752 | |
---|
753 | cd $add_source_path |
---|
754 | found=false |
---|
755 | |
---|
756 | Names=$(ls -1 *.f90 2>&1) |
---|
757 | [[ $(echo $Names | grep -c '*.f90') = 0 ]] && AddFilenames="$Names" |
---|
758 | Names=$(ls -1 *.F90 2>&1) |
---|
759 | [[ $(echo $Names | grep -c '*.F90') = 0 ]] && AddFilenames="$AddFilenames $Names" |
---|
760 | Names=$(ls -1 *.F 2>&1) |
---|
761 | [[ $(echo $Names | grep -c '*.F') = 0 ]] && AddFilenames="$AddFilenames $Names" |
---|
762 | Names=$(ls -1 *.f 2>&1) |
---|
763 | [[ $(echo $Names | grep -c '*.f') = 0 ]] && AddFilenames="$AddFilenames $Names" |
---|
764 | Names=$(ls -1 *.c 2>&1) |
---|
765 | [[ $(echo $Names | grep -c '*.c') = 0 ]] && AddFilenames="$AddFilenames $Names" |
---|
766 | |
---|
767 | cd - > /dev/null |
---|
768 | cd SOURCES_FOR_RUN_$fname |
---|
769 | |
---|
770 | # COPY MAKEFILE IF EXISTING |
---|
771 | if [[ -f $add_source_path/Makefile ]] |
---|
772 | then |
---|
773 | printf "\n\n *** user Makefile from directory" |
---|
774 | printf "\n \"$add_source_path\" is used \n" |
---|
775 | if [[ $silent == false ]] |
---|
776 | then |
---|
777 | sleep 1 |
---|
778 | fi |
---|
779 | cp $add_source_path/Makefile . |
---|
780 | fi |
---|
781 | |
---|
782 | for filename in $AddFilenames |
---|
783 | do |
---|
784 | if [[ -f $filename ]] |
---|
785 | then |
---|
786 | printf "\n +++ source code file \"$filename\" found in additional" |
---|
787 | printf "\n source code directory \"$add_source_path\" " |
---|
788 | printf "\n but was also given with option \"-s\" which means that it should be taken" |
---|
789 | printf "\n from directory \"$source_path\"." |
---|
790 | locat=source; exit |
---|
791 | fi |
---|
792 | |
---|
793 | cp $add_source_path/$filename . |
---|
794 | source_list="$source_list $filename" |
---|
795 | |
---|
796 | # CHECK IF FILE IS CONTAINED IN MAKEFILE |
---|
797 | if [[ $(grep -c $filename Makefile) = 0 ]] |
---|
798 | then |
---|
799 | printf "\n\n +++ user file \"$filename\" " |
---|
800 | printf "\n is not listed in Makefile \n" |
---|
801 | locat=source; exit |
---|
802 | else |
---|
803 | |
---|
804 | if [[ $found = false ]] |
---|
805 | then |
---|
806 | found=true |
---|
807 | printf "\n\n *** following user file(s) added to the" |
---|
808 | printf " files to be translated:\n " |
---|
809 | fi |
---|
810 | printf "$filename " |
---|
811 | if [[ $silent == false ]] |
---|
812 | then |
---|
813 | sleep 0.5 |
---|
814 | fi |
---|
815 | |
---|
816 | fi |
---|
817 | done |
---|
818 | [[ $found = true ]] && printf "\n" |
---|
819 | cd - > /dev/null |
---|
820 | fi |
---|
821 | fi |
---|
822 | |
---|
823 | # COPY CONFIGURATION FILES |
---|
824 | cp $config_file SOURCES_FOR_RUN_$fname |
---|
825 | cp $fileconnection_file SOURCES_FOR_RUN_$fname |
---|
826 | |
---|
827 | # COPY SHELLSCRIPTS |
---|
828 | cp ${source_path}/../SCRIPTS/palmrun SOURCES_FOR_RUN_$fname |
---|
829 | cp ${source_path}/../SCRIPTS/batch_scp SOURCES_FOR_RUN_$fname |
---|
830 | |
---|
831 | fi |
---|
832 | |
---|
833 | fi |
---|
834 | |
---|
835 | # GET THE GLOBAL REVISION-NUMBER OF THE SVN-REPOSITORY |
---|
836 | # (HANDED OVER TO RESTART-RUNS USING OPTION -G) |
---|
837 | if [[ "$global_revision" = "" ]] |
---|
838 | then |
---|
839 | global_revision=`svnversion $source_path 2>/dev/null` |
---|
840 | global_revision="Rev: $global_revision" |
---|
841 | fi |
---|
842 | |
---|
843 | |
---|
844 | # IN CASE OF PARALLEL EXECUTION, CHECK SOME SPECIFICATIONS CONCERNING PROCESSOR NUMBERS |
---|
845 | if [[ -n $cores ]] |
---|
846 | then |
---|
847 | |
---|
848 | # CHECK, IF THE NUMBER OF CORES PER NODE HAS BEEN GIVEN UND IF IT IS AN |
---|
849 | # INTEGRAL DIVISOR OF THE TOTAL NUMBER OF CORES GIVEN BY OPTION -X |
---|
850 | if [[ "$tasks_per_node" = "" && $host != lcxt5m ]] |
---|
851 | then |
---|
852 | printf "\n" |
---|
853 | printf "\n +++ option \"-T\" (tasks per node) is missing" |
---|
854 | printf "\n set -T option or define tasks_per_node in the config file" |
---|
855 | locat=tasks_per_node; (( iec = 0 )); exit |
---|
856 | fi |
---|
857 | |
---|
858 | if (( cores < tasks_per_node )) |
---|
859 | then |
---|
860 | printf "\n" |
---|
861 | printf "\n +++ tasks per node (-T) cannot exceed total number of cores (-X)" |
---|
862 | printf "\n given values: -T $tasks_per_node -X $cores" |
---|
863 | locat=tasks_per_node; (( iec = 0 )); exit |
---|
864 | fi |
---|
865 | |
---|
866 | (( nodes = cores / ( tasks_per_node * threads_per_task ) )) |
---|
867 | (( mpi_tasks = cores / threads_per_task )) |
---|
868 | [[ $mpi_tasks = 0 ]] && (( mpi_tasks = 1 )) |
---|
869 | (( ii = cores / tasks_per_node )) |
---|
870 | (( remaining_cores = cores - ii * tasks_per_node )) |
---|
871 | if (( remaining_cores > 0 )) |
---|
872 | then |
---|
873 | printf "\n" |
---|
874 | printf "\n +++ WARNING: tasks per node (option \"-T\") is not an integral" |
---|
875 | printf "\n divisor of the total number of cores (option \"-X\")" |
---|
876 | printf "\n values of this palmrun-call: \"-T $tasks_per_node\" \"-X $cores\"" |
---|
877 | printf "\n One of the nodes is filled with $remaining_cores instead of $tasks_per_node tasks" |
---|
878 | (( nodes = nodes + 1 )) |
---|
879 | fi |
---|
880 | |
---|
881 | # SET THE TOTAL NUMBER OF NODES, REQUIRED FOR THE SUBJOB-COMMAND (SEE FURTHER BELOW) |
---|
882 | if [[ "$tasks_per_node" != "" ]] |
---|
883 | then |
---|
884 | TOPT="-T $tasks_per_node" |
---|
885 | fi |
---|
886 | |
---|
887 | fi |
---|
888 | |
---|
889 | |
---|
890 | # SET DEFAULT VALUE FOR THE MAXIMUM NUMBER OF PARALLEL IO STREAMS |
---|
891 | if [[ "$maximum_parallel_io_streams" = "" ]] |
---|
892 | then |
---|
893 | maximum_parallel_io_streams=$cores |
---|
894 | fi |
---|
895 | |
---|
896 | |
---|
897 | # SET PORT NUMBER OPTION FOR CALLS OF SSH/SCP AND batch_scp SCRIPT |
---|
898 | if [[ "$scp_port" != "" ]] |
---|
899 | then |
---|
900 | PORTOPT="-P $scp_port" |
---|
901 | SSH_PORTOPT="-p $scp_port" |
---|
902 | fi |
---|
903 | |
---|
904 | |
---|
905 | # DETERMINE THE SSH-OPTION IN CASE THAT AN SSH-KEY IS EXPLICITLY GIVEN IN THE |
---|
906 | # CONFIG-FILE |
---|
907 | if [[ "$ssh_key" != "" ]] |
---|
908 | then |
---|
909 | ssh_key="-i $HOME/.ssh/$ssh_key" |
---|
910 | fi |
---|
911 | |
---|
912 | |
---|
913 | # SET QUEUE, IF NOT GIVEN |
---|
914 | if [[ $create_batch_job = true || $create_remote_batch_job = true ]] |
---|
915 | then |
---|
916 | |
---|
917 | if [[ $queue = none && "$defaultqueue" = "" ]] |
---|
918 | then |
---|
919 | printf "\n" |
---|
920 | printf "\n +++ no default queue given in configuration file and no queue" |
---|
921 | printf "\n given with option -q" |
---|
922 | fi |
---|
923 | if [[ $queue = none ]] |
---|
924 | then |
---|
925 | queue=$defaultqueue |
---|
926 | fi |
---|
927 | |
---|
928 | fi |
---|
929 | |
---|
930 | |
---|
931 | # GENERATE FULL FILENAMES OF INPUT-FILES, INCLUDING THEIR PATH |
---|
932 | # CHECK, IF INPUT-FILES EXIST, AND DETERMINE HIGHEST CYCLE NUMBER (IF CYCLES EXIST) |
---|
933 | (( i = 0 )) |
---|
934 | while (( i < iin )) |
---|
935 | do |
---|
936 | (( i = i + 1 )) |
---|
937 | (( maxcycle = 0 )) |
---|
938 | |
---|
939 | # GENERATE PATH AND FULL FILE NAME (then-BRANCH: FIXED FULL NAME IS GIVEN, I.E. THE |
---|
940 | # FILE IDENTIFIER IS NOT PART OF THE FILENAME)) |
---|
941 | if [[ "${actionin[$i]}" = di ]] |
---|
942 | then |
---|
943 | remotepathin[$i]=${pathin[$i]}/${endin[$i]} # EVALUATE REMOTE-PATH ON THE REMOTE |
---|
944 | # HOST ONLY |
---|
945 | eval filename=${pathin[$i]}/${endin[$i]} |
---|
946 | else |
---|
947 | remotepathin[$i]=${pathin[$i]}/${fname}${endin[$i]} # EVALUATE REMOTE-PATH ON THE REMOTE |
---|
948 | # HOST ONLY |
---|
949 | eval filename=${pathin[$i]}/${fname}${endin[$i]} |
---|
950 | fi |
---|
951 | eval pathname=${pathin[$i]} |
---|
952 | |
---|
953 | # CHECK IF FILE EXISTS |
---|
954 | if ! ls $filename* 1>/dev/null 2>&1 |
---|
955 | then |
---|
956 | |
---|
957 | # FILES WITH ATTRIBUTE locopt ARE OPTIONAL. NO ABORT, IF THEY DO NOT EXIST. |
---|
958 | if [[ "${transin[$i]}" != "locopt" ]] |
---|
959 | then |
---|
960 | printf "\n\n +++ INPUT-file: " |
---|
961 | if [[ "${extin[$i]}" = "" || "${extin[$i]}" = " " ]] |
---|
962 | then |
---|
963 | printf "\n $filename" |
---|
964 | else |
---|
965 | printf "\n $filename.${extin[$i]}" |
---|
966 | fi |
---|
967 | printf "\n does not exist\n" |
---|
968 | locat=input; exit |
---|
969 | else |
---|
970 | transin[$i]="unavailable" |
---|
971 | fi |
---|
972 | else |
---|
973 | |
---|
974 | # DETERMINE THE FILE'S CYCLE NUMBER |
---|
975 | ls -1 -d $filename > filelist 2>/dev/null |
---|
976 | ls -1 -d $filename.* >> filelist 2>/dev/null |
---|
977 | while read line |
---|
978 | do |
---|
979 | # filename without path (i.e. after the last "/") |
---|
980 | basefilename=$(basename ${line}) |
---|
981 | |
---|
982 | # check if there is an extension |
---|
983 | extension=${basefilename##*.} |
---|
984 | if [[ "$extension" = "$extin[$i]" ]] |
---|
985 | then |
---|
986 | basefilename=${basefilename&.*} |
---|
987 | fi |
---|
988 | |
---|
989 | # check for an existing cycle number |
---|
990 | cycle=${basefilename##*.} |
---|
991 | if [[ $cycle =~ ^-?[0-9]+$ ]] |
---|
992 | then |
---|
993 | (( icycle = $cycle )) |
---|
994 | else |
---|
995 | (( icycle = 0 )) |
---|
996 | fi |
---|
997 | |
---|
998 | if (( icycle > maxcycle )) |
---|
999 | then |
---|
1000 | (( maxcycle = icycle )) |
---|
1001 | fi |
---|
1002 | |
---|
1003 | done <filelist |
---|
1004 | rm filelist |
---|
1005 | |
---|
1006 | # APPEND CYCLE NUMBER TO FILENAME |
---|
1007 | if (( maxcycle > 0 )) |
---|
1008 | then |
---|
1009 | if [[ "${extin[$i]}" != " " && "${extin[$i]}" != "" ]] |
---|
1010 | then |
---|
1011 | filename=${filename}.$maxcycle.${extin[$i]} |
---|
1012 | else |
---|
1013 | filename=${filename}.$maxcycle |
---|
1014 | fi |
---|
1015 | else |
---|
1016 | if [[ "${extin[$i]}" != " " && "${extin[$i]}" != "" ]] |
---|
1017 | then |
---|
1018 | filename=${filename}.${extin[$i]} |
---|
1019 | fi |
---|
1020 | fi |
---|
1021 | |
---|
1022 | # STORE FILENAME WITHOUT PATH BUT WITH CYCLE NUMBER, |
---|
1023 | # IS LATER USED FOR TRANSFERRING FILES WIHIN THE JOB (SEE END OF FILE) |
---|
1024 | absnamein[$i]=$filename |
---|
1025 | if (( maxcycle > 0 )) |
---|
1026 | then |
---|
1027 | if [[ "${actionin[$i]}" = di ]] |
---|
1028 | then |
---|
1029 | frelin[$i]=${endin[$i]}.$maxcycle |
---|
1030 | else |
---|
1031 | frelin[$i]=${fname}${endin[$i]}.$maxcycle |
---|
1032 | fi |
---|
1033 | else |
---|
1034 | if [[ "${actionin[$i]}" = di ]] |
---|
1035 | then |
---|
1036 | frelin[$i]=${endin[$i]} |
---|
1037 | else |
---|
1038 | frelin[$i]=${fname}${endin[$i]} |
---|
1039 | fi |
---|
1040 | fi |
---|
1041 | |
---|
1042 | fi |
---|
1043 | done |
---|
1044 | |
---|
1045 | |
---|
1046 | # GENERATE FULL FILENAMES OF OUTPUT-FILES (WITHOUT $ OR ~), |
---|
1047 | # CHECK, IF OUTPUT-FILES EXIST, AND DETERMINE HIGHEST CYCLE NUMBER (IF CYCLES EXIST), |
---|
1048 | # OR, IN CASE THAT FILE DOES NOT EXIST, CHECK, IF IT CAN BE CREATED |
---|
1049 | # THESE ACTIONS ARE NOT CARRIED OUT, IF FILES SHALL BE TRASFERRED FROM THE REMOTE TO |
---|
1050 | # THE LOCAL HOST (BECAUSE THEIR IS NO DIRECT ACCESS TO THE LOCAL DIRECTORIES FROM THE |
---|
1051 | # REMOTE HOST) |
---|
1052 | (( i = 0 )) |
---|
1053 | while (( i < iout )) |
---|
1054 | do |
---|
1055 | (( i = i + 1 )) |
---|
1056 | if [[ ! ( $running_on_remote = true && ( "${actionout[$i]}" = tr || "${actionout[$i]}" = tra || "${actionout[$i]}" = trpe ) ) ]] |
---|
1057 | then |
---|
1058 | if [[ "${actionout[$i]}" = tr ]] |
---|
1059 | then |
---|
1060 | actionout[$i]="" |
---|
1061 | elif [[ "${actionout[$i]}" = trpe ]] |
---|
1062 | then |
---|
1063 | actionout[$i]=pe |
---|
1064 | elif [[ "${actionout[$i]}" = tra ]] |
---|
1065 | then |
---|
1066 | actionout[$i]=a |
---|
1067 | fi |
---|
1068 | (( maxcycle = 0 )) |
---|
1069 | eval filename=${pathout[$i]}/${fname}${endout[$i]} |
---|
1070 | eval catalogname=${pathout[$i]} |
---|
1071 | if ! ls $filename* 1>/dev/null 2>&1 |
---|
1072 | then |
---|
1073 | |
---|
1074 | # IF OUTPUT-FILE DOES NOT EXIST CHECK, IF IT CAN BE CREATED |
---|
1075 | if cat /dev/null > $filename |
---|
1076 | then |
---|
1077 | rm $filename |
---|
1078 | else |
---|
1079 | |
---|
1080 | # CHECK, IF THE DIRECTORY WHERE FILE SHALL BE COPIED TO EXISTS |
---|
1081 | # IF IT DOES NOT EXIST, TRY TO CREATE IT |
---|
1082 | if [[ ! -d $catalogname ]] |
---|
1083 | then |
---|
1084 | if mkdir -p $catalogname |
---|
1085 | then |
---|
1086 | printf "\n\n *** directory:" |
---|
1087 | printf "\n $catalogname" |
---|
1088 | printf "\n was created\n" |
---|
1089 | else |
---|
1090 | printf "\n\n +++ OUTPUT-file:" |
---|
1091 | printf "\n $filename" |
---|
1092 | printf "\n cannot be created, because directory does not exist" |
---|
1093 | printf "\n and cannot be created either" |
---|
1094 | printf "\n" |
---|
1095 | locat=output ; exit |
---|
1096 | fi 2>/dev/null |
---|
1097 | else |
---|
1098 | printf "\n\n +++ OUTPUT-file:" |
---|
1099 | printf "\n $filename" |
---|
1100 | printf "\n cannot be created, although directory exists" |
---|
1101 | printf "\n" |
---|
1102 | locat=output ; exit |
---|
1103 | fi |
---|
1104 | fi 2>/dev/null |
---|
1105 | else |
---|
1106 | |
---|
1107 | # DETERMINE THE CYCLE NUMBER |
---|
1108 | ls -1 -d $filename > filelist 2>/dev/null |
---|
1109 | ls -1 -d $filename.* >> filelist 2>/dev/null |
---|
1110 | while read line |
---|
1111 | do |
---|
1112 | |
---|
1113 | # filename without path (i.e. after the last "/") |
---|
1114 | basefilename=$(basename ${line}) |
---|
1115 | |
---|
1116 | # check if there is an extension |
---|
1117 | extension=${basefilename##*.} |
---|
1118 | if [[ "$extension" = "${extout[$i]}" ]] |
---|
1119 | then |
---|
1120 | basefilename=${basefilename%.*} |
---|
1121 | fi |
---|
1122 | |
---|
1123 | # check for an existing cycle number |
---|
1124 | cycle=${basefilename##*.} |
---|
1125 | if [[ $cycle =~ ^-?[0-9]+$ ]] |
---|
1126 | then |
---|
1127 | (( icycle = $cycle + 1 )) |
---|
1128 | else |
---|
1129 | (( icycle = 1 )) |
---|
1130 | fi |
---|
1131 | |
---|
1132 | if (( icycle > maxcycle )) |
---|
1133 | then |
---|
1134 | (( maxcycle = icycle )) |
---|
1135 | fi |
---|
1136 | |
---|
1137 | done <filelist |
---|
1138 | rm filelist |
---|
1139 | fi |
---|
1140 | |
---|
1141 | # APPEND CYCLE NUMBER TO FILENAME AND CHECK, IF FILE CAN BE CREATED |
---|
1142 | # IN CASE OF FILE-APPEND, FILE MUST BE APPENDED TO THE ONE WITH HIGHEST CYCLE NUMBER |
---|
1143 | if [[ "${actionout[$i]}" != a ]] |
---|
1144 | then |
---|
1145 | if (( maxcycle > 0 )) |
---|
1146 | then |
---|
1147 | filename_tmp=${filename}.$maxcycle |
---|
1148 | if cat /dev/null > $filename_tmp |
---|
1149 | then |
---|
1150 | rm $filename_tmp |
---|
1151 | else |
---|
1152 | printf "\n +++ OUTPUT-file:" |
---|
1153 | printf "\n $filename_tmp" |
---|
1154 | printf "\n cannot be created" |
---|
1155 | locat=output ; exit |
---|
1156 | fi |
---|
1157 | fi |
---|
1158 | else |
---|
1159 | (( maxcycle = maxcycle - 1 )) |
---|
1160 | fi |
---|
1161 | |
---|
1162 | (( cycnum[$i] = maxcycle )) |
---|
1163 | pathout[$i]=$filename |
---|
1164 | |
---|
1165 | fi |
---|
1166 | done |
---|
1167 | |
---|
1168 | |
---|
1169 | # DETERMINE THE NAME OF PALMRUN'S TEMPORARY WORKING DIRECTORY |
---|
1170 | if [[ $running_in_batch_mode = false ]] |
---|
1171 | then |
---|
1172 | run_id=$RANDOM |
---|
1173 | job_id=${fname}.$run_id |
---|
1174 | |
---|
1175 | TEMPDIR=$tmp_user_catalog/$job_id |
---|
1176 | fi |
---|
1177 | |
---|
1178 | |
---|
1179 | # CHECK SETTINGS REQUIRED FOR BATCH JOBS |
---|
1180 | if [[ $create_batch_job = true || $create_remote_batch_job = true ]] |
---|
1181 | then |
---|
1182 | |
---|
1183 | # CHECK, IF JOB DIRECTIVES HAVE BEEN GIVEN IN CONFIGURATION FILE |
---|
1184 | if [[ $ibd = 0 ]] |
---|
1185 | then |
---|
1186 | printf "\n" |
---|
1187 | printf "\n +++ no batch directives found in configuration file" |
---|
1188 | locat=config_file_batch_directives; (( iec = 0 )); exit |
---|
1189 | fi |
---|
1190 | |
---|
1191 | # CHECK IF CPUTIME IS GIVEN FOR JOB |
---|
1192 | done=false |
---|
1193 | while [[ $done = false ]] |
---|
1194 | do |
---|
1195 | cputime=$cpumax |
---|
1196 | if (( $cputime == 0 )) |
---|
1197 | then |
---|
1198 | printf "\n +++ cpu-time is undefined" |
---|
1199 | printf "\n >>> Please type CPU-time in seconds as INTEGER:" |
---|
1200 | printf "\n >>> " |
---|
1201 | read cputime 1>/dev/null 2>&1 |
---|
1202 | else |
---|
1203 | done=true |
---|
1204 | fi |
---|
1205 | done |
---|
1206 | |
---|
1207 | # CHECK THE MEMORY DEMAND |
---|
1208 | done=false |
---|
1209 | while [[ $done = false ]] |
---|
1210 | do |
---|
1211 | if (( memory == 0 )) |
---|
1212 | then |
---|
1213 | printf "\n +++ memory demand is undefined" |
---|
1214 | printf "\n >>> Please type memory in MByte per process as INTEGER:" |
---|
1215 | printf "\n >>> " |
---|
1216 | read memory 1>/dev/null 2>&1 |
---|
1217 | else |
---|
1218 | done=true |
---|
1219 | fi |
---|
1220 | done |
---|
1221 | |
---|
1222 | # IN CASE OF REMOTE-JOBS CHECK, IF A USERNAME FOR THE REMOTE HOST IS GIVEN |
---|
1223 | if [[ $create_remote_batch_job = true && -z $remote_username ]] |
---|
1224 | then |
---|
1225 | while [[ -z $remote_username ]] |
---|
1226 | do |
---|
1227 | printf "\n +++ username on remote host \"$remote_ip\" is undefined" |
---|
1228 | printf "\n >>> Please type username:" |
---|
1229 | printf "\n >>> " |
---|
1230 | read remote_username |
---|
1231 | done |
---|
1232 | fi |
---|
1233 | |
---|
1234 | else |
---|
1235 | |
---|
1236 | cputime=10000000 # NO LIMT FOR INTERACTIVE RUNS |
---|
1237 | |
---|
1238 | fi |
---|
1239 | cpumax=$cputime |
---|
1240 | |
---|
1241 | |
---|
1242 | # CALCULATE HOURS/MINUTES/SECONDS, E.G. FOR BATCH-DIRECTIVES |
---|
1243 | (( cpu_hours = cputime / 3600 )) |
---|
1244 | (( resttime = cputime - cpu_hours * 3600 )) |
---|
1245 | (( cpu_minutes = resttime / 60 )) |
---|
1246 | (( cpu_seconds = resttime - cpu_minutes * 60 )) |
---|
1247 | timestring=${cpu_hours}:${cpu_minutes}:${cpu_seconds} |
---|
1248 | |
---|
1249 | |
---|
1250 | # OUTPUT OF THE PALMRUN-HEADER |
---|
1251 | calltime=$(date) |
---|
1252 | printf "\n" |
---|
1253 | printf "#------------------------------------------------------------------------# \n" |
---|
1254 | printf "| %-35s%35s | \n" "$version" "$calltime" |
---|
1255 | printf "| | \n" |
---|
1256 | column1="called on:"; column2=$(hostname) |
---|
1257 | printf "| %-25s%-45s | \n" "$column1" "$column2" |
---|
1258 | if [[ $create_remote_batch_job = true ]] |
---|
1259 | then |
---|
1260 | column1="execution on:"; column2="$remote_hostname (username: $remote_username)" |
---|
1261 | else |
---|
1262 | if [[ $running_on_remote = true ]] |
---|
1263 | then |
---|
1264 | column1="execution on:"; column2="$remote_hostname" |
---|
1265 | else |
---|
1266 | column1="execution on:"; column2="$local_hostname" |
---|
1267 | fi |
---|
1268 | fi |
---|
1269 | printf "| %-25s%-45s | \n" "$column1" "$column2" |
---|
1270 | |
---|
1271 | column1="running in:" |
---|
1272 | if [[ $running_in_batch_mode = true ]] |
---|
1273 | then |
---|
1274 | column2="batch job mode" |
---|
1275 | else |
---|
1276 | if [[ $create_batch_job = true || $create_remote_batch_job = true ]] |
---|
1277 | then |
---|
1278 | column2="job creation mode" |
---|
1279 | else |
---|
1280 | column2="interactive run mode" |
---|
1281 | fi |
---|
1282 | fi |
---|
1283 | printf "| %-25s%-45s | \n" "$column1" "$column2" |
---|
1284 | |
---|
1285 | if [[ -n $cores ]] |
---|
1286 | then |
---|
1287 | if [[ $run_coupled_model = false ]] |
---|
1288 | then |
---|
1289 | column1="number of cores:"; column2=$cores |
---|
1290 | else |
---|
1291 | column1="number of cores:"; column2="$cores (atmosphere: $cores_atmos, ocean: $cores_ocean)" |
---|
1292 | fi |
---|
1293 | printf "| %-25s%-45s | \n" "$column1" "$column2" |
---|
1294 | fi |
---|
1295 | if [[ -n $tasks_per_node ]] |
---|
1296 | then |
---|
1297 | column1="tasks per node:"; column2="$tasks_per_node (number of nodes: $nodes)" |
---|
1298 | printf "| %-25s%-45s | \n" "$column1" "$column2" |
---|
1299 | if (( remaining_cores > 0 )) |
---|
1300 | then |
---|
1301 | column1=" "; column2="one of the nodes only filled with $remaining_cores tasks" |
---|
1302 | printf "| %-25s%-45s | \n" "$column1" "$column2" |
---|
1303 | fi |
---|
1304 | fi |
---|
1305 | if [[ $maximum_parallel_io_streams != $cores ]] |
---|
1306 | then |
---|
1307 | column1="max par io streams:"; column2="$maximum_parallel_io_streams" |
---|
1308 | printf "| %-25s%-45s | \n" "$column1" "$column2" |
---|
1309 | fi |
---|
1310 | if [[ $use_openmp = true ]] |
---|
1311 | then |
---|
1312 | column1="threads per task:"; column2="$threads_per_task" |
---|
1313 | printf "| %-25s%-45s | \n" "$column1" "$column2" |
---|
1314 | fi |
---|
1315 | printf "| | \n" |
---|
1316 | if [[ "$source_list" != "" ]] |
---|
1317 | then |
---|
1318 | if [[ "$make_options" != "" ]] |
---|
1319 | then |
---|
1320 | column1="make options:"; column2=$(echo "$make_options" | cut -c-45) |
---|
1321 | printf "| %-25s%-45s | \n" "$column1" "$column2" |
---|
1322 | line=$(echo "$make_options" | cut -c46-) |
---|
1323 | while [[ "$line" != "" ]] |
---|
1324 | do |
---|
1325 | column1="" |
---|
1326 | column2=$(echo "$line" | cut -c-45) |
---|
1327 | printf "| %-25s%-45s | \n" "$column1" "$column2" |
---|
1328 | line=$(echo "$line" | cut -c46-) |
---|
1329 | done |
---|
1330 | fi |
---|
1331 | fi |
---|
1332 | |
---|
1333 | column1="cpp directives:"; column2=$(echo "$cpp_options" | cut -c-45) |
---|
1334 | printf "| %-25s%-45s | \n" "$column1" "$column2" |
---|
1335 | line=$(echo "$cpp_options" | cut -c46-) |
---|
1336 | while [[ "$line" != "" ]] |
---|
1337 | do |
---|
1338 | column1="" |
---|
1339 | column2=$(echo "$line" | cut -c-45) |
---|
1340 | printf "| %-25s%-45s | \n" "$column1" "$column2" |
---|
1341 | line=$(echo "$line" | cut -c46-) |
---|
1342 | done |
---|
1343 | |
---|
1344 | column1="compiler options:"; column2=$(echo "$compiler_options" | cut -c-45) |
---|
1345 | printf "| %-25s%-45s | \n" "$column1" "$column2" |
---|
1346 | line=$(echo "$compiler_options" | cut -c46-) |
---|
1347 | while [[ "$line" != "" ]] |
---|
1348 | do |
---|
1349 | column1="" |
---|
1350 | column2=$(echo "$line" | cut -c-45) |
---|
1351 | printf "| %-25s%-45s | \n" "$column1" "$column2" |
---|
1352 | line=$(echo "$line" | cut -c46-) |
---|
1353 | done |
---|
1354 | |
---|
1355 | column1="loader options:"; column2=$(echo "$loader_options" | cut -c-45) |
---|
1356 | printf "| %-25s%-45s | \n" "$column1" "$column2" |
---|
1357 | line=$(echo "$loader_options" | cut -c46-) |
---|
1358 | while [[ "$line" != "" ]] |
---|
1359 | do |
---|
1360 | column1="" |
---|
1361 | column2=$(echo "$line" | cut -c-45) |
---|
1362 | printf "| %-25s%-45s | \n" "$column1" "$column2" |
---|
1363 | line=$(echo "$line" | cut -c46-) |
---|
1364 | done |
---|
1365 | |
---|
1366 | if [[ "$login_init_cmd" != "" ]] |
---|
1367 | then |
---|
1368 | column1="login init commands:"; column2=$(echo "$login_init_cmd" | cut -c-45) |
---|
1369 | printf "| %-25s%-45s | \n" "$column1" "$column2" |
---|
1370 | line=$(echo "$login_init_cmd" | cut -c46-) |
---|
1371 | while [[ "$line" != "" ]] |
---|
1372 | do |
---|
1373 | column1="" |
---|
1374 | column2=$(echo "$line" | cut -c-45) |
---|
1375 | printf "| %-25s%-45s | \n" "$column1" "$column2" |
---|
1376 | line=$(echo "$line" | cut -c46-) |
---|
1377 | done |
---|
1378 | fi |
---|
1379 | |
---|
1380 | if [[ "$module_commands" != "" ]] |
---|
1381 | then |
---|
1382 | column1="module commands:"; column2=$(echo "$module_commands" | cut -c-45) |
---|
1383 | printf "| %-25s%-45s | \n" "$column1" "$column2" |
---|
1384 | line=$(echo "$module_commands" | cut -c46-) |
---|
1385 | while [[ "$line" != "" ]] |
---|
1386 | do |
---|
1387 | column1="" |
---|
1388 | column2=$(echo "$line" | cut -c-45) |
---|
1389 | printf "| %-25s%-45s | \n" "$column1" "$column2" |
---|
1390 | line=$(echo "$line" | cut -c46-) |
---|
1391 | done |
---|
1392 | fi |
---|
1393 | printf "| | \n" |
---|
1394 | column1="base name of files:"; column2=$fname |
---|
1395 | printf "| %-25s%-45s | \n" "$column1" "$column2" |
---|
1396 | column1="activation string list:"; column2=$(echo $activation_string_list) |
---|
1397 | printf "| %-25s%-45s | \n" "$column1" "$column2" |
---|
1398 | |
---|
1399 | if [[ "$ocean_file_appendix" = true ]] |
---|
1400 | then |
---|
1401 | printf "| %-35s%-35s | \n" "suffix \"_O\" is added to local files" " " |
---|
1402 | fi |
---|
1403 | |
---|
1404 | if [[ $create_batch_job = true || "$LOADLBATCH" = yes ]] |
---|
1405 | then |
---|
1406 | column1="memory demand / PE":; column2="$memory MB" |
---|
1407 | printf "| %-25s%-45s | \n" "$column1" "$column2" |
---|
1408 | column1=CPU-time:; column2="$cpu_hours:$cpu_minutes:$cpu_seconds" |
---|
1409 | printf "| %-25s%-45s | \n" "$column1" "$column2" |
---|
1410 | fi |
---|
1411 | |
---|
1412 | if [[ "$source_list" != "" ]] |
---|
1413 | then |
---|
1414 | printf "| | \n" |
---|
1415 | printf "| Files to be compiled: | \n" |
---|
1416 | line=$source_list |
---|
1417 | while [[ "$line" != "" ]] |
---|
1418 | do |
---|
1419 | linestart=$(echo $line | cut -c-70) |
---|
1420 | printf "| %-70s | \n" "$linestart" |
---|
1421 | line=$(echo "$line" | cut -c71-) |
---|
1422 | done |
---|
1423 | fi |
---|
1424 | printf "#------------------------------------------------------------------------#" |
---|
1425 | |
---|
1426 | |
---|
1427 | |
---|
1428 | # OUTPUT OF FILE CONNECTIONS IN CASE OF TRACEBACK |
---|
1429 | if [[ $do_trace = true ]] |
---|
1430 | then |
---|
1431 | (( i = 0 )) |
---|
1432 | while (( i < iin )) |
---|
1433 | do |
---|
1434 | (( i = i + 1 )) |
---|
1435 | if (( i == 1 )) |
---|
1436 | then |
---|
1437 | printf "\n\n >>> INPUT-file assignments:\n" |
---|
1438 | fi |
---|
1439 | printf "\n ${localin[$i]} : ${absnamein[$i]}" |
---|
1440 | done |
---|
1441 | (( i = 0 )) |
---|
1442 | while (( i < iout )) |
---|
1443 | do |
---|
1444 | (( i = i + 1 )) |
---|
1445 | if (( i == 1 )) |
---|
1446 | then |
---|
1447 | printf "\n\n >>> OUTPUT-file assignments:\n" |
---|
1448 | fi |
---|
1449 | printf "\n ${localout[$i]} : ${pathout[$i]}" |
---|
1450 | done |
---|
1451 | (( i = 0 )) |
---|
1452 | while (( i < iic )) |
---|
1453 | do |
---|
1454 | (( i = i + 1 )) |
---|
1455 | if (( i == 1 )) |
---|
1456 | then |
---|
1457 | printf "\n\n >>> INPUT-commands:\n" |
---|
1458 | fi |
---|
1459 | printf "\n ${in_command[$i]}" |
---|
1460 | done |
---|
1461 | (( i = 0 )) |
---|
1462 | while (( i < ioc )) |
---|
1463 | do |
---|
1464 | (( i = i + 1 )) |
---|
1465 | if (( i == 1 )) |
---|
1466 | then |
---|
1467 | printf "\n\n >>> OUTPUT-commands:\n" |
---|
1468 | fi |
---|
1469 | printf "\n ${out_command[$i]}" |
---|
1470 | done |
---|
1471 | fi |
---|
1472 | |
---|
1473 | # QUERY FOR CONTINUE |
---|
1474 | if [[ $silent = false && $running_in_batch_mode = false ]] |
---|
1475 | then |
---|
1476 | antwort=dummy |
---|
1477 | printf "\n\n" |
---|
1478 | printf " >>> everything o.k. (y/n) ? " |
---|
1479 | while read antwort |
---|
1480 | do |
---|
1481 | if [[ "$antwort" != y && "$antwort" != Y && "$antwort" != n && "$antwort" != N ]] |
---|
1482 | then |
---|
1483 | printf " >>> everything o.k. (y/n) ? " |
---|
1484 | else |
---|
1485 | break |
---|
1486 | fi |
---|
1487 | done |
---|
1488 | if [[ $antwort = n || $antwort = N ]] |
---|
1489 | then |
---|
1490 | locat=user_abort; (( iec = 0 )); exit |
---|
1491 | fi |
---|
1492 | if [[ $create_batch_job = true || $create_remote_batch_job = true ]] |
---|
1493 | then |
---|
1494 | printf " *** batch-job will be created and submitted" |
---|
1495 | else |
---|
1496 | printf " *** PALMRUN will now continue to execute on this machine" |
---|
1497 | fi |
---|
1498 | fi |
---|
1499 | |
---|
1500 | |
---|
1501 | |
---|
1502 | # PROVIDE FILES TO EXECUTE PALM AND CREATE THE EXECUTABLE |
---|
1503 | if [[ $restart_run = false && $running_in_batch_mode = false ]] |
---|
1504 | then |
---|
1505 | |
---|
1506 | if [[ $create_batch_job = true || $create_remote_batch_job = true ]] |
---|
1507 | then |
---|
1508 | printf "\n\n *** creating executable and other sources for the remote host" |
---|
1509 | else |
---|
1510 | printf "\n\n *** creating executable and other sources for the local host" |
---|
1511 | fi |
---|
1512 | |
---|
1513 | palmbuild -v -h $host -d $fname |
---|
1514 | rm -rf SOURCES_FOR_RUN_$fname |
---|
1515 | |
---|
1516 | if [[ $? != 0 ]] |
---|
1517 | then |
---|
1518 | |
---|
1519 | # ABORT IN CASE OF COMPILATION PROBLEMS |
---|
1520 | printf "\n +++ error while creating executable and/or other sources" |
---|
1521 | locat=execution |
---|
1522 | exit |
---|
1523 | |
---|
1524 | else |
---|
1525 | |
---|
1526 | printf "\n$dashes\n *** executable and other sources created\n" |
---|
1527 | |
---|
1528 | fi |
---|
1529 | |
---|
1530 | fi |
---|
1531 | |
---|
1532 | |
---|
1533 | # NOW PERFORM THOSE ACTIONS REQUIRED TO EXECUTE THE PROGRAM (PALM) ON THIS MACHINE |
---|
1534 | # (COMPILING/LINKING, EXECUTING, COPYING I/O FILES) |
---|
1535 | if [[ $create_batch_job = false && $create_remote_batch_job = false ]] |
---|
1536 | then |
---|
1537 | |
---|
1538 | # CHANGE TO THE TEMPORARY WORKING DIRECTORY |
---|
1539 | if [[ $running_in_batch_mode = false ]] |
---|
1540 | then |
---|
1541 | # CREATE THE DIRECTORY AND COPY FILES FROM SOURCES_FOR_RUN_... TO THAT |
---|
1542 | # FOLDER |
---|
1543 | mkdir -p $TEMPDIR |
---|
1544 | chmod go+rx $TEMPDIR |
---|
1545 | tmpcreate=true |
---|
1546 | cd $TEMPDIR |
---|
1547 | cp $tmp_user_catalog/SOURCES_FOR_RUN_$fname/{*,.[!.]*} $TEMPDIR |
---|
1548 | printf "\n *** changed to temporary directory: $TEMPDIR" |
---|
1549 | |
---|
1550 | else |
---|
1551 | |
---|
1552 | # IN BATCH MODE PALMRUN IS CALLED FROM TEMPDIR |
---|
1553 | printf "\n *** running in temporary directory: $TEMPDIR" |
---|
1554 | |
---|
1555 | fi |
---|
1556 | |
---|
1557 | |
---|
1558 | # PROVIDE THE INPUT FILES |
---|
1559 | # LOOP OVER ALL ACTIVATED FILES (LISTED IN THE CONFIGURATION FILE) |
---|
1560 | (( i = 0 )) |
---|
1561 | while (( i < iin )) |
---|
1562 | do |
---|
1563 | (( i = i + 1 )) |
---|
1564 | if (( i == 1 )) |
---|
1565 | then |
---|
1566 | printf "\n\n *** providing INPUT-files:\n$dashes" |
---|
1567 | fi |
---|
1568 | |
---|
1569 | |
---|
1570 | # SKIP OPTIONAL FILES, IF THEY DO NOT EXIST |
---|
1571 | if [[ "${transin[$i]}" = unavailable ]] |
---|
1572 | then |
---|
1573 | if [[ "${extin[$i]}" = "" || "${extin[$i]}" = " " ]] |
---|
1574 | then |
---|
1575 | printf "\n *** INFORMATIVE: input file \"${pathin[$i]}/${fname}${endin[$i]}\" " |
---|
1576 | printf "\n is not available!" |
---|
1577 | else |
---|
1578 | printf "\n *** INFORMATIVE: input file \"${pathin[$i]}/${fname}${endin[$i]}.${extin[$i]}\" " |
---|
1579 | printf "\n is not available!" |
---|
1580 | fi |
---|
1581 | continue |
---|
1582 | fi |
---|
1583 | |
---|
1584 | # CHECK FOR SINGLE FILE (SERIAL RUN) OR DIRECTORY (ONE FILE PER CORE FOR PARELLEL EXECUTION) |
---|
1585 | files_for_cores=false; filetype=file |
---|
1586 | if [[ "${actionin[$i]}" = pe && -n $cores ]] |
---|
1587 | then |
---|
1588 | files_for_cores=true; filetype=files |
---|
1589 | actionin[$i]="" |
---|
1590 | elif [[ "${actionin[$i]}" = pe && ! -n $cores ]] |
---|
1591 | then |
---|
1592 | actionin[$i]="" |
---|
1593 | elif [[ "${actionin[$i]}" = lnpe && -n $cores ]] |
---|
1594 | then |
---|
1595 | files_for_cores=true; filetype=files |
---|
1596 | actionin[$i]="ln" |
---|
1597 | elif [[ "${actionin[$i]}" = lnpe && ! -n $cores ]] |
---|
1598 | then |
---|
1599 | actionin[$i]="ln" |
---|
1600 | fi |
---|
1601 | |
---|
1602 | if [[ $files_for_cores = true ]] |
---|
1603 | then |
---|
1604 | printf "\n >>> INPUT: ${absnamein[$i]}/.... to ${localin[$i]}" |
---|
1605 | else |
---|
1606 | printf "\n >>> INPUT: ${absnamein[$i]} to ${localin[$i]}" |
---|
1607 | fi |
---|
1608 | |
---|
1609 | # INPUT-FILES TO BE LINKED |
---|
1610 | if [[ "${actionin[$i]}" = ln ]] |
---|
1611 | then |
---|
1612 | |
---|
1613 | printf "\n $filetype will be linked" |
---|
1614 | if [[ $files_for_cores = false ]] |
---|
1615 | then |
---|
1616 | if [[ -f "${absnamein[$i]}" ]] |
---|
1617 | then |
---|
1618 | ln ${absnamein[$i]} ${localin[$i]} |
---|
1619 | got_tmp[$i]=true |
---|
1620 | fi |
---|
1621 | else |
---|
1622 | if [[ -d "${absnamein[$i]}" ]] |
---|
1623 | then |
---|
1624 | mkdir ${localin[$i]} |
---|
1625 | cd ${absnamein[$i]} |
---|
1626 | for file in $(ls *) |
---|
1627 | do |
---|
1628 | ln $file $TEMPDIR/${localin[$i]} |
---|
1629 | done >|/dev/null 2>&1 |
---|
1630 | cd $TEMPDIR |
---|
1631 | fi |
---|
1632 | |
---|
1633 | # IF "ln -f" HAS FAILED DO A NORMAL COPY "cp -r" |
---|
1634 | if [[ ! -f "${localin[$i]}/_000000" ]] |
---|
1635 | then |
---|
1636 | printf "\n --- WARNING: ln failed, using cp instead (might be time consuming...)" |
---|
1637 | cp -r ${absnamein[$i]}/* ${localin[$i]} |
---|
1638 | fi |
---|
1639 | |
---|
1640 | got_tmp[$i]=true |
---|
1641 | fi |
---|
1642 | fi |
---|
1643 | |
---|
1644 | # FILE IS STORED IN THE RESPECTIVE DIRECTORY GIVEN IN THE CONFIGURATION FILE |
---|
1645 | if [[ "${actionin[$i]}" = "" || "${actionin[$i]}" = "di" || "${actionin[$i]}" = "npe" ]] |
---|
1646 | then |
---|
1647 | |
---|
1648 | if [[ "${actionin[$i]}" = "npe" && -n $cores ]] |
---|
1649 | then |
---|
1650 | |
---|
1651 | # FILE COPIES ARE PROVIDED FOR ALL CORES |
---|
1652 | # EACH FILE GETS A UNIQUE FILENAME WITH A FOUR DIGIT NUMBER |
---|
1653 | printf "\n file will be provided for $cores processors" |
---|
1654 | mkdir ${localin[$i]} |
---|
1655 | ival=$cores |
---|
1656 | (( ii = 0 )) |
---|
1657 | while (( ii <= ival-1 )) |
---|
1658 | do |
---|
1659 | if (( ii < 10 )) |
---|
1660 | then |
---|
1661 | cp ${absnamein[$i]} ${localin[$i]}/_000$ii |
---|
1662 | elif (( ii < 100 )) |
---|
1663 | then |
---|
1664 | cp ${absnamein[$i]} ${localin[$i]}/_00$ii |
---|
1665 | elif (( ii < 1000 )) |
---|
1666 | then |
---|
1667 | cp ${absnamein[$i]} ${localin[$i]}/_0$ii |
---|
1668 | else |
---|
1669 | cp ${absnamein[$i]} ${localin[$i]}/_$ii |
---|
1670 | fi |
---|
1671 | (( ii = ii + 1 )) |
---|
1672 | done |
---|
1673 | |
---|
1674 | else |
---|
1675 | |
---|
1676 | if [[ $files_for_cores = true ]] |
---|
1677 | then |
---|
1678 | |
---|
1679 | # PROVIDE FILES FOR EACH CORE |
---|
1680 | # FIRST CREATE THE LOCAL DIRECTORY, THEN COPY FILES |
---|
1681 | # FROM THE PERMANENT DIRECTORY BY LINKING THEM TO THE LOCAL ONE |
---|
1682 | printf "\n providing $cores files for the respective cores" |
---|
1683 | mkdir ${localin[$i]} |
---|
1684 | if [[ $link_local_input = true ]] |
---|
1685 | then |
---|
1686 | printf " files will be linked\n" |
---|
1687 | cd ${absnamein[$i]} |
---|
1688 | for file in $(ls *) |
---|
1689 | do |
---|
1690 | ln -f $file ${localin[$i]} |
---|
1691 | done |
---|
1692 | cd $TEMPDIR |
---|
1693 | fi |
---|
1694 | |
---|
1695 | # IF "ln -f" FAILED OR IF "$link_local_input = false" DO A NORMAL "cp -r" |
---|
1696 | if [[ ! -f "${localin[$i]}/_000000" ]] |
---|
1697 | then |
---|
1698 | if [[ $link_local_input = true ]] |
---|
1699 | then |
---|
1700 | printf "\n --- WARNING: ln failed, using cp instead (might be time consuming...)" |
---|
1701 | fi |
---|
1702 | cp -r ${absnamein[$i]}/* ${localin[$i]} |
---|
1703 | fi |
---|
1704 | |
---|
1705 | else |
---|
1706 | |
---|
1707 | # PROVIDE FILE FOR RUNS ON A SINGLE CORE |
---|
1708 | if [[ $link_local_input = true ]] |
---|
1709 | then |
---|
1710 | printf " file will be linked\n" |
---|
1711 | ln -f ${absnamein[$i]} ${localin[$i]} |
---|
1712 | fi |
---|
1713 | # If "ln -f" fails of if "$link_local_input = false" do a normal "cp" |
---|
1714 | if [[ ! -f "${localin[$i]}" ]] |
---|
1715 | then |
---|
1716 | if [[ $link_local_input = true ]] |
---|
1717 | then |
---|
1718 | printf "\n --- WARNING: ln failed, using cp instead (might be time consuming...)" |
---|
1719 | fi |
---|
1720 | cp ${absnamein[$i]} ${localin[$i]} |
---|
1721 | fi |
---|
1722 | fi |
---|
1723 | fi |
---|
1724 | fi |
---|
1725 | |
---|
1726 | done |
---|
1727 | if (( i != 0 )) |
---|
1728 | then |
---|
1729 | printf "\n$dashes\n *** all INPUT-files provided \n" |
---|
1730 | fi |
---|
1731 | |
---|
1732 | |
---|
1733 | # EXECUTE INPUT-COMMANDS GIVEN IN THE CONFIGURATION FILE |
---|
1734 | (( i = 0 )) |
---|
1735 | while (( i < iic )) |
---|
1736 | do |
---|
1737 | (( i = i + 1 )) |
---|
1738 | if (( i == 1 )) |
---|
1739 | then |
---|
1740 | printf "\n\n *** execution of INPUT-commands:\n$dashes" |
---|
1741 | fi |
---|
1742 | printf "\n >>> ${in_command[$i]}" |
---|
1743 | eval ${in_command[$i]} |
---|
1744 | if (( i == iic )) |
---|
1745 | then |
---|
1746 | printf "\n$dashes\n" |
---|
1747 | fi |
---|
1748 | done |
---|
1749 | |
---|
1750 | |
---|
1751 | # CREATE THE NAMELIST-FILE WITH VALUES OF ENVIRONMENT-VARIABLES REQUIRED BY PALM |
---|
1752 | # (FILE ENVPAR WILL BE READ BY PALM) |
---|
1753 | cat > ENVPAR << EOF |
---|
1754 | &envpar run_identifier = '$fname', host = '$host', |
---|
1755 | write_binary = .${write_binary}., tasks_per_node = $tasks_per_node, |
---|
1756 | maximum_parallel_io_streams = $maximum_parallel_io_streams, |
---|
1757 | maximum_cpu_time_allowed = ${cpumax}., |
---|
1758 | revision = '$global_revision', |
---|
1759 | batch_job = .${running_in_batch_mode}. / |
---|
1760 | |
---|
1761 | EOF |
---|
1762 | |
---|
1763 | |
---|
1764 | # STARTING THE EXECUTABLE |
---|
1765 | printf "\n\n *** execution starts in directory\n \"`pwd`\"\n$dashes\n" |
---|
1766 | PATH=$PATH:$TEMPDIR |
---|
1767 | |
---|
1768 | |
---|
1769 | # REPLACE PARAMETERS IN THE EXECUTION COMMAND WITH REAL VALUES |
---|
1770 | line=`echo "${execute_command}" | sed 's/@MPI_TASKS@/$mpi_tasks/g' | sed 's/@TASKS_PER_NODE@/$tasks_per_node/g'` |
---|
1771 | line2=`echo "${execute_command}" | sed 's/@MPI_TASKS@/1/g' | sed 's/@TASKS_PER_NODE@/1/g' | sed 's/palm/combine_plot_fields.x/g'` |
---|
1772 | eval line=\"$line\" |
---|
1773 | execute_command="$line" |
---|
1774 | |
---|
1775 | |
---|
1776 | # EXECUTION COMMAND FOR COMBINE_PLOT_FIELDS |
---|
1777 | eval line2=\"$line2\" |
---|
1778 | execute_command_for_combine="$line2" |
---|
1779 | |
---|
1780 | |
---|
1781 | # PROVIDE A HOSTFILE, IF REQUIRED |
---|
1782 | if [[ "$hostfile" != "" ]] |
---|
1783 | then |
---|
1784 | |
---|
1785 | if [[ $hostfile = auto ]] |
---|
1786 | then |
---|
1787 | # CREATE A NEW HOSTFILE |
---|
1788 | (( ii = 1 )) |
---|
1789 | while (( ii <= cores / threads_per_task )) |
---|
1790 | do |
---|
1791 | echo $(hostname) >> hostfile |
---|
1792 | (( ii = ii + 1 )) |
---|
1793 | done |
---|
1794 | if (( cores / threads_per_task == 0 )) |
---|
1795 | then |
---|
1796 | echo $(hostname) >> hostfile |
---|
1797 | fi |
---|
1798 | |
---|
1799 | else |
---|
1800 | cp $hostfile hostfile |
---|
1801 | fi |
---|
1802 | eval line=\"`head -n $ii hostfile`\" |
---|
1803 | printf "\n *** running on: $line" |
---|
1804 | fi |
---|
1805 | |
---|
1806 | |
---|
1807 | |
---|
1808 | # SET THE NUMBER OF OPENMP-THREADS |
---|
1809 | if [[ $use_openmp = true ]] |
---|
1810 | then |
---|
1811 | export OMP_NUM_THREADS=$threads_per_task |
---|
1812 | printf "\n *** number of OpenMP threads per MPI-task: $OMP_NUM_THREADS" |
---|
1813 | else |
---|
1814 | export OMP_NUM_THREADS=1 |
---|
1815 | fi |
---|
1816 | |
---|
1817 | |
---|
1818 | # PROVIDE DATA FOR |
---|
1819 | if [[ $run_coupled_model = false ]] |
---|
1820 | then |
---|
1821 | if [[ "$ocean_file_appendix" = true ]] |
---|
1822 | then |
---|
1823 | echo "precursor_ocean" > coupling_steering |
---|
1824 | else |
---|
1825 | echo "precursor_atmos" > coupling_steering |
---|
1826 | fi |
---|
1827 | else |
---|
1828 | (( iia = $cores_atmos / $threads_per_task )) |
---|
1829 | (( iio = $cores_ocean / $threads_per_task )) |
---|
1830 | printf "\n coupled run ($iia atmosphere, $iio ocean)" |
---|
1831 | printf "\n\n" |
---|
1832 | echo "coupled_run $iia $iio" > coupling_steering |
---|
1833 | fi |
---|
1834 | |
---|
1835 | printf "\n *** execute command:" |
---|
1836 | printf "\n \"$execute_command\" \n\n" |
---|
1837 | |
---|
1838 | $execute_command < coupling_steering |
---|
1839 | |
---|
1840 | if [[ $? != 0 ]] |
---|
1841 | then |
---|
1842 | |
---|
1843 | # ABORT IN CASE OF RUNTIME ERRORS |
---|
1844 | printf "\n +++ runtime error occured" |
---|
1845 | locat=execution |
---|
1846 | exit |
---|
1847 | |
---|
1848 | else |
---|
1849 | |
---|
1850 | printf "\n$dashes\n *** execution finished \n" |
---|
1851 | |
---|
1852 | fi |
---|
1853 | |
---|
1854 | |
---|
1855 | # CALL OF combine_plot_fields IN ORDER TO MERGE SINGLE FILES WRITTEN |
---|
1856 | # BY EACH CORE INTO ONE FILE |
---|
1857 | if [[ ! -f combine_plot_fields.x ]] |
---|
1858 | then |
---|
1859 | |
---|
1860 | printf "\n\n\n +++ WARNING: no combine_plot_fields found" |
---|
1861 | printf "\n 2d- and/or 3d-data may be incomplete!" |
---|
1862 | printf "\n Your previous palmbuild may have failed. Please check.\n" |
---|
1863 | |
---|
1864 | elif [[ "$combine_plot_fields" == true ]] |
---|
1865 | then |
---|
1866 | |
---|
1867 | printf "\n\n\n *** post-processing: now executing \"$execute_command_for_combine\" ..." |
---|
1868 | $execute_command_for_combine |
---|
1869 | |
---|
1870 | else |
---|
1871 | |
---|
1872 | # TEMPORARY SOLUTION TO SKIP combine_plot_fields. THIS IS REQUIRED IN CASE OF HUGE AMOUNT OF |
---|
1873 | # DATA OUTPUT. TO DO: EXTEND THIS BRANCH BY CREATING A BATCH JOB for combine_plot_fields. |
---|
1874 | # ??? koennen wir das streichen ??? |
---|
1875 | printf "\n\n\n *** post-processing: skipping combine_plot_fields (-Z option set) ..." |
---|
1876 | fi |
---|
1877 | |
---|
1878 | |
---|
1879 | |
---|
1880 | # EXECUTE OUTPUT-COMMANDS GIVEN IN THE CONFIGURATION FILE |
---|
1881 | (( i = 0 )) |
---|
1882 | while (( i < ioc )) |
---|
1883 | do |
---|
1884 | (( i = i + 1 )) |
---|
1885 | if (( i == 1 )) |
---|
1886 | then |
---|
1887 | printf "\n\n *** execution of OUTPUT-commands:\n$dashes" |
---|
1888 | fi |
---|
1889 | printf "\n >>> ${out_command[$i]}" |
---|
1890 | eval ${out_command[$i]} |
---|
1891 | if (( i == ioc )) |
---|
1892 | then |
---|
1893 | printf "\n$dashes\n" |
---|
1894 | fi |
---|
1895 | done |
---|
1896 | |
---|
1897 | |
---|
1898 | # IN TRACE-MODE PRINT CONTENTS OF THE CURRENT (TEMPORARY) WORKING DIRECTORY |
---|
1899 | if [[ $do_trace = true ]] |
---|
1900 | then |
---|
1901 | printf "\n\n" |
---|
1902 | ls -al |
---|
1903 | fi |
---|
1904 | |
---|
1905 | |
---|
1906 | # COPY LOCAL OUTPUT-FILES TO THEIR PERMANENT DESTINATIONS |
---|
1907 | (( i = 0 )) |
---|
1908 | while (( i < iout )) |
---|
1909 | do |
---|
1910 | (( i = i + 1 )) |
---|
1911 | if (( i == 1 )) |
---|
1912 | then |
---|
1913 | printf "\n\n *** saving OUTPUT-files:" |
---|
1914 | |
---|
1915 | # GET RUN NUMBER ASSIGNED BY PALM |
---|
1916 | if [[ -f RUN_NUMBER ]] |
---|
1917 | then |
---|
1918 | read run_number < RUN_NUMBER |
---|
1919 | printf "\n *** PALM generated run_number = "$run_number" will be used as unified cycle number for all output files" |
---|
1920 | usecycle_option="-U $run_number" |
---|
1921 | else |
---|
1922 | run_number=0 |
---|
1923 | usecycle_option="" |
---|
1924 | fi |
---|
1925 | if [[ $running_on_remote = true && "$remote_loginnode" != "" ]] |
---|
1926 | then |
---|
1927 | printf "\n *** SCP transfers to local host via remote login-node \"$remote_loginnode\" " |
---|
1928 | fi |
---|
1929 | printf "\n$dashes" |
---|
1930 | fi |
---|
1931 | |
---|
1932 | # ADD CYCLE NUMBER TO FILENAME |
---|
1933 | if [[ ! ( $running_on_remote = true && ( "${actionout[$i]}" = tr || "${actionout[$i]}" = tra || "${actionout[$i]}" = trpe ) ) ]] |
---|
1934 | then |
---|
1935 | |
---|
1936 | # IN APPEND MODE, FILES KEEP THEIR CURRENT CYCLE NUMBER |
---|
1937 | if [[ "${actionout[$i]}" != "a" ]] |
---|
1938 | then |
---|
1939 | # SET RUN NUMBER AS CYCLE NUMBER, IF THERE IS NOT A CONFLICT |
---|
1940 | # WITH AN EXISTING CYCLE NUMBER |
---|
1941 | if (( run_number >= cycnum[$i] )) |
---|
1942 | then |
---|
1943 | (( cycnum[$i] = run_number )) |
---|
1944 | else |
---|
1945 | if (( run_number > 0 )) |
---|
1946 | then |
---|
1947 | printf "\n --- INFORMATIVE: The following file cannot get a unified cycle number" |
---|
1948 | fi |
---|
1949 | fi |
---|
1950 | fi |
---|
1951 | if (( cycnum[$i] > 0 )) |
---|
1952 | then |
---|
1953 | pathout[$i]=${pathout[$i]}.${cycnum[$i]} |
---|
1954 | fi |
---|
1955 | fi |
---|
1956 | |
---|
1957 | # CHECK FOR SINGLE FILE (SERIAL RUN) OR DIRECTORY (ONE FILE PER CORE FOR PARELLEL EXECUTION) |
---|
1958 | files_for_cores=false; filetype=file |
---|
1959 | link_local_output=false |
---|
1960 | if [[ "${actionout[$i]}" = pe && -n $cores ]] |
---|
1961 | then |
---|
1962 | files_for_cores=true; filetype=directory |
---|
1963 | actionout[$i]="" |
---|
1964 | elif [[ "${actionout[$i]}" = pe && ! -n $cores ]] |
---|
1965 | then |
---|
1966 | actionout[$i]="" |
---|
1967 | elif [[ "${actionout[$i]}" = lnpe && -n $cores ]] |
---|
1968 | then |
---|
1969 | files_for_cores=true; filetype=directory |
---|
1970 | link_local_output=true |
---|
1971 | actionout[$i]="" |
---|
1972 | elif [[ "${actionout[$i]}" = lnpe && ! -n $cores ]] |
---|
1973 | then |
---|
1974 | link_local_output |
---|
1975 | actionout[$i]="" |
---|
1976 | elif [[ "${actionout[$i]}" = trpe && -n $cores ]] |
---|
1977 | then |
---|
1978 | files_for_cores=true; filetype=directory |
---|
1979 | actionout[$i]="tr" |
---|
1980 | elif [[ "${actionout[$i]}" = trpe && ! -n $cores ]] |
---|
1981 | then |
---|
1982 | actionout[$i]="tr" |
---|
1983 | fi |
---|
1984 | |
---|
1985 | if [[ ! -f ${localout[$i]} && $files_for_cores = false ]] |
---|
1986 | then |
---|
1987 | printf "\n +++ temporary OUTPUT-file ${localout[$i]} does not exist\n" |
---|
1988 | elif [[ ! -d ${localout[$i]} && $files_for_cores = true ]] |
---|
1989 | then |
---|
1990 | printf "\n +++ temporary OUTPUT-file ${localout[$i]}/.... does not exist\n" |
---|
1991 | else |
---|
1992 | |
---|
1993 | |
---|
1994 | # COPY VIA SCP TO LOCAL HOST (ALWAYS IN BINARY MODE USING batch_scp option -m) |
---|
1995 | # IF TARGET DIRECTORY DOES NOT EXISTS, TRY TO CREATE IT |
---|
1996 | if [[ "${actionout[$i]}" = tr || "${actionout[$i]}" = tra ]] |
---|
1997 | then |
---|
1998 | if [[ $running_on_remote = true ]] |
---|
1999 | then |
---|
2000 | |
---|
2001 | # SET OPTIONS FOR TRANSFER |
---|
2002 | if [[ "${actionout[$i]}" = tr ]] |
---|
2003 | then |
---|
2004 | if [[ $files_for_cores = false ]] |
---|
2005 | then |
---|
2006 | catalog_option="" |
---|
2007 | catalog_string="" |
---|
2008 | else |
---|
2009 | catalog_option="-c" |
---|
2010 | catalog_string="/" |
---|
2011 | fi |
---|
2012 | append_option="" |
---|
2013 | append_string="" |
---|
2014 | else |
---|
2015 | append_option="-A" |
---|
2016 | append_string="append" |
---|
2017 | fi |
---|
2018 | |
---|
2019 | transfer_failed=false |
---|
2020 | printf "\n >>> OUTPUT: ${localout[$i]}$catalog_string $append_string by SCP to" |
---|
2021 | printf "\n ${pathout[$i]}/${remote_hostname}_${fname}${endout[$i]}$catalog_string\n" |
---|
2022 | |
---|
2023 | # TRANSFER VIA SCP |
---|
2024 | if [[ "$remote_loginnode" != "" ]] |
---|
2025 | then |
---|
2026 | echo "cd $TEMPDIR; ${tmp_user_catalog}/SOURCES_FOR_RUN_${fname}/batch_scp $PORTOPT $catalog_option $append_option -b -m $usecycle_option -u $local_username $return_address ${localout[$i]} \"${pathout[$i]}\" ${remote_hostname}_${fname}${endout[$i]} ${extout[$i]}" | ssh -q $remote_username@$remote_loginnode |
---|
2027 | else |
---|
2028 | batch_scp $PORTOPT $catalog_option $append_option -b -m $usecycle_option -u $local_username $return_address ${localout[$i]} "${pathout[$i]}" ${remote_hostname}_${fname}${endout[$i]} ${extout[$i]} |
---|
2029 | fi |
---|
2030 | [[ $? != 0 ]] && transfer_failed=true |
---|
2031 | |
---|
2032 | |
---|
2033 | # IF TRANSFER FAILED, CREATE BACKUP COPY ON THIS MACHINE |
---|
2034 | if [[ $transfer_failed = true ]] |
---|
2035 | then |
---|
2036 | printf " +++ transfer failed. Trying to save a copy on this host under:\n" |
---|
2037 | printf " ${pathout[$i]}/${remote_hostname}_${fname}${endout[$i]}_$run_id\n" |
---|
2038 | |
---|
2039 | # FIRST CHECK, IF DIRECTORY EXISTS, AND CREATE IT, IF NECESSARY |
---|
2040 | eval local_catalog=${pathout[$i]} |
---|
2041 | if [[ ! -d $local_catalog ]] |
---|
2042 | then |
---|
2043 | printf " *** local directory does not exist. Trying to create:\n" |
---|
2044 | printf " $local_catalog \n" |
---|
2045 | mkdir -p $local_catalog |
---|
2046 | fi |
---|
2047 | eval cp ${localout[$i]} ${pathout[$i]}/${remote_hostname}_${fname}${endout[$i]}_$run_id |
---|
2048 | transfer_problems=true |
---|
2049 | fi |
---|
2050 | |
---|
2051 | else |
---|
2052 | |
---|
2053 | # UNSET actionout. DUE TO THIS SETTING, FILE WILL LATER JUST |
---|
2054 | # BE COPIED OR APPENDED ON THIS MACHINE |
---|
2055 | if [[ "${actionout[$i]}" = tr ]] |
---|
2056 | then |
---|
2057 | actionout[$i]="" |
---|
2058 | else |
---|
2059 | actionout[$i]="a" |
---|
2060 | fi |
---|
2061 | fi |
---|
2062 | fi |
---|
2063 | |
---|
2064 | |
---|
2065 | # APPEND ON THIS MACHINE |
---|
2066 | if [[ "${actionout[$i]}" = "a" ]] |
---|
2067 | then |
---|
2068 | if [[ "${extout[$i]}" != " " && "${extout[$i]}" != "" ]] |
---|
2069 | then |
---|
2070 | printf "\n >>> OUTPUT: ${localout[$i]} append to" |
---|
2071 | printf "\n ${pathout[$i]}.${extout[$i]}\n" |
---|
2072 | cat ${localout[$i]} >> ${pathout[$i]}.${extout[$i]} |
---|
2073 | else |
---|
2074 | printf "\n >>> OUTPUT: ${localout[$i]} append to" |
---|
2075 | printf "\n ${pathout[$i]}\n" |
---|
2076 | cat ${localout[$i]} >> ${pathout[$i]} |
---|
2077 | fi |
---|
2078 | fi |
---|
2079 | |
---|
2080 | # COPY ON THIS MACHINE |
---|
2081 | # COPY HAS TO BE USED, BECAUSE MOVE DOES NOT WORK IF FILE-ORIGIN AND TARGET ARE |
---|
2082 | # ON DIFFERENT FILE-SYSTEMS |
---|
2083 | if [[ "${actionout[$i]}" = "" && $files_for_cores = false ]] |
---|
2084 | then |
---|
2085 | |
---|
2086 | # COPY IN CASE OF RUNS ON SINGLE CORES |
---|
2087 | if [[ "${extout[$i]}" != " " && "${extout[$i]}" != "" ]] |
---|
2088 | then |
---|
2089 | printf "\n >>> OUTPUT: ${localout[$i]} to" |
---|
2090 | printf "\n ${pathout[$i]}.${extout[$i]}\n" |
---|
2091 | if [[ $link_local_output = true ]] |
---|
2092 | then |
---|
2093 | printf " file will be linked\n" |
---|
2094 | ln -f ${localout[$i]} ${pathout[$i]}.${extout[$i]} |
---|
2095 | fi |
---|
2096 | # If "ln -f" fails of if "$link_local_output = false" do a normal "cp" |
---|
2097 | if [[ ! -f "${pathout[$i]}.${extout[$i]}" ]] |
---|
2098 | then |
---|
2099 | if [[ $link_local_output = true ]] |
---|
2100 | then |
---|
2101 | printf " --- WARNING: ln failed, using cp instead (might be time consuming...)\n" |
---|
2102 | fi |
---|
2103 | cp ${localout[$i]} ${pathout[$i]}.${extout[$i]} |
---|
2104 | else |
---|
2105 | printf "+++ no copy because file ${pathout[$i]}.${extout[$i]} exists\n" |
---|
2106 | fi |
---|
2107 | else |
---|
2108 | printf "\n >>> OUTPUT: ${localout[$i]} to" |
---|
2109 | printf "\n ${pathout[$i]}\n" |
---|
2110 | if [[ $link_local_output = true ]] |
---|
2111 | then |
---|
2112 | printf " file will be linked\n" |
---|
2113 | ln -f ${localout[$i]} ${pathout[$i]} |
---|
2114 | fi |
---|
2115 | # If "ln -f" fails of if "$link_local_output = false" do a normal "cp" |
---|
2116 | if [[ ! -f "${pathout[$i]}" ]] |
---|
2117 | then |
---|
2118 | if [[ $link_local_output = true ]] |
---|
2119 | then |
---|
2120 | printf " --- WARNING: ln failed, using cp instead (might be time consuming...)\n" |
---|
2121 | fi |
---|
2122 | cp ${localout[$i]} ${pathout[$i]} |
---|
2123 | else |
---|
2124 | printf "+++ no copy because file ${pathout[$i]} exists\n" |
---|
2125 | fi |
---|
2126 | fi |
---|
2127 | |
---|
2128 | elif [[ "${actionout[$i]}" = "" && $files_for_cores = true ]] |
---|
2129 | then |
---|
2130 | |
---|
2131 | # FILES FROM THE DIFFERENT CORES ARE MOVED WITH ln-COMMAND TO THE PERMANENT DIRECTORY |
---|
2132 | # AS A FIRST STEP, THE PERMANENT DIRECTORY IS CREATED |
---|
2133 | printf "\n >>> OUTPUT: ${localout[$i]}/_.... to" |
---|
2134 | printf "\n ${pathout[$i]}\n" |
---|
2135 | if [[ $link_local_output = true ]] |
---|
2136 | then |
---|
2137 | printf " files will be linked\n" |
---|
2138 | mkdir ${pathout[$i]} |
---|
2139 | cd ${localout[$i]} |
---|
2140 | for file in $(ls *) |
---|
2141 | do |
---|
2142 | ln -f $file ${pathout[$i]} |
---|
2143 | done >|/dev/null 2>&1 |
---|
2144 | cd $TEMPDIR |
---|
2145 | fi |
---|
2146 | |
---|
2147 | # IF "ln -f" HAS FAILED OR IF "$link_local_output = false" DO A NORMAL COPY "cp -r" |
---|
2148 | if [[ ! -f "${pathout[$i]}/_000000" ]] |
---|
2149 | then |
---|
2150 | if [[ $link_local_output = true ]] |
---|
2151 | then |
---|
2152 | printf " --- WARNING: ln failed, using cp instead (might be time consuming...)\n" |
---|
2153 | fi |
---|
2154 | cp -r ${localout[$i]}/* ${pathout[$i]} |
---|
2155 | fi |
---|
2156 | |
---|
2157 | fi |
---|
2158 | fi |
---|
2159 | done |
---|
2160 | |
---|
2161 | if (( i != 0 )) |
---|
2162 | then |
---|
2163 | if [[ $transfer_problems = true ]] |
---|
2164 | then |
---|
2165 | printf "\n$dashes\n *** OUTPUT-files saved" |
---|
2166 | printf "\n +++ WARNING: some data transfers failed! \n" |
---|
2167 | else |
---|
2168 | printf "\n$dashes\n *** all OUTPUT-files saved \n" |
---|
2169 | fi |
---|
2170 | fi |
---|
2171 | |
---|
2172 | |
---|
2173 | # IF REQUIRED, START A RESTART-JOB |
---|
2174 | # FILE CONTINUE_RUN MUST HAVE BEEN CREATED BY THE EXECUTABLE (PALM) |
---|
2175 | if [[ -f CONTINUE_RUN ]] |
---|
2176 | then |
---|
2177 | |
---|
2178 | # ADD RESTART-OPTIONS TO THE PALMRUN-CALL (IF THEY ARE NOT USED ALREADY): |
---|
2179 | # -C TELLS PALMRUN THAT IT IS A RESTART-RUN |
---|
2180 | # -v SILENT MODE WITHOUT INTERACTIVE QUERIES |
---|
2181 | # -b START A BATCH JOB |
---|
2182 | [[ $(echo $prc | grep -c "\-C") = 0 ]] && prc="$prc -C" |
---|
2183 | [[ $(echo $prc | grep -c "\-v") = 0 ]] && prc="$prc -v" |
---|
2184 | [[ $(echo $prc | grep -c "\-b") = 0 ]] && prc="$prc -b" |
---|
2185 | |
---|
2186 | |
---|
2187 | # REPLACE THE HASH IN THE ACTIVATION STRINGS (GIVEN WITH OPTION -a) |
---|
2188 | # SO THAT RESTARTS ACCESS DIFFERENT FILES THAN THE INITIAL RUN |
---|
2189 | if [[ $(echo $prc | grep -c "#") != 0 ]] |
---|
2190 | then |
---|
2191 | prc=`echo $prc | sed 's/#/f/g'` |
---|
2192 | fi |
---|
2193 | |
---|
2194 | |
---|
2195 | # START THE RESTART-JOB |
---|
2196 | printf "\n\n *** initiating restart-run on \"$local_ip\" using command:\n" |
---|
2197 | echo " $prc" |
---|
2198 | printf "\n$dashes\n" |
---|
2199 | if [[ $running_on_remote = true ]] |
---|
2200 | then |
---|
2201 | |
---|
2202 | echo "*** ssh will be used to initiate restart-runs!" |
---|
2203 | echo " return_address=\"$return_address\" " |
---|
2204 | echo " return_username=\"$local_username\" " |
---|
2205 | |
---|
2206 | if [[ "$remote_loginnode" != "" ]] |
---|
2207 | then |
---|
2208 | echo "echo \" PATH=\\\$PATH:$LOCAL_PALMRUN_PATH; export PALM_BIN=$LOCAL_PALMRUN_PATH; cd $LOCAL_PWD; $prc\" | ssh -q $SSH_PORTOPT $local_username@$return_address " | ssh -q $remote_username@$remote_loginnode |
---|
2209 | else |
---|
2210 | echo \" PATH=\\\$PATH:$LOCAL_PALMRUN_PATH; export PALM_BIN=$LOCAL_PALMRUN_PATH; cd $LOCAL_PWD; $prc\" | ssh -q $SSH_PORTOPT $local_username@$return_address |
---|
2211 | fi |
---|
2212 | |
---|
2213 | # WAIT TO ALLOW THE RESTART-JOB TO BE QUEUED, BEFORE THE CURRENT JOB IS FINISHED |
---|
2214 | sleep 30 |
---|
2215 | |
---|
2216 | else |
---|
2217 | |
---|
2218 | # START THE RESTART JOB ON THE LOCAL HOST |
---|
2219 | eval $prc # THE ' MUST BE EVALUATED |
---|
2220 | cd - > /dev/null |
---|
2221 | |
---|
2222 | fi |
---|
2223 | printf "\n$dashes\n *** restart-run initiated \n" |
---|
2224 | |
---|
2225 | |
---|
2226 | # DELETE INPUT-(RESTART)FILES, WHICH HAVE BEEN FETCHED FROM THE TEMPORARY DATA |
---|
2227 | # DIRECTORY, BACAUSE THEY ARE NOT REQUIRED BY THE RESTART-JOB. |
---|
2228 | # THIS IS DONE IN ORDER TO AVOID EXCEEDING DISC QUOTAS OR DISC SPACE (RESTART-FILES |
---|
2229 | # MAY BE VERY HUGE) |
---|
2230 | (( i = 0 )) |
---|
2231 | while (( i < iin )) |
---|
2232 | do |
---|
2233 | (( i = i + 1 )) |
---|
2234 | if [[ "${got_tmp[$i]}" = true && $keep_data_from_previous_run = false ]] |
---|
2235 | then |
---|
2236 | rm -r ${absnamein[$i]} |
---|
2237 | fi |
---|
2238 | done |
---|
2239 | |
---|
2240 | fi |
---|
2241 | |
---|
2242 | |
---|
2243 | # ALL ACTIONS FINISHED, TEMPORARY WORKING-DIRECTORY CAN BE DELETED |
---|
2244 | cd $HOME |
---|
2245 | [[ $delete_temporary_catalog = true ]] && rm -rf $TEMPDIR |
---|
2246 | |
---|
2247 | |
---|
2248 | else |
---|
2249 | |
---|
2250 | |
---|
2251 | # PREPARING ACTIONS, |
---|
2252 | # IF A BATCH-JOB IS TO BE GENERATED AND TO BE STARTED ON A LOCAL OR REMOTE-MACHINE |
---|
2253 | |
---|
2254 | # BUILD THE PALMRUN-COMMAND TO BE CALLED IN THE BATCH-JOB |
---|
2255 | palmrun_com="$palmrun_script_name -c $config_file -d $fname -h $host -m $memory -t $cpumax -q $queue -r $run_id -U $local_username" |
---|
2256 | [[ "$activation_string_list" != "" ]] && palmrun_com=${palmrun_com}" -a \"$activation_string_list\"" |
---|
2257 | [[ "$global_revision" != "" ]] && palmrun_com=${palmrun_com}" -G \"$global_revision\"" |
---|
2258 | [[ $keep_data_from_previous_run = true ]] && palmrun_com=${palmrun_com}" -k" |
---|
2259 | [[ $do_trace = true ]] && palmrun_com=${palmrun_com}" -x" |
---|
2260 | [[ "$cores" != "" ]] && palmrun_com=${palmrun_com}" -X $cores" |
---|
2261 | [[ $use_openmp = true ]] && palmrun_com=${palmrun_com}" -O $threads_per_task" |
---|
2262 | [[ "$tasks_per_node" != "" ]] && palmrun_com=${palmrun_com}" -T $tasks_per_node" |
---|
2263 | [[ $delete_temporary_catalog = false ]] && palmrun_com=${palmrun_com}" -B" |
---|
2264 | [[ "$ocean_file_appendix" = true ]] && palmrun_com=${palmrun_com}" -y" |
---|
2265 | [[ $run_coupled_model = true ]] && palmrun_com=${palmrun_com}" -Y \"$coupled_dist\"" |
---|
2266 | [[ "$combine_plot_fields" = false ]] && palmrun_com=${palmrun_com}" -Z" |
---|
2267 | [[ "$max_par_io_str" != "" ]] && palmrun_com=${palmrun_com}" -w $max_par_io_str" |
---|
2268 | if [[ $create_remote_batch_job = true ]] |
---|
2269 | then |
---|
2270 | palmrun_com=${palmrun_com}" -j -u $remote_username -R $local_ip" |
---|
2271 | printf "\n *** PALMRUN-command on remote host:\n $palmrun_com \n" |
---|
2272 | elif [[ $create_batch_job = true ]] |
---|
2273 | then |
---|
2274 | palmrun_com=${palmrun_com}" -j" |
---|
2275 | printf "\n *** PALMRUN-command on local host:\n $palmrun_com \n" |
---|
2276 | fi |
---|
2277 | |
---|
2278 | |
---|
2279 | # DETERMINE THE FULL PATHS FOR THE JOB PROTOCOL FILES ON THE LOCAL AND |
---|
2280 | # REMOTE HOST |
---|
2281 | job_protocol_file_local=${local_jobcatalog}/${host}_${job_id} |
---|
2282 | job_protocol_file=$job_protocol_file_local |
---|
2283 | if [[ $create_remote_batch_job = true ]] |
---|
2284 | then |
---|
2285 | job_protocol_file_remote=${remote_jobcatalog}/${host}_${job_id} |
---|
2286 | job_protocol_file=$job_protocol_file_remote |
---|
2287 | job_transfer_protocol_file=${remote_jobcatalog}/last_job_transfer_protocol |
---|
2288 | scpjob_file=${remote_jobcatalog}/scpjob.$run_id |
---|
2289 | fi |
---|
2290 | |
---|
2291 | |
---|
2292 | # BUILD THE JOB-SCRIPTS ON FILE jobfile |
---|
2293 | jobfile=jobfile.$run_id |
---|
2294 | |
---|
2295 | |
---|
2296 | # FIRST CREATE THE BATCH DIRECTIVES |
---|
2297 | (( i = 0 )) |
---|
2298 | while (( i < ibd )) |
---|
2299 | do |
---|
2300 | (( i = i + 1 )) |
---|
2301 | line=`echo "${batch_directive[$i]}" | sed 's/@JOB_ID@/$job_id/g' | sed 's/@JOBFILE@/$job_protocol_file/g' | sed 's/@CPU_HOURS@/$cpu_hours/g' | sed 's/@CPU_MINUTES@/$cpu_minutes/g' | sed 's/@CPU_SECONDS@/$cpu_seconds/g' | sed 's/@NODES@/$nodes/g' | sed 's/@CORES@/$cores/g' | sed 's/@TASKS_PER_NODE@/$tasks_per_node/g' | sed 's/@LOCAL_HOSTNAME@/${local_hostname}/g' | sed 's/@HOST@/${host}/g' | sed 's/@FNAME@/$fname/g' | sed 's/@QUEUE@/$queue/g'` |
---|
2302 | eval line=\"$line\" |
---|
2303 | echo "$line" >> $jobfile |
---|
2304 | done |
---|
2305 | echo " " >> $jobfile |
---|
2306 | |
---|
2307 | |
---|
2308 | # FOR BATCH JOBS ON REMOTE HOSTS, ADD THE JOBFILE TO SEND BACK THE JOB |
---|
2309 | # PROTOCOL |
---|
2310 | if [[ $create_remote_batch_job = true ]] |
---|
2311 | then |
---|
2312 | echo "set +vx" >> $jobfile |
---|
2313 | echo "trap '" >> $jobfile |
---|
2314 | echo "set +vx" >> $jobfile |
---|
2315 | echo "cd ${remote_jobcatalog}" >> $jobfile |
---|
2316 | echo "cat > scpjob.$run_id << %%END%%" >> $jobfile |
---|
2317 | |
---|
2318 | # ADD THE BATCH DIRECTIVES |
---|
2319 | (( i = 0 )) |
---|
2320 | while (( i < ibdt )) |
---|
2321 | do |
---|
2322 | (( i = i + 1 )) |
---|
2323 | line=`echo "${batch_directive_transfer[$i]}" | sed 's/@JOB_ID@/$job_id/g' | sed 's/@JOBFILE@/$job_protocol_file/g' | sed 's/@JOB_TRANSFER_PROTOCOL_FILE@/$job_transfer_protocol_file/g' | sed 's/@CPU_HOURS@/$cpu_hours/g' | sed 's/@CPU_MINUTES@/$cpu_minutes/g' | sed 's/@CPU_SECONDS@/$cpu_seconds/g' | sed 's/@NODES@/$nodes/g' | sed 's/@TASKS_PER_NODE@/$tasks_per_node/g' | sed 's/@LOCAL_HOSTNAME@/${local_hostname}/g' | sed 's/@HOST@/${host}/g' | sed 's/@FNAME@/$fname/g'` |
---|
2324 | eval line=\"$line\" |
---|
2325 | echo "$line" >> $jobfile |
---|
2326 | done |
---|
2327 | echo " " >> $jobfile |
---|
2328 | |
---|
2329 | echo "set -x" >> $jobfile |
---|
2330 | echo "${tmp_user_catalog}/SOURCES_FOR_RUN_${fname}/batch_scp $PORTOPT -d -w 10 -u $local_username $local_ip $job_protocol_file_remote \"$local_jobcatalog\" ${host}_${fname}" >> $jobfile |
---|
2331 | echo "%%END%%" >> $jobfile |
---|
2332 | echo "echo \" *** submitting job for transfering the job protocol file to $local_ip\" " >> $jobfile |
---|
2333 | echo "$submit_command $scpjob_file" >> $jobfile |
---|
2334 | echo "rm $scpjob_file" >> $jobfile |
---|
2335 | echo "rm $job_transfer_protocol_file" >> $jobfile |
---|
2336 | echo "set -x" >> $jobfile |
---|
2337 | echo " ' exit" >> $jobfile |
---|
2338 | fi |
---|
2339 | |
---|
2340 | |
---|
2341 | # ACTIVATE ERROR-TRACEBACK |
---|
2342 | if [[ $do_trace = true ]] |
---|
2343 | then |
---|
2344 | echo "set -x" >> $jobfile |
---|
2345 | else |
---|
2346 | echo "set +vx" >> $jobfile |
---|
2347 | fi |
---|
2348 | |
---|
2349 | |
---|
2350 | # INITIALIZE THE ENVIRONMENT AND LOAD MODULES |
---|
2351 | if [[ "$login_init_cmd" != "" ]] |
---|
2352 | then |
---|
2353 | echo "$login_init_cmd" >> $jobfile |
---|
2354 | fi |
---|
2355 | if [[ "$module_commands" != "" ]] |
---|
2356 | then |
---|
2357 | echo "$module_commands" >> $jobfile |
---|
2358 | fi |
---|
2359 | |
---|
2360 | |
---|
2361 | # CREATE TEMPORARY DIRECTORY AND SWITCH TO IT |
---|
2362 | echo "mkdir $TEMPDIR" >> $jobfile |
---|
2363 | echo "cd $TEMPDIR" >> $jobfile |
---|
2364 | echo "export TEMPDIR=$TEMPDIR" >> $jobfile |
---|
2365 | echo "cp $tmp_user_catalog/SOURCES_FOR_RUN_$fname/{*,.[!.]*} ." >> $jobfile |
---|
2366 | echo "export PATH=.:\$PATH" >> $jobfile |
---|
2367 | echo "export execute_palmrun=true" >> $jobfile |
---|
2368 | |
---|
2369 | |
---|
2370 | # GET REQUIRED INPUT-FILES BY SCP OR BY SENDING THEM WITH THE JOB AS HERE-DOCUMENT |
---|
2371 | # PUT THESE FILES INTO THE USER'S RESPECTIVE PERMANENT DIRECTORIES ON THE REMOTE-HOST |
---|
2372 | # IF THE DIRECTORIES DO NOT EXIST, TRY TO CREATE THEM |
---|
2373 | if [[ $create_remote_batch_job = true ]] |
---|
2374 | then |
---|
2375 | (( i = 0 )) |
---|
2376 | while (( i < iin )) |
---|
2377 | do |
---|
2378 | (( i = i + 1 )) |
---|
2379 | echo "[[ ! -d ${pathin[$i]} ]] && mkdir -p ${pathin[$i]}" >> $jobfile |
---|
2380 | if [[ "${transin[$i]}" = job ]] |
---|
2381 | then |
---|
2382 | echo "cat > ${remotepathin[$i]} <<\"%END%\"" >> $jobfile |
---|
2383 | eval cat ${pathin[$i]}/${frelin[$i]} >> $jobfile |
---|
2384 | echo " " >> $jobfile |
---|
2385 | echo "%END%" >> $jobfile |
---|
2386 | else |
---|
2387 | echo "batch_scp $PORTOPT -b -o -g -s -u $local_username $return_address ${remotepathin[$i]} \"${pathin[$i]}\" ${frelin[$i]}" >> $jobfile |
---|
2388 | fi |
---|
2389 | |
---|
2390 | # CHECK, IF FILE COULD BE CREATED |
---|
2391 | echo "if [[ \$? = 1 ]]" >> $jobfile |
---|
2392 | echo "then" >> $jobfile |
---|
2393 | echo " echo \" \" " >> $jobfile |
---|
2394 | echo " echo \"+++ file ${remotepathin[$i]} could not be created\" " >> $jobfile |
---|
2395 | echo " echo \" please check, if directory exists on $host!\" " >> $jobfile |
---|
2396 | echo " echo \"+++ PALMRUN will not be continued\" " >> $jobfile |
---|
2397 | echo " execute_palmrun=false" >> $jobfile |
---|
2398 | echo "fi" >> $jobfile |
---|
2399 | done |
---|
2400 | fi |
---|
2401 | |
---|
2402 | |
---|
2403 | # PROVIDE NAME OF THE CURRENT WORKING-DIRECTORY ON THE LOCAL MACHINE (FROM WHERE THE JOB IS |
---|
2404 | # STARTED) BY SETTING AN ENVIRONMENT-VARIABLE. THIS INFORMATION IS USED IN THE JOB BY PALMRUN |
---|
2405 | # IN CASE THAT RESTART-RUNS HAVE TO BE GENERATED |
---|
2406 | echo "LOCAL_PWD=$working_directory" >> $jobfile |
---|
2407 | echo "export LOCAL_PWD" >> $jobfile |
---|
2408 | |
---|
2409 | |
---|
2410 | # PROVIDE THE PATH OF THE LOCAL PALMRUN-SCRIPT FOR THE SAME REASON |
---|
2411 | echo "LOCAL_PALMRUN_PATH=$PALM_BIN" >> $jobfile |
---|
2412 | echo "export LOCAL_PALMRUN_PATH" >> $jobfile |
---|
2413 | |
---|
2414 | |
---|
2415 | # CALL PALMRUN WITHIN THE JOB |
---|
2416 | # AS FINAL ACTION, REMOVE THE TEMPORARY DIRECTORY CREATED AT THE BEGINNING OF THE JOB |
---|
2417 | echo "set -x" >> $jobfile |
---|
2418 | echo "[[ \$execute_palmrun = true ]] && $palmrun_com" >> $jobfile |
---|
2419 | |
---|
2420 | |
---|
2421 | # TRANSFER JOBFILE TO THE TARGET HOST |
---|
2422 | if [[ $create_jobfile_only = false ]] |
---|
2423 | then |
---|
2424 | |
---|
2425 | if [[ $create_remote_batch_job = true ]] |
---|
2426 | then |
---|
2427 | |
---|
2428 | echo " *** transfer of job to remote host via scp" |
---|
2429 | echo " scp $ssh_key $PORTOPT $jobfile ${remote_username}@${remote_ip}:${job_directory}/${host}_${job_id}" |
---|
2430 | scp $ssh_key $PORTOPT $jobfile ${remote_username}@${remote_ip}:${job_directory}/${host}_${job_id} |
---|
2431 | |
---|
2432 | echo " " |
---|
2433 | echo " *** submit the job" |
---|
2434 | echo " cd $job_directory; $submit_command ${host}_${job_id}; rm ${host}_${job_id} | ssh -q $ssh_key $SSH_PORTOPT ${remote_username}@${remote_ip} 2>&1" |
---|
2435 | echo "cd $job_directory; $submit_command ${host}_${job_id}; rm ${host}_${job_id}" | ssh -q $ssh_key $SSH_PORTOPT ${remote_username}@${remote_ip} 2>&1 |
---|
2436 | |
---|
2437 | elif [[ $create_batch_job = true ]] |
---|
2438 | then |
---|
2439 | |
---|
2440 | eval job_directory=$job_directory |
---|
2441 | cp $jobfile ${job_directory}/${host}_${job_id} |
---|
2442 | cd $job_directory |
---|
2443 | echo " " |
---|
2444 | echo "--- submit the job" |
---|
2445 | echo "$submit_command ${host}_${job_id}" |
---|
2446 | $submit_command ${host}_${job_id} |
---|
2447 | rm ${host}_${job_id} |
---|
2448 | cd - > /dev/null |
---|
2449 | |
---|
2450 | fi |
---|
2451 | |
---|
2452 | rm -rf $jobfile |
---|
2453 | |
---|
2454 | else |
---|
2455 | |
---|
2456 | printf "\n *** jobfile created under name \"$jobfile\" " |
---|
2457 | printf "\n no batch-job has been sent!" |
---|
2458 | |
---|
2459 | fi |
---|
2460 | |
---|
2461 | fi # END OF REMOTE-PART |
---|