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