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