source: palm/trunk/SCRIPTS/mbuild @ 23

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

script names changed from *_new to normal

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