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