source: palm/trunk/SCRIPTS/mbuild @ 731

Last change on this file since 731 was 717, checked in by gryschka, 14 years ago

added lckordi

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