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