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