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