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