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