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