source: palm/trunk/SCRIPTS/mbuild @ 798

Last change on this file since 798 was 793, checked in by maronga, 12 years ago

GUI for mrun added

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