source: palm/trunk/SCRIPTS/mbuild @ 31

Last change on this file since 31 was 29, checked in by raasch, 17 years ago

Bugfix in mbuild

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