[2380] | 1 | #!/bin/bash |
---|
| 2 | |
---|
| 3 | # palmbuild - script for compiling the PALM code and its utility programs |
---|
| 4 | |
---|
| 5 | #------------------------------------------------------------------------------# |
---|
[2696] | 6 | # This file is part of the PALM model system. |
---|
[2380] | 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 | # |
---|
[2718] | 19 | # Copyright 2017-2018 Leibniz Universitaet Hannover |
---|
[2380] | 20 | #------------------------------------------------------------------------------# |
---|
| 21 | # |
---|
| 22 | # Current revisions: |
---|
| 23 | # ------------------ |
---|
| 24 | # |
---|
[2410] | 25 | # |
---|
[2380] | 26 | # Former revisions: |
---|
| 27 | # ----------------- |
---|
[3033] | 28 | # $Id: palmbuild 3499 2018-11-07 10:55:15Z gronemeier $ |
---|
[3499] | 29 | # Temporarily avoid compilation of post-processing tool for surface output |
---|
| 30 | # until a workaround for compiler-specific intrinsic functions is found. |
---|
| 31 | # |
---|
| 32 | # 3494 2018-11-06 14:51:27Z suehring |
---|
[3494] | 33 | # Add tool for surface-output post-processing |
---|
| 34 | # |
---|
| 35 | # 3455 2018-10-30 14:12:31Z raasch |
---|
[3455] | 36 | # options -h and -d renamed -c and -r, respectively |
---|
| 37 | # |
---|
| 38 | # 3312 2018-10-06 14:15:46Z knoop |
---|
[3236] | 39 | # "host identifier" in header output renamed "config. identifier", |
---|
| 40 | # host_configuration renamed configuration_identifier, |
---|
| 41 | # jobname renamed run_identifier |
---|
| 42 | # header output of PALM code revision, |
---|
| 43 | # options -m, -s, and -S removed |
---|
| 44 | # |
---|
| 45 | # 3210 2018-08-28 07:31:13Z sward |
---|
[3210] | 46 | # Bugfix: agent_preprocessing stays in MAKE_DEPOSITORY after compilation |
---|
| 47 | # |
---|
| 48 | # 3208 2018-08-27 13:10:50Z sward |
---|
[3208] | 49 | # Added building of agent_preprocessing |
---|
| 50 | # |
---|
| 51 | # 3033 2018-05-23 15:26:19Z raasch |
---|
[2834] | 52 | # "fname" renamed to "jobname" |
---|
| 53 | # |
---|
| 54 | # 2718 2018-01-02 08:49:38Z maronga |
---|
[2716] | 55 | # Corrected "Former revisions" section |
---|
| 56 | # |
---|
| 57 | # 2696 2017-12-14 17:12:51Z kanani |
---|
| 58 | # Change in file header (GPL part) |
---|
| 59 | # |
---|
| 60 | # 2566 2017-10-20 08:50:47Z raasch |
---|
[2566] | 61 | # informative messages switched of almost completely in silent mode |
---|
| 62 | # two header blocks merged into one |
---|
| 63 | # |
---|
| 64 | # 2506 2017-09-29 08:30:37Z raasch |
---|
[2506] | 65 | # option -V added to check for an existing SOURCES_FOR_RUN_... folder |
---|
| 66 | # host configuration added to SOURCES_FOR_RUN_... folder name |
---|
| 67 | # SOURCES_FOR_RUN_... folder is deleted in case of compilation errors |
---|
| 68 | # host_identifier renamed host_configuration |
---|
| 69 | # |
---|
| 70 | # 2500 2017-09-25 11:10:03Z raasch |
---|
[2500] | 71 | # bugfix for r2492 |
---|
| 72 | # |
---|
| 73 | # 2492 2017-09-21 14:18:48Z raasch |
---|
[2489] | 74 | # ask for compilation, if SOURCES_FOR_RUN_... exists |
---|
| 75 | # |
---|
| 76 | # 2487 2017-09-21 11:30:10Z raasch |
---|
[2487] | 77 | # bugfix: abort in case of compiling/linking errors in silent mode |
---|
| 78 | # |
---|
| 79 | # 2422 2017-09-08 08:25:41Z raasch |
---|
[2422] | 80 | # initial revision |
---|
[2410] | 81 | # |
---|
[2380] | 82 | #------------------------------------------------------------------------------# |
---|
| 83 | # palmbuild - script for compiling the PALM code and its utility programs |
---|
| 84 | # |
---|
| 85 | # Procedure to compile code on local and remote hosts using the |
---|
| 86 | # make-mechanism. The source code must be provided on the local host. |
---|
| 87 | # |
---|
| 88 | # @note This script does not work on MAC OS |
---|
| 89 | #------------------------------------------------------------------------------# |
---|
| 90 | |
---|
| 91 | |
---|
| 92 | # VARIABLE DECLARATIONS + DEFAULT VALUES |
---|
| 93 | calltime="" |
---|
| 94 | column1="" |
---|
| 95 | column2="" |
---|
[3236] | 96 | configuration_identifier=default |
---|
| 97 | global_revision="" |
---|
[2380] | 98 | locat=normal |
---|
| 99 | makefile="" |
---|
| 100 | make_options="" |
---|
| 101 | module_commands="" |
---|
| 102 | program_name=palm |
---|
| 103 | remote_ip="" |
---|
| 104 | silent=false |
---|
| 105 | ssh_key="" |
---|
| 106 | suf=f90 |
---|
[2506] | 107 | use_existing_sources_folder=false |
---|
[2732] | 108 | version="palmbuild 1.0 Rev$Rev: 3499 $" |
---|
[2380] | 109 | working_directory=`pwd` |
---|
| 110 | |
---|
| 111 | |
---|
[3312] | 112 | # ERROR HANDLING IN CASE OF EXIT |
---|
[3236] | 113 | trap 'rm -rf ${source_path}/${configuration_identifier}_last_make_protocol |
---|
[3312] | 114 | if [[ $locat != normal && $locat != control_c ]] |
---|
[2380] | 115 | then |
---|
[3312] | 116 | printf "\n\n+++ palmbuild crashed \n\n" |
---|
[2380] | 117 | exit 1 |
---|
[3312] | 118 | elif [[ $locat != normal ]] |
---|
| 119 | then |
---|
| 120 | printf "\n+++ palmbuild killed by \"^C\" \n\n" |
---|
| 121 | exit 2 |
---|
[2380] | 122 | else |
---|
[2566] | 123 | if [[ $silent = false ]] |
---|
| 124 | then |
---|
[3312] | 125 | printf "\n --> palmbuild finished\n\n" |
---|
[2566] | 126 | fi |
---|
[2380] | 127 | exit 0 |
---|
[3312] | 128 | fi' exit |
---|
[2380] | 129 | |
---|
| 130 | |
---|
[3312] | 131 | # ACTIONS IN CASE OF TERMINAL-BREAK (CONTROL-C): |
---|
| 132 | trap 'locat=control_c |
---|
| 133 | exit 1 |
---|
[2380] | 134 | ' 2 |
---|
| 135 | |
---|
| 136 | |
---|
| 137 | |
---|
| 138 | # READ SHELLSCRIPT-OPTIONS |
---|
[3455] | 139 | while getopts :c:r:uvV option |
---|
[2380] | 140 | do |
---|
| 141 | case $option in |
---|
[3455] | 142 | (c) configuration_identifier=$OPTARG;; |
---|
| 143 | (r) run_identifier=$OPTARG;; |
---|
[2380] | 144 | (v) silent=true;; |
---|
[2506] | 145 | (V) use_existing_sources_folder=true;; |
---|
[2380] | 146 | (\?) printf "\n +++ unknown option $OPTARG \n"; |
---|
| 147 | locat=parameter; exit;; |
---|
| 148 | esac |
---|
| 149 | done |
---|
| 150 | |
---|
| 151 | |
---|
[2506] | 152 | # BUILD THE CONFIGURATION-FILE NAME AND THE SOURCES_FOR_RUN-FOLDER NAME |
---|
[3236] | 153 | config_file=.palm.config.$configuration_identifier |
---|
| 154 | sources_for_run_catalog=SOURCES_FOR_RUN_${configuration_identifier}_$run_identifier |
---|
[2380] | 155 | |
---|
| 156 | |
---|
| 157 | # CHECK, IF CONFIGURATION-FILE EXISTS |
---|
| 158 | if [[ ! -f $config_file ]] |
---|
| 159 | then |
---|
| 160 | printf "\n +++ configuration file: " |
---|
| 161 | printf "\n $config_file" |
---|
| 162 | printf "\n does not exist" |
---|
| 163 | locat=configuration; exit |
---|
| 164 | fi |
---|
| 165 | |
---|
| 166 | |
---|
| 167 | # ### is this really required? |
---|
| 168 | config_file=$PWD/$config_file |
---|
| 169 | |
---|
| 170 | |
---|
| 171 | # READ VARIABLE SETTINGS FROM CONFIG FILE LINE BY LINE |
---|
| 172 | while read line |
---|
| 173 | do |
---|
| 174 | |
---|
| 175 | # FIRST REPLACE ENVIRONMENT-VARIABLES BY THEIR RESPECTIVE VALUES |
---|
| 176 | eval line=\"$line\" |
---|
| 177 | |
---|
| 178 | |
---|
| 179 | # INTERPRET THE LINE |
---|
| 180 | if [[ "$(echo $line)" = "" ]] |
---|
| 181 | then |
---|
| 182 | |
---|
| 183 | # EMPTY LINE, NO ACTION |
---|
| 184 | continue |
---|
| 185 | |
---|
| 186 | elif [[ "$(echo $line | cut -c1)" = "#" ]] |
---|
| 187 | then |
---|
| 188 | |
---|
| 189 | # LINE IS A COMMENT LINE |
---|
| 190 | continue |
---|
| 191 | |
---|
| 192 | elif [[ "$(echo $line | cut -c1)" = "%" ]] |
---|
| 193 | then |
---|
| 194 | |
---|
| 195 | # LINE DEFINES AN ENVIRONMENT-VARIABLE |
---|
| 196 | var=`echo $line | cut -d" " -s -f1 | cut -c2-` |
---|
| 197 | value=`echo $line | cut -d" " -s -f2-` |
---|
| 198 | |
---|
| 199 | # REPLACE ":" BY " " IN COMPILER- CPP- OR LINKER-OPTIONS, |
---|
| 200 | # "::" IS REPLACED BY ":". |
---|
| 201 | #value=`echo $value | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` |
---|
| 202 | |
---|
| 203 | |
---|
| 204 | # VALUE FROM THE CONFIGURATION-FILE IS ASSIGNED TO THE |
---|
| 205 | # ENVIRONMENT-VARIABLE, BUT ONLY IF NO VALUE HAS BEEN ALREADY |
---|
| 206 | # ASSIGNED WITHIN THIS SCRIPT (E.G. BY SCRIPT-OPTIONS). |
---|
| 207 | # NON-ASSIGNED VARIABLES HAVE VALUE "" OR 0 (IN CASE OF INTEGER). |
---|
| 208 | # HENCE THE GENERAL RULE IS: SCRIPT-OPTION OVERWRITES THE |
---|
| 209 | # CONFIGURATION-FILE. |
---|
| 210 | if [[ "$(eval echo \$$var)" = "" || "$(eval echo \$$var)" = "0" ]] |
---|
| 211 | then |
---|
| 212 | eval export $var="\$value" |
---|
| 213 | |
---|
| 214 | # TERMINAL OUTPUT OF ENVIRONMENT-VARIABLES, IF TRACEBACK IS SWITCHED on |
---|
| 215 | if [[ $do_trace = true ]] |
---|
| 216 | then |
---|
| 217 | printf "\n*** ENVIRONMENT-VARIABLE $var = $value" |
---|
| 218 | fi |
---|
| 219 | fi |
---|
| 220 | |
---|
| 221 | else |
---|
| 222 | |
---|
| 223 | # SKIP ALL OTHER LINES |
---|
| 224 | continue |
---|
| 225 | |
---|
| 226 | fi |
---|
| 227 | |
---|
| 228 | done < $config_file |
---|
| 229 | |
---|
| 230 | |
---|
[2404] | 231 | # CHECK, IF THE BASE DIRECTORY PATH HAS BEEN GIVEN |
---|
| 232 | if [[ "$base_directory" = "" ]] |
---|
| 233 | then |
---|
| 234 | printf "\n +++ no base directory found in configuration file" |
---|
| 235 | locat=config_file; exit |
---|
| 236 | else |
---|
| 237 | if [[ ! -d $base_directory ]] |
---|
| 238 | then |
---|
| 239 | printf "\n\n +++ base directory \"$base_directory\" " |
---|
| 240 | printf "\n does not exist" |
---|
| 241 | locat=source_path; exit |
---|
| 242 | fi |
---|
| 243 | fi |
---|
| 244 | |
---|
| 245 | |
---|
[2380] | 246 | # CHECK SOURCE-CODE PATH |
---|
| 247 | if [[ "$source_path" = "" ]] |
---|
| 248 | then |
---|
| 249 | printf "\n +++ no source path found in configuration file" |
---|
| 250 | locat=config_file; exit |
---|
| 251 | else |
---|
| 252 | if [[ ! -d $source_path ]] |
---|
| 253 | then |
---|
| 254 | printf "\n\n +++ source path \"$source_path\" " |
---|
| 255 | printf "\n does not exist" |
---|
| 256 | locat=source_path; exit |
---|
| 257 | fi |
---|
| 258 | fi |
---|
| 259 | |
---|
| 260 | |
---|
| 261 | # CHECK MAKEFILE |
---|
[3236] | 262 | makefile=$source_path/Makefile |
---|
[2380] | 263 | if [[ ! -f $makefile ]] |
---|
| 264 | then |
---|
| 265 | printf "\n +++ makefile: " |
---|
| 266 | printf "\n $makefile" |
---|
| 267 | printf "\n does not exist" |
---|
| 268 | locat=makefile; exit |
---|
| 269 | fi |
---|
| 270 | |
---|
| 271 | |
---|
| 272 | # CHECK COMPILERNAME |
---|
| 273 | if [[ "$compiler_name" = "" ]] |
---|
| 274 | then |
---|
| 275 | printf "\n +++ no compiler name found in configuration file" |
---|
| 276 | locat=config_file; exit |
---|
| 277 | fi |
---|
| 278 | |
---|
| 279 | |
---|
| 280 | # CHECK SERIAL COMPILERNAME |
---|
| 281 | if [[ "$compiler_name_ser" = "" ]] |
---|
| 282 | then |
---|
| 283 | printf "\n +++ no compiler name for serial compilation in configuration file" |
---|
| 284 | locat=config_file; exit |
---|
| 285 | fi |
---|
| 286 | |
---|
| 287 | |
---|
| 288 | # DETERMINE SSH-KEY TO BE USED |
---|
| 289 | if [[ "$ssh_key" != "" ]] |
---|
| 290 | then |
---|
| 291 | ssh_key="-i $HOME/.ssh/`echo $line | cut -d" " -s -f2`" |
---|
| 292 | fi |
---|
| 293 | |
---|
| 294 | |
---|
| 295 | #CHECK CPP-OPTIONS |
---|
| 296 | if [[ "$cpp_options" = "" ]] |
---|
| 297 | then |
---|
| 298 | printf "\n +++ WARNING: no cpp-options found in configuration file" |
---|
| 299 | fi |
---|
| 300 | |
---|
| 301 | |
---|
| 302 | # CHECK SETTINGS IN CASE OF COMPILING ON REMOTE MACHINE |
---|
| 303 | if [[ "$remote_ip" != "" ]] |
---|
| 304 | then |
---|
| 305 | |
---|
| 306 | if [[ "$remote_username" = "" ]] |
---|
| 307 | then |
---|
| 308 | printf "\n +++ no user name given in configuration file" |
---|
| 309 | locat=config_file; exit |
---|
| 310 | fi |
---|
| 311 | |
---|
| 312 | # GET SOURCE AND DEPOSITORY PATH ON THE REMOTE MACHINE WITHOUT EVALUATING |
---|
| 313 | # THE $ |
---|
| 314 | # IF NOT GIVEN, USE THE LOCAL SOURCE AND DEPOSITORY PATH |
---|
| 315 | line=`grep %remote_source_path $config_file` |
---|
| 316 | if [[ "$line" != "" ]] |
---|
| 317 | then |
---|
| 318 | remote_source_path=`echo $line | cut -d" " -s -f2` |
---|
| 319 | else |
---|
| 320 | line=`grep %source_path $config_file` |
---|
| 321 | remote_source_path=`echo $line | cut -d" " -s -f2` |
---|
| 322 | fi |
---|
| 323 | |
---|
[2404] | 324 | line=`grep %base_directory $config_file` |
---|
[3236] | 325 | make_depository=`echo $line | cut -d" " -s -f2`/MAKE_DEPOSITORY_${configuration_identifier} |
---|
[2380] | 326 | |
---|
| 327 | else |
---|
| 328 | |
---|
[3236] | 329 | make_depository=${base_directory}/MAKE_DEPOSITORY_${configuration_identifier} |
---|
[2380] | 330 | |
---|
| 331 | fi |
---|
| 332 | |
---|
[3236] | 333 | |
---|
| 334 | # GET THE GLOBAL REVISION-NUMBER OF THE SVN-REPOSITORY |
---|
| 335 | global_revision=`svnversion $source_path 2>/dev/null` |
---|
| 336 | global_revision="Rev: $global_revision" |
---|
| 337 | |
---|
| 338 | |
---|
[2380] | 339 | # HEADER-OUTPUT (PART1: MESSAGES CONCERNING THE LOCAL HOST) |
---|
| 340 | if [[ $silent = false ]] |
---|
| 341 | then |
---|
[2566] | 342 | calltime=$(date) |
---|
| 343 | printf "\n" |
---|
| 344 | printf "#------------------------------------------------------------------------# \n" |
---|
| 345 | printf "| %-40s%30s | \n" "$version" "$calltime" |
---|
[3236] | 346 | printf "| %-40s%30s | \n" "PALM code $global_revision" " " |
---|
[2566] | 347 | printf "| | \n" |
---|
| 348 | printf "| %-13s%-57s | \n" "called on:" "$(hostname) (IP:$local_ip)" |
---|
| 349 | column2=$(echo $config_file | cut -c1-57 ) |
---|
| 350 | printf "| %-13s%-57s | \n" "config file:" "$column2" |
---|
| 351 | line=$(echo "$config_file" | cut -c58-) |
---|
| 352 | while [[ "$line" != "" ]] |
---|
[2380] | 353 | do |
---|
[2566] | 354 | column1="" |
---|
| 355 | column2=$(echo $line | cut -c1-57 ) |
---|
| 356 | printf "| %-13s%-57s | \n" "$column1" "$column2" |
---|
| 357 | line=$(echo "$line" | cut -c58-) |
---|
[2380] | 358 | done |
---|
[2566] | 359 | column2=$(echo $makefile | cut -c1-57 ) |
---|
| 360 | printf "| %-13s%-57s | \n" "makefile:" "$column2" |
---|
| 361 | line=$(echo "$makefile" | cut -c58-) |
---|
| 362 | while [[ "$line" != "" ]] |
---|
| 363 | do |
---|
| 364 | column1="" |
---|
| 365 | column2=$(echo $line | cut -c1-57 ) |
---|
| 366 | printf "| %-13s%-57s | \n" "$column1" "$column2" |
---|
| 367 | line=$(echo "$line" | cut -c58-) |
---|
| 368 | done |
---|
| 369 | column2=$(echo $source_path | cut -c1-57 ) |
---|
| 370 | printf "| %-13s%-57s | \n" "source path:" "$column2" |
---|
| 371 | line=$(echo "$source_path" | cut -c58-) |
---|
| 372 | while [[ "$line" != "" ]] |
---|
| 373 | do |
---|
| 374 | column1="" |
---|
| 375 | column2=$(echo $line | cut -c1-57 ) |
---|
| 376 | printf "| %-13s%-57s | \n" "$column1" "$column2" |
---|
| 377 | line=$(echo "$line" | cut -c58-) |
---|
| 378 | done |
---|
| 379 | printf "| | \n" |
---|
| 380 | |
---|
[2380] | 381 | if [[ "$remote_ip" != "" ]] |
---|
| 382 | then |
---|
[3236] | 383 | column2="$configuration_identifier" |
---|
| 384 | printf "| %-20s%-50s | \n" "config. identifier:" "$column2" |
---|
[2404] | 385 | column2=$(echo "$make_depository" | cut -c1-50 ) |
---|
[2380] | 386 | printf "| %-20s%-50s | \n" "remote depository:" "$column2" |
---|
| 387 | else |
---|
[3236] | 388 | column2="$configuration_identifier" |
---|
| 389 | printf "| %-20s%-50s | \n" "config. identifier:" "$column2" |
---|
[2404] | 390 | column2=$(echo "$make_depository" | cut -c1-50 ) |
---|
[2380] | 391 | printf "| %-20s%-50s | \n" "local depository:" "$column2" |
---|
| 392 | fi |
---|
[2404] | 393 | line=$(echo "$make_depository" | cut -c51-) |
---|
| 394 | while [[ "$line" != "" ]] |
---|
| 395 | do |
---|
| 396 | column1="" |
---|
| 397 | column2=$(echo "$line" | cut -c1-50 ) |
---|
| 398 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
| 399 | line=$(echo "$line" | cut -c51-) |
---|
| 400 | done |
---|
[2566] | 401 | |
---|
[2380] | 402 | if [[ "$remote_ip" != "" ]] |
---|
| 403 | then |
---|
| 404 | printf "| %-20s%-50s | \n" "remote username:" "$remote_username" |
---|
| 405 | printf "| %-20s%-50s | \n" "remote address:" "$remote_ip" |
---|
| 406 | else |
---|
| 407 | printf "| %-20s%-50s | \n" "username:" "$local_username" |
---|
| 408 | printf "| %-20s%-50s | \n" "address:" "$local_ip" |
---|
| 409 | fi |
---|
[2566] | 410 | |
---|
[2380] | 411 | printf "| %-20s%-50s | \n" "compiler:" "$compiler_name" |
---|
| 412 | printf "| %-20s%-50s | \n" "serial compiler:" "$compiler_name_ser" |
---|
[2566] | 413 | |
---|
[2380] | 414 | if [[ "$make_options" != "" ]] |
---|
| 415 | then |
---|
| 416 | printf "| %-20s%-50s | \n" "make options:" "$make_options" |
---|
| 417 | fi |
---|
| 418 | column2=$(echo "$cpp_options" | cut -c1-50 ) |
---|
| 419 | printf "| %-20s%-50s | \n" "cpp options:" "$column2" |
---|
| 420 | line=$(echo "$cpp_options" | cut -c51-) |
---|
| 421 | while [[ "$line" != "" ]] |
---|
| 422 | do |
---|
| 423 | column1="" |
---|
| 424 | column2=$(echo "$line" | cut -c1-50 ) |
---|
| 425 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
| 426 | line=$(echo "$line" | cut -c51-) |
---|
| 427 | done |
---|
| 428 | column2=$(echo "$compiler_options" | cut -c1-50 ) |
---|
| 429 | printf "| %-20s%-50s | \n" "compiler options:" "$column2" |
---|
| 430 | line=$(echo "$compiler_options" | cut -c51-) |
---|
| 431 | while [[ "$line" != "" ]] |
---|
| 432 | do |
---|
| 433 | column1="" |
---|
| 434 | column2=$(echo "$line" | cut -c1-50 ) |
---|
| 435 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
| 436 | line=$(echo "$line" | cut -c51-) |
---|
| 437 | done |
---|
[2388] | 438 | column2=$(echo "$linker_options" | cut -c1-50 ) |
---|
| 439 | printf "| %-20s%-50s | \n" "linker options:" "$column2" |
---|
| 440 | line=$(echo "$linker_options" | cut -c51-) |
---|
[2380] | 441 | while [[ "$line" != "" ]] |
---|
| 442 | do |
---|
| 443 | column1="" |
---|
| 444 | column2=$(echo "$line" | cut -c1-50 ) |
---|
| 445 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
| 446 | line=$(echo "$line" | cut -c51-) |
---|
| 447 | done |
---|
| 448 | if [[ "$login_init_cmd" != "" ]] |
---|
| 449 | then |
---|
| 450 | column2=$(echo "$login_init_cmd" | cut -c1-50 ) |
---|
| 451 | printf "| %-20s%-50s | \n" "login init command:" "$column2" |
---|
| 452 | line=$(echo "$login_init_cmd" | cut -c51-) |
---|
| 453 | while [[ "$line" != "" ]] |
---|
| 454 | do |
---|
| 455 | column1="" |
---|
| 456 | column2=$(echo "$line" | cut -c1-50 ) |
---|
| 457 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
| 458 | line=$(echo "$line" | cut -c51-) |
---|
| 459 | done |
---|
| 460 | fi |
---|
| 461 | if [[ "$module_commands" != "" ]] |
---|
| 462 | then |
---|
| 463 | column2=$(echo "$module_commands" | cut -c1-50 ) |
---|
| 464 | printf "| %-20s%-50s | \n" "module command(s):" "$column2" |
---|
| 465 | line=$(echo "$module_commands" | cut -c51-) |
---|
| 466 | while [[ "$line" != "" ]] |
---|
| 467 | do |
---|
| 468 | column1="" |
---|
| 469 | column2=$(echo "$line" | cut -c1-50 ) |
---|
| 470 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
| 471 | line=$(echo "$line" | cut -c51-) |
---|
| 472 | done |
---|
| 473 | fi |
---|
| 474 | printf "#------------------------------------------------------------------------# \n" |
---|
| 475 | |
---|
[2566] | 476 | answer=dummy |
---|
| 477 | printf "\n" |
---|
| 478 | while [[ "$answer" != y && "$answer" != Y && "$answer" != c && "$answer" != C && "$answer" != s && "$answer" != S && "$answer" != a && "$answer" != A ]] |
---|
| 479 | do |
---|
| 480 | printf " >>> continue (y(es)/c(ontinue)/a(bort)) ? " |
---|
| 481 | read answer |
---|
| 482 | done |
---|
| 483 | if [[ $answer = a || $answer = A ]] |
---|
[2380] | 484 | then |
---|
[2566] | 485 | locat=user_abort; exit |
---|
[2380] | 486 | fi |
---|
[2566] | 487 | if [[ $answer = c || $answer = C ]] |
---|
| 488 | then |
---|
| 489 | silent=true |
---|
| 490 | fi |
---|
| 491 | fi |
---|
[2380] | 492 | |
---|
| 493 | |
---|
[2566] | 494 | # TAR THE SOURCES AND MAKEFILES |
---|
| 495 | # UTILITIES ARE TEMPORARILY COPIED TO THE SOURCE DIRECTORY IN ORDER TO TAR |
---|
| 496 | # THEM TOO |
---|
| 497 | if [[ $silent = false ]] |
---|
| 498 | then |
---|
| 499 | printf "\n\n *** tar of makefile and source files in" |
---|
| 500 | printf "\n $source_path\n" |
---|
| 501 | fi |
---|
| 502 | cd $source_path |
---|
| 503 | cp -p ../UTIL/combine_plot_fields.f90 . |
---|
| 504 | cp -p ../UTIL/compare_palm_logs.f90 . |
---|
[3208] | 505 | cp -p ../UTIL/agent_preprocessing/agent_preprocessing.f90 . |
---|
[3499] | 506 | #cp -p ../UTIL/surface_output_processing/surface_output_to_vtk.f90 . |
---|
[2566] | 507 | cp -p ../UTIL/Makefile_utilities . |
---|
| 508 | tar -cf ${program_name}_sources.tar Makefile* *.$suf |
---|
[3499] | 509 | rm combine_plot_fields.f90 compare_palm_logs.f90 agent_preprocessing.f90 Makefile_utilities #surface_output_to_vtk.f90 |
---|
[2566] | 510 | |
---|
| 511 | |
---|
| 512 | # MAKE ON REMOTE HOST |
---|
| 513 | if [[ "$remote_ip" != "" ]] |
---|
| 514 | then |
---|
| 515 | |
---|
| 516 | # NEXT IS THE BRANCH FOR CREATING THE MAKE_DEPOSITORY_... |
---|
[3236] | 517 | if [[ "$run_identifier" = "" ]] |
---|
[2380] | 518 | then |
---|
| 519 | |
---|
[2566] | 520 | # COPY CURRENT SOURCE CODE TO SOURCE-CODE DIRECTORY ON THE REMOTE HOST |
---|
| 521 | # CREATE THIS DIRECTORY, IF IT DOES NOT EXIST |
---|
| 522 | if [[ $silent = false ]] |
---|
[2380] | 523 | then |
---|
[2566] | 524 | echo " " |
---|
[2404] | 525 | echo " *** copying \"${program_name}_sources.tar\" to \"${remote_ip}:${make_depository}/\" " |
---|
| 526 | echo "[[ ! -d ${make_depository} ]] && (echo \" *** ${make_depository} will be created\"; mkdir -p ${make_depository})" | ssh -q $ssh_key ${remote_username}@${remote_ip} 2>&1 |
---|
| 527 | scp $ssh_key ${source_path}/${program_name}_sources.tar ${remote_username}@${remote_ip}:${make_depository}/${program_name}_sources.tar |
---|
[2566] | 528 | else |
---|
| 529 | echo "[[ ! -d ${make_depository} ]] && mkdir -p ${make_depository}" | ssh -q $ssh_key ${remote_username}@${remote_ip} 2>&1 |
---|
| 530 | scp $ssh_key ${source_path}/${program_name}_sources.tar ${remote_username}@${remote_ip}:${make_depository}/${program_name}_sources.tar > /dev/null |
---|
| 531 | fi |
---|
[2380] | 532 | |
---|
| 533 | |
---|
| 534 | |
---|
[2566] | 535 | |
---|
| 536 | # UNTAR PREVIOUS UPDATE ON REMOTE HOST, IF EXISTING |
---|
| 537 | if [[ $silent = false ]] |
---|
| 538 | then |
---|
[2380] | 539 | echo " *** untar previous update on remote host, if existing" |
---|
[2566] | 540 | fi |
---|
| 541 | echo "cd ${make_depository}; [[ -f ${program_name}_current_version.tar ]] && tar -xf ${program_name}_current_version.tar" | ssh -q $ssh_key ${remote_username}@${remote_ip} 2>&1 |
---|
[2380] | 542 | |
---|
| 543 | |
---|
[2566] | 544 | # UNTAR CURRENT SOURCES ON REMOTE HOST |
---|
| 545 | if [[ $silent = false ]] |
---|
| 546 | then |
---|
[2380] | 547 | echo " *** untar current sources on remote host" |
---|
[2566] | 548 | fi |
---|
| 549 | echo "cd ${make_depository}; tar -xf ${program_name}_sources.tar" | ssh -q $ssh_key ${remote_username}@${remote_ip} 2>&1 |
---|
[2380] | 550 | |
---|
| 551 | |
---|
[2566] | 552 | # CREATE INIT AND MODULE COAMMNDS |
---|
| 553 | [[ "$login_init_cmd" != "" ]] && login_init_cmd=${login_init_cmd}";" |
---|
| 554 | [[ "$module_commands" != "" ]] && module_commands=${module_commands}";" |
---|
[2380] | 555 | |
---|
| 556 | |
---|
[2566] | 557 | # FIRST CREATE EXECUTABLES FOR THE UTILITY ROUTINES |
---|
| 558 | if [[ $silent = false ]] |
---|
| 559 | then |
---|
[2380] | 560 | echo " " |
---|
| 561 | echo " *** creating utilities on remote host" |
---|
[2566] | 562 | fi |
---|
| 563 | make_call_string="make -f Makefile_utilities $make_options F90=$compiler_name F90_SER=$compiler_name_ser COPT=\"$cpp_options\" F90FLAGS=\"$compiler_options\" LDFLAGS=\"$linker_options\" " |
---|
[3236] | 564 | echo "$login_init_cmd $module_commands cd ${make_depository}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh -q $ssh_key ${remote_username}@${remote_ip} 2>&1 | tee ${configuration_identifier}_last_make_protocol |
---|
[2380] | 565 | |
---|
[3236] | 566 | if [[ $(grep -c MAKE_ERROR ${configuration_identifier}_last_make_protocol) != 0 ]] |
---|
[2566] | 567 | then |
---|
| 568 | printf "\a\n +++ error(s) occurred during compiling or linking of utilities" |
---|
[3236] | 569 | printf "\n for host configuration \"$configuration_identifier\" " |
---|
[2566] | 570 | if [[ $silent = false ]] |
---|
[2380] | 571 | then |
---|
[2566] | 572 | answer=dummy |
---|
| 573 | printf "\n" |
---|
| 574 | while [[ "$answer" != c && "$answer" != k ]] |
---|
| 575 | do |
---|
| 576 | printf " >>> continue / list errors / kill palmbuild (c/l/k) ? " |
---|
| 577 | read answer |
---|
| 578 | if [[ "$answer" = l ]] |
---|
[2380] | 579 | then |
---|
[3236] | 580 | more ${configuration_identifier}_last_make_protocol |
---|
[2380] | 581 | fi |
---|
[2566] | 582 | done |
---|
| 583 | if [[ $answer = k ]] |
---|
| 584 | then |
---|
[2487] | 585 | locat=user_abort; exit |
---|
[2380] | 586 | fi |
---|
[2566] | 587 | else |
---|
| 588 | # ABORT ANYWAY |
---|
| 589 | locat=user_abort; exit |
---|
[2380] | 590 | fi |
---|
[2566] | 591 | fi |
---|
[2380] | 592 | |
---|
[2566] | 593 | # NOW COMPILE THE PALM CODE |
---|
| 594 | # COMMANDS WILL BE COMMUNICATED TO SSH VIA PIPE, SINCE THIS WAY THE SYSTEM- AND |
---|
| 595 | # USER-PROFILES OF THE SHELL ARE COMPLETELY EXECUTED (OTHERWISE, MAKE |
---|
| 596 | # MAY E.G. MISS THE COMPILER-PATHS) |
---|
| 597 | if [[ $silent = false ]] |
---|
| 598 | then |
---|
[2380] | 599 | echo " " |
---|
| 600 | echo " *** compile PALM sources on remote host" |
---|
[2566] | 601 | fi |
---|
| 602 | make_call_string="make $make_options PROG=$program_name F90=$compiler_name COPT=\"$cpp_options\" F90FLAGS=\"$compiler_options\" LDFLAGS=\"$linker_options\" " |
---|
[3236] | 603 | echo "$login_init_cmd $module_commands cd ${make_depository}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh -q $ssh_key ${remote_username}@${remote_ip} 2>&1 | tee ${configuration_identifier}_last_make_protocol |
---|
[2380] | 604 | |
---|
[3236] | 605 | if [[ $(grep -c MAKE_ERROR ${configuration_identifier}_last_make_protocol) != 0 ]] |
---|
[2566] | 606 | then |
---|
[3236] | 607 | printf "\a\n +++ error(s) occurred during compiling or linking for host configuration \"$configuration_identifier\" " |
---|
[2566] | 608 | if [[ $silent = false ]] |
---|
[2380] | 609 | then |
---|
[2566] | 610 | answer=dummy |
---|
| 611 | printf "\n" |
---|
| 612 | while [[ "$answer" != c && "$answer" != k ]] |
---|
| 613 | do |
---|
| 614 | printf " >>> continue / list errors / kill palmbuild (c/l/k) ? " |
---|
| 615 | read answer |
---|
| 616 | if [[ "$answer" = l ]] |
---|
[2380] | 617 | then |
---|
[3236] | 618 | more ${configuration_identifier}_last_make_protocol |
---|
[2380] | 619 | fi |
---|
[2566] | 620 | done |
---|
| 621 | if [[ $answer = k ]] |
---|
| 622 | then |
---|
[2487] | 623 | locat=user_abort; exit |
---|
[2380] | 624 | fi |
---|
[2566] | 625 | else |
---|
| 626 | # ABORT ANYWAY |
---|
| 627 | locat=user_abort; exit |
---|
[2380] | 628 | fi |
---|
[2566] | 629 | fi |
---|
[2380] | 630 | |
---|
[2566] | 631 | # TAR UPDATED VERSION ON THE REMOTE HOST |
---|
| 632 | if [[ $silent = false ]] |
---|
| 633 | then |
---|
[2380] | 634 | printf "\n *** tar update on remote host ..." |
---|
[2566] | 635 | fi |
---|
| 636 | echo "cd ${make_depository}; chmod u+w *; tar -cf ${program_name}_current_version.tar ${program_name} *.f90 *.o *.mod *.x" | ssh -q $ssh_key ${remote_username}@${remote_ip} 2>&1 |
---|
[2380] | 637 | |
---|
| 638 | |
---|
[2566] | 639 | # NOW COMES THE BRANCH FOR CREATING THE EXECUTABLE FOR THE CURRENT RUN |
---|
| 640 | # INCLUDING E.G. USER-INTERFACE ROUTINES. ALSO ADD OTHER UTILITY EXECUTABLES. EVERYTHING IS |
---|
| 641 | # COLLECTED IN DIRECTORY SOURCES_FOR_RUN_... |
---|
[3236] | 642 | elif [[ "$run_identifier" != "" ]] |
---|
[2566] | 643 | then |
---|
| 644 | |
---|
| 645 | # FIRST CHECK, IF COMPILED SOURCES FOR THIS RUN IDENTIFIER EXISTS |
---|
| 646 | # AND ASK, IF THEY SHALL BE USED |
---|
[3236] | 647 | echo "[[ -d ${fast_io_catalog}/${sources_for_run_catalog} ]] && echo sources for run found" | ssh -q $ssh_key ${remote_username}@${remote_ip} 2>&1 > ${configuration_identifier}_last_make_protocol |
---|
| 648 | if [[ $(grep -c "sources for run found" ${configuration_identifier}_last_make_protocol) != 0 && $use_existing_sources_folder = true ]] |
---|
[2380] | 649 | then |
---|
[3236] | 650 | printf "\a\n *** compiled sources for run \"$run_identifier\" found on remote host in folder" |
---|
[2566] | 651 | printf "\n ${fast_io_catalog}/${sources_for_run_catalog}" |
---|
| 652 | printf "\n will be used!" |
---|
| 653 | exit |
---|
| 654 | fi |
---|
[2380] | 655 | |
---|
[2566] | 656 | # COPY MAKE DEPOSITORY ON REMOTE MACHINE TO SOURCES_FOR_RUN_... |
---|
| 657 | if [[ $silent = false ]] |
---|
| 658 | then |
---|
[3236] | 659 | printf "\n *** copy MAKE_DEPOSITORY_${configuration_identifier} on remote host to $sources_for_run_catalog \n" |
---|
[2566] | 660 | fi |
---|
| 661 | echo "rm -rf ${fast_io_catalog}/${sources_for_run_catalog}; mkdir -p ${fast_io_catalog}/${sources_for_run_catalog}; cp ${make_depository}/${program_name}_current_version.tar ${fast_io_catalog}/${sources_for_run_catalog}; cd ${fast_io_catalog}/${sources_for_run_catalog}; tar xf ${program_name}_current_version.tar" | ssh -q $ssh_key ${remote_username}@${remote_ip} 2>&1 |
---|
[2380] | 662 | |
---|
| 663 | |
---|
[2566] | 664 | # COPY CONTENTS OF SOURCES_FOR_RUN_... TO SOURCES_FOR_RUN_... ON THE REMOTE MACHINE |
---|
| 665 | if [[ $silent = false ]] |
---|
| 666 | then |
---|
[2506] | 667 | printf "\n *** copy ${base_directory}/${sources_for_run_catalog}" |
---|
| 668 | printf "\n to $sources_for_run_catalog on remote host \n" |
---|
[2566] | 669 | fi |
---|
| 670 | scp -q $ssh_key ${base_directory}/${sources_for_run_catalog}/{*,.[!.]*} ${remote_username}@${remote_ip}:${fast_io_catalog}/${sources_for_run_catalog} |
---|
[2380] | 671 | |
---|
| 672 | |
---|
[2566] | 673 | # CREATE EXECUTABLE FROM THE NEW/MODIFIED SOURCE FILES, IF THERE ARE ANY |
---|
| 674 | if [[ $(ls -1 ${base_directory}/${sources_for_run_catalog}/ | grep -c .$suf) != 0 ]] |
---|
| 675 | then |
---|
| 676 | |
---|
| 677 | make_call_string="make $make_options PROG=$program_name F90=$compiler_name COPT=\"$cpp_options\" F90FLAGS=\"$compiler_options\" LDFLAGS=\"$linker_options\" " |
---|
| 678 | [[ "$login_init_cmd" != "" ]] && login_init_cmd=${login_init_cmd}";" |
---|
| 679 | [[ "$module_commands" != "" ]] && module_commands=${module_commands}";" |
---|
| 680 | if [[ $silent = false ]] |
---|
[2380] | 681 | then |
---|
| 682 | echo " *** execute \"make\" on remote host" |
---|
[2566] | 683 | fi |
---|
[3236] | 684 | echo "$login_init_cmd $module_commands cd ${fast_io_catalog}/${sources_for_run_catalog}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh -q $ssh_key ${remote_username}@${remote_ip} 2>&1 | tee ${configuration_identifier}_last_make_protocol |
---|
[2380] | 685 | |
---|
[3236] | 686 | if [[ $(grep -c MAKE_ERROR ${configuration_identifier}_last_make_protocol) != 0 ]] |
---|
[2566] | 687 | then |
---|
[3236] | 688 | printf "\a\n +++ error(s) occurred during compiling or linking for host configuration \"$configuration_identifier\" " |
---|
[2566] | 689 | if [[ $silent = false ]] |
---|
[2380] | 690 | then |
---|
[2566] | 691 | answer=dummy |
---|
| 692 | printf "\n" |
---|
| 693 | while [[ "$answer" != c && "$answer" != k ]] |
---|
| 694 | do |
---|
| 695 | printf " >>> continue / list errors / kill palmbuild (c/l/k) ? " |
---|
| 696 | read answer |
---|
| 697 | if [[ "$answer" = l ]] |
---|
[2380] | 698 | then |
---|
[3236] | 699 | more ${configuration_identifier}_last_make_protocol |
---|
[2380] | 700 | fi |
---|
[2566] | 701 | done |
---|
| 702 | if [[ $answer = k ]] |
---|
| 703 | then |
---|
[2506] | 704 | echo "rm -rf ${fast_io_catalog}/${sources_for_run_catalog}" | ssh -q $ssh_key ${remote_username}@${remote_ip} 2>&1 |
---|
[2487] | 705 | locat=user_abort; exit |
---|
[2380] | 706 | fi |
---|
[2566] | 707 | else |
---|
| 708 | # ABORT ANYWAY |
---|
| 709 | echo "rm -rf ${fast_io_catalog}/${sources_for_run_catalog}" | ssh -q $ssh_key ${remote_username}@${remote_ip} 2>&1 |
---|
| 710 | locat=user_abort; exit |
---|
[2380] | 711 | fi |
---|
[2566] | 712 | fi |
---|
[2380] | 713 | |
---|
[2566] | 714 | else |
---|
[2380] | 715 | |
---|
[2566] | 716 | echo " *** nothing to compile for this run" |
---|
[2380] | 717 | |
---|
| 718 | fi |
---|
| 719 | |
---|
[2566] | 720 | fi |
---|
[2380] | 721 | |
---|
[3236] | 722 | rm -rf ${source_path}/${configuration_identifier}_last_make_protocol |
---|
[2380] | 723 | |
---|
| 724 | |
---|
[2566] | 725 | # MAKE ON LOCAL HOST |
---|
| 726 | else |
---|
[2380] | 727 | |
---|
[2566] | 728 | |
---|
| 729 | # NEXT IS THE BRANCH FOR CREATING THE MAKE_DEPOSITORY_... ON THE |
---|
| 730 | # LOCAL HOST |
---|
[3236] | 731 | if [[ "$run_identifier" = "" ]] |
---|
[2566] | 732 | then |
---|
| 733 | |
---|
| 734 | # SET THE ENVIRONMENT (EXECUTE INIT AND MODULE COMMANDS) |
---|
| 735 | if [[ "$login_init_cmd" != "" ]] |
---|
[2380] | 736 | then |
---|
[2566] | 737 | $login_init_cmd |
---|
| 738 | fi |
---|
[2380] | 739 | |
---|
[2566] | 740 | if [[ "$module_commands" != "" ]] |
---|
| 741 | then |
---|
| 742 | $module_commands |
---|
| 743 | fi |
---|
[2380] | 744 | |
---|
| 745 | |
---|
[2566] | 746 | # CREATE MAKE-DEPOSITORY, IF IT DOES NOT EXIST |
---|
| 747 | eval make_depository=$make_depository |
---|
| 748 | if [[ ! -d $make_depository ]] |
---|
| 749 | then |
---|
| 750 | if mkdir -p $make_depository |
---|
[2380] | 751 | then |
---|
[2566] | 752 | if [[ $silent = false ]] |
---|
[2380] | 753 | then |
---|
| 754 | printf "\n\n *** directory for local make depository:" |
---|
[2404] | 755 | printf "\n $make_depository" |
---|
[2380] | 756 | printf "\n was created\n" |
---|
| 757 | fi |
---|
[2566] | 758 | else |
---|
| 759 | printf "\n +++ directory for local make depository:" |
---|
| 760 | printf "\n $make_depository" |
---|
| 761 | printf "\n cannot be created" |
---|
| 762 | locat=local_depository; exit |
---|
[2380] | 763 | fi |
---|
[2566] | 764 | fi |
---|
[2380] | 765 | |
---|
[2566] | 766 | # COPY SOURCE-CODE FROM REPOSITORY TO MAKE-DEPOSITORY |
---|
| 767 | if [[ $silent = false ]] |
---|
| 768 | then |
---|
[2380] | 769 | echo " " |
---|
| 770 | echo " *** untar current source sources on local host in" |
---|
[2404] | 771 | echo " $make_depository" |
---|
[2566] | 772 | fi |
---|
| 773 | cd $make_depository |
---|
| 774 | cp $source_path/${program_name}_sources.tar . |
---|
| 775 | tar xf ${program_name}_sources.tar |
---|
[2380] | 776 | |
---|
| 777 | |
---|
[2566] | 778 | # FIRST CREATE EXECUTABLES FOR THE UTILITY ROUTINES |
---|
| 779 | if [[ $silent = false ]] |
---|
| 780 | then |
---|
[2380] | 781 | echo " " |
---|
| 782 | echo " *** creating utilities on local host" |
---|
[2566] | 783 | fi |
---|
[3312] | 784 | make -f Makefile_utilities $make_options F90=$compiler_name F90_SER=$compiler_name_ser COPT="$cpp_options" F90FLAGS="$compiler_options" LDFLAGS="$linker_options" | tee ${configuration_identifier}_last_make_protocol |
---|
[2380] | 785 | |
---|
[3312] | 786 | if [[ ${PIPESTATUS[0]} != 0 ]] |
---|
| 787 | then |
---|
| 788 | printf "\a\n +++ error(s) occurred during compiling of the utilities for host configuration \"$configuration_identifier\" " |
---|
| 789 | if [[ $silent = false ]] |
---|
| 790 | then |
---|
| 791 | answer=dummy |
---|
| 792 | printf "\n" |
---|
| 793 | while [[ "$answer" != c && "$answer" != k ]] |
---|
| 794 | do |
---|
| 795 | printf " >>> continue / list errors / kill palmbuild (c/l/k) ? " |
---|
| 796 | read answer |
---|
| 797 | if [[ "$answer" = l ]] |
---|
| 798 | then |
---|
| 799 | more ${configuration_identifier}_last_make_protocol |
---|
| 800 | fi |
---|
| 801 | done |
---|
| 802 | if [[ $answer = k ]] |
---|
| 803 | then |
---|
| 804 | locat=user_abort; exit |
---|
| 805 | fi |
---|
| 806 | else |
---|
| 807 | # ABORT ANYWAY |
---|
| 808 | locat=user_abort; exit |
---|
| 809 | fi |
---|
| 810 | else |
---|
| 811 | cp agent_preprocessing $source_path/../SCRIPTS/. |
---|
| 812 | fi |
---|
[2380] | 813 | |
---|
[3312] | 814 | |
---|
[2566] | 815 | # CALL MAKE ON LOCAL HOST USING THE OPTIONS DETERMINED FURTHER ABOVE |
---|
| 816 | if [[ $silent = false ]] |
---|
| 817 | then |
---|
[2380] | 818 | echo " " |
---|
| 819 | echo " *** compile PALM sources on local host" |
---|
[2566] | 820 | fi |
---|
[2380] | 821 | |
---|
[3236] | 822 | make $make_options PROG=$program_name F90=$compiler_name COPT="$cpp_options" F90FLAGS="$compiler_options" LDFLAGS="$linker_options" 2>&1 | tee ${configuration_identifier}_last_make_protocol |
---|
[2380] | 823 | |
---|
[3312] | 824 | if [[ ${PIPESTATUS[0]} != 0 ]] |
---|
[2566] | 825 | then |
---|
[3236] | 826 | printf "\a\n +++ error(s) occurred during compiling or linking for host configuration \"$configuration_identifier\" " |
---|
[2566] | 827 | if [[ $silent = false ]] |
---|
[2380] | 828 | then |
---|
[2566] | 829 | answer=dummy |
---|
| 830 | printf "\n" |
---|
| 831 | while [[ "$answer" != c && "$answer" != k ]] |
---|
| 832 | do |
---|
| 833 | printf " >>> continue / list errors / kill palmbuild (c/l/k) ? " |
---|
| 834 | read answer |
---|
| 835 | if [[ "$answer" = l ]] |
---|
[2380] | 836 | then |
---|
[3236] | 837 | more ${configuration_identifier}_last_make_protocol |
---|
[2380] | 838 | fi |
---|
[2566] | 839 | done |
---|
| 840 | if [[ $answer = k ]] |
---|
| 841 | then |
---|
[2487] | 842 | locat=user_abort; exit |
---|
[2380] | 843 | fi |
---|
[2566] | 844 | else |
---|
| 845 | # ABORT ANYWAY |
---|
| 846 | locat=user_abort; exit |
---|
[2380] | 847 | fi |
---|
[2566] | 848 | fi |
---|
[2380] | 849 | |
---|
| 850 | |
---|
[2566] | 851 | # TAR NEW VERSION ON LOCAL HOST |
---|
| 852 | if [[ $silent = false ]] |
---|
| 853 | then |
---|
[2380] | 854 | printf "\n *** tar update on local host ..." |
---|
[2566] | 855 | fi |
---|
| 856 | tar -cf ${program_name}_current_version.tar ${program_name} *.$suf *.o *.mod *.x |
---|
[2380] | 857 | |
---|
[2566] | 858 | else |
---|
[2380] | 859 | |
---|
[2566] | 860 | # NOW COMES THE BRANCH FOR CREATING THE EXECUTABLE FOR THE CURRENT RUN |
---|
| 861 | # INCLUDING E.G. USER-INTERFACE ROUTINES. ALSO ADD OTHER UTILITY EXECUTABLES. EVERYTHING IS |
---|
| 862 | # COLLECTED IN DIRECTORY SOURCES_FOR_RUN_... |
---|
[2380] | 863 | |
---|
[2566] | 864 | # FIRST CHECK, IF COMPILED SOURCES FOR THIS RUN IDENTIFIER EXISTS |
---|
| 865 | # AND ASK, IF THEY SHALL BE USED |
---|
| 866 | if [[ -d ${fast_io_catalog}/${sources_for_run_catalog} && $use_existing_sources_folder = true ]] |
---|
| 867 | then |
---|
[3236] | 868 | printf "\a\n *** compiled sources for run \"$run_identifier\" found on local host in folder" |
---|
[2566] | 869 | printf "\n ${fast_io_catalog}/${sources_for_run_catalog}" |
---|
| 870 | printf "\n will be used!" |
---|
| 871 | exit |
---|
| 872 | fi |
---|
[2489] | 873 | |
---|
[2566] | 874 | # SECOND CHECK, IF A DEPOSITORY EXISTS ON THE LOCAL MACHINE |
---|
| 875 | if [[ ! -d ${make_depository} ]] |
---|
| 876 | then |
---|
| 877 | printf "\n +++ directory for local make depository:" |
---|
| 878 | printf "\n $make_depository" |
---|
[3455] | 879 | printf "\n not found. Please run \"palmbuild -c $configuration_identifier\" " |
---|
[2566] | 880 | locat=make_depository; exit |
---|
| 881 | fi |
---|
[2380] | 882 | |
---|
| 883 | |
---|
[2566] | 884 | # COPY MAKE DEPOSITORY ON LOCAL MACHINE TO SOURCES_FOR_RUN_... |
---|
| 885 | if [[ $silent = false ]] |
---|
| 886 | then |
---|
[3236] | 887 | printf "\n *** copy MAKE_DEPOSITORY_${configuration_identifier} on local host to " |
---|
[2506] | 888 | printf "\n ${fast_io_catalog}/${sources_for_run_catalog} \n" |
---|
[2566] | 889 | fi |
---|
| 890 | rm -rf ${fast_io_catalog}/${sources_for_run_catalog} |
---|
| 891 | mkdir -p ${fast_io_catalog}/${sources_for_run_catalog} |
---|
| 892 | cp ${make_depository}/${program_name}_current_version.tar ${fast_io_catalog}/${sources_for_run_catalog} |
---|
| 893 | cd $fast_io_catalog/${sources_for_run_catalog} |
---|
| 894 | tar xf ${program_name}_current_version.tar |
---|
[2380] | 895 | |
---|
| 896 | |
---|
[2566] | 897 | # COPY CONTENTS OF SOURCES_FOR_RUN_... TO SOURCES_FOR_RUN_... |
---|
| 898 | # IN THE FAST_IO_CATALOG ON THE LOCAL MACHINE |
---|
| 899 | if [[ $silent = false ]] |
---|
| 900 | then |
---|
[2506] | 901 | printf "\n *** copy ${base_directory}/${sources_for_run_catalog} to" |
---|
| 902 | printf "\n ${fast_io_catalog}/${sources_for_run_catalog} on local host \n" |
---|
[2566] | 903 | fi |
---|
| 904 | cp ${base_directory}/${sources_for_run_catalog}/{*,.[!.]*} ${fast_io_catalog}/${sources_for_run_catalog} |
---|
[2380] | 905 | |
---|
| 906 | |
---|
[2566] | 907 | # CREATE EXECUTABLE FROM THE NEW/MODIFIED SOURCE FILES, IF THERE ARE ANY |
---|
| 908 | if [[ $(ls -1 ${base_directory}/${sources_for_run_catalog}/ | grep -c .$suf) != 0 ]] |
---|
| 909 | then |
---|
| 910 | |
---|
| 911 | if [[ $silent = false ]] |
---|
[2380] | 912 | then |
---|
| 913 | echo " *** execute \"make\" on local host" |
---|
[2566] | 914 | fi |
---|
| 915 | [[ "$login_init_cmd" != "" ]] && $login_init_cmd |
---|
| 916 | [[ "$module_commands" != "" ]] && $module_commands |
---|
[2380] | 917 | |
---|
[2566] | 918 | make $make_options PROG=$program_name F90=$compiler_name COPT="$cpp_options" F90FLAGS="$compiler_options" LDFLAGS="$linker_options" |
---|
[2380] | 919 | |
---|
[3312] | 920 | if [[ ${PIPESTATUS[0]} != 0 ]] |
---|
[2566] | 921 | then |
---|
| 922 | |
---|
[3236] | 923 | printf "\a\n +++ error(s) occurred during compiling or linking for host configuration \"$configuration_identifier\" " |
---|
[2566] | 924 | if [[ $silent = false ]] |
---|
[2380] | 925 | then |
---|
[2566] | 926 | answer=dummy |
---|
| 927 | printf "\n" |
---|
| 928 | while [[ "$answer" != c && "$answer" != k ]] |
---|
| 929 | do |
---|
| 930 | printf " >>> continue / kill palmbuild (c/k) ? " |
---|
| 931 | read answer |
---|
| 932 | done |
---|
| 933 | if [[ $answer = k ]] |
---|
[2380] | 934 | then |
---|
[2506] | 935 | rm -rf ${fast_io_catalog}/${sources_for_run_catalog} |
---|
[2487] | 936 | locat=user_abort; exit |
---|
[2380] | 937 | fi |
---|
[2566] | 938 | else |
---|
| 939 | # ABORT ANYWAY |
---|
| 940 | rm -rf ${fast_io_catalog}/${sources_for_run_catalog} |
---|
| 941 | locat=user_abort; exit |
---|
[2380] | 942 | fi |
---|
[2566] | 943 | fi |
---|
[2380] | 944 | |
---|
[2566] | 945 | else |
---|
[2380] | 946 | |
---|
[2566] | 947 | echo " *** nothing to compile for this run" |
---|
[2380] | 948 | |
---|
[2566] | 949 | fi |
---|
[2380] | 950 | |
---|
| 951 | fi |
---|
[2566] | 952 | fi |
---|