source: palm/trunk/SCRIPTS/mbuild @ 1365

Last change on this file since 1365 was 1351, checked in by maronga, 11 years ago

last commit documented

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