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