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