source: palm/trunk/SCRIPTS/mbuild @ 1099

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

adjustments for Forwind cluster (lcflow) and Kuyshu University computing center (hayaka -lckyuh); further small adjustments for lckyut

  • Property svn:keywords set to Id Rev
File size: 47.1 KB
Line 
1#!/bin/ksh
2
3# mbuild - script for compiling the PALM code and its utility programs
4
5#--------------------------------------------------------------------------------#
6# This file is part of PALM.
7#
8# PALM is free software: you can redistribute it and/or modify it under the terms
9# of the GNU General Public License as published by the Free Software Foundation,
10# either version 3 of the License, or (at your option) any later version.
11#
12# PALM is distributed in the hope that it will be useful, but WITHOUT ANY
13# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License along with
17# PALM. If not, see <http://www.gnu.org/licenses/>.
18#
19# Copyright 1997-2012  Leibniz University Hannover
20#--------------------------------------------------------------------------------#
21#
22# Current revisions:
23# ------------------
24# adjustments for Forwind cluster (lcflow)
25#
26# Former revisions:
27# -----------------
28# $Id: mbuild 1099 2013-02-10 01:47:43Z 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: 1099 $"
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        (lcflow)         remote_addres="flow.hpc.uni-oldenburg.de";;
457        (lckordi)        remote_adress=210.219.61.8;;
458        (lcmuk)          remote_addres=130.75.105.2;;
459        (lcrte)          remote_addres=133.5.185.60;;
460        (lcsb)           remote_addres=147.46.30.151;;
461        (lcsgib)         remote_addres=130.73.232.102;;
462        (lcsgih)         remote_addres=130.75.4.101;;
463        (lck)            remote_addres=165.132.26.61;;
464        (lckiaps)        remote_addres=118.128.66.223;;
465        (lckyut)         remote_addres=133.5.4.37;;
466        (lctit)          remote_addres=10.1.6.170;;
467        (lcxe6)          remote_addres=129.177.20.113;;
468        (lcxt5m)         remote_addres=193.166.211.144;;
469        (ibmh)           remote_addres=136.172.40.15;;
470        (ibmkisti)       remote_addres=150.183.146.24;;
471        (ibmku)          remote_addres=133.5.4.129;;
472        (ibms)           remote_addres=150.183.5.101;;
473        (ibmy)           remote_addres=165.132.26.58;;
474        (nech)           remote_addres=136.172.44.192;;
475        (neck)           remote_addres=133.5.178.11;;
476        (ground.yonsei.ac.kr) remote_addres=134.75.155.33;;
477        (*)              if [[ $local_host != $remote_host ]]
478                         then
479                            printf "\n  +++ remote host \"$remote_host\" unknown";
480                            printf "\n      please inform PALM group support!"
481                            locat=remote_host; exit
482                         fi;;
483    esac
484
485
486       # REMOTE-USERNAMEN ERMITTELN
487    line=""
488    found=false
489    grep  "$remote_host_string" $config_file | grep "%remote_username"  >  $tmp_mbuild
490    while read line1
491    do
492
493       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
494       then
495          line="$line1"
496       fi
497
498       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
499       then
500          remote_username=`echo $line | cut -d" " -s -f2`
501          found=true
502       fi
503
504    done < $tmp_mbuild
505
506    if [[ $found = false ]]
507    then
508       printf "\n  +++ no remote username found in configuration file"
509       printf "\n      for \"$remote_host_string\" "
510       locat=config_file; exit
511    fi
512
513
514       # REMOTE-QUELLTEXTPFAD ERMITTELN
515    line=""
516    remote_source_path=""
517    grep  "$remote_host_string" $config_file | grep "%source_path"  >  $tmp_mbuild
518    while read line1
519    do
520
521       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
522       then
523          line="$line1"
524       fi
525
526       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
527       then
528          remote_source_path=`echo $line | cut -d" " -s -f2`
529       fi
530
531    done < $tmp_mbuild
532
533    if [[ "$remote_source_path" = "" ]]
534    then
535       if [[ "$global_source_path" != "" ]]
536       then
537          remote_source_path=$global_source_path
538       else
539          printf "\n  +++ no source path found in configuration file"
540          printf "\n      for \"$remote_host_string\" "
541          locat=config_file; exit
542       fi
543    fi
544
545    remote_ud=${remote_source_path}/../UTIL
546    remote_ud=$(eval echo $remote_ud)
547
548
549       # REMOTE-PFAD FUER MAKE-DEPOSITORY ERMITTELN
550    remote_md=""
551    line=""
552    grep  "$remote_host_string" $config_file | grep "%depository_path"  >  $tmp_mbuild
553    while read line1
554    do
555
556       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
557       then
558          line="$line1"
559       fi
560
561       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
562       then
563          remote_md=`echo $line | cut -d" " -s -f2`
564       fi
565
566    done < $tmp_mbuild
567
568    if [[ "$remote_md" = "" ]]
569    then
570       if [[ "$global_depository_path" != "" ]]
571       then
572          remote_md=$global_depository_path
573       else
574          printf "\n  +++ no depository path found in configuration file"
575          printf "\n      for \"$remote_host_string\" "
576          printf "\n      please set \"\%depository_path\" in configuration file"
577          locat=config_file; exit
578       fi
579    fi
580
581    remote_md=$(eval echo $remote_md)
582    block=""
583    [[ "$condition1" != "" ]]  &&  block=_$condition1
584    [[ "$condition2" != "" ]]  &&  block=${block}_$condition2
585    remote_md=${remote_md}$block
586
587
588       # COMPILERNAMEN ERMITTELN
589    line=""
590    found=false
591    grep  "$remote_host_string" $config_file | grep "%compiler_name "  >  $tmp_mbuild
592    while read line1
593    do
594
595       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
596       then
597          line="$line1"
598       fi
599
600       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
601       then
602          compiler_name=`echo $line | cut -d" " -s -f2`
603          found=true
604       fi
605
606    done < $tmp_mbuild
607
608    if [[ $found = false ]]
609    then
610       printf "\n  +++ no compiler name found in configuration file"
611       printf "\n      for \"$remote_host_string\" "
612       locat=config_file; exit
613    fi
614
615
616       # BEI BENUTZUNG EINES PARALLELEN COMPILERS MUSS AUCH EIN
617       # SERIELLER COMPILERNAME ERMITTELT WERDEN
618    if [[ $(echo $remote_host_string | grep -c parallel) = 1 ]]
619    then
620       line=""
621       found=false
622       grep  "$remote_host_string" $config_file | grep "%compiler_name_ser"  >  $tmp_mbuild
623       while read line1
624       do
625
626          if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
627          then
628             line="$line1"
629          fi
630
631          if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
632          then
633             compiler_name_ser=`echo $line | cut -d" " -s -f2`
634             found=true
635          fi
636
637       done < $tmp_mbuild
638
639       if [[ $found = false ]]
640       then
641          printf "\n  +++ no serial compiler name found in configuration file"
642          printf "\n      for \"$remote_host_string\" "
643          locat=config_file; exit
644       fi
645    else
646       compiler_name_ser=$compiler_name
647    fi
648
649
650
651       # PRAEPROZESSOR-OPTIONEN/DIREKTIVEN ERMITTELN
652    line=""
653    found=false
654    grep  "$remote_host_string" $config_file | grep "%cpp_options"  >  $tmp_mbuild
655    while read line1
656    do
657
658       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
659       then
660          line="$line1"
661       fi
662
663       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
664       then
665             # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING ENTFERNEN
666          cpp_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
667          found=true
668       fi
669
670    done < $tmp_mbuild
671
672    if [[ $found = false ]]
673    then
674       printf "\n  +++ no preprocessor options found in configuration file"
675       printf "\n      for \"$remote_host_string\" "
676       locat=config_file; exit
677    fi
678
679
680       # RECHNERSPEZIFISCHE CPP-DIREKTIVEN HINZUFUEGEN
681    for  string  in  $remote_host_string
682    do
683       if [[ $(echo $remote_host | cut -c1-2) = lc  &&  $(echo $string | cut -c1-2) = lc ]]
684       then
685          cpp_options="$cpp_options -D__lc "
686       elif [[ $(echo $remote_host | cut -c1-3) = ibm  &&  $(echo $string | cut -c1-3) = ibm ]]
687       then
688          cpp_options="${cpp_options},-D__ibm"
689       elif [[ $(echo $remote_host | cut -c1-3) = nec  &&  $(echo $string | cut -c1-3) = nec ]]
690       then
691          cpp_options="${cpp_options} -D__nec"
692       else
693          if [[ $(echo $remote_host | cut -c1-3) = ibm ]]
694          then
695             cpp_options="${cpp_options},-D__$string"
696          else
697             cpp_options="$cpp_options -D__$string "
698          fi
699       fi
700    done
701
702
703
704       # NETCDF-OPTIONEN ERMITTELN
705    line=""
706    grep  "$remote_host_string" $config_file | grep "%netcdf_inc"  >  $tmp_mbuild
707    while read line1
708    do
709
710       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
711       then
712          line="$line1"
713       fi
714
715       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
716       then
717             # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING ENTFERNEN
718          netcdf_inc=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
719       fi
720
721    done < $tmp_mbuild
722
723    line=""
724    grep  "$remote_host_string" $config_file | grep "%netcdf_lib"  >  $tmp_mbuild
725    while read line1
726    do
727
728       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
729       then
730          line="$line1"
731       fi
732
733       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
734       then
735             # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING ENTFERNEN
736          netcdf_lib=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
737       fi
738
739    done < $tmp_mbuild
740
741
742
743       # get make options
744    line=""
745    found=false
746    grep  "$remote_host_string" $config_file | grep "%mopts"  >  $tmp_mbuild
747    while read line1
748    do
749
750       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
751       then
752          line="$line1"
753       fi
754
755       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
756       then
757             # remove colons from directive string
758          make_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
759
760       fi
761
762    done < $tmp_mbuild
763
764
765
766       # COMPILEROPTIONEN ERMITTELN
767    line=""
768    found=false
769    grep  "$remote_host_string" $config_file | grep "%fopts"  >  $tmp_mbuild
770    while read line1
771    do
772
773       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
774       then
775          line="$line1"
776       fi
777
778       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
779       then
780             # EVENTUELLE DOPPELPUNKTE AUS DIREKTIVENSTRING ENTFERNEN
781          compiler_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
782          found=true
783
784             # NETCDF-INCLUDEVERZEICHNIS HINZUFUEGEN
785          compiler_options="$compiler_options $netcdf_inc"
786       fi
787
788    done < $tmp_mbuild
789
790    if [[ $found = false ]]
791    then
792       printf "\n  +++ no compiler options found in configuration file"
793       printf "\n      for \"$remote_host_string\" "
794       locat=config_file; exit
795    fi
796
797
798       # get login init commands, "::" is replacing a space
799    line=""
800    grep  "$remote_host_string" $config_file | grep "%login_init_cmd"  >  $tmp_mbuild
801    while read line1
802    do
803
804       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
805       then
806          line="$line1"
807       fi
808
809       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
810       then
811             # EVENTUELLE DOPPELPUNKTE AUS DIREKTIVENSTRING ENTFERNEN
812          init_cmds=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
813       fi
814       init_cmds="${init_cmds};"
815    done < $tmp_mbuild
816
817
818       # get modules to be loaded
819    line=""
820    grep  "$remote_host_string" $config_file | grep "%modules"  >  $tmp_mbuild
821    while read line1
822    do
823
824       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
825       then
826          line="$line1"
827       fi
828
829       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
830       then
831             # EVENTUELLE DOPPELPUNKTE AUS DIREKTIVENSTRING ENTFERNEN
832          modules=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
833       fi
834
835    done < $tmp_mbuild
836
837
838       # LADER-OPTIONEN ERMITTELN
839    line=""
840    found=false
841    grep  "$remote_host_string" $config_file | grep "%lopts"  >  $tmp_mbuild
842    while read line1
843    do
844
845       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
846       then
847          line="$line1"
848       fi
849
850       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
851       then
852             # EVENTUELLE DOPPELPUNKTE AUS DIREKTIVENSTRING ENTFERNEN
853          loader_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
854          found=true
855
856             # NETCDF-LIBRARY HINZUFUEGEN
857          loader_options="$loader_options $netcdf_lib"
858       fi
859
860    done < $tmp_mbuild
861
862    if [[ $found = false ]]
863    then
864       printf "\n  +++ no loader options found in configuration file"
865       printf "\n      for \"$remote_host_string\" "
866       locat=config_file; exit
867    fi
868
869
870    printf "\n\n#------------------------------------------------------------------------# \n"
871    if [[ $remote_host = $local_host ]]
872    then
873       column1="remote_host:"; column2="$remote_host (= local host!)"
874    else
875       column1="remote_host:"; column2=$remote_host
876    fi
877    printf "| $column1$column2 | \n"
878    printf "|                                                                        | \n"
879    column1="conditions:"; column2="$condition1 $condition2"
880    printf "| $column1$column2 | \n"
881    column1="make depository:"; column2=$remote_md
882    printf "| $column1$column2 | \n"
883    line=$(echo "$remote_md" | cut -c51-)
884    while [[ "$line" != "" ]]
885    do
886       column1=""
887       column2=$line
888       printf "| $column1$column2 | \n"
889       line=$(echo "$line" | cut -c51-)
890    done
891    if [[ $compile_utility_programs = true ]]
892    then
893       column1="utility directory:"; column2=$remote_ud
894       printf "| $column1$column2 | \n"
895    fi
896    column1="username:"; column2=$remote_username
897    printf "| $column1$column2 | \n"
898    column1="addres:"; column2=$remote_addres
899    printf "| $column1$column2 | \n"
900    column1="compiler:"; column2=$compiler_name
901    printf "| $column1$column2 | \n"
902    if [[ $compile_utility_programs = true ]]
903    then
904       column1="serial compiler:"; column2=$compiler_name_ser
905       printf "| $column1$column2 | \n"
906    fi
907    if [[ "$make_options" != "" ]]
908    then
909       column1="make options:"; column2=$make_options
910       printf "| $column1$column2 | \n"
911    fi
912    column1="cpp options:"; column2=$cpp_options
913    printf "| $column1$column2 | \n"
914    line=$(echo "$cpp_options" | cut -c51-)
915    while [[ "$line" != "" ]]
916    do
917       column1=""
918       column2=$line
919       printf "| $column1$column2 | \n"
920       line=$(echo "$line" | cut -c51-)
921    done
922    column1="compiler options:"; column2=$compiler_options
923    printf "| $column1$column2 | \n"
924    line=$(echo "$compiler_options" | cut -c51-)
925    while [[ "$line" != "" ]]
926    do
927       column1=""
928       column2=$line
929       printf "| $column1$column2 | \n"
930       line=$(echo "$line" | cut -c51-)
931    done
932    column1="loader options:"; column2=$loader_options
933    printf "| $column1$column2 | \n"
934    line=$(echo "$loader_options" | cut -c51-)
935    while [[ "$line" != "" ]]
936    do
937       column1=""
938       column2=$line
939       printf "| $column1$column2 | \n"
940       line=$(echo "$line" | cut -c51-)
941    done
942    if [[ $modules != "" ]]
943    then
944       column1="modules to be load:"; column2=$modules
945       printf "| $column1$column2 | \n"
946       line=$(echo "$modules" | cut -c51-)
947       while [[ "$line" != "" ]]
948       do
949          column1=""
950          column2=$line
951          printf "| $column1$column2 | \n"
952          line=$(echo "$line" | cut -c51-)
953       done
954    fi
955    printf "#------------------------------------------------------------------------# \n"
956
957    if [[ $silent = false ]]
958    then
959       answer=dummy
960       printf "\n\n"
961       while [[ "$answer" != y  &&  "$answer" != Y  && "$answer" != c  &&  "$answer" != C  && "$answer" != s  &&  "$answer" != S  &&  "$answer" != a  &&  "$answer" != A ]]
962       do
963          printf " >>> continue (y(es)/c(ontinue)/a(bort)/s(skip)) ?  "
964          read  answer
965       done
966       if [[ $answer = a  ||  $answer = A ]]
967       then
968          locat=user_abort; exit
969       fi
970       if [[ $answer = c  ||  $answer = C ]]
971       then
972          silent=true
973       fi
974       if [[ $answer = s  ||  $answer = S ]]
975       then
976          continue
977       fi
978    fi
979
980
981       # make on remote host
982    if [[ $remote_host != $local_host ]]
983    then
984       if [[ $compile_utility_programs = false ]]
985       then
986
987             # AKTUELLE QUELLTEXTVERSION INS REMOTE-QUELLTEXTVERZEICHNIS KOPIEREN
988             # FALLS DIESES NOCH NICHT EXISTIERT, WIRD ES ERZEUGT
989          echo "  *** copying \"${mainprog}_sources.tar\" to \"${remote_addres}:${remote_md}/\" "
990          if [[ $remote_host != lctit ]]
991          then
992             ssh  ${remote_username}@${remote_addres} "[[ ! -d ${remote_md} ]]  &&  (echo \"  *** ${remote_md} will be created\"; mkdir -p  ${remote_md})"
993          else
994                # TIT ERLAUBT NUR DIE AUSFï¿œHRUNG GANZ BESTIMMTER KOMMANDOS
995                # MIT SSH, DESHALB AUFRUF PER PIPE
996             print "[[ ! -d ${remote_md} ]]  &&  (echo \"  *** ${remote_md} will be created\"; mkdir -p  ${remote_md})"  |  ssh ${remote_username}@${remote_addres}  2>&1
997          fi
998
999          scp  ${local_source_path}/${mainprog}_sources.tar  ${remote_username}@${remote_addres}:${remote_md}/${mainprog}_sources.tar
1000
1001
1002
1003             # FALLS VORHANDEN, LETZTE VERSION AUF DEM REMOTE-RECHNER AUSPACKEN
1004          echo "  *** untar previous update on remote host, if existing"
1005          if [[ $remote_host != lctit ]]
1006          then
1007             ssh  ${remote_username}@${remote_addres}  "cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]]  &&  tar -xf  ${mainprog}_current_version.tar"
1008          else
1009                # TIT ERLAUBT NUR DIE AUSFï¿œHRUNG GANZ BESTIMMTER KOMMANDOS
1010                # MIT SSH, DESHALB AUFRUF PER PIPE
1011             print  "cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]]  &&  tar -xf  ${mainprog}_current_version.tar"  |  ssh  ${remote_username}@${remote_addres}  2>&1
1012          fi
1013
1014
1015             # AKTUELLE QUELLTEXTVERSION AUF REMOTE-RECHNER AUSPACKEN
1016          echo "  *** untar actual sources on remote host"
1017          if [[ $remote_host != lctit ]]
1018          then
1019             ssh  ${remote_username}@${remote_addres}  "cd ${remote_md}; tar -xf  ${mainprog}_sources.tar"
1020          else
1021                # TIT ERLAUBT NUR DIE AUSFï¿œHRUNG GANZ BESTIMMTER KOMMANDOS
1022                # MIT SSH, DESHALB AUFRUF PER PIPE
1023             print  "cd ${remote_md}; tar -xf  ${mainprog}_sources.tar"  |  ssh  ${remote_username}@${remote_addres}  2>&1
1024          fi
1025
1026
1027             # MAKE MIT ZUVOR ERMITTELTEN OPTIONEN AUF REMOTE RECHNER AUSFUEHREN
1028             # KOMMANDOUEBERGABE AN SSH PER PIPE, DA SO DIE SYSTEM- UND
1029             # BENUTZERPROFILE VOLLSTAENDIG AUSGEFUEHRT WERDEN (SONST FEHLEN MAKE
1030             # Z.B. DIE PFADE ZUM COMPILER)
1031          echo "  *** execute \"make\" on remote host"
1032
1033
1034             # generate make call with make options
1035          if [[ $remote_host = nech ]]
1036          then
1037             make_call_string="sxmake  $make_options  PROG=$mainprog  F90=$compiler_name  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$loader_options\" "
1038          else
1039             make_call_string="make  $make_options  PROG=$mainprog  F90=$compiler_name  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$loader_options\" "
1040          fi
1041
1042             # generate command to load modules, if modules are given
1043          if [[ "$modules" != "" ]]
1044          then
1045             if [[ $remote_host = lctit ]]
1046             then
1047                module_calls=". $modules"
1048             else
1049                module_calls="module load ${modules};"
1050             fi
1051
1052                # bugfix for wrong netcdf module
1053             if [[ $remote_host = lcsgib  ||  $remote_host = lcsgih ]]
1054             then
1055                if [[ $(echo $module_calls | grep -c netcdf/3.6.3-intel) != 0 ]]
1056                then
1057                   module_calls="$module_calls export LD_LIBRARY_PATH=/sw/dataformats/netcdf/3.6.3-intel/lib:\$LD_LIBRARY_PATH;"
1058                fi
1059             fi
1060          else
1061             module_calls=""
1062          fi
1063
1064          if [[ $remote_host = ibmkisti  ||  $remote_host = ibms  ||  $remote_host = ibmy ]]
1065          then
1066
1067             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
1068
1069          elif [[ $remote_host = ibmh ]]
1070          then
1071
1072             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
1073
1074          elif [[ $remote_host = lcsgib  ||  $remote_host = lcsgih ]]
1075          then
1076#             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
1077             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
1078
1079          elif [[ $remote_host = lctit ]]
1080          then
1081
1082             echo  " "  >  ${remote_host}_last_make_protokoll
1083             while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]]
1084             do
1085                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
1086             done
1087
1088          elif [[ $remote_host = lcxe6 ]]
1089          then
1090
1091             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
1092
1093          else
1094
1095             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
1096
1097          fi
1098
1099          if [[ $(grep -c MAKE_ERROR ${remote_host}_last_make_protokoll) != 0 ]]
1100          then
1101             printf "\a\n  +++ error(s) occurred during compiling or linking on host \"$remote_host\" "
1102             if [[ $silent = false ]]
1103             then
1104                answer=dummy
1105                printf "\n"
1106                while [[ "$answer" != c  &&  "$answer" != k ]]
1107                do
1108                   printf "  >>> continue / list errors / kill mbuild (c/l/k) ? "
1109                   read  answer
1110                   if [[ "$answer" = l ]]
1111                   then
1112                      more ${remote_host}_last_make_protokoll
1113                   fi
1114                done
1115                if [[ $answer = k ]]
1116                then
1117                   locat=user_abort; exit
1118                fi
1119             fi
1120          fi
1121
1122
1123
1124             # NEUE VERSION AUF REMOTE-RECHNER ZUSAMMENPACKEN
1125          printf "\n  *** tar update on remote host ..."
1126          if [[ $remote_host != lctit ]]
1127          then
1128             ssh  ${remote_username}@${remote_addres}  "cd ${remote_md}; chmod u+w *; tar -cf  ${mainprog}_current_version.tar  ${mainprog}  *.f90 *.o *.mod"
1129          else
1130                # TIT ERLAUBT NUR DIE AUSFï¿œHRUNG GANZ BESTIMMTER KOMMANDOS
1131                # MIT SSH, DESHALB AUFRUF PER PIPE
1132             print  "cd ${remote_md}; chmod u+w *; tar -cf  ${mainprog}_current_version.tar  ${mainprog}  *.f90 *.o *.mod"  |  ssh  ${remote_username}@${remote_addres}  2>&1
1133          fi
1134
1135
1136             # AKTUELLES VERSIONSVERZEICHNIS AUF REMOTE-RECHNER BEREINIGEN
1137#          printf "\n  *** \"make clean\" on remote host ..."
1138#          ssh  ${remote_username}@${remote_addres}  "cd ${remote_md}; make clean; rm ${mainprog}_sources.tar; rm *.f90 Makefile"
1139#          printf "\n"
1140
1141
1142
1143
1144          # GLEICHE AKTIONEN FUER DIE UTILITY-PROGRAMME DURCHFUEHREN
1145          # AKTUELLE QUELLTEXTVERSION INS REMOTE-QUELLTEXTVERZEICHNIS KOPIEREN
1146          # FALLS DIESES NOCH NICHT EXISTIERT, WIRD ES ERZEUGT
1147       elif [[ $compile_utility_programs = true ]]
1148       then
1149
1150          printf "\n\n"
1151          echo "  *** copying scripts and utility programs to \"${remote_addres}:${remote_ud}/\" "
1152          cd  ${local_source_path}/../SCRIPTS
1153
1154          if [[ $remote_host != lctit ]]
1155          then
1156             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)"
1157          else
1158                # TIT ERLAUBT NUR DIE AUSFUEHRUNG GANZ BESTIMMTER KOMMANDOS
1159                # MIT SSH, DESHALB AUFRUF PER PIPE
1160             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
1161          fi
1162
1163             # KOPIEREN DER SCRIPTE
1164          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
1165
1166          cd  -  > /dev/null
1167          cd  ${local_source_path}/../UTIL
1168
1169
1170             # KOPIEREN DER UTILITY-PROGRAMME
1171          scp  Makefile  *.f90  ${remote_username}@${remote_addres}:${remote_ud}  >  /dev/null
1172
1173
1174
1175             # MAKE MIT ZUVOR ERMITTELTEN OPTIONEN AUF REMOTE RECHNER AUSFUEHREN
1176             # KOMMANDOUEBERGABE AN SSH PER PIPE, DA SO DIE SYSTEM- UND
1177             # BENUTZERPROFILE VOLLSTAENDIG AUSGEFUEHRT WERDEN (SONST FEHLEN MAKE
1178             # Z.B. DIE PFADE ZUM COMPILER)
1179          echo "  *** execute \"make\" on remote host"
1180
1181          if [[ $remote_host = nech ]]
1182          then
1183             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\" "
1184          else
1185             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\" "
1186          fi
1187
1188             # generate command to load modules, if modules are given
1189          if [[ "$modules" != "" ]]
1190          then
1191             if [[ $remote_host = lctit ]]
1192             then
1193                module_calls=". $modules"
1194             else
1195                module_calls="module load ${modules};"
1196             fi
1197
1198                # bugfix for wrong netcdf module
1199             if [[ $remote_host = lcsgib  ||  $remote_host = lcsgih ]]
1200             then
1201                if [[ $(echo $module_calls | grep -c netcdf/3.6.3-intel) != 0 ]]
1202                then
1203                   module_calls="$module_calls export LD_LIBRARY_PATH=/sw/dataformats/netcdf/3.6.3-intel/lib:\$LD_LIBRARY_PATH;"
1204                fi
1205             fi
1206          else
1207             module_calls=""
1208          fi
1209
1210
1211          if [[ $remote_host = ibms  ||  $remote_host = ibmy ]]
1212          then
1213
1214             ssh  ${remote_username}@${remote_addres}  "$init_cmds $module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR"
1215
1216          elif [[ $remote_host = ibmh ]]
1217          then
1218
1219             print "$init_cmds $module_calls export OBJECT_MODE=64; cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres}
1220
1221          elif [[ $remote_host = lctit ]]
1222          then
1223
1224             echo  " "  >  ${remote_host}_last_make_protokoll
1225             while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]]
1226             do
1227                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
1228             done
1229
1230          elif [[ $remote_host = lcxe6 ]]
1231          then
1232
1233             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
1234
1235          else
1236
1237             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
1238
1239          fi
1240
1241       fi    # ENDE UEBERSETZUNG DER UTILITY-PROGRAMME
1242
1243       rm -rf  ${remote_host}_last_make_protokoll
1244
1245       # make on local host
1246    else
1247
1248          # workaround for lcxe6
1249       if [[ $remote_host = lcxe6 ]]
1250       then
1251
1252          eval $init_cmds
1253
1254       fi
1255
1256       # first load modules, if given
1257       if [[ "$modules" != "" ]]
1258       then
1259          if [[ $remote_host = lctit ]]
1260          then
1261             . $modules
1262          elif [[ $remote_host = lcflow ]]
1263          then
1264             eval `$MODULESHOME/bin/modulecmd ksh load ${modules}`
1265          else
1266             module load ${modules}
1267          fi
1268       fi
1269
1270
1271       if [[ $compile_utility_programs = false ]]
1272       then
1273
1274             # DEPOSITORY VERZEICHNIS ERZEUGEN, FALLS NOCH NICHT VORHANDEN
1275          eval remote_md=$remote_md
1276          if [[ ! -d $remote_md ]]
1277          then
1278             if  mkdir $remote_md
1279             then
1280                printf "\n\n  *** directory for make depository:"
1281                printf "\n           $remote_md"
1282                printf "\n      was created\n"
1283             else
1284                printf "\n  +++ directory for make depository:"
1285                printf "\n           $remote_md"
1286                printf "\n      cannot be created"
1287                locat=local_depository_path; exit
1288             fi
1289          fi
1290
1291             # QUELLTEXT-DATEIEN AUS REPOSITORY INS DEPOSITORY KOPIEREN
1292          echo " "
1293          echo "  *** updating sources in $remote_md"
1294          cd  $remote_md
1295          cp  $local_source_path/${mainprog}_sources.tar  .
1296          tar xf  ${mainprog}_sources.tar
1297
1298             # MAKE MIT ZUVOR ERMITTELTEN OPTIONEN AUF LOKALEM RECHNER AUSFUEHREN
1299          echo " "
1300          echo "  *** execute \"make\" on local host"
1301
1302          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
1303
1304          if [[ $? != 0 ]]
1305          then
1306             printf "\a\n  +++ error(s) occurred during compiling or linking on host \"$remote_host\" "
1307             if [[ $silent = false ]]
1308             then
1309                answer=dummy
1310                printf "\n"
1311                while [[ "$answer" != c  &&  "$answer" != k ]]
1312                do
1313                   printf "  >>> continue / list errors / kill mbuild (c/l/k) ? "
1314                   read  answer
1315                   if [[ "$answer" = l ]]
1316                   then
1317                      more ${remote_host}_last_make_protokoll
1318                   fi
1319                done
1320                if [[ $answer = k ]]
1321                then
1322                   locat=user_abort; exit
1323                fi
1324             fi
1325          fi
1326
1327
1328             # TAR NEW VERSION ON LOCAL HOST
1329          printf "\n  *** tar update on local host ..."
1330          tar -cf  ${mainprog}_current_version.tar  *.$suf *.o *.mod
1331
1332
1333          # COMPILE THE UTILITY PROGRAMS
1334       elif [[ $compile_utility_programs = true ]]
1335       then
1336          printf "\n\n"
1337          echo "  *** compiling the utility programs ..."
1338          cd ${local_source_path}/../UTIL
1339
1340             # TOUCH FILES IN ORDER TO FORCE COMPILATION FOR EVERY BLOCK
1341          touch  *.f90
1342          make  $make_options  BLOCK=$block  F90=$compiler_name  F90_SER=$compiler_name_ser  COPT="$cpp_options"  F90FLAGS="$compiler_options"  LDFLAGS="$loader_options"
1343
1344             # CHECK IF QMAKE IS AVAILABLE AND COMPILE MRUNGUI
1345          if [[ $util_compiled_localhost == false ]]
1346          then
1347             printf "\n\n"
1348             echo "  *** compiling the mrun GUI"
1349             if which qmake >/dev/null; then
1350                cd mrungui
1351                touch *
1352                qmake
1353                make
1354                make clean
1355                rm Makefile
1356                cd ..
1357             else
1358                echo "  +++ no qmake found. The (optional) GUI will not be compiled."
1359             fi
1360
1361             # COMPILE CHECK_NAMELIST_FILES (ONLY FOR ONE BRANCH on LOCALHOST NEEDED)
1362
1363             printf "\n\n"
1364             echo "  *** compiling check_namelist_files ..."
1365
1366             # GET CHECK OPTIONS
1367             line=""
1368             found=false
1369             grep  "$remote_host_string" $config_file | grep "%cpp_options"  >  $tmp_mbuild
1370             while read line1
1371             do
1372
1373                if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
1374                then
1375                   line="$line1"
1376                fi
1377
1378                if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
1379                then
1380                   # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING UND ALLE -D ENTFERNEN
1381                   line="$line "
1382                   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'`
1383                   found=true
1384                fi
1385
1386             done < $tmp_mbuild
1387             copts_check="$copts_check -D__check -D__parallel"
1388
1389             check_depository_path=${local_source_path}/../UTIL
1390             cd $check_depository_path
1391             mkdir check_tmp
1392             cp ${local_source_path}/${mainprog}_sources_check.tar ./check_tmp
1393             cd check_tmp
1394             tar -xf  ${mainprog}_sources_check.tar
1395             rm -rf ${mainprog}_sources_check.tar
1396             make  -f Makefile_check $make_options  F90=$compiler_name_ser  COPT="$copts_check"  F90FLAGS="$compiler_options"
1397             tar -cf  check_namelist_files.tar Makefile_check check_namelist_files.x *.f90 *.o *.mod
1398             mv check_namelist_files.tar $check_depository_path
1399             mv check_namelist_files.x $PALM_BIN
1400             cd $check_depository_path
1401             rm -rf check_tmp
1402             util_compiled_localhost=true
1403          else
1404             cd $check_depository_path
1405             printf "\n\n"
1406             echo "  *** skipped compilation of mrun GUI."       
1407             printf "\n\n"
1408             echo "  *** skipped compilation of check_namelist_files."           
1409          fi
1410
1411       fi
1412    fi
1413 done
1414
1415
1416 if [[ $host_found = false ]]
1417 then
1418    if [[ $host = all ]]
1419    then
1420       printf "\n  +++ no hosts found in configuration file"
1421    else
1422       printf "\n  +++ host \"$host\" not found in configuration file"
1423    fi
1424    locat=config_file; exit
1425 fi
1426
1427 if [[ "$block_conditions" != none  &&  $block_conditions_found = false ]]
1428 then
1429    printf "\n  +++ block conditions \"$block_conditions\" not found for host \"$host\""
1430 fi
1431
1432
1433    # FINAL WORK
1434 rm -f  hosts_found_in_config_file
1435 rm -f ${local_source_path}/${mainprog}_sources_check.tar
1436
Note: See TracBrowser for help on using the repository browser.