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