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