source: palm/trunk/SCRIPTS/mbuild @ 916

Last change on this file since 916 was 892, checked in by maronga, 12 years ago

bugfixes in parameter file check, adapted for lcxe6 (was lcxt4), new mrun.config parameter %login_init_cmd introduced

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