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