source: palm/trunk/SCRIPTS/mbuild @ 1090

Last change on this file since 1090 was 1090, checked in by raasch, 11 years ago

script adjustments for Kyushu-University computing center (lckyut)

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