source: palm/trunk/SCRIPTS/mbuild @ 449

Last change on this file since 449 was 437, checked in by raasch, 14 years ago

script adjustements for lcxt5m

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