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