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