source: palm/trunk/SCRIPTS/mbuild @ 717

Last change on this file since 717 was 717, checked in by gryschka, 13 years ago

added lckordi

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