source: palm/trunk/SCRIPTS/mbuild @ 216

Last change on this file since 216 was 215, checked in by raasch, 15 years ago

precompilation mechanism completely revised: now one depository per configuration block, further change of output messages

  • Property svn:keywords set to Id Rev
File size: 48.2 KB
Line 
1#!/bin/ksh
2# mbuild - Programmuebersetzungsscript
3# $Id: mbuild 215 2008-11-18 09:54:31Z raasch $
4
5     # Prozedur zur Uebersetzung von Programmteilen mittels make-Mechanismus
6     # auf einem Remote-Rechner, ausgehend von Quellcode auf einem lokalen
7     # Rechner
8
9     # Folgende Probleme existieren unter Linux, wenn keine AT&T-Korn-Shell
10     # verwendet wird:
11     # Wertzuweisungen an Variablen innerhalb von DO-Schleifen werden nicht
12     # nach aussen weitergegeben. "while read line" funktioniert nicht
13     # innerhalb einer Pipe.
14
15     # letzte Aenderung:
16     # 06/05/02 - Siggi - Beginn der Entwicklung
17     # 12/06/02 - Siggi - Abschluss der Entwicklungsarbeiten
18     # 23/06/02 - Siggi - voerst kein make-clean, Abbruch bei batch-mode
19     # 24/07/02 - Siggi - Keine Verwendung der temporaeren Datei tmp_mbuild
20     #                    unter linux mehr noetig, da nun AT&T-Korn-Shell
21     #                    benutzt wird
22     # 12/09/02 - Siggi - ibmh (hanni.hlrn.de) validiert
23     # 19/12/02 - Siggi - ibmb validiert
24     # 05/02/03 - Siggi - hostname nobela included
25     # 04/03/03 - Siggi - host nech included
26     # 06/03/03 - Siggi - make_call_string is echoed without '' to
27     #                    file LAST_MAKE_CALL (otherwise error on NEC, because
28     #                    '' are part of compiler options
29     # 16/03/03 - Siggi - Two underscores are placed in front of every define
30     #                    string, in case that palm.f90 version contains
31     #                    such strings
32     # 16/04/03 - Siggi - First extensions for linux machines
33     # 24/06/03 - Siggi - host orkan included
34     # 17/07/03 - Siggi - IP adress set to new "cross" machine at DKRZ
35     # 24/07/03 - Siggi - host maestro admitted
36     # 06/08/03 - Siggi - host gregale admitted
37     # 05/11/03 - Siggi - hosts irifi and quanero are now belonging to lcmuk
38     # 19/11/03 - Heiko - on lcmuk, mbuild does not tar the *.i files
39     # 08/01/04 - Siggi - additional preprocessor directive for ibm included
40     #                    (-D$OMP=OMP) in order to avoid problems with
41     #                    OMP_NUM_THREADS
42     # 09/01/04 - Siggi - action above cancelled
43     # 28/01/04 - Siggi - action above re-cancelled
44     # 08/03/04 - Siggi - host scirocco admitted
45     # 26/03/04 - Siggi - .o and .mod files are also deleted in depository, if
46     #                    the respective .f90 file is not listed in the makefile
47     #                    and deletion is demanded by the user
48     # 12/04/04 - Siggi - scp2 instead of scp used for transfer from decalpha
49     #                    due to error in ssh installation (otherwise a prompt
50     #                    for the password appears)
51     # 23/07/04 - Siggi - changes due to the new berni configuration
52     #                    (federation switch)
53     # 08/09/04 - Siggi - hanni IP address changed to 130.75.4.10
54     # 23/09/04 - Joerg - correction of IP-Address for 'cross' (DKRZ)
55     # 09/03/05 - Siggi - on nech, mbuild does not tar the *.i files
56     # 31/03/05 - Siggi - mbuild does not tar *.i files any more
57     # 24/04/05 - Siggi - netcdf support on lcmuk
58     # 25/04/05 - Siggi - netcdf support on gfdl3 (decalpha)
59     # 12/05/05 - Siggi - netcdf support on ibm
60     #                    set OBJECT_MODE=64 for compiling on ibmb, ibmh
61     # 18/05/05 - Siggi - netcdf support on nec
62     # 19/05/05 - Siggi - IP addres 134.75.155.74 changed to 165.132.26.56
63     # 23/05/05 - Siggi - netcdf support on ibms
64     # 01/06/05 - Siggi - reset of cpp_options to "" on lcmuk
65     # 30/06/05 - Siggi - netcdf support on bora
66     # 20/10/05 - Siggi - update of netcdf-version on decalpha (gfdl3)
67     # 04/11/05 - Siggi - netcdf 3.6.0-p1 on ibmh/ibmb
68     # 30/12/05 - Siggi - change of IP adresses in subnet 130.75.105
69     #                    host gfdl5 (ibmy) admitted
70     # 10/01/06 - Siggi - cpp directive for NetCDF 64bit support
71     # 20/01/06 - Siggi - cpp directive for ibmy
72     # 09/02/06 - Marcus- compile only once on lcmuk (as on ibmh/ibmb)
73     # 10/02/06 - Siggi - modifications for scp on decalpha
74     # 13/04/06 - Siggi - ostria admitted
75     # 19/04/06 - Siggi - preprocessor directive -D$OMP=OMP for ibm removed
76     # 23/05/05 - Siggi - lctit (SUN Fire X4600) admitted
77     # 29/05/05 - Siggi - atmos (lcide) admitted
78     # 23/08/06 - Siggi - netcdf support for scirocco (notebook)
79     # 24/11/06 - Siggi - breva and levanto admitted
80     # 07/02/07 - Siggi - adapted for RIAM (neck)
81     # 10/02/07 - Siggi - all hpmuk-related code removed
82     # 02/03/07 - Siggi - compilation of utility programs and transfer of
83     #                    scripts to remote hosts added (option -u)
84     # 14/03/07 - Siggi - fimm admitted, revision number added to terminal
85     #                    output
86     # 16/03/07 - Siggi - adjustments (netcdf) for lctit
87     #                    adjustments for running under pdksh, local ip-addres
88     #                    is not determined any more
89     # 30/03/07 - Siggi - cpp-directives/options + netcdf-options are read
90     #                    from configuration file
91     #                    host identifier (local_host) is read from config file
92     # 10/10/07 - Siggi - bugfix: handling of comment lines
93     # 18/07/08 - Siggi - adapted for lcsgih
94     # 21/07/08 - Siggi - mainprog (executable) is added to the tar-file
95     #                    ({mainprog}_current_version)
96     # 02/10/08 - Siggi - adapted for lcxt4
97     # 14/11/08 - Siggi - update mechanism completely revised: source tarfile
98     #                    remains in source directory, one depository per block
99     #                    (given in the config-file) is created, always all files
100     #                    from the source directory are copied to the respective
101     #                    depository, no additional file checks are done any more
102     #                    (version 2.1)
103
104
105
106    # VARIABLENVEREINBARUNGEN + DEFAULTWERTE
107 compile_utility_programs=false
108 config_file=.mrun.config
109 fimm=false
110 host=all
111 host_found=false
112 ibm_hb_done=false
113 lcmuk_done=false
114 locat=normal
115 makefile=""
116 remote_mode=interactive
117 scirocco=false
118 silent=false
119 suf=f90
120 update=false
121 working_directory=`pwd`
122
123 typeset -i  ih ihost=0
124
125 typeset  -R30 calltime
126 typeset  -L20 column1
127 typeset  -L50 column2
128 typeset  -L70 column3
129 typeset  -L40 version="MBUILD  2.1  Rev$Rev: 215 $"
130
131    # FEHLERBEHANDLUNG
132    # BEI EXIT:
133 trap 'rm -rf  $working_directory/tmp_mbuild
134       if [[ $locat != normal ]]
135       then
136          printf "\n\n +++ mbuild killed \n\n"
137       else
138          printf "\n\n *** mbuild finished \n\n"
139       fi' exit
140
141
142    # BEI TERMINAL-BREAK:
143 trap 'rm -rf  $working_directory/tmp_mbuild
144       printf "\n\n +++ mbuild killed by \"^C\" \n\n"
145       exit
146      ' 2
147
148
149 tmp_mbuild=${working_directory}/tmp_mbuild
150
151    # SHELLSCRIPT-OPTIONEN EINLESEN
152 while  getopts  :c:h:m:rs:u  option
153 do
154   case  $option  in
155       (c)   config_file=$OPTARG;;
156       (h)   host=$OPTARG;;
157       (m)   makefile=$OPTARG;;
158       (r)   remote_mode=batch;;
159       (s)   suf=$OPTARG;;
160       (u)   compile_utility_programs=true;;
161       (\?)  printf "\n  +++ unknown option $OPTARG \n";
162             locat=parameter; exit;;
163   esac
164 done
165
166
167
168    # BATCH-MODE IST ZUR ZEIT NICHT FUNKTIONSFAEHIG
169 if [[ $remote_mode = batch ]]
170 then
171    printf "\n  +++ sorry, batch mode does not work! \n"
172    locat=parameter; exit
173 fi
174
175
176
177    # PRUEFEN, OB KONFIGURATIONS-DATEI VORHANDEN
178 if [[ ! -f $config_file ]]
179 then
180    printf "\n  +++ configuration file: "
181    printf "\n           $config_file"
182    printf "\n      does not exist"
183    locat=configuration; exit 
184 fi
185
186
187
188    # LOKALEN RECHNER ERMITTELN
189 local_host_real_name=$(hostname)
190# local_addres=$(nslookup `hostname` 2>&1 | grep "Address:" | tail -1 | awk '{print $2}')
191
192
193
194    # HOST-IDENTIFIER (local_host) AUS KONFIGURATIONSDATEI BESTIMMEN
195 line=""
196 grep  "%host_identifier"  $config_file  >  $tmp_mbuild
197 while read line
198 do
199    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
200    then
201       HOSTNAME=`echo $line | cut -d" " -s -f2`
202       host_identifier=`echo $line | cut -d" " -s -f3`
203       if [[ $local_host_real_name = $HOSTNAME ]]
204       then
205          local_host=$host_identifier
206          break
207       fi
208    fi
209 done < $tmp_mbuild
210
211 if [[ "$local_host" = "" ]]
212 then
213    printf "\n  +++ no host identifier found in configuration file \"$config_file\""
214    printf "\n      for local host \"$local_host_real_name\"."
215    printf "\n      Please add line"
216    printf "\n      \"\%host_identifier $local_host_real_name <identifier>\""
217    printf "\n      to the configuration file."
218    locat=local_host; exit
219 fi
220
221
222
223 [[ $local_host_real_name = scirocco ]]  &&  scirocco=true
224 [[ $local_host_real_name = fimm.bccs.uib.no ]]  &&  fimm=true
225
226
227
228 if [[ $local_host != ibms ]]
229 then
230    config_file=$PWD/$config_file
231 else
232    config_file=`pwd`/$config_file
233 fi
234
235
236 
237    # BENUTZERNAMEN AUF LOKALEM RECHNER AUS KONFIGURATIONSDATEI ERMITTELN
238 line=""
239 grep  " $local_host" $config_file | grep "%remote_username"  >  $tmp_mbuild
240 while read line
241 do
242    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
243    then
244       local_username=`echo $line | cut -d" " -s -f2`
245    fi
246 done < $tmp_mbuild
247
248
249 if [[ "$local_username" = "" ]]
250 then
251    printf "\n  +++ no user name found in configuration file"
252    printf "\n      for local host \"$local_host\" "
253    locat=config_file; exit
254 fi
255
256
257    # LOKALEN QUELLTEXTPFAD ERMITTELN.
258    # ZUERST PRUEFEN, OB EIN GLOBALER QUELLTEXTPFAD FUER ALLE RECHNER
259    # VEREINBART WURDE.
260    # DAZU ZUNAECHST ALLE IN DER KONFIGURATIONSDATEI VEREINBARTEN GLOBALEN
261    # VARIABLEN SETZEN, WEIL DIESE EVTL. IN PFADNAMEN VERWENDET WERDEN
262 line=""
263 grep "%" $config_file  >  $tmp_mbuild
264 while read line
265 do
266    if [[ "$line" != ""  &&  "$(echo $line | cut -d" " -s -f3)" = ""  &&  $(echo $line | cut -c1) != "#" ]]
267    then
268       var=`echo $line | cut -d" " -s -f1 | cut -c2-`
269       value=`echo $line | cut -d" " -s -f2`
270       eval export $var=\$value
271#       eval echo \"   $var=\$$var \"   # AUSGABE ZU TESTZWECKEN
272    fi
273 done < $tmp_mbuild
274
275    # NUN PRUEFEN, OB EIN GLOBALER QUELLTEXTPFAD VEREINBART WURDE
276 line=""
277 grep "%source_path" $config_file  >  $tmp_mbuild
278 while read line
279 do
280    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
281    then
282       if [[ "$(echo $line | cut -d" " -s -f3)" = "" ]]
283       then
284          global_source_path=`echo $line | cut -d" " -s -f2`
285       fi
286    fi
287 done < $tmp_mbuild
288
289 line=""
290 grep  " $local_host" $config_file | grep "%source_path"  >  $tmp_mbuild
291 while read line
292 do
293    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
294    then
295       local_source_path=`echo $line | cut -d" " -s -f2`
296    fi
297 done < $tmp_mbuild
298
299 if [[ "$local_source_path" = "" ]]
300 then
301    if [[ "$global_source_path" != "" ]]
302    then
303       local_source_path=$global_source_path
304    else
305       printf "\n  +++ no source path found in configuration file"
306       printf "\n      for local host \"$local_host\" "
307       printf "\n      please set \"\%source_path\" in configuration file"
308       locat=config_file; exit
309    fi
310 fi
311 eval local_source_path=$local_source_path
312 eval local_source_path=$local_source_path
313
314
315
316    # GLOBALEN DEPOSITORY-PFAD ERMITTELN
317 line=""
318 grep "%depository_path" $config_file  >  $tmp_mbuild
319 while read line
320 do
321    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
322    then
323       if [[ "$(echo $line | cut -d" " -s -f3)" = "" ]]
324       then
325          global_depository_path=`echo $line | cut -d" " -s -f2`
326       fi
327    fi
328 done < $tmp_mbuild
329
330
331
332    # PRUEFEN, OB IN KONFIGURATIONSDATEI EIN HAUPTPROGRAMM
333    # VEREINBART WURDE
334 if [[ $(grep -c "%mainprog" $config_file) != 1 ]]
335 then
336    printf "\n  +++ no main program or more than one main program defined"
337    printf "\n      in configuration file"
338    locat=configuration; exit
339 else
340    line=`grep "%mainprog" $config_file`
341    if [[ "$line" = ""  ||  $(echo $line | cut -c1) = "#" ]]
342    then
343       printf "\n  +++ no main program defined in configuration file"
344       locat=configuration; exit
345    fi
346    mainprog=`echo $line | cut -d" " -s -f2 | cut -d"." -f1`
347 fi
348
349
350
351    # MAKEFILE vorhanden
352 [[ "$makefile" = "" ]]  &&  makefile=$local_source_path/Makefile
353 if [[ ! -f $makefile ]]
354 then
355    printf "\n  +++ makefile: "
356    printf "\n           $makefile"
357    printf "\n      does not exist"
358    locat=makefile; exit 
359 fi
360
361
362    # HEADER-AUSGABE (TEIL1: MELDUNGEN UEBER LOKALEN RECHNER)
363 calltime=$(date)
364 printf "\n"
365 printf "#------------------------------------------------------------------------# \n"
366 printf "| $version$calltime | \n"
367 printf "|                                                                        | \n"
368 column1="called on:"; column2=$local_host_real_name
369 printf "| $column1$column2 | \n"
370 column1="local username:"; column2=$local_username
371 printf "| $column1$column2 | \n"
372 column1="local IP-addres:"; column2=$local_addres
373 printf "| $column1$column2 | \n"
374 column1="config file:"; column2=$config_file
375 printf "| $column1$column2 | \n"
376 column1="makefile:"; column2=$makefile
377 printf "| $column1$column2 | \n"
378 column1="local source path:"; column2=$local_source_path
379 printf "| $column1$column2 | \n"
380 printf "#------------------------------------------------------------------------# \n"
381
382# printf "|                                                                        | \n"
383
384
385 if [[ $compile_utility_programs = false ]]
386 then
387
388       # IN JEDEM FALL ALLEN DATEIEN WRITE-PERMIT GEBEN, DAMIT ES AUF
389       # DEN REMOTE-RECHNERN NICHT EVTL. ZU PROBLEMEN BEIM UEBERSCHREIBEN KOMMT
390    cd  $local_source_path
391    printf "\n\n  *** tar of makefile and source files in $local_source_path" 
392    tar -cf  ${mainprog}_sources.tar  Makefile  *.$suf
393    printf "\n"
394
395 fi
396
397
398
399    # BESTAETIGUNG ZUM WEITERMACHEN EINHOLEN
400 if [[ $host = all ]]
401 then
402    printf "\n  *** updates will be made for ALL hosts found in"
403    printf "\n      the configuration file"
404 else
405    printf "\n  *** update will be made for host \"$host\" "
406 fi
407
408 if [[ $silent = false ]]
409 then
410    answer=dummy
411    printf "\n\n"
412    while [[ "$answer" != y  &&  "$answer" != Y  &&  "$answer" != n  &&  "$answer" != N ]]
413    do
414       printf " >>> continue (y/n) ?  "
415       read  answer
416    done
417    if [[ $answer = n  ||  $answer = N ]]
418    then
419       locat=user_abort; exit
420    fi
421 fi
422 
423 
424
425   
426    # GENERIERUNG DER AKTUELLEN MODELLVERSION FUER ALLE RECHNER-/UEBERSETZUNGS-
427    # VERSIONEN, DIE IN DER KONFIGURATIONSDATEI GEFUNDEN WERDEN
428 printf "\n  *** scanning configuration file for host(s) ..."
429
430 grep  %fopts  $config_file  >  $tmp_mbuild
431 while read line
432 do
433       # KOMMENTARZEILEN UEBERSPRINGEN
434    [[ $(echo $line | cut -c1) = "#" ]]  &&  continue
435    (( ihost = ihost + 1 ))
436    hostline[$ihost]="$line"
437 done < $tmp_mbuild
438
439 
440 while (( ih < ihost ))
441 do
442
443    (( ih = ih + 1 ))
444
445       # REMOTE-RECHNER UND UEBERSETZUNGS-VERSION FESTSTELLEN
446       # NUR WEITERMACHEN, WENN ENTSPRECHENDER REMOTE-RECHNER MITTELS
447       # SHELLSCRIPT-OPTION AUCH AUSGEWAEHLT WURDE
448    remote_host_string=`echo ${hostline[$ih]} | cut -d" " -s -f3-`
449    remote_host=`echo $remote_host_string | cut -d" " -f1`
450    if [[ $host != all ]]
451    then
452       [[ $remote_host != $host ]]  &&  continue
453    fi
454    host_found=true
455    condition1=`echo $remote_host_string | cut -d" " -s -f2`
456    if [[ $condition1 = $remote_host ]]
457    then
458       condition1=""
459    else
460       condition2=`echo $remote_host_string | cut -d" " -s -f3`
461    fi
462
463    netcdf_inc=""
464    netcdf_lib=""
465
466       # AUF HLRN-RECHNER NUR EINMAL UEBERSETZEN
467    if [[ $remote_host = ibmb  ||  $remote_host = ibmh ]]
468    then
469       if [[ $ibm_hb_done = true ]]
470       then
471          printf "\n *** remote host \"$remote_host\" skipped since compilation has already"
472          printf "\n     been carried out on one of the HLRN machines\n"
473          continue
474       fi
475    fi
476
477       # AUF LCMUK-RECHNER NUR EINMAL UEBERSETZEN
478    if [[ $remote_host = lcmuk ]]
479    then
480       if [[ $lcmuk_done = true ]]
481       then
482          printf "\n *** local host \"$remote_host\" skipped since compilation has already"
483          printf "\n     been carried out on this host\n"
484          continue
485       fi
486    fi
487
488
489       # IP-ADRESSE DES REMOTE-RECHNERS BESTIMMEN
490    case  $remote_host  in
491        (lcmuk)          remote_addres=130.75.105.2;;
492        (lcsgib)         remote_addres=130.73.232.102;;
493        (lcsgih)         remote_addres=130.75.4.103;;
494        (lctit)          remote_addres=172.17.75.161;;
495        (lcxt4)          remote_addres=129.177.20.113;;
496        (decalpha)       remote_addres=165.132.26.56;;
497        (ibmb)           remote_addres=130.73.230.10;;
498        (ibmh)           remote_addres=130.75.4.10;;
499        (ibms)           remote_addres=150.183.5.101;;
500        (ibmy)           remote_addres=165.132.26.58;;
501        (nech)           remote_addres=136.172.44.192;;
502        (neck)           remote_addres=133.5.178.11;;
503        (ground.yonsei.ac.kr) remote_addres=134.75.155.33;;
504        (*)              if [[ $local_host != $remote_host ]]
505                         then
506                            printf "\n  +++ remote host \"$remote_host\" unknown";
507                            printf "\n      please inform S. Raasch!"
508                         fi;;
509    esac
510
511
512       # REMOTE-USERNAMEN ERMITTELN
513    line=""
514    found=false
515    grep  "$remote_host_string" $config_file | grep "%remote_username"  >  $tmp_mbuild
516    while read line1
517    do
518
519       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
520       then
521          line="$line1"
522       fi
523
524       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
525       then
526          remote_username=`echo $line | cut -d" " -s -f2`
527          found=true
528       fi
529
530    done < $tmp_mbuild
531
532    if [[ $found = false ]]
533    then
534       printf "\n  +++ no remote username found in configuration file"
535       printf "\n      for \"$remote_host_string\" "
536       locat=config_file; exit
537    fi
538
539
540       # REMOTE-QUELLTEXTPFAD ERMITTELN
541    line=""
542    remote_source_path=""
543    grep  "$remote_host_string" $config_file | grep "%source_path"  >  $tmp_mbuild
544    while read line1
545    do
546
547       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
548       then
549          line="$line1"
550       fi
551
552       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
553       then
554          remote_source_path=`echo $line | cut -d" " -s -f2`
555       fi
556
557    done < $tmp_mbuild
558
559    if [[ "$remote_source_path" = "" ]]
560    then
561       if [[ "$global_source_path" != "" ]]
562       then
563          remote_source_path=$global_source_path
564       else
565          printf "\n  +++ no source path found in configuration file"
566          printf "\n      for \"$remote_host_string\" "
567          locat=config_file; exit
568       fi
569    fi
570
571    remote_ud=${remote_source_path}/../UTIL
572    remote_ud=$(eval echo $remote_ud)
573
574
575       # REMOTE-PFAD FUER MAKE-DEPOSITORY ERMITTELN
576    remote_md=""
577    line=""
578    grep  "$remote_host_string" $config_file | grep "%depository_path"  >  $tmp_mbuild
579    while read line1
580    do
581
582       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
583       then
584          line="$line1"
585       fi
586
587       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
588       then
589          remote_md=`echo $line | cut -d" " -s -f2`
590       fi
591
592    done < $tmp_mbuild
593
594    if [[ "$remote_md" = "" ]]
595    then
596       if [[ "$global_depository_path" != "" ]]
597       then
598          remote_md=$global_depository_path
599       else
600          printf "\n  +++ no depository path found in configuration file"
601          printf "\n      for \"$remote_host_string\" "
602          printf "\n      please set \"\%depository_path\" in configuration file"
603          locat=config_file; exit
604       fi
605    fi
606
607    remote_md=$(eval echo $remote_md)
608    [[ "$condition1" != "" ]]  &&  remote_md=${remote_md}_$condition1
609    [[ "$condition2" != "" ]]  &&  remote_md=${remote_md}_$condition2
610
611
612       # COMPILERNAMEN ERMITTELN
613    line=""
614    found=false
615    grep  "$remote_host_string" $config_file | grep "%compiler_name "  >  $tmp_mbuild
616    while read line1
617    do
618
619       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
620       then
621          line="$line1"
622       fi
623
624       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
625       then
626          compiler_name=`echo $line | cut -d" " -s -f2`
627          found=true
628       fi
629
630    done < $tmp_mbuild
631
632    if [[ $found = false ]]
633    then
634       printf "\n  +++ no compiler name found in configuration file"
635       printf "\n      for \"$remote_host_string\" "
636       locat=config_file; exit
637    fi
638
639
640       # BEI BENUTZUNG EINES PARALLELEN COMPILERS MUSS AUCH EIN
641       # SERIELLER COMPILERNAME ERMITTELT WERDEN
642    if [[ $(echo $remote_host_string | grep -c parallel) = 1 ]]
643    then
644       line=""
645       found=false
646       grep  "$remote_host_string" $config_file | grep "%compiler_name_ser"  >  $tmp_mbuild
647       while read line1
648       do
649
650          if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
651          then
652             line="$line1"
653          fi
654
655          if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
656          then
657             compiler_name_ser=`echo $line | cut -d" " -s -f2`
658             found=true
659          fi
660
661       done < $tmp_mbuild
662
663       if [[ $found = false ]]
664       then
665          printf "\n  +++ no serial compiler name found in configuration file"
666          printf "\n      for \"$remote_host_string\" "
667          locat=config_file; exit
668       fi
669    else
670       compiler_name_ser=$compiler_name
671    fi
672
673
674
675       # PRAEPROZESSOR-OPTIONEN/DIREKTIVEN ERMITTELN
676    line=""
677    found=false
678    grep  "$remote_host_string" $config_file | grep "%cpp_options"  >  $tmp_mbuild
679    while read line1
680    do
681
682       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
683       then
684          line="$line1"
685       fi
686
687       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
688       then
689             # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING ENTFERNEN
690          cpp_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
691          found=true
692       fi
693
694    done < $tmp_mbuild
695
696    if [[ $found = false ]]
697    then
698       printf "\n  +++ no preprocessor options found in configuration file"
699       printf "\n      for \"$remote_host_string\" "
700       locat=config_file; exit
701    fi
702
703
704       # RECHNERSPEZIFISCHE CPP-DIREKTIVEN HINZUFUEGEN
705    for  string  in  $remote_host_string
706    do
707       if [[ $(echo $remote_host | cut -c1-2) = lc  &&  $(echo $string | cut -c1-2) = lc ]]
708       then
709          cpp_options="$cpp_options -D__lc "
710       elif [[ $(echo $remote_host | cut -c1-3) = ibm  &&  $(echo $string | cut -c1-3) = ibm ]]
711       then
712          cpp_options="${cpp_options},-D__ibm"
713       elif [[ $(echo $remote_host | cut -c1-3) = nec  &&  $(echo $string | cut -c1-3) = nec ]]
714       then
715          cpp_options="${cpp_options} -D__nec"
716       else
717          if [[ $(echo $remote_host | cut -c1-3) = ibm ]]
718          then
719             cpp_options="${cpp_options},-D__$string"
720          else
721             cpp_options="$cpp_options -D__$string "
722          fi
723       fi
724    done
725
726
727
728       # NETCDF-OPTIONEN ERMITTELN
729    line=""
730    grep  "$remote_host_string" $config_file | grep "%netcdf_inc"  >  $tmp_mbuild
731    while read line1
732    do
733
734       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
735       then
736          line="$line1"
737       fi
738
739       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
740       then
741             # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING ENTFERNEN
742          netcdf_inc=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
743       fi
744
745    done < $tmp_mbuild
746
747    line=""
748    grep  "$remote_host_string" $config_file | grep "%netcdf_lib"  >  $tmp_mbuild
749    while read line1
750    do
751
752       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
753       then
754          line="$line1"
755       fi
756
757       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
758       then
759             # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING ENTFERNEN
760          netcdf_lib=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
761       fi
762
763    done < $tmp_mbuild
764
765
766
767       # COMPILEROPTIONEN ERMITTELN
768    line=""
769    found=false
770    grep  "$remote_host_string" $config_file | grep "%fopts"  >  $tmp_mbuild
771    while read line1
772    do
773
774       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
775       then
776          line="$line1"
777       fi
778
779       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
780       then
781             # EVENTUELLE DOPPELPUNKTE AUS DIREKTIVENSTRING ENTFERNEN
782          compiler_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
783          found=true
784
785             # NETCDF-INCLUDEVERZEICHNIS HINZUFUEGEN
786          compiler_options="$compiler_options $netcdf_inc"
787       fi
788
789    done < $tmp_mbuild
790
791    if [[ $found = false ]]
792    then
793       printf "\n  +++ no compiler options found in configuration file"
794       printf "\n      for \"$remote_host_string\" "
795       locat=config_file; exit
796    fi
797
798
799
800       # LADER-OPTIONEN ERMITTELN
801    line=""
802    found=false
803    grep  "$remote_host_string" $config_file | grep "%lopts"  >  $tmp_mbuild
804    while read line1
805    do
806
807       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
808       then
809          line="$line1"
810       fi
811
812       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
813       then
814             # EVENTUELLE DOPPELPUNKTE AUS DIREKTIVENSTRING ENTFERNEN
815          loader_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
816          found=true
817
818             # NETCDF-LIBRARY HINZUFUEGEN
819          loader_options="$loader_options $netcdf_lib"
820       fi
821
822    done < $tmp_mbuild
823
824    if [[ $found = false ]]
825    then
826       printf "\n  +++ no loader options found in configuration file"
827       printf "\n      for \"$remote_host_string\" "
828       locat=config_file; exit
829    fi
830
831
832    printf "\n\n#------------------------------------------------------------------------# \n"
833    if [[ $remote_host = $local_host ]]
834    then
835       column1="remote_host:"; column2="$remote_host (= local host!)"
836    else
837       column1="remote_host:"; column2=$remote_host
838    fi
839    printf "| $column1$column2 | \n"
840    printf "|                                                                        | \n"
841    column1="conditions:"; column2="$condition1 $condition2"
842    printf "| $column1$column2 | \n"
843    column1="make depository:"; column2=$remote_md
844    printf "| $column1$column2 | \n"
845    line=$(echo "$remote_md" | cut -c51-)
846    while [[ "$line" != "" ]]
847    do
848       column1=""
849       column2=$line
850       printf "| $column1$column2 | \n"
851       line=$(echo "$line" | cut -c51-)
852    done
853    if [[ $compile_utility_programs = true ]]
854    then
855       column1="utility directory:"; column2=$remote_ud
856       printf "| $column1$column2 | \n"
857    fi
858    column1="username:"; column2=$remote_username
859    printf "| $column1$column2 | \n"
860    column1="addres:"; column2=$remote_addres
861    printf "| $column1$column2 | \n"
862    column1="compiler:"; column2=$compiler_name
863    printf "| $column1$column2 | \n"
864    if [[ $compile_utility_programs = true ]]
865    then
866       column1="serial compiler:"; column2=$compiler_name_ser
867       printf "| $column1$column2 | \n"
868    fi
869    column1="cpp options:"; column2=$cpp_options
870    printf "| $column1$column2 | \n"
871    line=$(echo "$cpp_options" | cut -c51-)
872    while [[ "$line" != "" ]]
873    do
874       column1=""
875       column2=$line
876       printf "| $column1$column2 | \n"
877       line=$(echo "$line" | cut -c51-)
878    done
879    column1="compiler options:"; column2=$compiler_options
880    printf "| $column1$column2 | \n"
881    line=$(echo "$compiler_options" | cut -c51-)
882    while [[ "$line" != "" ]]
883    do
884       column1=""
885       column2=$line
886       printf "| $column1$column2 | \n"
887       line=$(echo "$line" | cut -c51-)
888    done
889    column1="loader options:"; column2=$loader_options
890    printf "| $column1$column2 | \n"
891    line=$(echo "$loader_options" | cut -c51-)
892    while [[ "$line" != "" ]]
893    do
894       column1=""
895       column2=$line
896       printf "| $column1$column2 | \n"
897       line=$(echo "$line" | cut -c51-)
898    done
899    printf "#------------------------------------------------------------------------# \n"
900
901    if [[ $silent = false ]]
902    then
903       answer=dummy
904       printf "\n\n"
905       while [[ "$answer" != y  &&  "$answer" != Y  && "$answer" != c  &&  "$answer" != C  && "$answer" != s  &&  "$answer" != S  &&  "$answer" != a  &&  "$answer" != A ]]
906       do
907          printf " >>> continue (y(es)/c(ontinue)/a(bort)/s(skip)) ?  "
908          read  answer
909       done
910       if [[ $answer = a  ||  $answer = A ]]
911       then
912          locat=user_abort; exit
913       fi
914       if [[ $answer = c  ||  $answer = C ]]
915       then
916          silent=false
917       fi
918       if [[ $answer = s  ||  $answer = S ]]
919       then
920          continue
921       fi
922    fi
923
924
925    if [[ $remote_mode = batch ]]
926    then
927
928          # BATCH-JOB PARAMETER SETZEN
929       case  $remote_host  in
930           (t3eb)           queue=berte; memory=60; cputime=1000; xoption="-X 0";;
931           (t3eh)           queue=comp_t3e; memory=60; cputime=360;;
932           (t3ej2)          queue=normal; memory=60; cputime=1000; xoption="-X 0";;
933           (t3ej5|ground.yonsei.ac.kr)  printf "\n  --- remote host \"$remote_host\" does not allow batch jobs"; continue;;
934       esac
935
936
937          # BATCH-JOB ZUSAMMENSTELLEN
938       printf "\n  *** creating batch-job for remote host"
939       echo " "  >  mbuild_job
940
941          # AUF CRAY-RECHNERN IN JUELICH WIRD KEIN BENUTZER-PROFILE AUSGEFUEHRT
942          # DIES WIRD HIER GETAN, UM PFADE USW. ZU SETZEN
943       if [[ $remote_host = t3ej2 ]]
944       then
945          echo "set +vx"                       >>  mbuild_job
946          echo ". .profile"                    >>  mbuild_job
947          echo "set -x"                        >>  mbuild_job
948       fi
949
950          # AUF CRAY-RECHNERN GELADENE MODULE AUFLISTEN
951       if [[ $host = t3eb  || $host = t3eh  ||  $host = t3ej2 ]]
952       then
953          echo "module list"                   >>  mbuild_job
954       fi
955
956
957          # WECHSEL IN TEMPORAERES VERZEICHNIS
958       echo "cd ${remote_md}"  >>  mbuild_job
959
960
961          # AKTUELLE QUELLTEXTVERSION INS REMOTE-QUELLTEXTVERZEICHNIS KOPIEREN
962       echo  "scp  ${local_username}@${local_addres}:~/modell/code_3dp/palm_current_version/${mainprog}_sources.tar  ${mainprog}_sources.tar"  >>  mbuild_job
963#       echo  "[[ \$? != 0 ]]  &&  (echo "+++ scp failed"; exit)"  >>  mbuild_job
964
965
966          # FALLS VORHANDEN, LETZTE VERSION AUF DEM REMOTE-RECHNER AUSPACKEN
967       echo  "[[ -f ${mainprog}_current_version.tar ]]  &&  tar -xvf  ${mainprog}_current_version.tar"  >>  mbuild_job
968
969
970          # AKTUELLE QUELLTEXTVERSION AUF REMOTE-RECHNER AUSPACKEN
971       echo  "tar -xvf  ${mainprog}_sources.tar"              >>  mbuild_job
972
973
974          # MAKE MIT ZUVOR ERMITTELTEN OPTIONEN AUF REMOTE RECHNER AUSFUEHREN
975       echo  "make  PROG=$mainprog  F90=$compiler_name  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$loader_options\" "  >>  mbuild_job
976       echo  "chmod  u+w  *"                                  >>  mbuild_job
977
978          # NEUE VERSION AUF REMOTE-RECHNER ZUSAMMENPACKEN
979       echo  "tar -cvf  ${mainprog}_current_version.tar  *.f90  *.o"  >>  mbuild_job
980
981
982          # AKTUELLES VERSIONSVERZEICHNIS AUF REMOTE-RECHNER BEREINIGEN
983       echo  "make  clean"                                    >>  mbuild_job
984       echo  "rm ${mainprog}_sources.tar"                     >>  mbuild_job
985       echo  "rm *.f90 Makefile"                              >>  mbuild_job
986
987
988
989          # JOB MITTELS SUBJOB STARTEN
990       printf "\n  *** sending batch job to remote host"
991#       subjob  $xoption  -h $remote_host  -q $queue  -m $memory  -t $cputime  -v  mbuild_job
992
993
994          # JOBFILE LOESCHEN
995#       rm  aljob
996
997    else
998
999       if [[ $remote_host != $local_host ]]
1000       then
1001
1002          if [[ $compile_utility_programs = false ]]
1003          then
1004
1005                # AKTUELLE QUELLTEXTVERSION INS REMOTE-QUELLTEXTVERZEICHNIS KOPIEREN
1006                # FALLS DIESES NOCH NICHT EXISTIERT, WIRD ES ERZEUGT
1007             echo "  *** copying \"${mainprog}_sources.tar\" to \"${remote_addres}:${remote_md}/\" "
1008             if [[ $remote_host != lctit ]]
1009             then
1010                ssh  ${remote_username}@${remote_addres} "[[ ! -d ${remote_md} ]]  &&  (echo \"  *** ${remote_md} will be created\"; mkdir -p  ${remote_md})"
1011             else
1012                   # TIT ERLAUBT NUR DIE AUSFï¿œHRUNG GANZ BESTIMMTER KOMMANDOS
1013                   # MIT SSH, DESHALB AUFRUF PER PIPE
1014                print "[[ ! -d ${remote_md} ]]  &&  (echo \"  *** ${remote_md} will be created\"; mkdir -p  ${remote_md})"  |  ssh ${remote_username}@${remote_addres}  2>&1
1015             fi
1016             if [[ $local_host = decalpha ]]
1017             then
1018                   # DECALPHA BENUTZT BEI NICHTANGABE DES VOLLSTï¿œNDIGEN PFADES
1019                   # IRGENDEIN ANDERES SCP (WAS NICHT FUNKTIONIERT). AUSSERDEM
1020                   # KOENNEN DOLLAR-ZEICHEN NICHT BENUTZT WERDEN
1021                remote_md=`echo $remote_md | sed 's/\$HOME\///'`
1022                /bin/scp  ${local_source_path}/${mainprog}_sources.tar  ${remote_username}@${remote_addres}:${remote_md}/${mainprog}_sources.tar
1023             else
1024                scp  ${local_source_path}/${mainprog}_sources.tar  ${remote_username}@${remote_addres}:${remote_md}/${mainprog}_sources.tar
1025             fi
1026
1027
1028
1029                # FALLS VORHANDEN, LETZTE VERSION AUF DEM REMOTE-RECHNER AUSPACKEN
1030             echo "  *** untar previous update on remote host, if existing"
1031             if [[ $remote_host != lctit ]]
1032             then
1033                ssh  ${remote_username}@${remote_addres}  "cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]]  &&  tar -xf  ${mainprog}_current_version.tar"
1034             else
1035                   # TIT ERLAUBT NUR DIE AUSFï¿œHRUNG GANZ BESTIMMTER KOMMANDOS
1036                   # MIT SSH, DESHALB AUFRUF PER PIPE
1037                print  "cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]]  &&  tar -xf  ${mainprog}_current_version.tar"  |  ssh  ${remote_username}@${remote_addres}  2>&1
1038             fi
1039
1040
1041                # AKTUELLE QUELLTEXTVERSION AUF REMOTE-RECHNER AUSPACKEN
1042             echo "  *** untar actual sources on remote host"
1043             if [[ $remote_host != lctit ]]
1044             then
1045                ssh  ${remote_username}@${remote_addres}  "cd ${remote_md}; tar -xf  ${mainprog}_sources.tar"
1046             else
1047                   # TIT ERLAUBT NUR DIE AUSFï¿œHRUNG GANZ BESTIMMTER KOMMANDOS
1048                   # MIT SSH, DESHALB AUFRUF PER PIPE
1049                print  "cd ${remote_md}; tar -xf  ${mainprog}_sources.tar"  |  ssh  ${remote_username}@${remote_addres}  2>&1
1050             fi
1051
1052
1053                # MAKE MIT ZUVOR ERMITTELTEN OPTIONEN AUF REMOTE RECHNER AUSFUEHREN
1054                # KOMMANDOUEBERGABE AN SSH PER PIPE, DA SO DIE SYSTEM- UND
1055                # BENUTZERPROFILE VOLLSTAENDIG AUSGEFUEHRT WERDEN (SONST FEHLEN MAKE
1056                # Z.B. DIE PFADE ZUM COMPILER)
1057             echo "  *** execute \"make\" on remote host"
1058
1059             if [[ $remote_host = nech ]]
1060             then
1061                make_call_string="sxmake  PROG=$mainprog  F90=$compiler_name  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$loader_options\" "
1062             else
1063                make_call_string="make  PROG=$mainprog  F90=$compiler_name  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$loader_options\" "
1064             fi
1065
1066             if [[ $remote_host = t3eh ]]
1067             then
1068       
1069                print "xterm\nexit\n cd ${remote_md}; make  PROG=$mainprog  F90=$compiler_name  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$loader_options\" " | ssh  ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
1070
1071             elif [[ $remote_host = t3ej2  ||  $remote_host = ibms  ||  $remote_host = ibmy ]]
1072             then
1073
1074                ssh  ${remote_username}@${remote_addres}  "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
1075
1076             elif [[ $remote_host = ibmb  ||  $remote_host = ibmh ]]
1077             then
1078
1079                print "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
1080
1081             elif [[ $remote_host = lcsgib  ||  $remote_host = lcsgih ]]
1082             then
1083
1084                print ". /usr/share/modules/init/bash; module load mpt/1.21; 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
1085#                print ". /usr/share/modules/init/bash; module load mvapich2/1.2rc1-intel; cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
1086#                print ". /usr/share/modules/init/bash; module load mvapich2; 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
1088             elif [[ $remote_host = lctit ]]
1089             then
1090
1091                echo  " "  >  ${remote_host}_last_make_protokoll
1092                while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]]
1093                do
1094                   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
1095                done
1096
1097             elif [[ $remote_host = lcxt4 ]]
1098             then
1099
1100                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
1101
1102             else
1103
1104                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
1105
1106             fi
1107
1108             if [[ $(grep -c MAKE_ERROR ${remote_host}_last_make_protokoll) != 0 ]]
1109             then
1110                printf "\a\n  +++ error(s) occurred during compiling or linking on host \"$remote_host\" "
1111                if [[ $silent = false ]]
1112                then
1113                   answer=dummy
1114                   printf "\n"
1115                   while [[ "$answer" != c  &&  "$answer" != k ]]
1116                   do
1117                      printf "  >>> continue / list errors / kill mbuild (c/l/k) ? "
1118                      read  answer
1119                      if [[ "$answer" = l ]]
1120                      then
1121                         more ${remote_host}_last_make_protokoll
1122                      fi
1123                   done
1124                   if [[ $answer = k ]]
1125                   then
1126                      locat=user_abort; exit
1127                   fi
1128                fi
1129             fi
1130
1131
1132
1133                # NEUE VERSION AUF REMOTE-RECHNER ZUSAMMENPACKEN
1134             printf "\n  *** tar update on remote host ..."
1135             if [[ $remote_host != lctit ]]
1136             then
1137                ssh  ${remote_username}@${remote_addres}  "cd ${remote_md}; chmod u+w *; tar -cf  ${mainprog}_current_version.tar  ${mainprog}  *.f90 *.o *.mod"
1138             else
1139                   # TIT ERLAUBT NUR DIE AUSFï¿œHRUNG GANZ BESTIMMTER KOMMANDOS
1140                   # MIT SSH, DESHALB AUFRUF PER PIPE
1141                print  "cd ${remote_md}; chmod u+w *; tar -cf  ${mainprog}_current_version.tar  ${mainprog}  *.f90 *.o *.mod"  |  ssh  ${remote_username}@${remote_addres}  2>&1
1142             fi
1143
1144
1145                # AKTUELLES VERSIONSVERZEICHNIS AUF REMOTE-RECHNER BEREINIGEN
1146#             printf "\n  *** \"make clean\" on remote host ..."
1147#             ssh  ${remote_username}@${remote_addres}  "cd ${remote_md}; make clean; rm ${mainprog}_sources.tar; rm *.f90 Makefile"
1148#             printf "\n"
1149
1150
1151
1152
1153             # GLEICHE AKTIONEN FUER DIE UTILITY-PROGRAMME DURCHFUEHREN
1154             # AKTUELLE QUELLTEXTVERSION INS REMOTE-QUELLTEXTVERZEICHNIS KOPIEREN
1155             # FALLS DIESES NOCH NICHT EXISTIERT, WIRD ES ERZEUGT
1156          elif [[ $compile_utility_programs = true ]]
1157          then
1158
1159             printf "\n\n"
1160             echo "  *** copying scripts and utility programs to \"${remote_addres}:${remote_ud}/\" "
1161             cd  ${local_source_path}/../SCRIPTS
1162
1163             if [[ $remote_host != lctit ]]
1164             then
1165                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)"
1166             else
1167                   # TIT ERLAUBT NUR DIE AUSFï¿œHRUNG GANZ BESTIMMTER KOMMANDOS
1168                   # MIT SSH, DESHALB AUFRUF PER PIPE
1169                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
1170             fi
1171
1172                # KOPIEREN DER SCRIPTE
1173             if [[ $local_host = decalpha ]]
1174             then
1175                   # DECALPHA BENUTZT BEI NICHTANGABE DES VOLLSTï¿œNDIGEN PFADES
1176                   # IRGENDEIN ANDERES SCP (WAS NICHT FUNKTIONIERT). AUSSERDEM
1177                   # KOENNEN DOLLAR-ZEICHEN NICHT BENUTZT WERDEN
1178                remote_ud=`echo $remote_ud | sed 's/\$HOME\///'`
1179                /bin/scp  batch_scp mbuild mrun subjob  ${remote_username}@${remote_addres}:${remote_ud}/../SCRIPTS  >  /dev/null
1180             else
1181                scp  batch_scp mbuild mrun subjob  ${remote_username}@${remote_addres}:${remote_ud}/../SCRIPTS  >  /dev/null
1182             fi
1183
1184             cd  -  > /dev/null
1185             cd  ${local_source_path}/../UTIL
1186
1187
1188                # KOPIEREN DER UTILITY-PROGRAMME
1189             if [[ $local_host = decalpha ]]
1190             then
1191                   # DECALPHA BENUTZT BEI NICHTANGABE DES VOLLSTï¿œNDIGEN PFADES
1192                   # IRGENDEIN ANDERES SCP (WAS NICHT FUNKTIONIERT). AUSSERDEM
1193                   # KOENNEN DOLLAR-ZEICHEN NICHT BENUTZT WERDEN
1194                remote_ud=`echo $remote_ud | sed 's/\$HOME\///'`
1195                /bin/scp  Makefile  *.f90  ${remote_username}@${remote_addres}:${remote_ud}  >  /dev/null
1196             else
1197                scp  Makefile  *.f90  ${remote_username}@${remote_addres}:${remote_ud}  >  /dev/null
1198             fi
1199
1200
1201
1202                # MAKE MIT ZUVOR ERMITTELTEN OPTIONEN AUF REMOTE RECHNER AUSFUEHREN
1203                # KOMMANDOUEBERGABE AN SSH PER PIPE, DA SO DIE SYSTEM- UND
1204                # BENUTZERPROFILE VOLLSTAENDIG AUSGEFUEHRT WERDEN (SONST FEHLEN MAKE
1205                # Z.B. DIE PFADE ZUM COMPILER)
1206             echo "  *** execute \"make\" on remote host"
1207
1208             if [[ $remote_host = nech ]]
1209             then
1210                make_call_string="sxmake  F90=$compiler_name  F90_SER=$compiler_name_ser  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$loader_options\" "
1211             else
1212                make_call_string="make  F90=$compiler_name  F90_SER=$compiler_name_ser  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$loader_options\" "
1213             fi
1214
1215             if [[ $remote_host = ibms  ||  $remote_host = ibmy ]]
1216             then
1217
1218                ssh  ${remote_username}@${remote_addres}  "cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR"
1219
1220             elif [[ $remote_host = ibmb  ||  $remote_host = ibmh ]]
1221             then
1222
1223                print "export OBJECT_MODE=64; cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres}
1224
1225             elif [[ $remote_host = lctit ]]
1226             then
1227
1228                echo  " "  >  ${remote_host}_last_make_protokoll
1229                while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]]
1230                do
1231                   print "cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
1232                done
1233
1234             else
1235
1236                print "cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
1237
1238             fi
1239
1240          fi    # ENDE UEBERSETZUNG DER UTILITY-PROGRAMME
1241
1242          rm -rf  ${remote_host}_last_make_protokoll
1243
1244             # NUR AUF EINEM HLRN-RECHNER UEBERSETZEN
1245          [[ $remote_host = ibmb  ||  $remote_host = ibmh ]]  &&  ibm_hb_done=true
1246
1247       else
1248
1249          if [[ $compile_utility_programs = false ]]
1250          then
1251
1252                # DEPOSITORY VERZEICHNIS ERZEUGEN, FALLS NOCH NICHT VORHANDEN
1253             eval remote_md=$remote_md
1254             if [[ ! -d $remote_md ]]
1255             then
1256                if  mkdir $remote_md
1257                then
1258                   printf "\n\n  *** directory for make depository:"
1259                   printf "\n           $remote_md"
1260                   printf "\n      was created\n"
1261                else
1262                   printf "\n  +++ directory for make depository:"
1263                   printf "\n           $remote_md"
1264                   printf "\n      cannot be created"
1265                   locat=local_depository_path; exit
1266                fi
1267             fi
1268
1269                # QUELLTEXT-DATEIEN AUS REPOSITORY INS DEPOSITORY KOPIEREN
1270             echo " "
1271             echo "  *** updating sources in $remote_md"
1272             cd  $remote_md
1273             cp  $local_source_path/${mainprog}_sources.tar  .
1274             tar xf  ${mainprog}_sources.tar
1275
1276                # MAKE MIT ZUVOR ERMITTELTEN OPTIONEN AUF LOKALEM RECHNER AUSFUEHREN
1277             echo " "
1278             echo "  *** execute \"make\" on local host"
1279
1280             make  PROG=$mainprog  F90=$compiler_name  COPT="$cpp_options"  F90FLAGS="$compiler_options"  LDFLAGS="$loader_options"  2>&1 | tee ${remote_host}_last_make_protokoll
1281
1282             if [[ $? != 0 ]]
1283             then
1284                printf "\a\n  +++ error(s) occurred during compiling or linking on host \"$remote_host\" "
1285                if [[ $silent = false ]]
1286                then
1287                   answer=dummy
1288                   printf "\n"
1289                   while [[ "$answer" != c  &&  "$answer" != k ]]
1290                   do
1291                      printf "  >>> continue / list errors / kill mbuild (c/l/k) ? "
1292                      read  answer
1293                      if [[ "$answer" = l ]]
1294                      then
1295                         more ${remote_host}_last_make_protokoll
1296                      fi
1297                   done
1298                   if [[ $answer = k ]]
1299                   then
1300                      locat=user_abort; exit
1301                   fi
1302                fi
1303             fi
1304
1305
1306                # NEUE VERSION AUF LOKALEM RECHNER ZUSAMMENPACKEN
1307             printf "\n  *** tar update on local host ..."
1308             tar -cf  ${mainprog}_current_version.tar  *.$suf *.o *.mod
1309
1310
1311             # COMPILE THE UTILITY PROGRAMS
1312          elif [[ $compile_utility_programs = true ]]
1313          then
1314             printf "\n\n"
1315             echo "  *** compiling the utility programs ..."
1316             cd ${local_source_path}/../UTIL
1317             make  F90=$compiler_name  F90_SER=$compiler_name_ser  COPT="$cpp_options"  F90FLAGS="$compiler_options"  LDFLAGS="$loader_options"
1318             cd  -  > /dev/null
1319          fi
1320
1321
1322             # NUR EINMAL AUF LCMUK UEBERSETZEN
1323          [[ $remote_host = lcmuk ]]  &&  lcmuk_done=true
1324
1325       fi
1326
1327    fi
1328 done
1329
1330
1331 if [[ $host_found = false ]]
1332 then
1333    if [[ $host = all ]]
1334    then
1335       printf "\n  +++ no hosts found in configuration file"
1336    else
1337       printf "\n  +++ host \"$host\" not found in configuration file"
1338    fi
1339    locat=config_file; exit
1340 fi
1341
1342
1343
1344    # ABSCHLIESSENDE ARBEITEN
1345 rm -f  hosts_found_in_config_file
1346
Note: See TracBrowser for help on using the repository browser.