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