source: palm/trunk/SCRIPTS/mbuild @ 25

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

small changes to mbuild

File size: 51.5 KB
RevLine 
[1]1#!/bin/ksh
[22]2# mbuild - Programmuebersetzungsscript   Version:  @(#)MBUILD 1.0    28/02/07
[1]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)
[5]80     # 10/02/07 - Siggi - all hpmuk-related code removed
[22]81     # 28/02/07 - Siggi - compilation of utility programs added (option -u)
[1]82
83
84
85    # VARIABLENVEREINBARUNGEN + DEFAULTWERTE
[22]86 compile_utility_programs=false
[1]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
[22]126 while  getopts  :c:h:m:rs:u  option
[1]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;;
[22]134       (u)   compile_utility_programs=true;;
[1]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
[5]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)" = "" ]]
[1]220    then
[5]221       var=`echo $line | cut -d" " -s -f1 | cut -c2-`
222       value=`echo $line | cut -d" " -s -f2`
[8]223       eval export $var=\$value
[9]224#       eval echo \"   $var=\$$var \"   # AUSGABE ZU TESTZWECKEN
[1]225    fi
[5]226 done
[1]227
[5]228    # NUN PRUEFEN, OB EIN GLOBALER QUELLTEXTPFAD VEREINBART WURDE
[1]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
[8]263 eval local_source_path=$local_source_path
[1]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
[8]301 eval local_depository_path=$local_depository_path
[1]302
303
304
[5]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
[1]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
[22]759    remote_ud=${remote_source_path}/../UTIL
[24]760    remote_ud=$(eval echo $remote_ud)
[1]761
762       # REMOTE-PFAD FUER MAKE-DEPOSITORY ERMITTELN
763    line=""
764    grep  "$remote_host_string" $config_file | grep "%depository_path"  |  while read line1
765    do
766       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
767       then
768          line="$line1"
769       fi
770    done
771
772    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
773    then
774       remote_md=`echo $line | cut -d" " -s -f2`
775    fi
776    if [[ "$remote_md" = "" ]]
777    then
778       if [[ "$global_depository_path" != "" ]]
779       then
780          remote_md=$global_depository_path
781       else
782          printf "\n  +++ no depository path found in configuration file"
783          printf "\n      for \"$remote_host_string\" "
784          printf "\n      please set \"\%depository_path\" in configuration file"
785          locat=config_file; exit
786       fi
787    fi
788
[8]789    remote_md=$(eval echo $remote_md)
[1]790
[8]791
[1]792       # COMPILERNAMEN ERMITTELN
793    line=""
794    grep  "$remote_host_string" $config_file | grep "%compiler_name"  |  while read line1
795    do
796       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
797       then
798          line="$line1"
799       fi
800    done
801
802    if [[ "$line" = ""  ||  $(echo $line | cut -c1) = "#" ]]
803    then
804       printf "\n  +++ no compiler name found in configuration file"
805       printf "\n      for \"$remote_host_string\" "
806       locat=config_file; exit
807    else
808       compiler_name=`echo $line | cut -d" " -s -f2`
809    fi
810
811
812
813       # PRAEPROZESSOR-DIREKTIVEN SETZEN
814    if [[ $(echo $remote_host | cut -c1-3) = ibm ]]
815    then
816       if [[ $remote_host = ibms ]]
817       then
818          cpp_options="$cpp_options -WF,-DMPI_REAL=MPI_DOUBLE_PRECISION"
819          [[ $netcdf_support = true ]]  &&  cpp_options="${cpp_options},-D__netcdf"
820       else
821          cpp_options="$cpp_options -WF,-DMPI_REAL=MPI_DOUBLE_PRECISION"
822          [[ $netcdf_support = true ]]  &&  cpp_options="${cpp_options},-D__netcdf,-D__netcdf_64bit"
823          [[ $remote_host = ibmy ]]  &&  cpp_options="${cpp_options},-D__ibmy_special"
824       fi
825    elif [[ $remote_host = lcmuk ]]
826    then
827       cpp_options="$cpp_options -DMPI_REAL=MPI_DOUBLE_PRECISION -DMPI_2REAL=MPI_2DOUBLE_PRECISION"
828       [[ $netcdf_support = true ]]  &&  cpp_options="$cpp_options -D__netcdf -D__netcdf_64bit"
829    elif [[ $remote_host = lctit ]]
830    then
831       cpp_options="$cpp_options -DMPI_REAL=MPI_DOUBLE_PRECISION -DMPI_2REAL=MPI_2DOUBLE_PRECISION"
832       [[ $netcdf_support = true ]]  &&  cpp_options="$cpp_options -D__netcdf"
833    elif [[ $remote_host = decalpha ]]
834    then
835       cpp_options="$cpp_options -DMPI_REAL=MPI_DOUBLE_PRECISION -DMPI_2REAL=MPI_2DOUBLE_PRECISION"
836       [[ $netcdf_support = true ]]  &&  cpp_options="$cpp_options -D__netcdf"
837    elif [[ $remote_host = nech  ||  $remote_host = neck ]]
838    then
839       cpp_options="$cpp_options -DMPI_REAL=MPI_REAL8 -DMPI_2REAL=MPI_2REAL8 -DSCFFT=DZFFT -DCSFFT=ZDFFT"
840       [[ $netcdf_support = true ]]  &&  cpp_options="$cpp_options -D__netcdf -D__netcdf_64bit"
841    fi
842
843    if [[ $(echo $remote_host | cut -c1-3) = ibm ]]
844    then
845       for  string  in  $remote_host_string
846       do
847          if [[ $(echo $string | cut -c1-3) = ibm ]]
848          then
849             cpp_options="${cpp_options},-D__ibm"
850             if [[ $remote_host = ibmy ]]
851             then
852                cpp_options="${cpp_options},-D__ibmy_special"
853             fi
854          else
855             cpp_options="${cpp_options},-D__$string"
856          fi
857       done
858       cpp_options="$cpp_options "
859    elif [[ $remote_host = nech  ||  $remote_host = neck ]]
860    then
861       for  string  in  $remote_host_string
862       do
863          if [[ $(echo $string | cut -c1-3) = nec ]]
864          then
865             cpp_options="${cpp_options} -D__nec"
866          else
867             cpp_options="${cpp_options} -D__$string"
868          fi
869       done
870       cpp_options="$cpp_options "
871    else
872       for  string  in  $remote_host_string
873       do
874          cpp_options="$cpp_options -D__$string "
875       done
876    fi
877
878
879       # COMPILEROPTIONEN ERMITTELN
880    line=""
881    grep  "$remote_host_string" $config_file | grep "%fopts"  |  while read line1
882    do
883       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
884       then
885          line="$line1"
886       fi
887    done
888    if [[ "$line" = ""  ||  $(echo $line | cut -c1) = "#" ]]
889    then
890       printf "\n  +++ no compiler options found in configuration file"
891       printf "\n      for \"$remote_host_string\" "
892       locat=config_file; exit
893    else
894          # EVENTUELLE DOPPELPUNKTE AUS DIREKTIVENSTRING ENTFERNEN
895       compiler_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
896    fi
897    if [[ $netcdf_support = true ]]
898    then
899       case  $remote_host  in
900          (decalpha)  compiler_options="-I${netcdf_path}/include  $compiler_options";;
901          (ibmb|ibmh) compiler_options="-I ${netcdf_path}/include-64  $compiler_options";;
902          (ibms)      compiler_options="-I /applic/netcdf64/src/f90  $compiler_options";;
903          (ibmy)      compiler_options="-I ${netcdf_path}/include  $compiler_options";;
904          (lcmuk)     compiler_options="-I ${netcdf_path}/include  $compiler_options";;
905          (lctit)     compiler_options="-I ${netcdf_path}/f90      $compiler_options";;
906          (nech|neck) compiler_options="-I ${netcdf_path}/include  $compiler_options";;
907       esac
908    fi
909
910
911
912       # LADER-OPTIONEN ERMITTELN
913    line=""
914    grep  "$remote_host_string" $config_file | grep "%lopts"  |  while read line1
915    do
916       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
917       then
918          line="$line1"
919       fi
920    done
921
922    if [[ "$line" = ""  ||  $(echo $line | cut -c1) = "#" ]]
923    then
924       printf "\n  +++ no loader options found in configuration file"
925       printf "\n      for \"$remote_host_string\" "
926       locat=config_file; exit
927    else
928          # EVENTUELLE DOPPELPUNKTE AUS DIREKTIVENSTRING ENTFERNEN
929       loader_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
930    fi
931    if [[ $netcdf_support = true ]]
932    then
933       case  $remote_host  in
934          (decalpha)                   loader_options="$loader_options -L${netcdf_path}/lib -lnetcdf";;
935          (ibmb|ibmh|lcmuk|nech|neck)  loader_options="$loader_options -L${netcdf_path}/lib -lnetcdf";;
936          (ibms)                       loader_options="$loader_options -L${netcdf_path} -lnetcdf";;
937          (ibmy)                       loader_options="$loader_options -L${netcdf_path}/lib -lnetcdf";;
938          (lctit)                      loader_options="$loader_options -L${netcdf_path}/libsrc -lnetcdf";;
939       esac
940    fi
941
942
943    printf "\n\n#------------------------------------------------------------------------# \n"
944    if [[ $remote_host = $local_host ]]
945    then
946       column1="remote_host:"; column2="$remote_host (= local host!)"
947    else
948       column1="remote_host:"; column2=$remote_host
949    fi
950    printf "| $column1$column2 | \n"
951    printf "|                                                                        | \n"
952    column1="conditions:"; column2="$condition1 $condition2"
953    printf "| $column1$column2 | \n"
954    column1="make depository:"; column2=$remote_md
955    printf "| $column1$column2 | \n"
[25]956    if [[ $compile_utility_programs = true ]]
957    then
958       column1="utility directory:"; column2=$remote_ud
959       printf "| $column1$column2 | \n"
960    fi
[1]961    column1="username:"; column2=$remote_username
962    printf "| $column1$column2 | \n"
963    column1="addres:"; column2=$remote_addres
964    printf "| $column1$column2 | \n"
965    column1="compiler:"; column2=$compiler_name
966    printf "| $column1$column2 | \n"
967    column1="cpp options:"; column2=$cpp_options
968    printf "| $column1$column2 | \n"
969    line=$(echo "$cpp_options" | cut -c51-)
970    while [[ "$line" != "" ]]
971    do
972       column1=""
973       column2=$line
974       printf "| $column1$column2 | \n"
975       line=$(echo "$line" | cut -c51-)
976    done
977    column1="compiler options:"; column2=$compiler_options
978    printf "| $column1$column2 | \n"
979    line=$(echo "$compiler_options" | cut -c51-)
980    while [[ "$line" != "" ]]
981    do
982       column1=""
983       column2=$line
984       printf "| $column1$column2 | \n"
985       line=$(echo "$line" | cut -c51-)
986    done
987    column1="loader options:"; column2=$loader_options
988    printf "| $column1$column2 | \n"
989    line=$(echo "$loader_options" | cut -c51-)
990    while [[ "$line" != "" ]]
991    do
992       column1=""
993       column2=$line
994       printf "| $column1$column2 | \n"
995       line=$(echo "$line" | cut -c51-)
996    done
997    printf "#------------------------------------------------------------------------# \n"
998
999    if [[ $silent = false ]]
1000    then
1001       answer=dummy
1002       printf "\n\n"
1003       while [[ "$answer" != y  &&  "$answer" != Y  && "$answer" != c  &&  "$answer" != C  && "$answer" != s  &&  "$answer" != S  &&  "$answer" != a  &&  "$answer" != A ]]
1004       do
1005          printf " >>> continue (y(es)/c(ontinue)/a(bort)/s(skip)) ?  "
1006          read  answer
1007       done
1008       if [[ $answer = a  ||  $answer = A ]]
1009       then
1010          locat=user_abort; exit
1011       fi
1012       if [[ $answer = c  ||  $answer = C ]]
1013       then
1014          silent=false
1015       fi
1016       if [[ $answer = s  ||  $answer = S ]]
1017       then
1018          continue
1019       fi
1020    fi
1021
1022
1023    if [[ $remote_mode = batch ]]
1024    then
1025
1026          # BATCH-JOB PARAMETER SETZEN
1027       case  $remote_host  in
1028           (t3eb)           queue=berte; memory=60; cputime=1000; xoption="-X 0";;
1029           (t3eh)           queue=comp_t3e; memory=60; cputime=360;;
1030           (t3ej2)          queue=normal; memory=60; cputime=1000; xoption="-X 0";;
[5]1031           (t3ej5|ground.yonsei.ac.kr)  printf "\n  --- remote host \"$remote_host\" does not allow batch jobs"; continue;;
[1]1032       esac
1033
1034
1035          # BATCH-JOB ZUSAMMENSTELLEN
1036       printf "\n  *** creating batch-job for remote host"
1037       echo " "  >  mbuild_job
1038
1039          # AUF CRAY-RECHNERN IN JUELICH WIRD KEIN BENUTZER-PROFILE AUSGEFUEHRT
1040          # DIES WIRD HIER GETAN, UM PFADE USW. ZU SETZEN
1041       if [[ $remote_host = t3ej2 ]]
1042       then
1043          echo "set +vx"                       >>  mbuild_job
1044          echo ". .profile"                    >>  mbuild_job
1045          echo "set -x"                        >>  mbuild_job
1046       fi
1047
1048          # AUF CRAY-RECHNERN GELADENE MODULE AUFLISTEN
1049       if [[ $host = t3eb  || $host = t3eh  ||  $host = t3ej2 ]]
1050       then
1051          echo "module list"                   >>  mbuild_job
1052       fi
1053
1054
1055          # WECHSEL IN TEMPORAERES VERZEICHNIS
1056       echo "cd ${remote_md}"  >>  mbuild_job
1057
1058
1059          # AKTUELLE QUELLTEXTVERSION INS REMOTE-QUELLTEXTVERZEICHNIS KOPIEREN
1060       echo  "scp  ${local_username}@${local_addres}:~/modell/code_3dp/palm_current_version/${mainprog}_sources.tar  ${mainprog}_sources.tar"  >>  mbuild_job
1061#       echo  "[[ \$? != 0 ]]  &&  (echo "+++ scp failed"; exit)"  >>  mbuild_job
1062
1063
1064          # FALLS VORHANDEN, LETZTE VERSION AUF DEM REMOTE-RECHNER AUSPACKEN
1065       echo  "[[ -f ${mainprog}_current_version.tar ]]  &&  tar -xvf  ${mainprog}_current_version.tar"  >>  mbuild_job
1066
1067
1068          # AKTUELLE QUELLTEXTVERSION AUF REMOTE-RECHNER AUSPACKEN
1069       echo  "tar -xvf  ${mainprog}_sources.tar"              >>  mbuild_job
1070
1071
1072          # MAKE MIT ZUVOR ERMITTELTEN OPTIONEN AUF REMOTE RECHNER AUSFUEHREN
1073       echo  "make  PROG=$mainprog  F90=$compiler_name  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$loader_options\" "  >>  mbuild_job
1074       echo  "chmod  u+w  *"                                  >>  mbuild_job
1075
1076          # NEUE VERSION AUF REMOTE-RECHNER ZUSAMMENPACKEN
1077       echo  "tar -cvf  ${mainprog}_current_version.tar  *.f90  *.o"  >>  mbuild_job
1078
1079
1080          # AKTUELLES VERSIONSVERZEICHNIS AUF REMOTE-RECHNER BEREINIGEN
1081       echo  "make  clean"                                    >>  mbuild_job
1082       echo  "rm ${mainprog}_sources.tar"                     >>  mbuild_job
1083       echo  "rm *.f90 Makefile"                              >>  mbuild_job
1084
1085
1086
1087          # JOB MITTELS SUBJOB STARTEN
1088       printf "\n  *** sending batch job to remote host"
1089#       subjob  $xoption  -h $remote_host  -q $queue  -m $memory  -t $cputime  -v  mbuild_job
1090
1091
1092          # JOBFILE LOESCHEN
1093#       rm  aljob
1094
1095    else
1096
1097       if [[ $remote_host != $local_host ]]
1098       then
1099
1100             # AKTUELLE QUELLTEXTVERSION INS REMOTE-QUELLTEXTVERZEICHNIS KOPIEREN
1101             # FALLS DIESES NOCH NICHT EXISTIERT, WIRD ES ERZEUGT
1102          echo "  *** copying \"${mainprog}_sources.tar\" to \"${remote_addres}:${remote_md}/\" "
1103          if [[ $remote_host != lctit ]]
1104          then
1105             ssh  ${remote_username}@${remote_addres} "[[ ! -d ${remote_md} ]]  &&  (echo \"  *** ${remote_md} will be created\"; mkdir -p  ${remote_md})"
1106          else
1107                # TIT ERLAUBT NUR DIE AUSFÜHRUNG GANZ BESTIMMTER KOMMANDOS
1108                # MIT SSH, DESHALB AUFRUF PER PIPE
1109             print "[[ ! -d ${remote_md} ]]  &&  (echo \"  *** ${remote_md} will be created\"; mkdir -p  ${remote_md})"  |  ssh ${remote_username}@${remote_addres}  2>&1
1110          fi
1111          if [[ $local_host = decalpha ]]
1112          then
1113                # DECALPHA BENUTZT BEI NICHTANGABE DES VOLLSTÄNDIGEN PFADES
1114                # IRGENDEIN ANDERES SCP (WAS NICHT FUNKTIONIERT). AUSSERDEM
1115                # KOENNEN DOLLAR-ZEICHEN NICHT BENUTZT WERDEN
1116             remote_md=`echo $remote_md | sed 's/\$HOME\///'`
1117             /bin/scp  ${mainprog}_sources.tar  ${remote_username}@${remote_addres}:${remote_md}/${mainprog}_sources.tar
1118          else
1119             scp  ${mainprog}_sources.tar  ${remote_username}@${remote_addres}:${remote_md}/${mainprog}_sources.tar
1120          fi
1121
1122
1123
1124             # FALLS VORHANDEN, LETZTE VERSION AUF DEM REMOTE-RECHNER AUSPACKEN
1125          echo "  *** untar previous update on remote host, if existing"
1126          if [[ $remote_host != lctit ]]
1127          then
1128             ssh  ${remote_username}@${remote_addres}  "cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]]  &&  tar -xf  ${mainprog}_current_version.tar"
1129          else
1130                # TIT ERLAUBT NUR DIE AUSFÜHRUNG GANZ BESTIMMTER KOMMANDOS
1131                # MIT SSH, DESHALB AUFRUF PER PIPE
1132             print  "cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]]  &&  tar -xf  ${mainprog}_current_version.tar"  |  ssh  ${remote_username}@${remote_addres}  2>&1
1133          fi
1134
1135
1136             # AKTUELLE QUELLTEXTVERSION AUF REMOTE-RECHNER AUSPACKEN
1137          echo "  *** untar actual sources on remote host"
1138          if [[ $remote_host != lctit ]]
1139          then
1140             ssh  ${remote_username}@${remote_addres}  "cd ${remote_md}; tar -xf  ${mainprog}_sources.tar"
1141          else
1142                # TIT ERLAUBT NUR DIE AUSFÜHRUNG GANZ BESTIMMTER KOMMANDOS
1143                # MIT SSH, DESHALB AUFRUF PER PIPE
1144             print  "cd ${remote_md}; tar -xf  ${mainprog}_sources.tar"  |  ssh  ${remote_username}@${remote_addres}  2>&1
1145          fi
1146
1147
1148             # MAKE MIT ZUVOR ERMITTELTEN OPTIONEN AUF REMOTE RECHNER AUSFUEHREN
1149             # KOMMANDOUEBERGABE AN SSH PER PIPE, DA SO DIE SYSTEM- UND
1150             # BENUTZERPROFILE VOLLSTAENDIG AUSGEFUEHRT WERDEN (SONST FEHLEN MAKE
1151             # Z.B. DIE PFADE ZUM COMPILER)
1152          echo "  *** execute \"make\" on remote host"
1153
1154          if [[ $remote_host = nech ]]
1155          then
1156             make_call_string="sxmake  PROG=$mainprog  F90=$compiler_name  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$loader_options\" "
1157          else
1158             make_call_string="make  PROG=$mainprog  F90=$compiler_name  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$loader_options\" "
1159          fi
1160
1161          if [[ $remote_host = t3eh ]]
1162          then
1163       
1164             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
1165
1166          elif [[ $remote_host = t3ej2  ||  $remote_host = ibms  ||  $remote_host = ibmy ]]
1167          then
1168
1169             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
1170
1171          elif [[ $remote_host = ibmb  ||  $remote_host = ibmh ]]
1172          then
1173
1174             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
1175
1176          elif [[ $remote_host = lctit ]]
1177          then
1178
1179             echo  " "  >  ${remote_host}_last_make_protokoll
1180             while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]]
1181             do
1182                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
1183             done
1184
1185          else
1186
1187             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
1188
1189          fi
1190
1191          if [[ $(grep -c MAKE_ERROR ${remote_host}_last_make_protokoll) != 0 ]]
1192          then
1193             printf "\a\n  +++ error(s) occurred during compiling or linking on host \"$remote_host\" "
1194             if [[ $silent = false ]]
1195             then
1196                answer=dummy
1197                printf "\n"
1198                while [[ "$answer" != c  &&  "$answer" != k ]]
1199                do
1200                   printf "  >>> continue / list errors / kill mbuild (c/l/k) ? "
1201                   read  answer
1202                   if [[ "$answer" = l ]]
1203                   then
1204                      more ${remote_host}_last_make_protokoll
1205                   fi
1206                done
1207                if [[ $answer = k ]]
1208                then
1209                   locat=user_abort; exit
1210                fi
1211             fi
1212          fi
1213
1214
1215
1216             # NEUE VERSION AUF REMOTE-RECHNER ZUSAMMENPACKEN
1217          printf "\n  *** tar update on remote host ..."
1218          if [[ $remote_host != lctit ]]
1219          then
1220             ssh  ${remote_username}@${remote_addres}  "cd ${remote_md}; chmod u+w *; tar -cf  ${mainprog}_current_version.tar  *.f90 *.o *.mod"
1221          else
1222                # TIT ERLAUBT NUR DIE AUSFÜHRUNG GANZ BESTIMMTER KOMMANDOS
1223                # MIT SSH, DESHALB AUFRUF PER PIPE
1224             print  "cd ${remote_md}; chmod u+w *; tar -cf  ${mainprog}_current_version.tar  *.f90 *.o *.mod"  |  ssh  ${remote_username}@${remote_addres}  2>&1
1225          fi
1226
1227
1228             # AKTUELLES VERSIONSVERZEICHNIS AUF REMOTE-RECHNER BEREINIGEN
1229#          printf "\n  *** \"make clean\" on remote host ..."
1230#          ssh  ${remote_username}@${remote_addres}  "cd ${remote_md}; make clean; rm ${mainprog}_sources.tar; rm *.f90 Makefile"
1231#          printf "\n"
1232
1233
[25]1234
1235
[22]1236             # GLEICHE AKTIONEN FUER DIE UTILITY-PROGRAMME DURCHFUEHREN
1237             # AKTUELLE QUELLTEXTVERSION INS REMOTE-QUELLTEXTVERZEICHNIS KOPIEREN
1238             # FALLS DIESES NOCH NICHT EXISTIERT, WIRD ES ERZEUGT
1239          if [[ $compile_utility_programs = true ]]
1240          then
1241
[24]1242             printf "\n\n"
[22]1243             echo "  *** copying utility programs to \"${remote_addres}:${remote_ud}/\" "
1244             cd  ${local_source_path}/../UTIL
1245
1246             if [[ $remote_host != lctit ]]
1247             then
[24]1248                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)"
[22]1249             else
1250                   # TIT ERLAUBT NUR DIE AUSFÜHRUNG GANZ BESTIMMTER KOMMANDOS
1251                   # MIT SSH, DESHALB AUFRUF PER PIPE
[24]1252                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
[22]1253             fi
1254
1255             if [[ $local_host = decalpha ]]
1256             then
1257                   # DECALPHA BENUTZT BEI NICHTANGABE DES VOLLSTÄNDIGEN PFADES
1258                   # IRGENDEIN ANDERES SCP (WAS NICHT FUNKTIONIERT). AUSSERDEM
1259                   # KOENNEN DOLLAR-ZEICHEN NICHT BENUTZT WERDEN
1260                remote_ud=`echo $remote_ud | sed 's/\$HOME\///'`
[24]1261                /bin/scp  Makefile  *.f90  ${remote_username}@${remote_addres}:${remote_ud}  >  /dev/null
[22]1262             else
[24]1263                scp  Makefile  *.f90  ${remote_username}@${remote_addres}:${remote_ud}  >  /dev/null
[22]1264             fi
1265
1266
1267
1268                # MAKE MIT ZUVOR ERMITTELTEN OPTIONEN AUF REMOTE RECHNER AUSFUEHREN
1269                # KOMMANDOUEBERGABE AN SSH PER PIPE, DA SO DIE SYSTEM- UND
1270                # BENUTZERPROFILE VOLLSTAENDIG AUSGEFUEHRT WERDEN (SONST FEHLEN MAKE
1271                # Z.B. DIE PFADE ZUM COMPILER)
1272             echo "  *** execute \"make\" on remote host"
1273
1274             if [[ $remote_host = nech ]]
1275             then
1276                make_call_string="sxmake  F90=$compiler_name  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$loader_options\" "
1277             else
1278                make_call_string="make  F90=$compiler_name  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$loader_options\" "
1279             fi
1280
1281             if [[ $remote_host = ibms  ||  $remote_host = ibmy ]]
1282             then
1283
[25]1284                ssh  ${remote_username}@${remote_addres}  "cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR"
[22]1285
1286             elif [[ $remote_host = ibmb  ||  $remote_host = ibmh ]]
1287             then
1288
[25]1289                print "export OBJECT_MODE=64; cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres}
[22]1290
1291             elif [[ $remote_host = lctit ]]
1292             then
1293
1294                echo  " "  >  ${remote_host}_last_make_protokoll
1295                while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]]
1296                do
1297                   print "cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
1298                done
1299
1300             else
1301
1302                print "cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
1303
1304             fi
1305
1306          fi    # ENDE UEBERSETZUNG DER UTILITY-PROGRAMME
1307
1308
[1]1309             # NUR AUF EINEM HLRN-RECHNER UEBERSETZEN
1310          [[ $remote_host = ibmb  ||  $remote_host = ibmh ]]  &&  ibm_hb_done=true
1311
1312       else
1313
1314             # MAKE MIT ZUVOR ERMITTELTEN OPTIONEN AUF LOKALEM RECHNER AUSFUEHREN
[22]1315          echo " "
[1]1316          echo "  *** execute \"make\" on local host"
1317
1318          make  PROG=$mainprog  F90=$compiler_name  COPT="$cpp_options"  F90FLAGS="$compiler_options"  LDFLAGS="$loader_options"  2>&1 | tee ${remote_host}_last_make_protokoll
1319
1320          if [[ $? != 0 ]]
1321          then
1322             printf "\a\n  +++ error(s) occurred during compiling or linking on host \"$remote_host\" "
1323             if [[ $silent = false ]]
1324             then
1325                answer=dummy
1326                printf "\n"
1327                while [[ "$answer" != c  &&  "$answer" != k ]]
1328                do
1329                   printf "  >>> continue / list errors / kill mbuild (c/l/k) ? "
1330                   read  answer
1331                   if [[ "$answer" = l ]]
1332                   then
1333                      more ${remote_host}_last_make_protokoll
1334                   fi
1335                done
1336                if [[ $answer = k ]]
1337                then
1338                   locat=user_abort; exit
1339                fi
1340             fi
1341          fi
1342
1343
1344             # NEUE VERSION AUF LOKALEM RECHNER ZUSAMMENPACKEN
1345          printf "\n  *** tar update on local host ..."
1346          tar -cf  ${mainprog}_current_version.tar  *.$suf *.o *.mod
1347
[22]1348
1349             # COMPILE THE UTILITY PROGRAMS
1350          if [[ $compile_utility_programs = true ]]
1351          then
1352             printf "\n\n"
1353             echo "  *** compiling the utility programs ..."
1354             cd ${local_source_path}/../UTIL
1355             make  F90=$compiler_name  COPT="$cpp_options"  F90FLAGS="$compiler_options"  LDFLAGS="$loader_options"
1356             cd  -  > /dev/null
1357          fi
1358
1359
[1]1360             # NUR EINMAL AUF LCMUK UEBERSETZEN
1361          [[ $remote_host = lcmuk ]]  &&  lcmuk_done=true
1362
1363       fi
1364
1365    fi
1366 done
1367
1368
1369 if [[ $host_found = false ]]
1370 then
1371    if [[ $host = all ]]
1372    then
1373       printf "\n  +++ no hosts found in configuration file"
1374    else
1375       printf "\n  +++ host \"$host\" not found in configuration file"
1376    fi
1377    locat=config_file; exit
1378 fi
1379
1380
1381
1382    # ABSCHLIESSENDE ARBEITEN
1383 rm -f  hosts_found_in_config_file
1384
Note: See TracBrowser for help on using the repository browser.