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