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