source: palm/trunk/SCRIPTS/mbuild @ 1094

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

last commit documented

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