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