source: palm/trunk/SCRIPTS/mbuild @ 66

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

Rev properties set fro scripts, small adjustments for RIAM, fimm (Igor) admitted

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