[2380] | 1 | #!/bin/bash |
---|
| 2 | |
---|
| 3 | # palmbuild - script for compiling the PALM code and its utility programs |
---|
| 4 | |
---|
| 5 | #------------------------------------------------------------------------------# |
---|
| 6 | # This file is part of PALM. |
---|
| 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 | # |
---|
| 19 | # Copyright 2017 Leibniz Universitaet Hannover |
---|
| 20 | #------------------------------------------------------------------------------# |
---|
| 21 | # |
---|
| 22 | # Current revisions: |
---|
| 23 | # ------------------ |
---|
| 24 | # |
---|
[2410] | 25 | # |
---|
[2380] | 26 | # Former revisions: |
---|
| 27 | # ----------------- |
---|
| 28 | # $Id: palmbuild 2420 2017-09-07 06:20:11Z raasch $ |
---|
[2412] | 29 | # |
---|
[2410] | 30 | # 2404 2017-09-05 09:33:14Z raasch |
---|
[2412] | 31 | # Initial revision |
---|
[2410] | 32 | # |
---|
[2380] | 33 | #------------------------------------------------------------------------------# |
---|
| 34 | # palmbuild - script for compiling the PALM code and its utility programs |
---|
| 35 | # |
---|
| 36 | # Procedure to compile code on local and remote hosts using the |
---|
| 37 | # make-mechanism. The source code must be provided on the local host. |
---|
| 38 | # |
---|
| 39 | # @note This script does not work on MAC OS |
---|
| 40 | #------------------------------------------------------------------------------# |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | # VARIABLE DECLARATIONS + DEFAULT VALUES |
---|
| 44 | calltime="" |
---|
| 45 | column1="" |
---|
| 46 | column2="" |
---|
[2420] | 47 | host_identifier=default |
---|
[2380] | 48 | locat=normal |
---|
| 49 | makefile="" |
---|
| 50 | make_options="" |
---|
| 51 | module_commands="" |
---|
| 52 | program_name=palm |
---|
| 53 | remote_ip="" |
---|
| 54 | silent=false |
---|
| 55 | ssh_key="" |
---|
| 56 | suf=f90 |
---|
[2384] | 57 | version="palmbuild 0.1 Rev$Rev: 2316 $" |
---|
[2380] | 58 | working_directory=`pwd` |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | # ERROR HANDLING |
---|
| 63 | # IN CASE OF EXIT: |
---|
| 64 | trap 'if [[ $locat != normal ]] |
---|
| 65 | then |
---|
| 66 | printf "\n\n +++ palmbuild killed \n\n" |
---|
| 67 | exit 1 |
---|
| 68 | else |
---|
| 69 | printf "\n\n *** palmbuild finished \n\n" |
---|
| 70 | exit 0 |
---|
| 71 | fi' exit |
---|
| 72 | |
---|
| 73 | |
---|
| 74 | # IN CASE OF TERMINAL-BREAK: |
---|
| 75 | trap 'printf "\n\n +++ palmbuild killed by \"^C\" \n\n" |
---|
| 76 | exit |
---|
| 77 | ' 2 |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | |
---|
| 81 | # READ SHELLSCRIPT-OPTIONS |
---|
| 82 | while getopts :d:h:m:s:S:uv option |
---|
| 83 | do |
---|
| 84 | case $option in |
---|
| 85 | (d) fname=$OPTARG;; |
---|
[2420] | 86 | (h) host_identifier=$OPTARG;; |
---|
[2380] | 87 | (m) makefile=$OPTARG;; |
---|
| 88 | (s) suf=$OPTARG;; |
---|
| 89 | (S) source_list="$OPTARG";; |
---|
| 90 | (v) silent=true;; |
---|
| 91 | (\?) printf "\n +++ unknown option $OPTARG \n"; |
---|
| 92 | locat=parameter; exit;; |
---|
| 93 | esac |
---|
| 94 | done |
---|
| 95 | |
---|
| 96 | |
---|
| 97 | # BUILD THE CONFIGURATION-FILE NAME |
---|
[2420] | 98 | config_file=.palm.config.$host_identifier |
---|
[2380] | 99 | |
---|
| 100 | |
---|
| 101 | # CHECK, IF CONFIGURATION-FILE EXISTS |
---|
| 102 | if [[ ! -f $config_file ]] |
---|
| 103 | then |
---|
| 104 | printf "\n +++ configuration file: " |
---|
| 105 | printf "\n $config_file" |
---|
| 106 | printf "\n does not exist" |
---|
| 107 | locat=configuration; exit |
---|
| 108 | fi |
---|
| 109 | |
---|
| 110 | |
---|
| 111 | # ### is this really required? |
---|
| 112 | config_file=$PWD/$config_file |
---|
| 113 | |
---|
| 114 | |
---|
| 115 | # READ VARIABLE SETTINGS FROM CONFIG FILE LINE BY LINE |
---|
| 116 | while read line |
---|
| 117 | do |
---|
| 118 | |
---|
| 119 | # FIRST REPLACE ENVIRONMENT-VARIABLES BY THEIR RESPECTIVE VALUES |
---|
| 120 | eval line=\"$line\" |
---|
| 121 | |
---|
| 122 | |
---|
| 123 | # INTERPRET THE LINE |
---|
| 124 | if [[ "$(echo $line)" = "" ]] |
---|
| 125 | then |
---|
| 126 | |
---|
| 127 | # EMPTY LINE, NO ACTION |
---|
| 128 | continue |
---|
| 129 | |
---|
| 130 | elif [[ "$(echo $line | cut -c1)" = "#" ]] |
---|
| 131 | then |
---|
| 132 | |
---|
| 133 | # LINE IS A COMMENT LINE |
---|
| 134 | continue |
---|
| 135 | |
---|
| 136 | elif [[ "$(echo $line | cut -c1)" = "%" ]] |
---|
| 137 | then |
---|
| 138 | |
---|
| 139 | # LINE DEFINES AN ENVIRONMENT-VARIABLE |
---|
| 140 | var=`echo $line | cut -d" " -s -f1 | cut -c2-` |
---|
| 141 | value=`echo $line | cut -d" " -s -f2-` |
---|
| 142 | |
---|
| 143 | # REPLACE ":" BY " " IN COMPILER- CPP- OR LINKER-OPTIONS, |
---|
| 144 | # "::" IS REPLACED BY ":". |
---|
| 145 | #value=`echo $value | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` |
---|
| 146 | |
---|
| 147 | |
---|
| 148 | # VALUE FROM THE CONFIGURATION-FILE IS ASSIGNED TO THE |
---|
| 149 | # ENVIRONMENT-VARIABLE, BUT ONLY IF NO VALUE HAS BEEN ALREADY |
---|
| 150 | # ASSIGNED WITHIN THIS SCRIPT (E.G. BY SCRIPT-OPTIONS). |
---|
| 151 | # NON-ASSIGNED VARIABLES HAVE VALUE "" OR 0 (IN CASE OF INTEGER). |
---|
| 152 | # HENCE THE GENERAL RULE IS: SCRIPT-OPTION OVERWRITES THE |
---|
| 153 | # CONFIGURATION-FILE. |
---|
| 154 | if [[ "$(eval echo \$$var)" = "" || "$(eval echo \$$var)" = "0" ]] |
---|
| 155 | then |
---|
| 156 | eval export $var="\$value" |
---|
| 157 | |
---|
| 158 | # TERMINAL OUTPUT OF ENVIRONMENT-VARIABLES, IF TRACEBACK IS SWITCHED on |
---|
| 159 | if [[ $do_trace = true ]] |
---|
| 160 | then |
---|
| 161 | printf "\n*** ENVIRONMENT-VARIABLE $var = $value" |
---|
| 162 | fi |
---|
| 163 | fi |
---|
| 164 | |
---|
| 165 | else |
---|
| 166 | |
---|
| 167 | # SKIP ALL OTHER LINES |
---|
| 168 | continue |
---|
| 169 | |
---|
| 170 | fi |
---|
| 171 | |
---|
| 172 | done < $config_file |
---|
| 173 | |
---|
| 174 | |
---|
[2404] | 175 | # CHECK, IF THE BASE DIRECTORY PATH HAS BEEN GIVEN |
---|
| 176 | if [[ "$base_directory" = "" ]] |
---|
| 177 | then |
---|
| 178 | printf "\n +++ no base directory found in configuration file" |
---|
| 179 | locat=config_file; exit |
---|
| 180 | else |
---|
| 181 | if [[ ! -d $base_directory ]] |
---|
| 182 | then |
---|
| 183 | printf "\n\n +++ base directory \"$base_directory\" " |
---|
| 184 | printf "\n does not exist" |
---|
| 185 | locat=source_path; exit |
---|
| 186 | fi |
---|
| 187 | fi |
---|
| 188 | |
---|
| 189 | |
---|
[2380] | 190 | # CHECK SOURCE-CODE PATH |
---|
| 191 | if [[ "$source_path" = "" ]] |
---|
| 192 | then |
---|
| 193 | printf "\n +++ no source path found in configuration file" |
---|
| 194 | locat=config_file; exit |
---|
| 195 | else |
---|
| 196 | if [[ ! -d $source_path ]] |
---|
| 197 | then |
---|
| 198 | printf "\n\n +++ source path \"$source_path\" " |
---|
| 199 | printf "\n does not exist" |
---|
| 200 | locat=source_path; exit |
---|
| 201 | fi |
---|
| 202 | fi |
---|
| 203 | |
---|
| 204 | |
---|
| 205 | # CHECK MAKEFILE |
---|
| 206 | [[ "$makefile" = "" ]] && makefile=$source_path/Makefile |
---|
| 207 | if [[ ! -f $makefile ]] |
---|
| 208 | then |
---|
| 209 | printf "\n +++ makefile: " |
---|
| 210 | printf "\n $makefile" |
---|
| 211 | printf "\n does not exist" |
---|
| 212 | locat=makefile; exit |
---|
| 213 | fi |
---|
| 214 | |
---|
| 215 | |
---|
| 216 | # CHECK COMPILERNAME |
---|
| 217 | if [[ "$compiler_name" = "" ]] |
---|
| 218 | then |
---|
| 219 | printf "\n +++ no compiler name found in configuration file" |
---|
| 220 | locat=config_file; exit |
---|
| 221 | fi |
---|
| 222 | |
---|
| 223 | |
---|
| 224 | # CHECK SERIAL COMPILERNAME |
---|
| 225 | if [[ "$compiler_name_ser" = "" ]] |
---|
| 226 | then |
---|
| 227 | printf "\n +++ no compiler name for serial compilation in configuration file" |
---|
| 228 | locat=config_file; exit |
---|
| 229 | fi |
---|
| 230 | |
---|
| 231 | |
---|
| 232 | # DETERMINE SSH-KEY TO BE USED |
---|
| 233 | if [[ "$ssh_key" != "" ]] |
---|
| 234 | then |
---|
| 235 | ssh_key="-i $HOME/.ssh/`echo $line | cut -d" " -s -f2`" |
---|
| 236 | fi |
---|
| 237 | |
---|
| 238 | |
---|
| 239 | #CHECK CPP-OPTIONS |
---|
| 240 | if [[ "$cpp_options" = "" ]] |
---|
| 241 | then |
---|
| 242 | printf "\n +++ WARNING: no cpp-options found in configuration file" |
---|
| 243 | fi |
---|
| 244 | |
---|
| 245 | |
---|
| 246 | # CHECK SETTINGS IN CASE OF COMPILING ON REMOTE MACHINE |
---|
| 247 | if [[ "$remote_ip" != "" ]] |
---|
| 248 | then |
---|
| 249 | |
---|
| 250 | if [[ "$remote_username" = "" ]] |
---|
| 251 | then |
---|
| 252 | printf "\n +++ no user name given in configuration file" |
---|
| 253 | locat=config_file; exit |
---|
| 254 | fi |
---|
| 255 | |
---|
| 256 | # GET SOURCE AND DEPOSITORY PATH ON THE REMOTE MACHINE WITHOUT EVALUATING |
---|
| 257 | # THE $ |
---|
| 258 | # IF NOT GIVEN, USE THE LOCAL SOURCE AND DEPOSITORY PATH |
---|
| 259 | line=`grep %remote_source_path $config_file` |
---|
| 260 | if [[ "$line" != "" ]] |
---|
| 261 | then |
---|
| 262 | remote_source_path=`echo $line | cut -d" " -s -f2` |
---|
| 263 | else |
---|
| 264 | line=`grep %source_path $config_file` |
---|
| 265 | remote_source_path=`echo $line | cut -d" " -s -f2` |
---|
| 266 | fi |
---|
| 267 | |
---|
[2404] | 268 | line=`grep %base_directory $config_file` |
---|
[2420] | 269 | make_depository=`echo $line | cut -d" " -s -f2`/MAKE_DEPOSITORY_${host_identifier} |
---|
[2380] | 270 | |
---|
| 271 | else |
---|
| 272 | |
---|
[2420] | 273 | make_depository=${base_directory}/MAKE_DEPOSITORY_${host_identifier} |
---|
[2380] | 274 | |
---|
| 275 | fi |
---|
| 276 | |
---|
| 277 | # HEADER-OUTPUT (PART1: MESSAGES CONCERNING THE LOCAL HOST) |
---|
| 278 | calltime=$(date) |
---|
| 279 | printf "\n" |
---|
| 280 | printf "#------------------------------------------------------------------------# \n" |
---|
| 281 | printf "| %-40s%30s | \n" "$version" "$calltime" |
---|
| 282 | printf "| | \n" |
---|
[2420] | 283 | printf "| %-13s%-57s | \n" "called on:" "$(hostname) (IP:$local_ip)" |
---|
[2380] | 284 | column2=$(echo $config_file | cut -c1-57 ) |
---|
| 285 | printf "| %-13s%-57s | \n" "config file:" "$column2" |
---|
| 286 | line=$(echo "$config_file" | cut -c58-) |
---|
| 287 | while [[ "$line" != "" ]] |
---|
| 288 | do |
---|
| 289 | column1="" |
---|
| 290 | column2=$(echo $line | cut -c1-57 ) |
---|
| 291 | printf "| %-13s%-57s | \n" "$column1" "$column2" |
---|
| 292 | line=$(echo "$line" | cut -c58-) |
---|
| 293 | done |
---|
| 294 | column2=$(echo $makefile | cut -c1-57 ) |
---|
| 295 | printf "| %-13s%-57s | \n" "makefile:" "$column2" |
---|
| 296 | line=$(echo "$makefile" | cut -c58-) |
---|
| 297 | while [[ "$line" != "" ]] |
---|
| 298 | do |
---|
| 299 | column1="" |
---|
| 300 | column2=$(echo $line | cut -c1-57 ) |
---|
| 301 | printf "| %-13s%-57s | \n" "$column1" "$column2" |
---|
| 302 | line=$(echo "$line" | cut -c58-) |
---|
| 303 | done |
---|
| 304 | column2=$(echo $source_path | cut -c1-57 ) |
---|
| 305 | printf "| %-13s%-57s | \n" "source path:" "$column2" |
---|
| 306 | line=$(echo "$source_path" | cut -c58-) |
---|
| 307 | while [[ "$line" != "" ]] |
---|
| 308 | do |
---|
| 309 | column1="" |
---|
| 310 | column2=$(echo $line | cut -c1-57 ) |
---|
| 311 | printf "| %-13s%-57s | \n" "$column1" "$column2" |
---|
| 312 | line=$(echo "$line" | cut -c58-) |
---|
| 313 | done |
---|
| 314 | printf "#------------------------------------------------------------------------# \n" |
---|
| 315 | |
---|
| 316 | |
---|
| 317 | |
---|
| 318 | # TAR THE SOURCES AND MAKEFILES |
---|
| 319 | # UTILITIES ARE TEMPORARILY COPIED TO THE SOURCE DIRECTORY IN ORDER TO TAR |
---|
| 320 | # THEM TOO |
---|
| 321 | cd $source_path |
---|
| 322 | printf "\n\n *** tar of makefile and source files in" |
---|
| 323 | printf "\n $source_path" |
---|
| 324 | cp -p ../UTIL/combine_plot_fields.f90 . |
---|
| 325 | cp -p ../UTIL/compare_palm_logs.f90 . |
---|
| 326 | cp -p ../UTIL/Makefile_utilities . |
---|
| 327 | tar -cf ${program_name}_sources.tar Makefile* *.$suf |
---|
| 328 | rm combine_plot_fields.f90 compare_palm_logs.f90 Makefile_utilities |
---|
| 329 | printf "\n" |
---|
| 330 | |
---|
| 331 | |
---|
| 332 | |
---|
| 333 | # GET CONFIRMATION TO CONTINUE |
---|
[2420] | 334 | printf "\n *** update will be made for host \"$host_identifier\" " |
---|
[2380] | 335 | |
---|
| 336 | |
---|
| 337 | if [[ $silent = false ]] |
---|
| 338 | then |
---|
| 339 | answer=dummy |
---|
| 340 | printf "\n\n" |
---|
| 341 | while [[ "$answer" != y && "$answer" != Y && "$answer" != n && "$answer" != N ]] |
---|
| 342 | do |
---|
| 343 | printf " >>> continue (y/n) ? " |
---|
| 344 | read answer |
---|
| 345 | done |
---|
| 346 | if [[ $answer = n || $answer = N ]] |
---|
| 347 | then |
---|
| 348 | locat=user_abort; exit |
---|
| 349 | fi |
---|
| 350 | fi |
---|
| 351 | |
---|
| 352 | |
---|
| 353 | |
---|
| 354 | |
---|
| 355 | printf "\n\n#------------------------------------------------------------------------# \n" |
---|
| 356 | |
---|
| 357 | if [[ "$remote_ip" != "" ]] |
---|
| 358 | then |
---|
[2420] | 359 | column2="$host_identifier" |
---|
| 360 | printf "| %-20s%-50s | \n" "host identifier:" "$column2" |
---|
[2380] | 361 | printf "| | \n" |
---|
[2404] | 362 | column2=$(echo "$make_depository" | cut -c1-50 ) |
---|
[2380] | 363 | printf "| %-20s%-50s | \n" "remote depository:" "$column2" |
---|
| 364 | else |
---|
[2420] | 365 | column2="$host_identifier" |
---|
| 366 | printf "| %-20s%-50s | \n" "host identifier:" "$column2" |
---|
[2380] | 367 | printf "| | \n" |
---|
[2404] | 368 | column2=$(echo "$make_depository" | cut -c1-50 ) |
---|
[2380] | 369 | printf "| %-20s%-50s | \n" "local depository:" "$column2" |
---|
| 370 | fi |
---|
[2404] | 371 | line=$(echo "$make_depository" | cut -c51-) |
---|
| 372 | while [[ "$line" != "" ]] |
---|
| 373 | do |
---|
| 374 | column1="" |
---|
| 375 | column2=$(echo "$line" | cut -c1-50 ) |
---|
| 376 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
| 377 | line=$(echo "$line" | cut -c51-) |
---|
| 378 | done |
---|
[2380] | 379 | |
---|
| 380 | if [[ "$remote_ip" != "" ]] |
---|
| 381 | then |
---|
| 382 | printf "| %-20s%-50s | \n" "remote username:" "$remote_username" |
---|
| 383 | printf "| %-20s%-50s | \n" "remote address:" "$remote_ip" |
---|
| 384 | else |
---|
| 385 | printf "| %-20s%-50s | \n" "username:" "$local_username" |
---|
| 386 | printf "| %-20s%-50s | \n" "address:" "$local_ip" |
---|
| 387 | fi |
---|
| 388 | |
---|
| 389 | printf "| %-20s%-50s | \n" "compiler:" "$compiler_name" |
---|
| 390 | printf "| %-20s%-50s | \n" "serial compiler:" "$compiler_name_ser" |
---|
| 391 | |
---|
| 392 | if [[ "$make_options" != "" ]] |
---|
| 393 | then |
---|
| 394 | printf "| %-20s%-50s | \n" "make options:" "$make_options" |
---|
| 395 | fi |
---|
| 396 | column2=$(echo "$cpp_options" | cut -c1-50 ) |
---|
| 397 | printf "| %-20s%-50s | \n" "cpp options:" "$column2" |
---|
| 398 | line=$(echo "$cpp_options" | cut -c51-) |
---|
| 399 | while [[ "$line" != "" ]] |
---|
| 400 | do |
---|
| 401 | column1="" |
---|
| 402 | column2=$(echo "$line" | cut -c1-50 ) |
---|
| 403 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
| 404 | line=$(echo "$line" | cut -c51-) |
---|
| 405 | done |
---|
| 406 | column2=$(echo "$compiler_options" | cut -c1-50 ) |
---|
| 407 | printf "| %-20s%-50s | \n" "compiler options:" "$column2" |
---|
| 408 | line=$(echo "$compiler_options" | cut -c51-) |
---|
| 409 | while [[ "$line" != "" ]] |
---|
| 410 | do |
---|
| 411 | column1="" |
---|
| 412 | column2=$(echo "$line" | cut -c1-50 ) |
---|
| 413 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
| 414 | line=$(echo "$line" | cut -c51-) |
---|
| 415 | done |
---|
[2388] | 416 | column2=$(echo "$linker_options" | cut -c1-50 ) |
---|
| 417 | printf "| %-20s%-50s | \n" "linker options:" "$column2" |
---|
| 418 | line=$(echo "$linker_options" | cut -c51-) |
---|
[2380] | 419 | while [[ "$line" != "" ]] |
---|
| 420 | do |
---|
| 421 | column1="" |
---|
| 422 | column2=$(echo "$line" | cut -c1-50 ) |
---|
| 423 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
| 424 | line=$(echo "$line" | cut -c51-) |
---|
| 425 | done |
---|
| 426 | if [[ "$login_init_cmd" != "" ]] |
---|
| 427 | then |
---|
| 428 | column2=$(echo "$login_init_cmd" | cut -c1-50 ) |
---|
| 429 | printf "| %-20s%-50s | \n" "login init command:" "$column2" |
---|
| 430 | line=$(echo "$login_init_cmd" | 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 |
---|
| 438 | fi |
---|
| 439 | if [[ "$module_commands" != "" ]] |
---|
| 440 | then |
---|
| 441 | column2=$(echo "$module_commands" | cut -c1-50 ) |
---|
| 442 | printf "| %-20s%-50s | \n" "module command(s):" "$column2" |
---|
| 443 | line=$(echo "$module_commands" | cut -c51-) |
---|
| 444 | while [[ "$line" != "" ]] |
---|
| 445 | do |
---|
| 446 | column1="" |
---|
| 447 | column2=$(echo "$line" | cut -c1-50 ) |
---|
| 448 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
| 449 | line=$(echo "$line" | cut -c51-) |
---|
| 450 | done |
---|
| 451 | fi |
---|
| 452 | printf "#------------------------------------------------------------------------# \n" |
---|
| 453 | |
---|
| 454 | if [[ $silent = false ]] |
---|
| 455 | then |
---|
| 456 | answer=dummy |
---|
| 457 | printf "\n\n" |
---|
| 458 | while [[ "$answer" != y && "$answer" != Y && "$answer" != c && "$answer" != C && "$answer" != s && "$answer" != S && "$answer" != a && "$answer" != A ]] |
---|
| 459 | do |
---|
[2412] | 460 | printf " >>> continue (y(es)/c(ontinue)/a(bort)) ? " |
---|
[2380] | 461 | read answer |
---|
| 462 | done |
---|
| 463 | if [[ $answer = a || $answer = A ]] |
---|
| 464 | then |
---|
| 465 | locat=user_abort; exit |
---|
| 466 | fi |
---|
| 467 | if [[ $answer = c || $answer = C ]] |
---|
| 468 | then |
---|
| 469 | silent=true |
---|
| 470 | fi |
---|
| 471 | fi |
---|
| 472 | |
---|
| 473 | |
---|
| 474 | # MAKE ON REMOTE HOST |
---|
| 475 | if [[ "$remote_ip" != "" ]] |
---|
| 476 | then |
---|
| 477 | |
---|
| 478 | # NEXT IS THE BRANCH FOR CREATING THE MAKE_DEPOSITORY_... |
---|
| 479 | if [[ "$fname" = "" ]] |
---|
| 480 | then |
---|
| 481 | |
---|
| 482 | # COPY CURRENT SOURCE CODE TO SOURCE-CODE DIRECTORY ON THE REMOTE HOST |
---|
| 483 | # CREATE THIS DIRECTORY, IF IT DOES NOT EXIST |
---|
[2404] | 484 | echo " *** copying \"${program_name}_sources.tar\" to \"${remote_ip}:${make_depository}/\" " |
---|
| 485 | echo "[[ ! -d ${make_depository} ]] && (echo \" *** ${make_depository} will be created\"; mkdir -p ${make_depository})" | ssh -q $ssh_key ${remote_username}@${remote_ip} 2>&1 |
---|
[2380] | 486 | |
---|
[2404] | 487 | scp $ssh_key ${source_path}/${program_name}_sources.tar ${remote_username}@${remote_ip}:${make_depository}/${program_name}_sources.tar |
---|
[2380] | 488 | |
---|
| 489 | |
---|
| 490 | |
---|
| 491 | # UNTAR PREVIOUS UPDATE ON REMOTE HOST, IF EXISTING |
---|
| 492 | echo " *** untar previous update on remote host, if existing" |
---|
[2404] | 493 | 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 |
---|
[2380] | 494 | |
---|
| 495 | |
---|
| 496 | # UNTAR CURRENT SOURCES ON REMOTE HOST |
---|
| 497 | echo " *** untar current sources on remote host" |
---|
[2404] | 498 | echo "cd ${make_depository}; tar -xf ${program_name}_sources.tar" | ssh -q $ssh_key ${remote_username}@${remote_ip} 2>&1 |
---|
[2380] | 499 | |
---|
| 500 | |
---|
| 501 | # CREATE INIT AND MODULE COAMMNDS |
---|
| 502 | [[ "$login_init_cmd" != "" ]] && login_init_cmd=${login_init_cmd}";" |
---|
| 503 | [[ "$module_commands" != "" ]] && module_commands=${module_commands}";" |
---|
| 504 | |
---|
| 505 | |
---|
| 506 | # FIRST CREATE EXECUTABLES FOR THE UTILITY ROUTINES |
---|
| 507 | echo " " |
---|
| 508 | echo " *** creating utilities on remote host" |
---|
[2388] | 509 | 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\" " |
---|
[2420] | 510 | 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 ${host_identifier}_last_make_protokoll |
---|
[2380] | 511 | |
---|
[2420] | 512 | if [[ $(grep -c MAKE_ERROR ${host_identifier}_last_make_protokoll) != 0 ]] |
---|
[2380] | 513 | then |
---|
| 514 | printf "\a\n +++ error(s) occurred during compiling or linking of utilities" |
---|
[2420] | 515 | printf "\n for host \"$host_identifier\" " |
---|
[2380] | 516 | if [[ $silent = false ]] |
---|
| 517 | then |
---|
| 518 | answer=dummy |
---|
| 519 | printf "\n" |
---|
| 520 | while [[ "$answer" != c && "$answer" != k ]] |
---|
| 521 | do |
---|
| 522 | printf " >>> continue / list errors / kill palmbuild (c/l/k) ? " |
---|
| 523 | read answer |
---|
| 524 | if [[ "$answer" = l ]] |
---|
| 525 | then |
---|
[2420] | 526 | more ${host_identifier}_last_make_protokoll |
---|
[2380] | 527 | fi |
---|
| 528 | done |
---|
| 529 | if [[ $answer = k ]] |
---|
| 530 | then |
---|
| 531 | locat=user_abort; exit |
---|
| 532 | fi |
---|
| 533 | fi |
---|
| 534 | fi |
---|
| 535 | |
---|
| 536 | |
---|
| 537 | # NOW COMPILE THE PALM CODE |
---|
| 538 | # COMMANDS WILL BE COMMUNICATED TO SSH VIA PIPE, SINCE THIS WAY THE SYSTEM- AND |
---|
| 539 | # USER-PROFILES OF THE SHELL ARE COMPLETELY EXECUTED (OTHERWISE, MAKE |
---|
| 540 | # MAY E.G. MISS THE COMPILER-PATHS) |
---|
| 541 | echo " " |
---|
| 542 | echo " *** compile PALM sources on remote host" |
---|
[2388] | 543 | make_call_string="make $make_options PROG=$program_name F90=$compiler_name COPT=\"$cpp_options\" F90FLAGS=\"$compiler_options\" LDFLAGS=\"$linker_options\" " |
---|
[2420] | 544 | 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 ${host_identifier}_last_make_protokoll |
---|
[2380] | 545 | |
---|
[2420] | 546 | if [[ $(grep -c MAKE_ERROR ${host_identifier}_last_make_protokoll) != 0 ]] |
---|
[2380] | 547 | then |
---|
[2420] | 548 | printf "\a\n +++ error(s) occurred during compiling or linking for host \"$host_identifier\" " |
---|
[2380] | 549 | if [[ $silent = false ]] |
---|
| 550 | then |
---|
| 551 | answer=dummy |
---|
| 552 | printf "\n" |
---|
| 553 | while [[ "$answer" != c && "$answer" != k ]] |
---|
| 554 | do |
---|
| 555 | printf " >>> continue / list errors / kill palmbuild (c/l/k) ? " |
---|
| 556 | read answer |
---|
| 557 | if [[ "$answer" = l ]] |
---|
| 558 | then |
---|
[2420] | 559 | more ${host_identifier}_last_make_protokoll |
---|
[2380] | 560 | fi |
---|
| 561 | done |
---|
| 562 | if [[ $answer = k ]] |
---|
| 563 | then |
---|
| 564 | locat=user_abort; exit |
---|
| 565 | fi |
---|
| 566 | fi |
---|
| 567 | fi |
---|
| 568 | |
---|
| 569 | # TAR UPDATED VERSION ON THE REMOTE HOST |
---|
| 570 | printf "\n *** tar update on remote host ..." |
---|
[2404] | 571 | 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 |
---|
[2380] | 572 | |
---|
| 573 | |
---|
| 574 | # NOW COMES THE BRANCH FOR CREATING THE EXECUTABLE FOR THE CURRENT RUN |
---|
| 575 | # INCLUDING E.G. USER-INTERFACE ROUTINES. ALSO ADD OTHER UTILITY EXECUTABLES. EVERYTHING IS |
---|
| 576 | # COLLECTED IN DIRECTORY SOURCES_FOR_RUN_... |
---|
| 577 | elif [[ "$fname" != "" ]] |
---|
| 578 | then |
---|
| 579 | |
---|
| 580 | # FIRST CHECK, IF A DEPOSITORY EXISTS ON THE REMOTE MACHINE |
---|
[2420] | 581 | echo "[[ ! -d ${make_depository} ]] && echo depository not found" | ssh -q $ssh_key ${remote_username}@${remote_ip} 2>&1 | tee ${host_identifier}_last_make_protokoll |
---|
[2380] | 582 | |
---|
| 583 | |
---|
| 584 | # COPY MAKE DEPOSITORY ON REMOTE MACHINE TO SOURCES_FOR_RUN_... |
---|
[2420] | 585 | printf "\n *** copy MAKE_DEPOSITORY_${host_identifier} on remote host to SOURCES_FOR_RUN_$fname \n" |
---|
[2404] | 586 | echo "rm -rf $fast_io_catalog/SOURCES_FOR_RUN_$fname; mkdir -p $fast_io_catalog/SOURCES_FOR_RUN_$fname; cp ${make_depository}/${program_name}_current_version.tar $fast_io_catalog/SOURCES_FOR_RUN_$fname; cd $fast_io_catalog/SOURCES_FOR_RUN_$fname; tar xf ${program_name}_current_version.tar" | ssh -q $ssh_key ${remote_username}@${remote_ip} 2>&1 |
---|
[2380] | 587 | |
---|
| 588 | |
---|
| 589 | # COPY CONTENTS OF SOURCES_FOR_RUN_... TO SOURCES_FOR_RUN_... ON THE REMOTE MACHINE |
---|
[2420] | 590 | printf "\n *** copy $base_directory/SOURCES_FOR_RUN_$fname" |
---|
| 591 | printf "\n to SOURCES_FOR_RUN_$fname on remote host \n" |
---|
[2404] | 592 | scp -q $ssh_key $base_directory/SOURCES_FOR_RUN_$fname/{*,.[!.]*} ${remote_username}@${remote_ip}:${fast_io_catalog}/SOURCES_FOR_RUN_$fname |
---|
[2380] | 593 | |
---|
| 594 | |
---|
| 595 | # CREATE EXECUTABLE FROM THE NEW/MODIFIED SOURCE FILES, IF THERE ARE ANY |
---|
| 596 | if [[ $(ls -1 $base_directory/SOURCES_FOR_RUN_$fname/ | grep -c .$suf) != 0 ]] |
---|
| 597 | then |
---|
| 598 | |
---|
[2388] | 599 | make_call_string="make $make_options PROG=$program_name F90=$compiler_name COPT=\"$cpp_options\" F90FLAGS=\"$compiler_options\" LDFLAGS=\"$linker_options\" " |
---|
[2380] | 600 | [[ "$login_init_cmd" != "" ]] && login_init_cmd=${login_init_cmd}";" |
---|
| 601 | [[ "$module_commands" != "" ]] && module_commands=${module_commands}";" |
---|
| 602 | echo " *** execute \"make\" on remote host" |
---|
[2420] | 603 | echo "$login_init_cmd $module_commands cd ${fast_io_catalog}/SOURCES_FOR_RUN_$fname; 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 ${host_identifier}_last_make_protokoll |
---|
[2380] | 604 | |
---|
[2420] | 605 | if [[ $(grep -c MAKE_ERROR ${host_identifier}_last_make_protokoll) != 0 ]] |
---|
[2380] | 606 | then |
---|
[2420] | 607 | printf "\a\n +++ error(s) occurred during compiling or linking for host \"$host_identifier\" " |
---|
[2380] | 608 | if [[ $silent = false ]] |
---|
| 609 | then |
---|
| 610 | answer=dummy |
---|
| 611 | printf "\n" |
---|
| 612 | while [[ "$answer" != c && "$answer" != k ]] |
---|
| 613 | do |
---|
| 614 | printf " >>> continue / list errors / kill palmbuild (c/l/k) ? " |
---|
| 615 | read answer |
---|
| 616 | if [[ "$answer" = l ]] |
---|
| 617 | then |
---|
[2420] | 618 | more ${host_identifier}_last_make_protokoll |
---|
[2380] | 619 | fi |
---|
| 620 | done |
---|
| 621 | if [[ $answer = k ]] |
---|
| 622 | then |
---|
| 623 | locat=user_abort; exit |
---|
| 624 | fi |
---|
| 625 | fi |
---|
| 626 | fi |
---|
| 627 | |
---|
| 628 | else |
---|
| 629 | |
---|
| 630 | echo " *** nothing to compile for this run" |
---|
| 631 | |
---|
| 632 | fi |
---|
| 633 | |
---|
| 634 | fi |
---|
| 635 | |
---|
[2420] | 636 | rm -rf ${host_identifier}_last_make_protokoll |
---|
[2380] | 637 | |
---|
| 638 | |
---|
| 639 | # MAKE ON LOCAL HOST |
---|
| 640 | else |
---|
| 641 | |
---|
| 642 | |
---|
| 643 | # NEXT IS THE BRANCH FOR CREATING THE MAKE_DEPOSITORY_... ON THE |
---|
| 644 | # LOCAL HOST |
---|
| 645 | if [[ "$fname" = "" ]] |
---|
| 646 | then |
---|
| 647 | |
---|
| 648 | # SET THE ENVIRONMENT (EXECUTE INIT AND MODULE COMMANDS) |
---|
| 649 | if [[ "$login_init_cmd" != "" ]] |
---|
| 650 | then |
---|
| 651 | $login_init_cmd |
---|
| 652 | fi |
---|
| 653 | |
---|
| 654 | if [[ "$module_commands" != "" ]] |
---|
| 655 | then |
---|
| 656 | $module_commands |
---|
| 657 | fi |
---|
| 658 | |
---|
| 659 | |
---|
| 660 | # CREATE MAKE-DEPOSITORY, IF IT DOES NOT EXIST |
---|
[2404] | 661 | eval make_depository=$make_depository |
---|
| 662 | if [[ ! -d $make_depository ]] |
---|
[2380] | 663 | then |
---|
[2404] | 664 | if mkdir -p $make_depository |
---|
[2380] | 665 | then |
---|
| 666 | printf "\n\n *** directory for local make depository:" |
---|
[2404] | 667 | printf "\n $make_depository" |
---|
[2380] | 668 | printf "\n was created\n" |
---|
| 669 | else |
---|
| 670 | printf "\n +++ directory for local make depository:" |
---|
[2404] | 671 | printf "\n $make_depository" |
---|
[2380] | 672 | printf "\n cannot be created" |
---|
[2404] | 673 | locat=local_depository; exit |
---|
[2380] | 674 | fi |
---|
| 675 | fi |
---|
| 676 | |
---|
| 677 | # COPY SOURCE-CODE FROM REPOSITORY TO MAKE-DEPOSITORY |
---|
| 678 | echo " " |
---|
| 679 | echo " *** untar current source sources on local host in" |
---|
[2404] | 680 | echo " $make_depository" |
---|
| 681 | cd $make_depository |
---|
[2380] | 682 | cp $source_path/${program_name}_sources.tar . |
---|
| 683 | tar xf ${program_name}_sources.tar |
---|
| 684 | |
---|
| 685 | |
---|
| 686 | # FIRST CREATE EXECUTABLES FOR THE UTILITY ROUTINES |
---|
| 687 | echo " " |
---|
| 688 | echo " *** creating utilities on local host" |
---|
[2388] | 689 | make -f Makefile_utilities $make_options F90=$compiler_name F90_SER=$compiler_name_ser COPT="$cpp_options" F90FLAGS="$compiler_options" LDFLAGS="$linker_options" |
---|
[2380] | 690 | |
---|
| 691 | |
---|
| 692 | # CALL MAKE ON LOCAL HOST USING THE OPTIONS DETERMINED FURTHER ABOVE |
---|
| 693 | echo " " |
---|
| 694 | echo " *** compile PALM sources on local host" |
---|
| 695 | |
---|
[2420] | 696 | make $make_options PROG=$program_name F90=$compiler_name COPT="$cpp_options" F90FLAGS="$compiler_options" LDFLAGS="$linker_options" 2>&1 | tee ${host_identifier}_last_make_protokoll |
---|
[2380] | 697 | |
---|
| 698 | if [[ $? != 0 ]] |
---|
| 699 | then |
---|
[2420] | 700 | printf "\a\n +++ error(s) occurred during compiling or linking for host \"$host_identifier\" " |
---|
[2380] | 701 | if [[ $silent = false ]] |
---|
| 702 | then |
---|
| 703 | answer=dummy |
---|
| 704 | printf "\n" |
---|
| 705 | while [[ "$answer" != c && "$answer" != k ]] |
---|
| 706 | do |
---|
| 707 | printf " >>> continue / list errors / kill palmbuild (c/l/k) ? " |
---|
| 708 | read answer |
---|
| 709 | if [[ "$answer" = l ]] |
---|
| 710 | then |
---|
[2420] | 711 | more ${host_identifier}_last_make_protokoll |
---|
[2380] | 712 | fi |
---|
| 713 | done |
---|
| 714 | if [[ $answer = k ]] |
---|
| 715 | then |
---|
| 716 | locat=user_abort; exit |
---|
| 717 | fi |
---|
| 718 | fi |
---|
| 719 | fi |
---|
| 720 | |
---|
| 721 | |
---|
| 722 | # TAR NEW VERSION ON LOCAL HOST |
---|
| 723 | printf "\n *** tar update on local host ..." |
---|
| 724 | tar -cf ${program_name}_current_version.tar ${program_name} *.$suf *.o *.mod *.x |
---|
| 725 | |
---|
| 726 | else |
---|
| 727 | |
---|
| 728 | # NOW COMES THE BRANCH FOR CREATING THE EXECUTABLE FOR THE CURRENT RUN |
---|
| 729 | # INCLUDING E.G. USER-INTERFACE ROUTINES. ALSO ADD OTHER UTILITY EXECUTABLES. EVERYTHING IS |
---|
| 730 | # COLLECTED IN DIRECTORY SOURCES_FOR_RUN_... |
---|
| 731 | |
---|
| 732 | # FIRST CHECK, IF A DEPOSITORY EXISTS ON THE LOCAL MACHINE |
---|
[2404] | 733 | if [[ ! -d ${make_depository} ]] |
---|
[2380] | 734 | then |
---|
| 735 | printf "\n +++ directory for local make depository:" |
---|
[2404] | 736 | printf "\n $make_depository" |
---|
[2420] | 737 | printf "\n not found. Please run \"palmbuild -h $host_identifier\" " |
---|
[2404] | 738 | locat=make_depository; exit |
---|
[2380] | 739 | fi |
---|
| 740 | |
---|
| 741 | |
---|
| 742 | # COPY MAKE DEPOSITORY ON LOCAL MACHINE TO SOURCES_FOR_RUN_... |
---|
[2420] | 743 | printf "\n *** copy MAKE_DEPOSITORY_${host_identifier} on local host to " |
---|
[2404] | 744 | printf "\n $fast_io_catalog/SOURCES_FOR_RUN_$fname \n" |
---|
| 745 | rm -rf $fast_io_catalog/SOURCES_FOR_RUN_$fname |
---|
| 746 | mkdir -p $fast_io_catalog/SOURCES_FOR_RUN_$fname |
---|
| 747 | cp ${make_depository}/${program_name}_current_version.tar $fast_io_catalog/SOURCES_FOR_RUN_$fname |
---|
| 748 | cd $fast_io_catalog/SOURCES_FOR_RUN_$fname |
---|
[2380] | 749 | tar xf ${program_name}_current_version.tar |
---|
| 750 | |
---|
| 751 | |
---|
| 752 | # COPY CONTENTS OF SOURCES_FOR_RUN_... TO SOURCES_FOR_RUN_... |
---|
[2404] | 753 | # IN THE FAST_IO_CATALOG ON THE LOCAL MACHINE |
---|
[2380] | 754 | printf "\n *** copy $base_directory/SOURCES_FOR_RUN_$fname to" |
---|
[2404] | 755 | printf "\n $fast_io_catalog/SOURCES_FOR_RUN_$fname on local host \n" |
---|
[2412] | 756 | cp $base_directory/SOURCES_FOR_RUN_$fname/{*,.[!.]*} ${fast_io_catalog}/SOURCES_FOR_RUN_$fname |
---|
[2380] | 757 | |
---|
| 758 | |
---|
| 759 | # CREATE EXECUTABLE FROM THE NEW/MODIFIED SOURCE FILES, IF THERE ARE ANY |
---|
| 760 | if [[ $(ls -1 $base_directory/SOURCES_FOR_RUN_$fname/ | grep -c .$suf) != 0 ]] |
---|
| 761 | then |
---|
| 762 | |
---|
| 763 | echo " *** execute \"make\" on local host" |
---|
| 764 | [[ "$login_init_cmd" != "" ]] && $login_init_cmd |
---|
| 765 | [[ "$module_commands" != "" ]] && $module_commands |
---|
| 766 | |
---|
[2388] | 767 | make $make_options PROG=$program_name F90=$compiler_name COPT="$cpp_options" F90FLAGS="$compiler_options" LDFLAGS="$linker_options" |
---|
[2380] | 768 | |
---|
| 769 | if [[ \$? != 0 ]] |
---|
| 770 | then |
---|
| 771 | |
---|
[2420] | 772 | printf "\a\n +++ error(s) occurred during compiling or linking for host \"$host_identifier\" " |
---|
[2380] | 773 | if [[ $silent = false ]] |
---|
| 774 | then |
---|
| 775 | answer=dummy |
---|
| 776 | printf "\n" |
---|
| 777 | while [[ "$answer" != c && "$answer" != k ]] |
---|
| 778 | do |
---|
| 779 | printf " >>> continue / list errors / kill palmbuild (c/k) ? " |
---|
| 780 | read answer |
---|
| 781 | done |
---|
| 782 | if [[ $answer = k ]] |
---|
| 783 | then |
---|
| 784 | locat=user_abort; exit |
---|
| 785 | fi |
---|
| 786 | fi |
---|
| 787 | fi |
---|
| 788 | |
---|
| 789 | else |
---|
| 790 | |
---|
| 791 | echo " *** nothing to compile for this run" |
---|
| 792 | |
---|
| 793 | fi |
---|
| 794 | |
---|
| 795 | fi |
---|
| 796 | fi |
---|