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