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