[1841] | 1 | #!/bin/bash |
---|
[1046] | 2 | |
---|
[1090] | 3 | # mbuild - script for compiling the PALM code and its utility programs |
---|
| 4 | |
---|
[1046] | 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 | # |
---|
[1310] | 19 | # Copyright 1997-2014 Leibniz Universitaet Hannover |
---|
[1046] | 20 | #--------------------------------------------------------------------------------# |
---|
| 21 | # |
---|
| 22 | # Current revisions: |
---|
[1090] | 23 | # ------------------ |
---|
[1351] | 24 | # |
---|
[1945] | 25 | # |
---|
[1046] | 26 | # Former revisions: |
---|
| 27 | # ----------------- |
---|
[1047] | 28 | # $Id: mbuild 2365 2017-08-21 14:59:59Z basit $ |
---|
[2365] | 29 | # Added lckea & lckeam. KIT/IMK-IFU Garmisch cluster. LRZ (SadiqHuq) |
---|
| 30 | # |
---|
| 31 | # 2316 2017-07-20 07:53:42Z maronga |
---|
[2316] | 32 | # Removed qmake block as mrungui now runs as a python script |
---|
| 33 | # |
---|
| 34 | # 2257 2017-06-07 14:07:05Z witha |
---|
[2257] | 35 | # adjustments for lceddy, removed lcflow-specific code |
---|
| 36 | # |
---|
| 37 | # 1945 2016-06-15 07:17:24Z raasch |
---|
[1945] | 38 | # |
---|
| 39 | # 1944 2016-06-15 06:29:00Z raasch |
---|
| 40 | # adjustments for using HLRN ssh-keys |
---|
| 41 | # |
---|
[1842] | 42 | # 1841 2016-04-07 19:14:06Z raasch |
---|
| 43 | # script now running under bash |
---|
| 44 | # |
---|
[1818] | 45 | # 1817 2016-04-06 15:44:20Z maronga |
---|
| 46 | # Bugfix: Makefile_check removed (parameter file check) |
---|
| 47 | # |
---|
[1805] | 48 | # 1804 2016-04-05 16:30:18Z maronga |
---|
| 49 | # Removed parameter file check |
---|
| 50 | # |
---|
[1653] | 51 | # 1652 2015-09-17 08:12:24Z raasch |
---|
| 52 | # bugfix for terminal output of configuration settings removed, |
---|
| 53 | # output of login init commands |
---|
| 54 | # |
---|
[1623] | 55 | # 1621 2015-07-17 11:39:33Z heinze |
---|
[1621] | 56 | # adjustments for Mistral at DKRZ Hamburg (lcbullhh) |
---|
[1047] | 57 | # |
---|
[1614] | 58 | # 1613 2015-07-08 14:53:29Z maronga |
---|
| 59 | # nc2vdf removed |
---|
| 60 | # |
---|
[1548] | 61 | # 1547 2015-01-29 15:09:12Z witha |
---|
| 62 | # adjustments for ForWind computing cluster (lcflow) |
---|
| 63 | # |
---|
[1488] | 64 | # 1487 2014-10-25 14:36:28Z raasch |
---|
| 65 | # bash compatibility adjustments: output formatting with printf instead |
---|
| 66 | # of "typeset -L/-R", print replaced by echo |
---|
| 67 | # |
---|
[1469] | 68 | # 1468 2014-09-24 14:06:57Z maronga |
---|
| 69 | # Typo removed (addres->address) |
---|
| 70 | # Adjustments for lcxe6 |
---|
| 71 | # |
---|
[1391] | 72 | # 1390 2014-05-06 07:57:37Z maronga |
---|
| 73 | # disabled compilation of parameter file check (currently not working), |
---|
| 74 | # adjustments for lcxe6 |
---|
| 75 | # |
---|
[1389] | 76 | # 1388 2014-05-06 07:42:38Z maronga |
---|
| 77 | # small adjustments for lcxe6 |
---|
| 78 | # |
---|
[1351] | 79 | # 1350 2014-04-04 13:01:30Z maronga |
---|
[1388] | 80 | # init_cmds is now executed before module calls in case of compilation on local |
---|
[1351] | 81 | # host |
---|
| 82 | # |
---|
[1290] | 83 | # 1289 2014-03-04 07:12:34Z raasch |
---|
| 84 | # comments translated from German to English |
---|
| 85 | # fimm-, scirocco-, ibmy-, and sgi-specific code removed |
---|
| 86 | # |
---|
[1275] | 87 | # 1274 2014-01-09 13:14:54Z heinze |
---|
| 88 | # adjustments for lccrayh |
---|
| 89 | # |
---|
[1256] | 90 | # 1255 2013-11-07 14:43:35Z raasch |
---|
| 91 | # further adjustments for lccrayb remote access |
---|
| 92 | # |
---|
[1230] | 93 | # 1229 2013-09-20 06:55:19Z raasch |
---|
| 94 | # adjustments for lccrayb |
---|
| 95 | # |
---|
[1217] | 96 | # 1216 2013-08-26 09:31:42Z raasch |
---|
[1230] | 97 | # RCS renamed SOURCES |
---|
[1217] | 98 | # |
---|
[1211] | 99 | # 1210 2013-08-14 10:58:20Z raasch |
---|
| 100 | # fftw support added |
---|
| 101 | # |
---|
[1210] | 102 | # 1197 2013-07-04 06:19:45Z raasch |
---|
| 103 | # adjustments for CSC Helsinki (lccrayf) |
---|
| 104 | # |
---|
[1100] | 105 | # 1099 2013-02-10 01:47:43Z raasch |
---|
| 106 | # adjustments for Forwind cluster (lcflow) |
---|
| 107 | # |
---|
[1096] | 108 | # 1096 2013-02-03 01:52:12Z raasch |
---|
| 109 | # decalpha parts (yonsei) removed |
---|
| 110 | # |
---|
[1091] | 111 | # 2013-02-02 07:06:13Z raasch |
---|
| 112 | # adjustments for Kyushu-University computing center (lckyut) |
---|
| 113 | # old changelog messages removed |
---|
| 114 | # |
---|
[1084] | 115 | # 1083 2013-01-04 10:22:09Z maronga |
---|
| 116 | # bugfix in parameter file check (in case that no preprocessor flag, i.e. -cpp was |
---|
| 117 | # set in %cpp_options, the last directive in the variable was processed. |
---|
| 118 | # |
---|
| 119 | # 1081 2013-01-03 08:44:36Z maronga |
---|
[1082] | 120 | # loader options set for parameter file check_depository_path |
---|
| 121 | # |
---|
[1070] | 122 | # 1069 2012-11-28 16:18:43Z maronga |
---|
| 123 | # added copy of nc2vdf tools to remote host_found |
---|
| 124 | # |
---|
[1047] | 125 | # 1046 2012-11-09 14:38:45Z maronga |
---|
| 126 | # code put under GPL (PALM 3.9) |
---|
| 127 | # |
---|
[1090] | 128 | # 12/06/02 - Siggi - first version finished |
---|
| 129 | # 06/05/02 - Siggi - script development started |
---|
| 130 | # |
---|
| 131 | #--------------------------------------------------------------------------------# |
---|
[503] | 132 | # mbuild - script for compiling the PALM code and its utility programs |
---|
[1090] | 133 | # |
---|
| 134 | # Procedure to compile code on local and remote hosts using the |
---|
| 135 | # make-mechanism. The source code must be provided on the local host. |
---|
[1826] | 136 | # |
---|
| 137 | # @note This script does not work on MAC OS |
---|
[1090] | 138 | #--------------------------------------------------------------------------------# |
---|
[1] | 139 | |
---|
| 140 | |
---|
[503] | 141 | # VARIABLE DECLARATIONS + DEFAULT VALUES |
---|
[936] | 142 | block_conditions=none |
---|
| 143 | block_conditions_found=false |
---|
[1488] | 144 | calltime="" |
---|
| 145 | column1="" |
---|
| 146 | column2="" |
---|
[22] | 147 | compile_utility_programs=false |
---|
[1] | 148 | config_file=.mrun.config |
---|
| 149 | host=all |
---|
| 150 | host_found=false |
---|
| 151 | locat=normal |
---|
| 152 | makefile="" |
---|
[493] | 153 | module_calls="" |
---|
[811] | 154 | util_compiled_localhost=false |
---|
[1] | 155 | silent=false |
---|
| 156 | suf=f90 |
---|
| 157 | update=false |
---|
[1488] | 158 | version="MBUILD 2.1 Rev$Rev: 2365 $" |
---|
[83] | 159 | working_directory=`pwd` |
---|
[1] | 160 | |
---|
| 161 | typeset -i ih ihost=0 |
---|
| 162 | |
---|
| 163 | |
---|
[503] | 164 | # ERROR HANDLING |
---|
| 165 | # IN CASE OF EXIT: |
---|
[83] | 166 | trap 'rm -rf $working_directory/tmp_mbuild |
---|
[69] | 167 | if [[ $locat != normal ]] |
---|
[1] | 168 | then |
---|
| 169 | printf "\n\n +++ mbuild killed \n\n" |
---|
| 170 | else |
---|
| 171 | printf "\n\n *** mbuild finished \n\n" |
---|
| 172 | fi' exit |
---|
| 173 | |
---|
| 174 | |
---|
[503] | 175 | # IN CASE OF TERMINAL-BREAK: |
---|
[83] | 176 | trap 'rm -rf $working_directory/tmp_mbuild |
---|
[69] | 177 | printf "\n\n +++ mbuild killed by \"^C\" \n\n" |
---|
[1] | 178 | exit |
---|
| 179 | ' 2 |
---|
| 180 | |
---|
| 181 | |
---|
[215] | 182 | tmp_mbuild=${working_directory}/tmp_mbuild |
---|
[1] | 183 | |
---|
[503] | 184 | # READ SHELLSCRIPT-OPTIONS |
---|
[936] | 185 | while getopts :c:h:K:m:s:uv option |
---|
[1] | 186 | do |
---|
| 187 | case $option in |
---|
| 188 | (c) config_file=$OPTARG;; |
---|
| 189 | (h) host=$OPTARG;; |
---|
[936] | 190 | (K) block_conditions=$OPTARG;; |
---|
[1] | 191 | (m) makefile=$OPTARG;; |
---|
| 192 | (s) suf=$OPTARG;; |
---|
[22] | 193 | (u) compile_utility_programs=true;; |
---|
[935] | 194 | (v) silent=true;; |
---|
[1] | 195 | (\?) printf "\n +++ unknown option $OPTARG \n"; |
---|
| 196 | locat=parameter; exit;; |
---|
| 197 | esac |
---|
| 198 | done |
---|
| 199 | |
---|
| 200 | |
---|
| 201 | |
---|
[503] | 202 | # CHECK, IF CONFIGURATION-FILE EXISTS |
---|
[82] | 203 | if [[ ! -f $config_file ]] |
---|
| 204 | then |
---|
| 205 | printf "\n +++ configuration file: " |
---|
| 206 | printf "\n $config_file" |
---|
| 207 | printf "\n does not exist" |
---|
| 208 | locat=configuration; exit |
---|
| 209 | fi |
---|
| 210 | |
---|
| 211 | |
---|
| 212 | |
---|
[503] | 213 | # DETERMINE THE LOCAL HOST |
---|
[1] | 214 | local_host_real_name=$(hostname) |
---|
[1487] | 215 | local_address=$(nslookup `hostname` 2>&1 | grep "Address:" | tail -1 | awk '{echo $2}') |
---|
[69] | 216 | |
---|
[1] | 217 | |
---|
[82] | 218 | |
---|
[503] | 219 | # DETERMINE HOST-IDENTIFIER (local_host) FROM THE CONFIG-FILE |
---|
[82] | 220 | line="" |
---|
[215] | 221 | grep "%host_identifier" $config_file > $tmp_mbuild |
---|
[82] | 222 | while read line |
---|
| 223 | do |
---|
[116] | 224 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
[82] | 225 | then |
---|
| 226 | HOSTNAME=`echo $line | cut -d" " -s -f2` |
---|
| 227 | host_identifier=`echo $line | cut -d" " -s -f3` |
---|
[83] | 228 | if [[ $local_host_real_name = $HOSTNAME ]] |
---|
[82] | 229 | then |
---|
| 230 | local_host=$host_identifier |
---|
| 231 | break |
---|
| 232 | fi |
---|
| 233 | fi |
---|
[215] | 234 | done < $tmp_mbuild |
---|
[82] | 235 | |
---|
| 236 | if [[ "$local_host" = "" ]] |
---|
| 237 | then |
---|
| 238 | printf "\n +++ no host identifier found in configuration file \"$config_file\"" |
---|
| 239 | printf "\n for local host \"$local_host_real_name\"." |
---|
| 240 | printf "\n Please add line" |
---|
| 241 | printf "\n \"\%host_identifier $local_host_real_name <identifier>\"" |
---|
| 242 | printf "\n to the configuration file." |
---|
| 243 | locat=local_host; exit |
---|
| 244 | fi |
---|
| 245 | |
---|
| 246 | |
---|
[1] | 247 | if [[ $local_host != ibms ]] |
---|
| 248 | then |
---|
| 249 | config_file=$PWD/$config_file |
---|
| 250 | else |
---|
| 251 | config_file=`pwd`/$config_file |
---|
| 252 | fi |
---|
| 253 | |
---|
| 254 | |
---|
[1289] | 255 | # DETERMINE THE BLOCK CONDITIONS |
---|
[936] | 256 | if [[ $block_conditions != none ]] |
---|
| 257 | then |
---|
| 258 | block_condition1=`echo $block_conditions | cut -d" " -f1` |
---|
| 259 | block_condition2=`echo $block_conditions | cut -d" " -f2` |
---|
| 260 | if [[ "$block_condition2" = "$block_condition1" ]] |
---|
| 261 | then |
---|
| 262 | block_condition2="" |
---|
| 263 | fi |
---|
| 264 | fi |
---|
| 265 | |
---|
[1] | 266 | |
---|
[503] | 267 | # DETERMINE USER NAME ON LOCAL HOST FROM THE CONFIG-FILE |
---|
[1] | 268 | line="" |
---|
[215] | 269 | grep " $local_host" $config_file | grep "%remote_username" > $tmp_mbuild |
---|
[69] | 270 | while read line |
---|
[1] | 271 | do |
---|
[116] | 272 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
[1] | 273 | then |
---|
| 274 | local_username=`echo $line | cut -d" " -s -f2` |
---|
| 275 | fi |
---|
[215] | 276 | done < $tmp_mbuild |
---|
[1] | 277 | |
---|
[82] | 278 | |
---|
[1] | 279 | if [[ "$local_username" = "" ]] |
---|
| 280 | then |
---|
| 281 | printf "\n +++ no user name found in configuration file" |
---|
| 282 | printf "\n for local host \"$local_host\" " |
---|
| 283 | locat=config_file; exit |
---|
| 284 | fi |
---|
| 285 | |
---|
| 286 | |
---|
[503] | 287 | # DETERMINE LOCAL SOURCE-CODE PATH. |
---|
| 288 | # FIRST CHECK, IF A GLOBAL SOURCE-CODE PATH HAS BEEN DECLARED FOR ALL HOSTS. |
---|
| 289 | # THEREFORE, FIRST SET ALL GLOBAL VARIABLES DECLARED IN THE CONFIG-FILE, |
---|
| 290 | # BECAUSE THEY MAY BE USED AS PART OF THE PATH NAME. |
---|
[5] | 291 | line="" |
---|
[215] | 292 | grep "%" $config_file > $tmp_mbuild |
---|
[69] | 293 | while read line |
---|
[5] | 294 | do |
---|
[116] | 295 | if [[ "$line" != "" && "$(echo $line | cut -d" " -s -f3)" = "" && $(echo $line | cut -c1) != "#" ]] |
---|
[1] | 296 | then |
---|
[5] | 297 | var=`echo $line | cut -d" " -s -f1 | cut -c2-` |
---|
| 298 | value=`echo $line | cut -d" " -s -f2` |
---|
[8] | 299 | eval export $var=\$value |
---|
[1] | 300 | fi |
---|
[215] | 301 | done < $tmp_mbuild |
---|
[1] | 302 | |
---|
[503] | 303 | # NOW CHECK, IF A GLOBAL SOURCE-CODE-PATH HAS BEEN DECLARED |
---|
[1] | 304 | line="" |
---|
[215] | 305 | grep "%source_path" $config_file > $tmp_mbuild |
---|
[69] | 306 | while read line |
---|
[1] | 307 | do |
---|
| 308 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
| 309 | then |
---|
| 310 | if [[ "$(echo $line | cut -d" " -s -f3)" = "" ]] |
---|
| 311 | then |
---|
| 312 | global_source_path=`echo $line | cut -d" " -s -f2` |
---|
| 313 | fi |
---|
| 314 | fi |
---|
[215] | 315 | done < $tmp_mbuild |
---|
[1] | 316 | |
---|
| 317 | line="" |
---|
[215] | 318 | grep " $local_host" $config_file | grep "%source_path" > $tmp_mbuild |
---|
[69] | 319 | while read line |
---|
[1] | 320 | do |
---|
| 321 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
| 322 | then |
---|
| 323 | local_source_path=`echo $line | cut -d" " -s -f2` |
---|
| 324 | fi |
---|
[215] | 325 | done < $tmp_mbuild |
---|
[1] | 326 | |
---|
| 327 | if [[ "$local_source_path" = "" ]] |
---|
| 328 | then |
---|
| 329 | if [[ "$global_source_path" != "" ]] |
---|
| 330 | then |
---|
| 331 | local_source_path=$global_source_path |
---|
| 332 | else |
---|
| 333 | printf "\n +++ no source path found in configuration file" |
---|
| 334 | printf "\n for local host \"$local_host\" " |
---|
| 335 | printf "\n please set \"\%source_path\" in configuration file" |
---|
| 336 | locat=config_file; exit |
---|
| 337 | fi |
---|
| 338 | fi |
---|
| 339 | eval local_source_path=$local_source_path |
---|
[8] | 340 | eval local_source_path=$local_source_path |
---|
[1] | 341 | |
---|
| 342 | |
---|
[215] | 343 | |
---|
[503] | 344 | # DETERMINE GLOBAL DEPOSITORY-PATH |
---|
[1] | 345 | line="" |
---|
[215] | 346 | grep "%depository_path" $config_file > $tmp_mbuild |
---|
[69] | 347 | while read line |
---|
[1] | 348 | do |
---|
| 349 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
| 350 | then |
---|
| 351 | if [[ "$(echo $line | cut -d" " -s -f3)" = "" ]] |
---|
| 352 | then |
---|
| 353 | global_depository_path=`echo $line | cut -d" " -s -f2` |
---|
| 354 | fi |
---|
| 355 | fi |
---|
[215] | 356 | done < $tmp_mbuild |
---|
[1] | 357 | |
---|
[807] | 358 | if [[ $found = false ]] |
---|
| 359 | then |
---|
| 360 | printf "\n +++ no \%depository_path found in" |
---|
| 361 | printf "\n $config_file" |
---|
| 362 | locat=depository_path; exit |
---|
| 363 | fi |
---|
[1] | 364 | |
---|
[503] | 365 | # CHECK, IF A MAIN PROGRAM HAS BEEN DEFINED IN THE CONFIG-FILE |
---|
[5] | 366 | if [[ $(grep -c "%mainprog" $config_file) != 1 ]] |
---|
| 367 | then |
---|
| 368 | printf "\n +++ no main program or more than one main program defined" |
---|
| 369 | printf "\n in configuration file" |
---|
| 370 | locat=configuration; exit |
---|
| 371 | else |
---|
| 372 | line=`grep "%mainprog" $config_file` |
---|
| 373 | if [[ "$line" = "" || $(echo $line | cut -c1) = "#" ]] |
---|
| 374 | then |
---|
| 375 | printf "\n +++ no main program defined in configuration file" |
---|
| 376 | locat=configuration; exit |
---|
| 377 | fi |
---|
| 378 | mainprog=`echo $line | cut -d" " -s -f2 | cut -d"." -f1` |
---|
| 379 | fi |
---|
| 380 | |
---|
| 381 | |
---|
| 382 | |
---|
[503] | 383 | # CHECK IF MAKEFILE EXITS |
---|
[1] | 384 | [[ "$makefile" = "" ]] && makefile=$local_source_path/Makefile |
---|
| 385 | if [[ ! -f $makefile ]] |
---|
| 386 | then |
---|
| 387 | printf "\n +++ makefile: " |
---|
| 388 | printf "\n $makefile" |
---|
| 389 | printf "\n does not exist" |
---|
| 390 | locat=makefile; exit |
---|
| 391 | fi |
---|
| 392 | |
---|
| 393 | |
---|
[503] | 394 | # HEADER-OUTPUT (PART1: MESSAGES CONCERNING THE LOCAL HOST) |
---|
[1] | 395 | calltime=$(date) |
---|
| 396 | printf "\n" |
---|
| 397 | printf "#------------------------------------------------------------------------# \n" |
---|
[1487] | 398 | printf "| %-40s%30s | \n" "$version" "$calltime" |
---|
[1] | 399 | printf "| | \n" |
---|
[1487] | 400 | printf "| %-20s%-50s | \n" "called on:" "$local_host_real_name" |
---|
| 401 | printf "| %-20s%-50s | \n" "local username:" "$local_username" |
---|
| 402 | printf "| %-20s%-50s | \n" "local IP-address:" "$local_address" |
---|
| 403 | column2=$(echo $config_file | cut -c1-50 ) |
---|
| 404 | printf "| %-20s%-50s | \n" "config file:" "$column2" |
---|
| 405 | line=$(echo "$config_file" | cut -c51-) |
---|
| 406 | while [[ "$line" != "" ]] |
---|
| 407 | do |
---|
| 408 | column1="" |
---|
| 409 | column2=$(echo $line | cut -c1-50 ) |
---|
| 410 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
| 411 | line=$(echo "$line" | cut -c51-) |
---|
| 412 | done |
---|
| 413 | column2=$(echo $makefile | cut -c1-50 ) |
---|
| 414 | printf "| %-20s%-50s | \n" "makefile:" "$column2" |
---|
| 415 | line=$(echo "$makefile" | cut -c51-) |
---|
| 416 | while [[ "$line" != "" ]] |
---|
| 417 | do |
---|
| 418 | column1="" |
---|
| 419 | column2=$(echo $line | cut -c1-50 ) |
---|
| 420 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
| 421 | line=$(echo "$line" | cut -c51-) |
---|
| 422 | done |
---|
| 423 | column2=$(echo $local_source_path | cut -c1-50 ) |
---|
| 424 | printf "| %-20s%-50s | \n" "local source path:" "$column2" |
---|
| 425 | line=$(echo "$local_source_path" | cut -c51-) |
---|
| 426 | while [[ "$line" != "" ]] |
---|
| 427 | do |
---|
| 428 | column1="" |
---|
| 429 | column2=$(echo $line | cut -c1-50 ) |
---|
| 430 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
| 431 | line=$(echo "$line" | cut -c51-) |
---|
| 432 | done |
---|
[1] | 433 | printf "#------------------------------------------------------------------------# \n" |
---|
| 434 | |
---|
| 435 | |
---|
[40] | 436 | if [[ $compile_utility_programs = false ]] |
---|
| 437 | then |
---|
[1] | 438 | |
---|
[503] | 439 | # IN ANY CASE, GIVE ALL FILES WRITE-PERMIT, IN ORDER TO AVOID PROBLEMS |
---|
| 440 | # WITH OVERWRITING FILES ON THE REMOTE HOST |
---|
[215] | 441 | cd $local_source_path |
---|
| 442 | printf "\n\n *** tar of makefile and source files in $local_source_path" |
---|
[40] | 443 | tar -cf ${mainprog}_sources.tar Makefile *.$suf |
---|
| 444 | printf "\n" |
---|
[1] | 445 | |
---|
[807] | 446 | else |
---|
| 447 | cd $local_source_path |
---|
| 448 | printf "\n\n *** tar of makefile and source files in $local_source_path" |
---|
| 449 | printf "\n" |
---|
[40] | 450 | fi |
---|
[1] | 451 | |
---|
| 452 | |
---|
[40] | 453 | |
---|
[503] | 454 | # GET CONFIRMATION TO CONTINUE |
---|
[1] | 455 | if [[ $host = all ]] |
---|
| 456 | then |
---|
| 457 | printf "\n *** updates will be made for ALL hosts found in" |
---|
| 458 | printf "\n the configuration file" |
---|
| 459 | else |
---|
| 460 | printf "\n *** update will be made for host \"$host\" " |
---|
| 461 | fi |
---|
| 462 | |
---|
| 463 | if [[ $silent = false ]] |
---|
| 464 | then |
---|
| 465 | answer=dummy |
---|
| 466 | printf "\n\n" |
---|
| 467 | while [[ "$answer" != y && "$answer" != Y && "$answer" != n && "$answer" != N ]] |
---|
| 468 | do |
---|
| 469 | printf " >>> continue (y/n) ? " |
---|
| 470 | read answer |
---|
| 471 | done |
---|
| 472 | if [[ $answer = n || $answer = N ]] |
---|
| 473 | then |
---|
| 474 | locat=user_abort; exit |
---|
| 475 | fi |
---|
| 476 | fi |
---|
| 477 | |
---|
| 478 | |
---|
| 479 | |
---|
| 480 | |
---|
[1289] | 481 | # GENERATE MODEL-VERSIONS FOR ALL HOST-BLOCKS |
---|
| 482 | # FOUND IN THE CONFIGURATION-FILE |
---|
[1] | 483 | printf "\n *** scanning configuration file for host(s) ..." |
---|
| 484 | |
---|
[215] | 485 | grep %fopts $config_file > $tmp_mbuild |
---|
[69] | 486 | while read line |
---|
[1] | 487 | do |
---|
[1289] | 488 | # SKIP COMMENT-LINES |
---|
[1] | 489 | [[ $(echo $line | cut -c1) = "#" ]] && continue |
---|
| 490 | (( ihost = ihost + 1 )) |
---|
| 491 | hostline[$ihost]="$line" |
---|
[215] | 492 | done < $tmp_mbuild |
---|
[1] | 493 | |
---|
| 494 | |
---|
| 495 | while (( ih < ihost )) |
---|
| 496 | do |
---|
| 497 | |
---|
| 498 | (( ih = ih + 1 )) |
---|
| 499 | |
---|
[1289] | 500 | # DETERMINE REMOTE HOST AND CONDITIONS FOR THE RESPECTIVE BLOCK |
---|
| 501 | # CONTINUE, ONLY IF THIS HOST HAS BEEN CHOSEN VIA -h OPTION AND IF |
---|
| 502 | # CONDITIONS HAVE BEEN CHOSEN VIA -K OPTION |
---|
[1] | 503 | remote_host_string=`echo ${hostline[$ih]} | cut -d" " -s -f3-` |
---|
| 504 | remote_host=`echo $remote_host_string | cut -d" " -f1` |
---|
| 505 | if [[ $host != all ]] |
---|
| 506 | then |
---|
| 507 | [[ $remote_host != $host ]] && continue |
---|
| 508 | fi |
---|
| 509 | host_found=true |
---|
| 510 | condition1=`echo $remote_host_string | cut -d" " -s -f2` |
---|
| 511 | if [[ $condition1 = $remote_host ]] |
---|
| 512 | then |
---|
| 513 | condition1="" |
---|
| 514 | else |
---|
| 515 | condition2=`echo $remote_host_string | cut -d" " -s -f3` |
---|
| 516 | fi |
---|
| 517 | |
---|
[936] | 518 | if [[ $block_conditions != none ]] |
---|
| 519 | then |
---|
| 520 | if [[ "$condition1" != "$block_condition1" || "$condition2" != "$block_condition2" ]] |
---|
| 521 | then |
---|
| 522 | continue |
---|
| 523 | fi |
---|
| 524 | block_conditions_found=true |
---|
| 525 | fi |
---|
| 526 | |
---|
[1210] | 527 | fftw_inc="" |
---|
| 528 | fftw_lib="" |
---|
[493] | 529 | modules="" |
---|
[82] | 530 | netcdf_inc="" |
---|
| 531 | netcdf_lib="" |
---|
[784] | 532 | make_options="" |
---|
[1] | 533 | |
---|
[1289] | 534 | # DETERMINE IP-ADDRES OF THE REMOTE-HOST |
---|
[1] | 535 | case $remote_host in |
---|
[2365] | 536 | (lcbwuni) remote_address="129.13.82.89";; |
---|
[1620] | 537 | (lcbullhh) remote_address=136.172.50.13;; |
---|
[1468] | 538 | (lccrayb) remote_address=130.73.233.1;; |
---|
| 539 | (lccrayh) remote_address=130.75.4.1;; |
---|
[980] | 540 | (lckordi) remote_adress=210.219.61.8;; |
---|
[1468] | 541 | (lcmuk) remote_address=130.75.105.2;; |
---|
| 542 | (lcrte) remote_address=133.5.185.60;; |
---|
| 543 | (lcsb) remote_address=147.46.30.151;; |
---|
| 544 | (lck) remote_address=165.132.26.61;; |
---|
| 545 | (lckiaps) remote_address=118.128.66.223;; |
---|
| 546 | (lckyut) remote_address=133.5.4.37;; |
---|
[2365] | 547 | (lclrz) remote_address=129.187.20.240;; |
---|
| 548 | (lckea*) remote_address=172.27.80.109;; |
---|
[1468] | 549 | (lctit) remote_address=10.1.6.170;; |
---|
| 550 | (lcxe6) remote_address=129.177.20.113;; |
---|
| 551 | (lcxt5m) remote_address=193.166.211.144;; |
---|
| 552 | (ibmh) remote_address=136.172.40.15;; |
---|
| 553 | (ibmkisti) remote_address=150.183.146.24;; |
---|
| 554 | (ibmku) remote_address=133.5.4.129;; |
---|
[2365] | 555 | (ibmmuc) remote_address=129.187.11.197;; |
---|
[1468] | 556 | (ibms) remote_address=150.183.5.101;; |
---|
| 557 | (nech) remote_address=136.172.44.192;; |
---|
| 558 | (neck) remote_address=133.5.178.11;; |
---|
| 559 | (ground.yonsei.ac.kr) remote_address=134.75.155.33;; |
---|
[83] | 560 | (*) if [[ $local_host != $remote_host ]] |
---|
[1] | 561 | then |
---|
[83] | 562 | printf "\n +++ remote host \"$remote_host\" unknown"; |
---|
[503] | 563 | printf "\n please inform PALM group support!" |
---|
[1040] | 564 | locat=remote_host; exit |
---|
[1] | 565 | fi;; |
---|
| 566 | esac |
---|
| 567 | |
---|
| 568 | |
---|
[1289] | 569 | # DETERMINE REMOTE-USERNAME |
---|
[1] | 570 | line="" |
---|
[116] | 571 | found=false |
---|
[215] | 572 | grep "$remote_host_string" $config_file | grep "%remote_username" > $tmp_mbuild |
---|
[69] | 573 | while read line1 |
---|
[1] | 574 | do |
---|
[116] | 575 | |
---|
[1] | 576 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
| 577 | then |
---|
| 578 | line="$line1" |
---|
| 579 | fi |
---|
[116] | 580 | |
---|
| 581 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
| 582 | then |
---|
| 583 | remote_username=`echo $line | cut -d" " -s -f2` |
---|
| 584 | found=true |
---|
| 585 | fi |
---|
| 586 | |
---|
[215] | 587 | done < $tmp_mbuild |
---|
[1] | 588 | |
---|
[116] | 589 | if [[ $found = false ]] |
---|
[1] | 590 | then |
---|
| 591 | printf "\n +++ no remote username found in configuration file" |
---|
| 592 | printf "\n for \"$remote_host_string\" " |
---|
| 593 | locat=config_file; exit |
---|
| 594 | fi |
---|
| 595 | |
---|
| 596 | |
---|
[1289] | 597 | # DETERMINE REMOTE-SOURCE-CODE-PATH |
---|
[1] | 598 | line="" |
---|
[54] | 599 | remote_source_path="" |
---|
[215] | 600 | grep "$remote_host_string" $config_file | grep "%source_path" > $tmp_mbuild |
---|
[69] | 601 | while read line1 |
---|
[1] | 602 | do |
---|
[116] | 603 | |
---|
[1] | 604 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
| 605 | then |
---|
| 606 | line="$line1" |
---|
| 607 | fi |
---|
[116] | 608 | |
---|
| 609 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
| 610 | then |
---|
| 611 | remote_source_path=`echo $line | cut -d" " -s -f2` |
---|
| 612 | fi |
---|
| 613 | |
---|
[215] | 614 | done < $tmp_mbuild |
---|
[1] | 615 | |
---|
| 616 | if [[ "$remote_source_path" = "" ]] |
---|
| 617 | then |
---|
| 618 | if [[ "$global_source_path" != "" ]] |
---|
| 619 | then |
---|
| 620 | remote_source_path=$global_source_path |
---|
| 621 | else |
---|
| 622 | printf "\n +++ no source path found in configuration file" |
---|
| 623 | printf "\n for \"$remote_host_string\" " |
---|
| 624 | locat=config_file; exit |
---|
| 625 | fi |
---|
| 626 | fi |
---|
| 627 | |
---|
[22] | 628 | remote_ud=${remote_source_path}/../UTIL |
---|
[24] | 629 | remote_ud=$(eval echo $remote_ud) |
---|
[1] | 630 | |
---|
[54] | 631 | |
---|
[1289] | 632 | # DETERMINE REMOTE-PATH FOR MAKE-DEPOSITORY |
---|
[54] | 633 | remote_md="" |
---|
[1] | 634 | line="" |
---|
[215] | 635 | grep "$remote_host_string" $config_file | grep "%depository_path" > $tmp_mbuild |
---|
[69] | 636 | while read line1 |
---|
[1] | 637 | do |
---|
[116] | 638 | |
---|
[1] | 639 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
| 640 | then |
---|
| 641 | line="$line1" |
---|
| 642 | fi |
---|
[116] | 643 | |
---|
| 644 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
| 645 | then |
---|
| 646 | remote_md=`echo $line | cut -d" " -s -f2` |
---|
| 647 | fi |
---|
| 648 | |
---|
[215] | 649 | done < $tmp_mbuild |
---|
[1] | 650 | |
---|
| 651 | if [[ "$remote_md" = "" ]] |
---|
| 652 | then |
---|
| 653 | if [[ "$global_depository_path" != "" ]] |
---|
| 654 | then |
---|
| 655 | remote_md=$global_depository_path |
---|
| 656 | else |
---|
| 657 | printf "\n +++ no depository path found in configuration file" |
---|
| 658 | printf "\n for \"$remote_host_string\" " |
---|
| 659 | printf "\n please set \"\%depository_path\" in configuration file" |
---|
| 660 | locat=config_file; exit |
---|
| 661 | fi |
---|
| 662 | fi |
---|
| 663 | |
---|
[8] | 664 | remote_md=$(eval echo $remote_md) |
---|
[503] | 665 | block="" |
---|
| 666 | [[ "$condition1" != "" ]] && block=_$condition1 |
---|
| 667 | [[ "$condition2" != "" ]] && block=${block}_$condition2 |
---|
[508] | 668 | remote_md=${remote_md}$block |
---|
[1] | 669 | |
---|
[8] | 670 | |
---|
[1289] | 671 | # DETERMINE COMPILERNAME |
---|
[1] | 672 | line="" |
---|
[116] | 673 | found=false |
---|
[215] | 674 | grep "$remote_host_string" $config_file | grep "%compiler_name " > $tmp_mbuild |
---|
[69] | 675 | while read line1 |
---|
[1] | 676 | do |
---|
[116] | 677 | |
---|
[1] | 678 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
| 679 | then |
---|
| 680 | line="$line1" |
---|
| 681 | fi |
---|
[116] | 682 | |
---|
| 683 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
| 684 | then |
---|
| 685 | compiler_name=`echo $line | cut -d" " -s -f2` |
---|
| 686 | found=true |
---|
| 687 | fi |
---|
| 688 | |
---|
[215] | 689 | done < $tmp_mbuild |
---|
[1] | 690 | |
---|
[116] | 691 | if [[ $found = false ]] |
---|
[1] | 692 | then |
---|
| 693 | printf "\n +++ no compiler name found in configuration file" |
---|
| 694 | printf "\n for \"$remote_host_string\" " |
---|
| 695 | locat=config_file; exit |
---|
| 696 | fi |
---|
| 697 | |
---|
| 698 | |
---|
[1944] | 699 | # DETERMINE SSH-KEY TO BE USED |
---|
| 700 | ssh_key="" |
---|
| 701 | line="" |
---|
| 702 | grep "$remote_host_string" $config_file | grep "%ssh_key " > $tmp_mbuild |
---|
| 703 | while read line1 |
---|
| 704 | do |
---|
| 705 | |
---|
| 706 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
| 707 | then |
---|
| 708 | line="$line1" |
---|
| 709 | fi |
---|
| 710 | |
---|
| 711 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
| 712 | then |
---|
| 713 | ssh_key="-i $HOME/.ssh/`echo $line | cut -d" " -s -f2`" |
---|
| 714 | fi |
---|
| 715 | |
---|
| 716 | done < $tmp_mbuild |
---|
| 717 | |
---|
| 718 | |
---|
| 719 | |
---|
[1289] | 720 | # IN CASE OF PARALLEL EXECUTION (COMPILER FOR PARALLEL EXECUTION), |
---|
| 721 | # A SERIAL COMPILERNAME MUST BE DETERMINED ALSO |
---|
[27] | 722 | if [[ $(echo $remote_host_string | grep -c parallel) = 1 ]] |
---|
| 723 | then |
---|
| 724 | line="" |
---|
[116] | 725 | found=false |
---|
[215] | 726 | grep "$remote_host_string" $config_file | grep "%compiler_name_ser" > $tmp_mbuild |
---|
[69] | 727 | while read line1 |
---|
[27] | 728 | do |
---|
[116] | 729 | |
---|
[27] | 730 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
| 731 | then |
---|
| 732 | line="$line1" |
---|
| 733 | fi |
---|
[116] | 734 | |
---|
| 735 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
| 736 | then |
---|
| 737 | compiler_name_ser=`echo $line | cut -d" " -s -f2` |
---|
| 738 | found=true |
---|
| 739 | fi |
---|
| 740 | |
---|
[215] | 741 | done < $tmp_mbuild |
---|
[1] | 742 | |
---|
[116] | 743 | if [[ $found = false ]] |
---|
[27] | 744 | then |
---|
[28] | 745 | printf "\n +++ no serial compiler name found in configuration file" |
---|
[27] | 746 | printf "\n for \"$remote_host_string\" " |
---|
| 747 | locat=config_file; exit |
---|
| 748 | fi |
---|
| 749 | else |
---|
| 750 | compiler_name_ser=$compiler_name |
---|
| 751 | fi |
---|
| 752 | |
---|
| 753 | |
---|
| 754 | |
---|
[1289] | 755 | # DETERMINE PREPROCESSOR-OPTIONS AND DIRECTIVES |
---|
[82] | 756 | line="" |
---|
[116] | 757 | found=false |
---|
[215] | 758 | grep "$remote_host_string" $config_file | grep "%cpp_options" > $tmp_mbuild |
---|
[82] | 759 | while read line1 |
---|
| 760 | do |
---|
[116] | 761 | |
---|
[82] | 762 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
| 763 | then |
---|
| 764 | line="$line1" |
---|
| 765 | fi |
---|
[116] | 766 | |
---|
| 767 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
| 768 | then |
---|
[1289] | 769 | # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY |
---|
[116] | 770 | cpp_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` |
---|
| 771 | found=true |
---|
| 772 | fi |
---|
| 773 | |
---|
[215] | 774 | done < $tmp_mbuild |
---|
[116] | 775 | |
---|
| 776 | if [[ $found = false ]] |
---|
[82] | 777 | then |
---|
| 778 | printf "\n +++ no preprocessor options found in configuration file" |
---|
| 779 | printf "\n for \"$remote_host_string\" " |
---|
| 780 | locat=config_file; exit |
---|
| 781 | fi |
---|
| 782 | |
---|
[116] | 783 | |
---|
[1289] | 784 | # ADD HOST-SPECIFIC PREPROCESSOR-DIRECTIVES |
---|
[82] | 785 | for string in $remote_host_string |
---|
| 786 | do |
---|
| 787 | if [[ $(echo $remote_host | cut -c1-2) = lc && $(echo $string | cut -c1-2) = lc ]] |
---|
| 788 | then |
---|
| 789 | cpp_options="$cpp_options -D__lc " |
---|
[83] | 790 | elif [[ $(echo $remote_host | cut -c1-3) = ibm && $(echo $string | cut -c1-3) = ibm ]] |
---|
| 791 | then |
---|
[2365] | 792 | if [[ $remote_host = ibmmuc ]] |
---|
| 793 | then |
---|
| 794 | cpp_options="${cpp_options}" |
---|
| 795 | else |
---|
| 796 | cpp_options="${cpp_options},-D__ibm" |
---|
| 797 | fi |
---|
[83] | 798 | elif [[ $(echo $remote_host | cut -c1-3) = nec && $(echo $string | cut -c1-3) = nec ]] |
---|
| 799 | then |
---|
| 800 | cpp_options="${cpp_options} -D__nec" |
---|
[82] | 801 | else |
---|
[83] | 802 | if [[ $(echo $remote_host | cut -c1-3) = ibm ]] |
---|
| 803 | then |
---|
[2365] | 804 | if [[ $remote_host = ibmmuc ]] |
---|
| 805 | then |
---|
| 806 | cpp_options="${cpp_options} -D__parallel" |
---|
| 807 | else |
---|
| 808 | cpp_options="${cpp_options},-D__$string" |
---|
| 809 | fi |
---|
[83] | 810 | else |
---|
| 811 | cpp_options="$cpp_options -D__$string " |
---|
| 812 | fi |
---|
[82] | 813 | fi |
---|
| 814 | done |
---|
| 815 | |
---|
| 816 | |
---|
| 817 | |
---|
[1289] | 818 | # GET netCDF OPTIONS |
---|
[82] | 819 | line="" |
---|
[215] | 820 | grep "$remote_host_string" $config_file | grep "%netcdf_inc" > $tmp_mbuild |
---|
[82] | 821 | while read line1 |
---|
| 822 | do |
---|
[116] | 823 | |
---|
[82] | 824 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
| 825 | then |
---|
| 826 | line="$line1" |
---|
| 827 | fi |
---|
[116] | 828 | |
---|
| 829 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
| 830 | then |
---|
[1289] | 831 | # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY |
---|
[116] | 832 | netcdf_inc=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` |
---|
| 833 | fi |
---|
| 834 | |
---|
[215] | 835 | done < $tmp_mbuild |
---|
[82] | 836 | |
---|
| 837 | line="" |
---|
[215] | 838 | grep "$remote_host_string" $config_file | grep "%netcdf_lib" > $tmp_mbuild |
---|
[82] | 839 | while read line1 |
---|
| 840 | do |
---|
[116] | 841 | |
---|
[82] | 842 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
| 843 | then |
---|
| 844 | line="$line1" |
---|
| 845 | fi |
---|
[116] | 846 | |
---|
| 847 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
| 848 | then |
---|
[1289] | 849 | # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY |
---|
[116] | 850 | netcdf_lib=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` |
---|
| 851 | fi |
---|
| 852 | |
---|
[215] | 853 | done < $tmp_mbuild |
---|
[82] | 854 | |
---|
| 855 | |
---|
| 856 | |
---|
[1289] | 857 | # GET FFTW OPTIONS |
---|
[1210] | 858 | line="" |
---|
| 859 | grep "$remote_host_string" $config_file | grep "%fftw_inc" > $tmp_mbuild |
---|
| 860 | while read line1 |
---|
| 861 | do |
---|
| 862 | |
---|
| 863 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
| 864 | then |
---|
| 865 | line="$line1" |
---|
| 866 | fi |
---|
| 867 | |
---|
| 868 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
| 869 | then |
---|
[1289] | 870 | # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY |
---|
[1210] | 871 | fftw_inc=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` |
---|
| 872 | fi |
---|
| 873 | |
---|
| 874 | done < $tmp_mbuild |
---|
| 875 | |
---|
| 876 | line="" |
---|
| 877 | grep "$remote_host_string" $config_file | grep "%fftw_lib" > $tmp_mbuild |
---|
| 878 | while read line1 |
---|
| 879 | do |
---|
| 880 | |
---|
| 881 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
| 882 | then |
---|
| 883 | line="$line1" |
---|
| 884 | fi |
---|
| 885 | |
---|
| 886 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
| 887 | then |
---|
[1289] | 888 | # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY |
---|
[1210] | 889 | fftw_lib=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` |
---|
| 890 | fi |
---|
| 891 | |
---|
| 892 | done < $tmp_mbuild |
---|
| 893 | |
---|
| 894 | |
---|
| 895 | |
---|
[1289] | 896 | # GET MAKE OPTIONS |
---|
[475] | 897 | line="" |
---|
| 898 | found=false |
---|
| 899 | grep "$remote_host_string" $config_file | grep "%mopts" > $tmp_mbuild |
---|
| 900 | while read line1 |
---|
| 901 | do |
---|
| 902 | |
---|
| 903 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
| 904 | then |
---|
| 905 | line="$line1" |
---|
| 906 | fi |
---|
| 907 | |
---|
| 908 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
| 909 | then |
---|
[1289] | 910 | # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY |
---|
[475] | 911 | make_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` |
---|
| 912 | |
---|
| 913 | fi |
---|
| 914 | |
---|
| 915 | done < $tmp_mbuild |
---|
| 916 | |
---|
| 917 | |
---|
| 918 | |
---|
[1289] | 919 | # GET COMPILER OPTIONS |
---|
[1] | 920 | line="" |
---|
[116] | 921 | found=false |
---|
[215] | 922 | grep "$remote_host_string" $config_file | grep "%fopts" > $tmp_mbuild |
---|
[69] | 923 | while read line1 |
---|
[1] | 924 | do |
---|
[116] | 925 | |
---|
[1] | 926 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
| 927 | then |
---|
| 928 | line="$line1" |
---|
| 929 | fi |
---|
[116] | 930 | |
---|
| 931 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
| 932 | then |
---|
[1289] | 933 | # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY |
---|
[116] | 934 | compiler_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` |
---|
| 935 | found=true |
---|
| 936 | |
---|
[1289] | 937 | # ADD INCLUDE PATHS FOR netCDF AND FFTW |
---|
[1210] | 938 | compiler_options="$compiler_options $netcdf_inc $fftw_inc" |
---|
[116] | 939 | fi |
---|
| 940 | |
---|
[215] | 941 | done < $tmp_mbuild |
---|
[116] | 942 | |
---|
| 943 | if [[ $found = false ]] |
---|
[1] | 944 | then |
---|
| 945 | printf "\n +++ no compiler options found in configuration file" |
---|
| 946 | printf "\n for \"$remote_host_string\" " |
---|
| 947 | locat=config_file; exit |
---|
| 948 | fi |
---|
[82] | 949 | |
---|
[1] | 950 | |
---|
[1289] | 951 | # GET LOGIN INIT COMMANDS |
---|
[892] | 952 | line="" |
---|
| 953 | grep "$remote_host_string" $config_file | grep "%login_init_cmd" > $tmp_mbuild |
---|
| 954 | while read line1 |
---|
| 955 | do |
---|
[1] | 956 | |
---|
[892] | 957 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
| 958 | then |
---|
| 959 | line="$line1" |
---|
| 960 | fi |
---|
| 961 | |
---|
| 962 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
| 963 | then |
---|
[1289] | 964 | # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY |
---|
[892] | 965 | init_cmds=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` |
---|
[1255] | 966 | init_cmds="${init_cmds};" |
---|
[892] | 967 | fi |
---|
| 968 | done < $tmp_mbuild |
---|
| 969 | |
---|
| 970 | |
---|
[1289] | 971 | # GET MODULES TO BE LOADED |
---|
[221] | 972 | line="" |
---|
[493] | 973 | grep "$remote_host_string" $config_file | grep "%modules" > $tmp_mbuild |
---|
[221] | 974 | while read line1 |
---|
| 975 | do |
---|
| 976 | |
---|
| 977 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
| 978 | then |
---|
| 979 | line="$line1" |
---|
| 980 | fi |
---|
| 981 | |
---|
| 982 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
| 983 | then |
---|
[1289] | 984 | # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY |
---|
[493] | 985 | modules=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` |
---|
[221] | 986 | fi |
---|
| 987 | |
---|
| 988 | done < $tmp_mbuild |
---|
| 989 | |
---|
| 990 | |
---|
[1289] | 991 | # GET LINKER OPTIONS |
---|
[1] | 992 | line="" |
---|
[116] | 993 | found=false |
---|
[215] | 994 | grep "$remote_host_string" $config_file | grep "%lopts" > $tmp_mbuild |
---|
[69] | 995 | while read line1 |
---|
[1] | 996 | do |
---|
[116] | 997 | |
---|
[1] | 998 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
| 999 | then |
---|
| 1000 | line="$line1" |
---|
| 1001 | fi |
---|
[116] | 1002 | |
---|
| 1003 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
| 1004 | then |
---|
[1289] | 1005 | # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY |
---|
[116] | 1006 | loader_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` |
---|
| 1007 | found=true |
---|
| 1008 | |
---|
[1289] | 1009 | # ADD netCDF- AND FFTW-LIBRARY |
---|
[1210] | 1010 | loader_options="$loader_options $netcdf_lib $fftw_lib" |
---|
[116] | 1011 | fi |
---|
| 1012 | |
---|
[215] | 1013 | done < $tmp_mbuild |
---|
[1] | 1014 | |
---|
[116] | 1015 | if [[ $found = false ]] |
---|
[1] | 1016 | then |
---|
| 1017 | printf "\n +++ no loader options found in configuration file" |
---|
| 1018 | printf "\n for \"$remote_host_string\" " |
---|
| 1019 | locat=config_file; exit |
---|
| 1020 | fi |
---|
[82] | 1021 | |
---|
[1] | 1022 | |
---|
| 1023 | printf "\n\n#------------------------------------------------------------------------# \n" |
---|
| 1024 | if [[ $remote_host = $local_host ]] |
---|
| 1025 | then |
---|
[1487] | 1026 | column2="$remote_host (= local host!)" |
---|
[1] | 1027 | else |
---|
[1487] | 1028 | column2=$remote_host |
---|
[1] | 1029 | fi |
---|
[1487] | 1030 | printf "| %-20s%-50s | \n" "remote_host:" "$column2" |
---|
[1] | 1031 | printf "| | \n" |
---|
[1487] | 1032 | printf "| %-20s%-50s | \n" "conditions:" "$condition1 $condition2" |
---|
| 1033 | column2=$(echo "$remote_md" | cut -c1-50 ) |
---|
| 1034 | printf "| %-20s%-50s | \n" "make depository:" "$column2" |
---|
[215] | 1035 | line=$(echo "$remote_md" | cut -c51-) |
---|
| 1036 | while [[ "$line" != "" ]] |
---|
| 1037 | do |
---|
| 1038 | column1="" |
---|
[1487] | 1039 | column2=$(echo "$line" | cut -c1-50 ) |
---|
| 1040 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
[215] | 1041 | line=$(echo "$line" | cut -c51-) |
---|
| 1042 | done |
---|
[25] | 1043 | if [[ $compile_utility_programs = true ]] |
---|
| 1044 | then |
---|
[1487] | 1045 | column2=$(echo "$remote_ud" | cut -c1-50 ) |
---|
| 1046 | printf "| %-20s%-50s | \n" "utility directory:" "$column2" |
---|
| 1047 | line=$(echo "$remote_ud" | cut -c51-) |
---|
| 1048 | while [[ "$line" != "" ]] |
---|
| 1049 | do |
---|
| 1050 | column1="" |
---|
| 1051 | column2=$(echo "$line" | cut -c1-50 ) |
---|
| 1052 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
| 1053 | line=$(echo "$line" | cut -c51-) |
---|
| 1054 | done |
---|
[25] | 1055 | fi |
---|
[1487] | 1056 | printf "| %-20s%-50s | \n" "username:" "$remote_username" |
---|
| 1057 | printf "| %-20s%-50s | \n" "address:" "$remote_address" |
---|
| 1058 | printf "| %-20s%-50s | \n" "compiler:" "$compiler_name" |
---|
[28] | 1059 | if [[ $compile_utility_programs = true ]] |
---|
| 1060 | then |
---|
[1487] | 1061 | printf "| %-20s%-50s | \n" "serial compiler:" "$compiler_name_ser" |
---|
[28] | 1062 | fi |
---|
[475] | 1063 | if [[ "$make_options" != "" ]] |
---|
| 1064 | then |
---|
[1487] | 1065 | printf "| %-20s%-50s | \n" "make options:" "$make_options" |
---|
[475] | 1066 | fi |
---|
[1487] | 1067 | column2=$(echo $cpp_options | cut -c1-50 ) |
---|
| 1068 | printf "| %-20s%-50s | \n" "cpp options:" "$column2" |
---|
[1] | 1069 | line=$(echo "$cpp_options" | cut -c51-) |
---|
| 1070 | while [[ "$line" != "" ]] |
---|
| 1071 | do |
---|
| 1072 | column1="" |
---|
[1487] | 1073 | column2=$(echo $line | cut -c1-50 ) |
---|
| 1074 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
[1] | 1075 | line=$(echo "$line" | cut -c51-) |
---|
| 1076 | done |
---|
[1487] | 1077 | column2=$(echo $compiler_options | cut -c1-50 ) |
---|
| 1078 | printf "| %-20s%-50s | \n" "compiler options:" "$column2" |
---|
[1] | 1079 | line=$(echo "$compiler_options" | cut -c51-) |
---|
| 1080 | while [[ "$line" != "" ]] |
---|
| 1081 | do |
---|
| 1082 | column1="" |
---|
[1487] | 1083 | column2=$(echo $line | cut -c1-50 ) |
---|
| 1084 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
[1] | 1085 | line=$(echo "$line" | cut -c51-) |
---|
| 1086 | done |
---|
[1487] | 1087 | column2=$(echo $loader_options | cut -c1-50 ) |
---|
| 1088 | printf "| %-20s%-50s | \n" "loader options:" "$column2" |
---|
[1] | 1089 | line=$(echo "$loader_options" | cut -c51-) |
---|
| 1090 | while [[ "$line" != "" ]] |
---|
| 1091 | do |
---|
| 1092 | column1="" |
---|
[1487] | 1093 | column2=$(echo $line | cut -c1-50 ) |
---|
| 1094 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
[1] | 1095 | line=$(echo "$line" | cut -c51-) |
---|
| 1096 | done |
---|
[1652] | 1097 | if [[ $init_cmds != "" ]] |
---|
| 1098 | then |
---|
| 1099 | column2=$(echo $init_cmds | cut -c1-50 ) |
---|
| 1100 | printf "| %-20s%-50s | \n" "login init command:" "$column2" |
---|
| 1101 | line=$(echo "$init_cmds" | cut -c51-) |
---|
| 1102 | while [[ "$line" != "" ]] |
---|
| 1103 | do |
---|
| 1104 | column1="" |
---|
| 1105 | column2=$(echo $line | cut -c1-50 ) |
---|
| 1106 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
| 1107 | line=$(echo "$line" | cut -c51-) |
---|
| 1108 | done |
---|
| 1109 | fi |
---|
[493] | 1110 | if [[ $modules != "" ]] |
---|
| 1111 | then |
---|
[1487] | 1112 | column2=$(echo $modules | cut -c1-50 ) |
---|
| 1113 | printf "| %-20s%-50s | \n" "modules to be load:" "$column2" |
---|
[493] | 1114 | line=$(echo "$modules" | cut -c51-) |
---|
| 1115 | while [[ "$line" != "" ]] |
---|
| 1116 | do |
---|
| 1117 | column1="" |
---|
[1487] | 1118 | column2=$(echo $line | cut -c1-50 ) |
---|
| 1119 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
[493] | 1120 | line=$(echo "$line" | cut -c51-) |
---|
| 1121 | done |
---|
| 1122 | fi |
---|
[1] | 1123 | printf "#------------------------------------------------------------------------# \n" |
---|
| 1124 | |
---|
| 1125 | if [[ $silent = false ]] |
---|
| 1126 | then |
---|
| 1127 | answer=dummy |
---|
| 1128 | printf "\n\n" |
---|
| 1129 | while [[ "$answer" != y && "$answer" != Y && "$answer" != c && "$answer" != C && "$answer" != s && "$answer" != S && "$answer" != a && "$answer" != A ]] |
---|
| 1130 | do |
---|
| 1131 | printf " >>> continue (y(es)/c(ontinue)/a(bort)/s(skip)) ? " |
---|
| 1132 | read answer |
---|
| 1133 | done |
---|
| 1134 | if [[ $answer = a || $answer = A ]] |
---|
| 1135 | then |
---|
| 1136 | locat=user_abort; exit |
---|
| 1137 | fi |
---|
| 1138 | if [[ $answer = c || $answer = C ]] |
---|
| 1139 | then |
---|
[503] | 1140 | silent=true |
---|
[1] | 1141 | fi |
---|
| 1142 | if [[ $answer = s || $answer = S ]] |
---|
| 1143 | then |
---|
| 1144 | continue |
---|
| 1145 | fi |
---|
| 1146 | fi |
---|
| 1147 | |
---|
| 1148 | |
---|
[1289] | 1149 | # MAKE ON REMOTE HOST |
---|
[475] | 1150 | if [[ $remote_host != $local_host ]] |
---|
[1] | 1151 | then |
---|
[475] | 1152 | if [[ $compile_utility_programs = false ]] |
---|
[1] | 1153 | then |
---|
| 1154 | |
---|
[1289] | 1155 | # COPY CURRENT SOURCE CODE TO SOURCE-CODE DIRECTORY ON THE REMOTE HOST |
---|
| 1156 | # CREATE THIS DIRECTORY, IF IT DOES NOT EXIST |
---|
[1468] | 1157 | echo " *** copying \"${mainprog}_sources.tar\" to \"${remote_address}:${remote_md}/\" " |
---|
[475] | 1158 | if [[ $remote_host != lctit ]] |
---|
| 1159 | then |
---|
[1944] | 1160 | ssh $ssh_key ${remote_username}@${remote_address} "[[ ! -d ${remote_md} ]] && (echo \" *** ${remote_md} will be created\"; mkdir -p ${remote_md})" |
---|
[475] | 1161 | else |
---|
[1289] | 1162 | # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS |
---|
[1487] | 1163 | echo "[[ ! -d ${remote_md} ]] && (echo \" *** ${remote_md} will be created\"; mkdir -p ${remote_md})" | ssh ${remote_username}@${remote_address} 2>&1 |
---|
[475] | 1164 | fi |
---|
[1] | 1165 | |
---|
[1944] | 1166 | scp $ssh_key ${local_source_path}/${mainprog}_sources.tar ${remote_username}@${remote_address}:${remote_md}/${mainprog}_sources.tar |
---|
[1] | 1167 | |
---|
| 1168 | |
---|
[1096] | 1169 | |
---|
[1289] | 1170 | # UNTAR PREVIOUS UPDATE ON REMOTE HOST, IF EXISTING |
---|
[475] | 1171 | echo " *** untar previous update on remote host, if existing" |
---|
| 1172 | if [[ $remote_host != lctit ]] |
---|
| 1173 | then |
---|
[1944] | 1174 | ssh $ssh_key ${remote_username}@${remote_address} "cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]] && tar -xf ${mainprog}_current_version.tar" |
---|
[475] | 1175 | else |
---|
[1289] | 1176 | # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS |
---|
[1487] | 1177 | echo "cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]] && tar -xf ${mainprog}_current_version.tar" | ssh ${remote_username}@${remote_address} 2>&1 |
---|
[475] | 1178 | fi |
---|
[1] | 1179 | |
---|
| 1180 | |
---|
[1289] | 1181 | # UNTAR CURRENT SOURCES ON REMOTE HOST |
---|
| 1182 | echo " *** untar current sources on remote host" |
---|
[475] | 1183 | if [[ $remote_host != lctit ]] |
---|
| 1184 | then |
---|
[1944] | 1185 | ssh $ssh_key ${remote_username}@${remote_address} "cd ${remote_md}; tar -xf ${mainprog}_sources.tar" |
---|
[475] | 1186 | else |
---|
[1289] | 1187 | # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS |
---|
[1487] | 1188 | echo "cd ${remote_md}; tar -xf ${mainprog}_sources.tar" | ssh ${remote_username}@${remote_address} 2>&1 |
---|
[475] | 1189 | fi |
---|
[1] | 1190 | |
---|
| 1191 | |
---|
[1289] | 1192 | # EXECUTE MAKE WITH THOSE OPTIONS DETERMINED ABOVE |
---|
| 1193 | # COMMANDS WILL BE COMMUNICATED TO SSH VIA PIPE, SINCE THIS WAY THE SYSTEM- AND |
---|
| 1194 | # USER-PROFILES OF THE SHELL ARE COMPLETELY EXECUTED (OTHERWISE, MAKE |
---|
| 1195 | # WILL E.G. MISS THE COMPILER-PATHS) |
---|
[475] | 1196 | echo " *** execute \"make\" on remote host" |
---|
[1] | 1197 | |
---|
[493] | 1198 | |
---|
[1289] | 1199 | # GENERATE MAKE CALL WITH MAKE OPTIONS |
---|
[475] | 1200 | if [[ $remote_host = nech ]] |
---|
| 1201 | then |
---|
| 1202 | make_call_string="sxmake $make_options PROG=$mainprog F90=$compiler_name COPT=\"$cpp_options\" F90FLAGS=\"$compiler_options\" LDFLAGS=\"$loader_options\" " |
---|
| 1203 | else |
---|
| 1204 | make_call_string="make $make_options PROG=$mainprog F90=$compiler_name COPT=\"$cpp_options\" F90FLAGS=\"$compiler_options\" LDFLAGS=\"$loader_options\" " |
---|
| 1205 | fi |
---|
[1] | 1206 | |
---|
[1289] | 1207 | # GENERATE COMMAND TO LOAD MODULES, IF MODULES ARE GIVEN |
---|
[493] | 1208 | if [[ "$modules" != "" ]] |
---|
| 1209 | then |
---|
[678] | 1210 | if [[ $remote_host = lctit ]] |
---|
| 1211 | then |
---|
| 1212 | module_calls=". $modules" |
---|
| 1213 | else |
---|
| 1214 | module_calls="module load ${modules};" |
---|
| 1215 | fi |
---|
[503] | 1216 | else |
---|
| 1217 | module_calls="" |
---|
[493] | 1218 | fi |
---|
| 1219 | |
---|
[1289] | 1220 | if [[ $remote_host = ibmkisti || $remote_host = ibms ]] |
---|
[475] | 1221 | then |
---|
[1] | 1222 | |
---|
[1468] | 1223 | ssh ${remote_username}@${remote_address} "$init_cmds $module_calls cd ${remote_md}; echo '$make_call_string' > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" 2>&1 | tee ${remote_host}_last_make_protokoll |
---|
[1] | 1224 | |
---|
[475] | 1225 | elif [[ $remote_host = ibmh ]] |
---|
| 1226 | then |
---|
[1] | 1227 | |
---|
[1487] | 1228 | echo "$init_cmds $module_calls export OBJECT_MODE=64; cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll |
---|
[1] | 1229 | |
---|
[475] | 1230 | elif [[ $remote_host = lctit ]] |
---|
| 1231 | then |
---|
[1] | 1232 | |
---|
[475] | 1233 | echo " " > ${remote_host}_last_make_protokoll |
---|
| 1234 | while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]] |
---|
| 1235 | do |
---|
[1487] | 1236 | echo "cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll |
---|
[475] | 1237 | done |
---|
[1] | 1238 | |
---|
[892] | 1239 | elif [[ $remote_host = lcxe6 ]] |
---|
[1] | 1240 | then |
---|
| 1241 | |
---|
[1468] | 1242 | ssh ${remote_username}@${remote_address} "$init_cmds $module_calls cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" 2>&1 | tee ${remote_host}_last_make_protokoll |
---|
[1] | 1243 | |
---|
[475] | 1244 | else |
---|
[1] | 1245 | |
---|
[1944] | 1246 | echo "$init_cmds $module_calls cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh $ssh_key ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll |
---|
[1] | 1247 | |
---|
[475] | 1248 | fi |
---|
[1] | 1249 | |
---|
[475] | 1250 | if [[ $(grep -c MAKE_ERROR ${remote_host}_last_make_protokoll) != 0 ]] |
---|
| 1251 | then |
---|
| 1252 | printf "\a\n +++ error(s) occurred during compiling or linking on host \"$remote_host\" " |
---|
| 1253 | if [[ $silent = false ]] |
---|
[40] | 1254 | then |
---|
[475] | 1255 | answer=dummy |
---|
| 1256 | printf "\n" |
---|
| 1257 | while [[ "$answer" != c && "$answer" != k ]] |
---|
[40] | 1258 | do |
---|
[475] | 1259 | printf " >>> continue / list errors / kill mbuild (c/l/k) ? " |
---|
| 1260 | read answer |
---|
| 1261 | if [[ "$answer" = l ]] |
---|
| 1262 | then |
---|
| 1263 | more ${remote_host}_last_make_protokoll |
---|
| 1264 | fi |
---|
[40] | 1265 | done |
---|
[475] | 1266 | if [[ $answer = k ]] |
---|
[40] | 1267 | then |
---|
[475] | 1268 | locat=user_abort; exit |
---|
[1] | 1269 | fi |
---|
| 1270 | fi |
---|
[475] | 1271 | fi |
---|
[1] | 1272 | |
---|
| 1273 | |
---|
| 1274 | |
---|
[1289] | 1275 | # TAR UPDATED VERSION ON THE REMOTE HOST |
---|
[475] | 1276 | printf "\n *** tar update on remote host ..." |
---|
| 1277 | if [[ $remote_host != lctit ]] |
---|
| 1278 | then |
---|
[1944] | 1279 | ssh $ssh_key ${remote_username}@${remote_address} "cd ${remote_md}; chmod u+w *; tar -cf ${mainprog}_current_version.tar ${mainprog} *.f90 *.o *.mod" |
---|
[475] | 1280 | else |
---|
[1289] | 1281 | # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS |
---|
[1487] | 1282 | echo "cd ${remote_md}; chmod u+w *; tar -cf ${mainprog}_current_version.tar ${mainprog} *.f90 *.o *.mod" | ssh ${remote_username}@${remote_address} 2>&1 |
---|
[475] | 1283 | fi |
---|
[1] | 1284 | |
---|
| 1285 | |
---|
| 1286 | |
---|
[1289] | 1287 | # DO THE SAME THINGS FOR THE UTILITY-ROUTINES: |
---|
| 1288 | # COPY CURRENT SOURCE CODE TO SOURCE-CODE DIRECTORY ON THE REMOTE HOST |
---|
| 1289 | # CREATE THIS DIRECTORY, IF IT DOES NOT EXIST |
---|
[475] | 1290 | elif [[ $compile_utility_programs = true ]] |
---|
| 1291 | then |
---|
| 1292 | |
---|
| 1293 | printf "\n\n" |
---|
[1468] | 1294 | echo " *** copying scripts and utility programs to \"${remote_address}:${remote_ud}/\" " |
---|
[475] | 1295 | cd ${local_source_path}/../SCRIPTS |
---|
| 1296 | |
---|
| 1297 | if [[ $remote_host != lctit ]] |
---|
[22] | 1298 | then |
---|
[1944] | 1299 | ssh $ssh_key ${remote_username}@${remote_address} "[[ ! -d ${remote_ud} ]] && (echo \" *** ${remote_ud} will be created\"; mkdir -p ${remote_ud}); [[ ! -d ${remote_ud}/../SCRIPTS ]] && (echo \" *** ${remote_ud}/../SCRIPTS will be created\"; mkdir -p ${remote_ud}/../SCRIPTS)" |
---|
[475] | 1300 | else |
---|
[1289] | 1301 | # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS |
---|
[1487] | 1302 | echo "[[ ! -d ${remote_ud} ]] && (echo \" *** ${remote_ud} will be created\"; mkdir -p ${remote_ud}); [[ ! -d ${remote_ud}/../SCRIPTS ]] && (echo \" *** ${remote_ud}/../SCRIPTS will be created\"; mkdir -p ${remote_ud}/../SCRIPTS)" | ssh ${remote_username}@${remote_address} 2>&1 |
---|
[475] | 1303 | fi |
---|
[22] | 1304 | |
---|
[1289] | 1305 | # COPY SHELL-SCRIPTS |
---|
[1944] | 1306 | scp $ssh_key batch_scp mbuild mrun process_dvr_output .dvrserver.config subjob ${remote_username}@${remote_address}:${remote_ud}/../SCRIPTS > /dev/null |
---|
[22] | 1307 | |
---|
[475] | 1308 | cd - > /dev/null |
---|
| 1309 | cd ${local_source_path}/../UTIL |
---|
[22] | 1310 | |
---|
[27] | 1311 | |
---|
[1289] | 1312 | # COPY UTILITY-ROUTINES |
---|
[1944] | 1313 | scp $ssh_key Makefile *.f90 ${remote_username}@${remote_address}:${remote_ud} > /dev/null |
---|
[27] | 1314 | |
---|
| 1315 | |
---|
[22] | 1316 | |
---|
[1289] | 1317 | # EXECUTE MAKE WITH THOSE OPTIONS DETERMINED ABOVE |
---|
| 1318 | # COMMANDS WILL BE COMMUNICATED TO SSH VIA PIPE, SINCE THIS WAY THE SYSTEM- AND |
---|
| 1319 | # USER-PROFILES OF THE SHELL ARE COMPLETELY EXECUTED (OTHERWISE, MAKE |
---|
| 1320 | # WILL E.G. MISS THE COMPILER-PATHS) |
---|
[475] | 1321 | echo " *** execute \"make\" on remote host" |
---|
[22] | 1322 | |
---|
[475] | 1323 | if [[ $remote_host = nech ]] |
---|
| 1324 | then |
---|
[503] | 1325 | make_call_string="sxmake $make_options BLOCK=$block F90=$compiler_name F90_SER=$compiler_name_ser COPT=\"$cpp_options\" F90FLAGS=\"$compiler_options\" LDFLAGS=\"$loader_options\" " |
---|
[475] | 1326 | else |
---|
[503] | 1327 | make_call_string="make $make_options BLOCK=$block F90=$compiler_name F90_SER=$compiler_name_ser COPT=\"$cpp_options\" F90FLAGS=\"$compiler_options\" LDFLAGS=\"$loader_options\" " |
---|
[475] | 1328 | fi |
---|
[22] | 1329 | |
---|
[1289] | 1330 | # GENERATE COMMAND TO LOAD MODULES, IF MODULES ARE GIVEN |
---|
[493] | 1331 | if [[ "$modules" != "" ]] |
---|
| 1332 | then |
---|
[678] | 1333 | if [[ $remote_host = lctit ]] |
---|
| 1334 | then |
---|
| 1335 | module_calls=". $modules" |
---|
| 1336 | else |
---|
| 1337 | module_calls="module load ${modules};" |
---|
| 1338 | fi |
---|
[503] | 1339 | else |
---|
| 1340 | module_calls="" |
---|
[493] | 1341 | fi |
---|
| 1342 | |
---|
[892] | 1343 | |
---|
[1289] | 1344 | if [[ $remote_host = ibms ]] |
---|
[475] | 1345 | then |
---|
[22] | 1346 | |
---|
[1468] | 1347 | ssh ${remote_username}@${remote_address} "$init_cmds $module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" |
---|
[22] | 1348 | |
---|
[475] | 1349 | elif [[ $remote_host = ibmh ]] |
---|
| 1350 | then |
---|
[22] | 1351 | |
---|
[1487] | 1352 | echo "$init_cmds $module_calls export OBJECT_MODE=64; cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh ${remote_username}@${remote_address} |
---|
[22] | 1353 | |
---|
[475] | 1354 | elif [[ $remote_host = lctit ]] |
---|
| 1355 | then |
---|
[22] | 1356 | |
---|
[475] | 1357 | echo " " > ${remote_host}_last_make_protokoll |
---|
| 1358 | while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]] |
---|
| 1359 | do |
---|
[1487] | 1360 | echo "$init_cmds $module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll |
---|
[475] | 1361 | done |
---|
[22] | 1362 | |
---|
[892] | 1363 | elif [[ $remote_host = lcxe6 ]] |
---|
[475] | 1364 | then |
---|
[22] | 1365 | |
---|
[1468] | 1366 | ssh ${remote_username}@${remote_address} "$init_cmds $module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" 2>&1 | tee ${remote_host}_last_make_protokoll |
---|
[22] | 1367 | |
---|
[475] | 1368 | else |
---|
[407] | 1369 | |
---|
[1944] | 1370 | echo "$init_cmds $module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh $ssh_key ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll |
---|
[407] | 1371 | |
---|
[475] | 1372 | fi |
---|
[22] | 1373 | |
---|
[1289] | 1374 | fi # END OF COMPILING UTILITY-ROUTINES |
---|
[22] | 1375 | |
---|
[475] | 1376 | rm -rf ${remote_host}_last_make_protokoll |
---|
[22] | 1377 | |
---|
[1289] | 1378 | # MAKE ON LOCAL HOST |
---|
[475] | 1379 | else |
---|
[22] | 1380 | |
---|
[1289] | 1381 | # INIT WORKAROUND FOR lcxe6 |
---|
[1274] | 1382 | if [[ $remote_host = lcxe6 || $remote_host = lccrayb || $remote_host = lccrayf || $remote_host = lccrayh ]] |
---|
[544] | 1383 | then |
---|
[920] | 1384 | |
---|
[1197] | 1385 | eval $init_cmds > /dev/null 2>&1 |
---|
[920] | 1386 | |
---|
[544] | 1387 | fi |
---|
| 1388 | |
---|
[1289] | 1389 | # FIRST LOAD MODULES, IF GIVEN |
---|
[544] | 1390 | if [[ "$modules" != "" ]] |
---|
| 1391 | then |
---|
[678] | 1392 | if [[ $remote_host = lctit ]] |
---|
| 1393 | then |
---|
| 1394 | . $modules |
---|
[2257] | 1395 | elif [[ $remote_host = lceddy ]] |
---|
[1099] | 1396 | then |
---|
[2257] | 1397 | eval `$MODULESHOME/libexec/lmod load ${modules}` |
---|
[678] | 1398 | else |
---|
[1390] | 1399 | eval init_cmds=$init_cmds |
---|
[678] | 1400 | module load ${modules} |
---|
| 1401 | fi |
---|
[544] | 1402 | fi |
---|
| 1403 | |
---|
| 1404 | |
---|
[475] | 1405 | if [[ $compile_utility_programs = false ]] |
---|
| 1406 | then |
---|
[22] | 1407 | |
---|
[1289] | 1408 | # CREATE MAKE-DEPOSITORY, IF IT DOES NOT EXIST |
---|
[475] | 1409 | eval remote_md=$remote_md |
---|
| 1410 | if [[ ! -d $remote_md ]] |
---|
[40] | 1411 | then |
---|
[475] | 1412 | if mkdir $remote_md |
---|
[215] | 1413 | then |
---|
[475] | 1414 | printf "\n\n *** directory for make depository:" |
---|
| 1415 | printf "\n $remote_md" |
---|
| 1416 | printf "\n was created\n" |
---|
| 1417 | else |
---|
| 1418 | printf "\n +++ directory for make depository:" |
---|
| 1419 | printf "\n $remote_md" |
---|
| 1420 | printf "\n cannot be created" |
---|
| 1421 | locat=local_depository_path; exit |
---|
[215] | 1422 | fi |
---|
[475] | 1423 | fi |
---|
[215] | 1424 | |
---|
[1289] | 1425 | # COPY SOURCE-CODE FROM REPOSITORY TO MAKE-DEPOSITORY |
---|
[475] | 1426 | echo " " |
---|
| 1427 | echo " *** updating sources in $remote_md" |
---|
| 1428 | cd $remote_md |
---|
| 1429 | cp $local_source_path/${mainprog}_sources.tar . |
---|
| 1430 | tar xf ${mainprog}_sources.tar |
---|
[215] | 1431 | |
---|
[1289] | 1432 | # CALL MAKE ON LOCAL HOST USING THE OPTIONS DETERMINED FURTHER ABOVE |
---|
[475] | 1433 | echo " " |
---|
| 1434 | echo " *** execute \"make\" on local host" |
---|
[1] | 1435 | |
---|
[475] | 1436 | make $make_options PROG=$mainprog F90=$compiler_name COPT="$cpp_options" F90FLAGS="$compiler_options" LDFLAGS="$loader_options" 2>&1 | tee ${remote_host}_last_make_protokoll |
---|
[40] | 1437 | |
---|
[475] | 1438 | if [[ $? != 0 ]] |
---|
| 1439 | then |
---|
| 1440 | printf "\a\n +++ error(s) occurred during compiling or linking on host \"$remote_host\" " |
---|
| 1441 | if [[ $silent = false ]] |
---|
[1] | 1442 | then |
---|
[475] | 1443 | answer=dummy |
---|
| 1444 | printf "\n" |
---|
| 1445 | while [[ "$answer" != c && "$answer" != k ]] |
---|
| 1446 | do |
---|
| 1447 | printf " >>> continue / list errors / kill mbuild (c/l/k) ? " |
---|
| 1448 | read answer |
---|
| 1449 | if [[ "$answer" = l ]] |
---|
[1] | 1450 | then |
---|
[475] | 1451 | more ${remote_host}_last_make_protokoll |
---|
[1] | 1452 | fi |
---|
[475] | 1453 | done |
---|
| 1454 | if [[ $answer = k ]] |
---|
| 1455 | then |
---|
| 1456 | locat=user_abort; exit |
---|
[1] | 1457 | fi |
---|
| 1458 | fi |
---|
[475] | 1459 | fi |
---|
[1] | 1460 | |
---|
| 1461 | |
---|
[503] | 1462 | # TAR NEW VERSION ON LOCAL HOST |
---|
[475] | 1463 | printf "\n *** tar update on local host ..." |
---|
| 1464 | tar -cf ${mainprog}_current_version.tar *.$suf *.o *.mod |
---|
[1] | 1465 | |
---|
[22] | 1466 | |
---|
[475] | 1467 | # COMPILE THE UTILITY PROGRAMS |
---|
| 1468 | elif [[ $compile_utility_programs = true ]] |
---|
| 1469 | then |
---|
| 1470 | printf "\n\n" |
---|
| 1471 | echo " *** compiling the utility programs ..." |
---|
| 1472 | cd ${local_source_path}/../UTIL |
---|
[503] | 1473 | |
---|
| 1474 | # TOUCH FILES IN ORDER TO FORCE COMPILATION FOR EVERY BLOCK |
---|
| 1475 | touch *.f90 |
---|
[1390] | 1476 | eval init_cmds=$init_cmds |
---|
[503] | 1477 | make $make_options BLOCK=$block F90=$compiler_name F90_SER=$compiler_name_ser COPT="$cpp_options" F90FLAGS="$compiler_options" LDFLAGS="$loader_options" |
---|
[1] | 1478 | fi |
---|
| 1479 | fi |
---|
| 1480 | done |
---|
| 1481 | |
---|
| 1482 | |
---|
| 1483 | if [[ $host_found = false ]] |
---|
| 1484 | then |
---|
| 1485 | if [[ $host = all ]] |
---|
| 1486 | then |
---|
| 1487 | printf "\n +++ no hosts found in configuration file" |
---|
| 1488 | else |
---|
| 1489 | printf "\n +++ host \"$host\" not found in configuration file" |
---|
| 1490 | fi |
---|
| 1491 | locat=config_file; exit |
---|
| 1492 | fi |
---|
| 1493 | |
---|
[936] | 1494 | if [[ "$block_conditions" != none && $block_conditions_found = false ]] |
---|
| 1495 | then |
---|
| 1496 | printf "\n +++ block conditions \"$block_conditions\" not found for host \"$host\"" |
---|
| 1497 | fi |
---|
[1] | 1498 | |
---|
| 1499 | |
---|
[503] | 1500 | # FINAL WORK |
---|
[1] | 1501 | rm -f hosts_found_in_config_file |
---|