source: palm/trunk/SCRIPTS/mbuild @ 1097

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

last commit documented

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