source: palm/trunk/SCRIPTS/mbuild @ 1122

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

last commit documented

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