source: palm/trunk/SCRIPTS/mbuild @ 792

Last change on this file since 792 was 784, checked in by raasch, 13 years ago

Bugfix for make options setting (-j)

  • Property svn:keywords set to Id Rev
File size: 48.5 KB
RevLine 
[1]1#!/bin/ksh
[503]2# mbuild - script for compiling the PALM code and its utility programs
[169]3# $Id: mbuild 784 2011-11-27 07:37:48Z raasch $
[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
[740]122     # 17/08/11 - Siggi - HLRN access via hicegate0 (130.75.4.101)
[784]123     # 27/11/11 - Siggi - Bugfix for make options setting (-j)
[1]124
125
[508]126
[503]127    # VARIABLE DECLARATIONS + DEFAULT VALUES
[22]128 compile_utility_programs=false
[1]129 config_file=.mrun.config
[67]130 fimm=false
[1]131 host=all
132 host_found=false
133 locat=normal
134 makefile=""
[493]135 module_calls=""
[1]136 scirocco=false
137 silent=false
138 suf=f90
139 update=false
[83]140 working_directory=`pwd`
[1]141
142 typeset -i  ih ihost=0
143
[66]144 typeset  -R30 calltime
[1]145 typeset  -L20 column1
146 typeset  -L50 column2
147 typeset  -L70 column3
[215]148 typeset  -L40 version="MBUILD  2.1  Rev$Rev: 784 $"
[1]149
[503]150    # ERROR HANDLING
151    # IN CASE OF EXIT:
[83]152 trap 'rm -rf  $working_directory/tmp_mbuild
[69]153       if [[ $locat != normal ]]
[1]154       then
155          printf "\n\n +++ mbuild killed \n\n"
156       else
157          printf "\n\n *** mbuild finished \n\n"
158       fi' exit
159
160
[503]161    # IN CASE OF TERMINAL-BREAK:
[83]162 trap 'rm -rf  $working_directory/tmp_mbuild
[69]163       printf "\n\n +++ mbuild killed by \"^C\" \n\n"
[1]164       exit
165      ' 2
166
167
[215]168 tmp_mbuild=${working_directory}/tmp_mbuild
[1]169
[503]170    # READ SHELLSCRIPT-OPTIONS
[475]171 while  getopts  :c:h:m:s:u  option
[1]172 do
173   case  $option  in
174       (c)   config_file=$OPTARG;;
175       (h)   host=$OPTARG;;
176       (m)   makefile=$OPTARG;;
177       (s)   suf=$OPTARG;;
[22]178       (u)   compile_utility_programs=true;;
[1]179       (\?)  printf "\n  +++ unknown option $OPTARG \n";
180             locat=parameter; exit;;
181   esac
182 done
183
184
185
[503]186    # CHECK, IF CONFIGURATION-FILE EXISTS
[82]187 if [[ ! -f $config_file ]]
188 then
189    printf "\n  +++ configuration file: "
190    printf "\n           $config_file"
191    printf "\n      does not exist"
192    locat=configuration; exit 
193 fi
194
195
196
[503]197    # DETERMINE THE LOCAL HOST
[1]198 local_host_real_name=$(hostname)
[69]199# local_addres=$(nslookup `hostname` 2>&1 | grep "Address:" | tail -1 | awk '{print $2}')
200
[1]201
[82]202
[503]203    # DETERMINE HOST-IDENTIFIER (local_host) FROM THE CONFIG-FILE
[82]204 line=""
[215]205 grep  "%host_identifier"  $config_file  >  $tmp_mbuild
[82]206 while read line
207 do
[116]208    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
[82]209    then
210       HOSTNAME=`echo $line | cut -d" " -s -f2`
211       host_identifier=`echo $line | cut -d" " -s -f3`
[83]212       if [[ $local_host_real_name = $HOSTNAME ]]
[82]213       then
214          local_host=$host_identifier
215          break
216       fi
217    fi
[215]218 done < $tmp_mbuild
[82]219
220 if [[ "$local_host" = "" ]]
221 then
222    printf "\n  +++ no host identifier found in configuration file \"$config_file\""
223    printf "\n      for local host \"$local_host_real_name\"."
224    printf "\n      Please add line"
225    printf "\n      \"\%host_identifier $local_host_real_name <identifier>\""
226    printf "\n      to the configuration file."
227    locat=local_host; exit
228 fi
229
230
231
[1]232 [[ $local_host_real_name = scirocco ]]  &&  scirocco=true
[67]233 [[ $local_host_real_name = fimm.bccs.uib.no ]]  &&  fimm=true
[1]234
235
236
237 if [[ $local_host != ibms ]]
238 then
239    config_file=$PWD/$config_file
240 else
241    config_file=`pwd`/$config_file
242 fi
243
244
245 
[503]246    # DETERMINE USER NAME ON LOCAL HOST FROM THE CONFIG-FILE
[1]247 line=""
[215]248 grep  " $local_host" $config_file | grep "%remote_username"  >  $tmp_mbuild
[69]249 while read line
[1]250 do
[116]251    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
[1]252    then
253       local_username=`echo $line | cut -d" " -s -f2`
254    fi
[215]255 done < $tmp_mbuild
[1]256
[82]257
[1]258 if [[ "$local_username" = "" ]]
259 then
260    printf "\n  +++ no user name found in configuration file"
261    printf "\n      for local host \"$local_host\" "
262    locat=config_file; exit
263 fi
264
265
[503]266    # DETERMINE LOCAL SOURCE-CODE PATH.
267    # FIRST CHECK, IF A GLOBAL SOURCE-CODE PATH HAS BEEN DECLARED FOR ALL HOSTS.
268    # THEREFORE, FIRST SET ALL GLOBAL VARIABLES DECLARED IN THE CONFIG-FILE,
269    # BECAUSE THEY MAY BE USED AS PART OF THE PATH NAME.
[5]270 line=""
[215]271 grep "%" $config_file  >  $tmp_mbuild
[69]272 while read line
[5]273 do
[116]274    if [[ "$line" != ""  &&  "$(echo $line | cut -d" " -s -f3)" = ""  &&  $(echo $line | cut -c1) != "#" ]]
[1]275    then
[5]276       var=`echo $line | cut -d" " -s -f1 | cut -c2-`
277       value=`echo $line | cut -d" " -s -f2`
[8]278       eval export $var=\$value
[1]279    fi
[215]280 done < $tmp_mbuild
[1]281
[503]282    # NOW CHECK, IF A GLOBAL SOURCE-CODE-PATH HAS BEEN DECLARED
[1]283 line=""
[215]284 grep "%source_path" $config_file  >  $tmp_mbuild
[69]285 while read line
[1]286 do
287    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
288    then
289       if [[ "$(echo $line | cut -d" " -s -f3)" = "" ]]
290       then
291          global_source_path=`echo $line | cut -d" " -s -f2`
292       fi
293    fi
[215]294 done < $tmp_mbuild
[1]295
296 line=""
[215]297 grep  " $local_host" $config_file | grep "%source_path"  >  $tmp_mbuild
[69]298 while read line
[1]299 do
300    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
301    then
302       local_source_path=`echo $line | cut -d" " -s -f2`
303    fi
[215]304 done < $tmp_mbuild
[1]305
306 if [[ "$local_source_path" = "" ]]
307 then
308    if [[ "$global_source_path" != "" ]]
309    then
310       local_source_path=$global_source_path
311    else
312       printf "\n  +++ no source path found in configuration file"
313       printf "\n      for local host \"$local_host\" "
314       printf "\n      please set \"\%source_path\" in configuration file"
315       locat=config_file; exit
316    fi
317 fi
318 eval local_source_path=$local_source_path
[8]319 eval local_source_path=$local_source_path
[1]320
321
[215]322
[503]323    # DETERMINE GLOBAL DEPOSITORY-PATH
[1]324 line=""
[215]325 grep "%depository_path" $config_file  >  $tmp_mbuild
[69]326 while read line
[1]327 do
328    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
329    then
330       if [[ "$(echo $line | cut -d" " -s -f3)" = "" ]]
331       then
332          global_depository_path=`echo $line | cut -d" " -s -f2`
333       fi
334    fi
[215]335 done < $tmp_mbuild
[1]336
337
338
[503]339    # CHECK, IF A MAIN PROGRAM HAS BEEN DEFINED IN THE CONFIG-FILE
[5]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
[503]357    # CHECK IF MAKEFILE EXITS
[1]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
[503]368    # HEADER-OUTPUT (PART1: MESSAGES CONCERNING THE LOCAL HOST)
[1]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
[40]391 if [[ $compile_utility_programs = false ]]
392 then
[1]393
[503]394       # IN ANY CASE, GIVE ALL FILES WRITE-PERMIT, IN ORDER TO AVOID PROBLEMS
395       # WITH OVERWRITING FILES ON THE REMOTE HOST
[215]396    cd  $local_source_path
397    printf "\n\n  *** tar of makefile and source files in $local_source_path" 
[40]398    tar -cf  ${mainprog}_sources.tar  Makefile  *.$suf
399    printf "\n"
[1]400
[40]401 fi
[1]402
403
[40]404
[503]405    # GET CONFIRMATION TO CONTINUE
[1]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
[215]436 grep  %fopts  $config_file  >  $tmp_mbuild
[69]437 while read line
[1]438 do
439       # KOMMENTARZEILEN UEBERSPRINGEN
440    [[ $(echo $line | cut -c1) = "#" ]]  &&  continue
441    (( ihost = ihost + 1 ))
442    hostline[$ihost]="$line"
[215]443 done < $tmp_mbuild
[1]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
[493]469    modules=""
[82]470    netcdf_inc=""
471    netcdf_lib=""
[784]472    make_options=""
[1]473
474       # IP-ADRESSE DES REMOTE-RECHNERS BESTIMMEN
475    case  $remote_host  in
[717]476        (lckordi)          remote_adress=210.219.61.8;;
[116]477        (lcmuk)          remote_addres=130.75.105.2;;
[622]478        (lcrte)          remote_addres=133.5.185.60;;
[181]479        (lcsgib)         remote_addres=130.73.232.102;;
[740]480        (lcsgih)         remote_addres=130.75.4.101;;
[367]481        (lck)            remote_addres=165.132.26.61;;
[635]482        (lctit)          remote_addres=10.1.6.170;;
[206]483        (lcxt4)          remote_addres=129.177.20.113;;
[437]484        (lcxt5m)         remote_addres=193.166.211.144;;
[83]485        (decalpha)       remote_addres=165.132.26.56;;
[305]486        (ibmh)           remote_addres=136.172.40.15;;
[693]487        (ibmkisti)       remote_addres=150.183.146.24;;
[622]488        (ibmku)          remote_addres=133.5.4.129;;
[83]489        (ibms)           remote_addres=150.183.5.101;;
490        (ibmy)           remote_addres=165.132.26.58;;
491        (nech)           remote_addres=136.172.44.192;;
492        (neck)           remote_addres=133.5.178.11;;
493        (ground.yonsei.ac.kr) remote_addres=134.75.155.33;;
494        (*)              if [[ $local_host != $remote_host ]]
[1]495                         then
[83]496                            printf "\n  +++ remote host \"$remote_host\" unknown";
[503]497                            printf "\n      please inform PALM group support!"
[1]498                         fi;;
499    esac
500
501
502       # REMOTE-USERNAMEN ERMITTELN
503    line=""
[116]504    found=false
[215]505    grep  "$remote_host_string" $config_file | grep "%remote_username"  >  $tmp_mbuild
[69]506    while read line1
[1]507    do
[116]508
[1]509       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
510       then
511          line="$line1"
512       fi
[116]513
514       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
515       then
516          remote_username=`echo $line | cut -d" " -s -f2`
517          found=true
518       fi
519
[215]520    done < $tmp_mbuild
[1]521
[116]522    if [[ $found = false ]]
[1]523    then
524       printf "\n  +++ no remote username found in configuration file"
525       printf "\n      for \"$remote_host_string\" "
526       locat=config_file; exit
527    fi
528
529
530       # REMOTE-QUELLTEXTPFAD ERMITTELN
531    line=""
[54]532    remote_source_path=""
[215]533    grep  "$remote_host_string" $config_file | grep "%source_path"  >  $tmp_mbuild
[69]534    while read line1
[1]535    do
[116]536
[1]537       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
538       then
539          line="$line1"
540       fi
[116]541
542       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
543       then
544          remote_source_path=`echo $line | cut -d" " -s -f2`
545       fi
546
[215]547    done < $tmp_mbuild
[1]548
549    if [[ "$remote_source_path" = "" ]]
550    then
551       if [[ "$global_source_path" != "" ]]
552       then
553          remote_source_path=$global_source_path
554       else
555          printf "\n  +++ no source path found in configuration file"
556          printf "\n      for \"$remote_host_string\" "
557          locat=config_file; exit
558       fi
559    fi
560
[22]561    remote_ud=${remote_source_path}/../UTIL
[24]562    remote_ud=$(eval echo $remote_ud)
[1]563
[54]564
[1]565       # REMOTE-PFAD FUER MAKE-DEPOSITORY ERMITTELN
[54]566    remote_md=""
[1]567    line=""
[215]568    grep  "$remote_host_string" $config_file | grep "%depository_path"  >  $tmp_mbuild
[69]569    while read line1
[1]570    do
[116]571
[1]572       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
573       then
574          line="$line1"
575       fi
[116]576
577       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
578       then
579          remote_md=`echo $line | cut -d" " -s -f2`
580       fi
581
[215]582    done < $tmp_mbuild
[1]583
584    if [[ "$remote_md" = "" ]]
585    then
586       if [[ "$global_depository_path" != "" ]]
587       then
588          remote_md=$global_depository_path
589       else
590          printf "\n  +++ no depository path found in configuration file"
591          printf "\n      for \"$remote_host_string\" "
592          printf "\n      please set \"\%depository_path\" in configuration file"
593          locat=config_file; exit
594       fi
595    fi
596
[8]597    remote_md=$(eval echo $remote_md)
[503]598    block=""
599    [[ "$condition1" != "" ]]  &&  block=_$condition1
600    [[ "$condition2" != "" ]]  &&  block=${block}_$condition2
[508]601    remote_md=${remote_md}$block
[1]602
[8]603
[1]604       # COMPILERNAMEN ERMITTELN
605    line=""
[116]606    found=false
[215]607    grep  "$remote_host_string" $config_file | grep "%compiler_name "  >  $tmp_mbuild
[69]608    while read line1
[1]609    do
[116]610
[1]611       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
612       then
613          line="$line1"
614       fi
[116]615
616       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
617       then
618          compiler_name=`echo $line | cut -d" " -s -f2`
619          found=true
620       fi
621
[215]622    done < $tmp_mbuild
[1]623
[116]624    if [[ $found = false ]]
[1]625    then
626       printf "\n  +++ no compiler name found in configuration file"
627       printf "\n      for \"$remote_host_string\" "
628       locat=config_file; exit
629    fi
630
631
[27]632       # BEI BENUTZUNG EINES PARALLELEN COMPILERS MUSS AUCH EIN
633       # SERIELLER COMPILERNAME ERMITTELT WERDEN
634    if [[ $(echo $remote_host_string | grep -c parallel) = 1 ]]
635    then
636       line=""
[116]637       found=false
[215]638       grep  "$remote_host_string" $config_file | grep "%compiler_name_ser"  >  $tmp_mbuild
[69]639       while read line1
[27]640       do
[116]641
[27]642          if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
643          then
644             line="$line1"
645          fi
[116]646
647          if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
648          then
649             compiler_name_ser=`echo $line | cut -d" " -s -f2`
650             found=true
651          fi
652
[215]653       done < $tmp_mbuild
[1]654
[116]655       if [[ $found = false ]]
[27]656       then
[28]657          printf "\n  +++ no serial compiler name found in configuration file"
[27]658          printf "\n      for \"$remote_host_string\" "
659          locat=config_file; exit
660       fi
661    else
662       compiler_name_ser=$compiler_name
663    fi
664
665
666
[82]667       # PRAEPROZESSOR-OPTIONEN/DIREKTIVEN ERMITTELN
668    line=""
[116]669    found=false
[215]670    grep  "$remote_host_string" $config_file | grep "%cpp_options"  >  $tmp_mbuild
[82]671    while read line1
672    do
[116]673
[82]674       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
675       then
676          line="$line1"
677       fi
[116]678
679       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
680       then
681             # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING ENTFERNEN
682          cpp_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
683          found=true
684       fi
685
[215]686    done < $tmp_mbuild
[116]687
688    if [[ $found = false ]]
[82]689    then
690       printf "\n  +++ no preprocessor options found in configuration file"
691       printf "\n      for \"$remote_host_string\" "
692       locat=config_file; exit
693    fi
694
[116]695
[82]696       # RECHNERSPEZIFISCHE CPP-DIREKTIVEN HINZUFUEGEN
697    for  string  in  $remote_host_string
698    do
699       if [[ $(echo $remote_host | cut -c1-2) = lc  &&  $(echo $string | cut -c1-2) = lc ]]
700       then
701          cpp_options="$cpp_options -D__lc "
[83]702       elif [[ $(echo $remote_host | cut -c1-3) = ibm  &&  $(echo $string | cut -c1-3) = ibm ]]
703       then
704          cpp_options="${cpp_options},-D__ibm"
705       elif [[ $(echo $remote_host | cut -c1-3) = nec  &&  $(echo $string | cut -c1-3) = nec ]]
706       then
707          cpp_options="${cpp_options} -D__nec"
[82]708       else
[83]709          if [[ $(echo $remote_host | cut -c1-3) = ibm ]]
710          then
711             cpp_options="${cpp_options},-D__$string"
712          else
713             cpp_options="$cpp_options -D__$string "
714          fi
[82]715       fi
716    done
717
718
719
720       # NETCDF-OPTIONEN ERMITTELN
721    line=""
[215]722    grep  "$remote_host_string" $config_file | grep "%netcdf_inc"  >  $tmp_mbuild
[82]723    while read line1
724    do
[116]725
[82]726       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
727       then
728          line="$line1"
729       fi
[116]730
731       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
732       then
733             # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING ENTFERNEN
734          netcdf_inc=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
735       fi
736
[215]737    done < $tmp_mbuild
[82]738
739    line=""
[215]740    grep  "$remote_host_string" $config_file | grep "%netcdf_lib"  >  $tmp_mbuild
[82]741    while read line1
742    do
[116]743
[82]744       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
745       then
746          line="$line1"
747       fi
[116]748
749       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
750       then
751             # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING ENTFERNEN
752          netcdf_lib=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
753       fi
754
[215]755    done < $tmp_mbuild
[82]756
757
758
[475]759       # get make options
760    line=""
761    found=false
762    grep  "$remote_host_string" $config_file | grep "%mopts"  >  $tmp_mbuild
763    while read line1
764    do
765
766       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
767       then
768          line="$line1"
769       fi
770
771       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
772       then
773             # remove colons from directive string
774          make_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
775
776       fi
777
778    done < $tmp_mbuild
779
780
781
[1]782       # COMPILEROPTIONEN ERMITTELN
783    line=""
[116]784    found=false
[215]785    grep  "$remote_host_string" $config_file | grep "%fopts"  >  $tmp_mbuild
[69]786    while read line1
[1]787    do
[116]788
[1]789       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
790       then
791          line="$line1"
792       fi
[116]793
794       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
795       then
796             # EVENTUELLE DOPPELPUNKTE AUS DIREKTIVENSTRING ENTFERNEN
797          compiler_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
798          found=true
799
800             # NETCDF-INCLUDEVERZEICHNIS HINZUFUEGEN
801          compiler_options="$compiler_options $netcdf_inc"
802       fi
803
[215]804    done < $tmp_mbuild
[116]805
806    if [[ $found = false ]]
[1]807    then
808       printf "\n  +++ no compiler options found in configuration file"
809       printf "\n      for \"$remote_host_string\" "
810       locat=config_file; exit
811    fi
[82]812
[1]813
814
[503]815       # get modules to be loaded
[221]816    line=""
[493]817    grep  "$remote_host_string" $config_file | grep "%modules"  >  $tmp_mbuild
[221]818    while read line1
819    do
820
821       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
822       then
823          line="$line1"
824       fi
825
826       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
827       then
828             # EVENTUELLE DOPPELPUNKTE AUS DIREKTIVENSTRING ENTFERNEN
[493]829          modules=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
[221]830       fi
831
832    done < $tmp_mbuild
833
834
835
836
[1]837       # LADER-OPTIONEN ERMITTELN
838    line=""
[116]839    found=false
[215]840    grep  "$remote_host_string" $config_file | grep "%lopts"  >  $tmp_mbuild
[69]841    while read line1
[1]842    do
[116]843
[1]844       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
845       then
846          line="$line1"
847       fi
[116]848
849       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
850       then
851             # EVENTUELLE DOPPELPUNKTE AUS DIREKTIVENSTRING ENTFERNEN
852          loader_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
853          found=true
854
855             # NETCDF-LIBRARY HINZUFUEGEN
856          loader_options="$loader_options $netcdf_lib"
857       fi
858
[215]859    done < $tmp_mbuild
[1]860
[116]861    if [[ $found = false ]]
[1]862    then
863       printf "\n  +++ no loader options found in configuration file"
864       printf "\n      for \"$remote_host_string\" "
865       locat=config_file; exit
866    fi
[82]867
[1]868
869    printf "\n\n#------------------------------------------------------------------------# \n"
870    if [[ $remote_host = $local_host ]]
871    then
872       column1="remote_host:"; column2="$remote_host (= local host!)"
873    else
874       column1="remote_host:"; column2=$remote_host
875    fi
876    printf "| $column1$column2 | \n"
877    printf "|                                                                        | \n"
878    column1="conditions:"; column2="$condition1 $condition2"
879    printf "| $column1$column2 | \n"
880    column1="make depository:"; column2=$remote_md
881    printf "| $column1$column2 | \n"
[215]882    line=$(echo "$remote_md" | cut -c51-)
883    while [[ "$line" != "" ]]
884    do
885       column1=""
886       column2=$line
887       printf "| $column1$column2 | \n"
888       line=$(echo "$line" | cut -c51-)
889    done
[25]890    if [[ $compile_utility_programs = true ]]
891    then
892       column1="utility directory:"; column2=$remote_ud
893       printf "| $column1$column2 | \n"
894    fi
[1]895    column1="username:"; column2=$remote_username
896    printf "| $column1$column2 | \n"
897    column1="addres:"; column2=$remote_addres
898    printf "| $column1$column2 | \n"
899    column1="compiler:"; column2=$compiler_name
900    printf "| $column1$column2 | \n"
[28]901    if [[ $compile_utility_programs = true ]]
902    then
903       column1="serial compiler:"; column2=$compiler_name_ser
904       printf "| $column1$column2 | \n"
905    fi
[475]906    if [[ "$make_options" != "" ]]
907    then
908       column1="make options:"; column2=$make_options
909       printf "| $column1$column2 | \n"
910    fi
[1]911    column1="cpp options:"; column2=$cpp_options
912    printf "| $column1$column2 | \n"
913    line=$(echo "$cpp_options" | cut -c51-)
914    while [[ "$line" != "" ]]
915    do
916       column1=""
917       column2=$line
918       printf "| $column1$column2 | \n"
919       line=$(echo "$line" | cut -c51-)
920    done
921    column1="compiler options:"; column2=$compiler_options
922    printf "| $column1$column2 | \n"
923    line=$(echo "$compiler_options" | cut -c51-)
924    while [[ "$line" != "" ]]
925    do
926       column1=""
927       column2=$line
928       printf "| $column1$column2 | \n"
929       line=$(echo "$line" | cut -c51-)
930    done
931    column1="loader options:"; column2=$loader_options
932    printf "| $column1$column2 | \n"
933    line=$(echo "$loader_options" | cut -c51-)
934    while [[ "$line" != "" ]]
935    do
936       column1=""
937       column2=$line
938       printf "| $column1$column2 | \n"
939       line=$(echo "$line" | cut -c51-)
940    done
[493]941    if [[ $modules != "" ]]
942    then
943       column1="modules to be load:"; column2=$modules
944       printf "| $column1$column2 | \n"
945       line=$(echo "$modules" | cut -c51-)
946       while [[ "$line" != "" ]]
947       do
948          column1=""
949          column2=$line
950          printf "| $column1$column2 | \n"
951          line=$(echo "$line" | cut -c51-)
952       done
953    fi
[1]954    printf "#------------------------------------------------------------------------# \n"
955
956    if [[ $silent = false ]]
957    then
958       answer=dummy
959       printf "\n\n"
960       while [[ "$answer" != y  &&  "$answer" != Y  && "$answer" != c  &&  "$answer" != C  && "$answer" != s  &&  "$answer" != S  &&  "$answer" != a  &&  "$answer" != A ]]
961       do
962          printf " >>> continue (y(es)/c(ontinue)/a(bort)/s(skip)) ?  "
963          read  answer
964       done
965       if [[ $answer = a  ||  $answer = A ]]
966       then
967          locat=user_abort; exit
968       fi
969       if [[ $answer = c  ||  $answer = C ]]
970       then
[503]971          silent=true
[1]972       fi
973       if [[ $answer = s  ||  $answer = S ]]
974       then
975          continue
976       fi
977    fi
978
979
[475]980       # make on remote host
981    if [[ $remote_host != $local_host ]]
[1]982    then
983
[475]984       if [[ $compile_utility_programs = false ]]
[1]985       then
986
[475]987             # AKTUELLE QUELLTEXTVERSION INS REMOTE-QUELLTEXTVERZEICHNIS KOPIEREN
988             # FALLS DIESES NOCH NICHT EXISTIERT, WIRD ES ERZEUGT
989          echo "  *** copying \"${mainprog}_sources.tar\" to \"${remote_addres}:${remote_md}/\" "
990          if [[ $remote_host != lctit ]]
991          then
992             ssh  ${remote_username}@${remote_addres} "[[ ! -d ${remote_md} ]]  &&  (echo \"  *** ${remote_md} will be created\"; mkdir -p  ${remote_md})"
993          else
994                # TIT ERLAUBT NUR DIE AUSFï¿œHRUNG GANZ BESTIMMTER KOMMANDOS
995                # MIT SSH, DESHALB AUFRUF PER PIPE
996             print "[[ ! -d ${remote_md} ]]  &&  (echo \"  *** ${remote_md} will be created\"; mkdir -p  ${remote_md})"  |  ssh ${remote_username}@${remote_addres}  2>&1
997          fi
998          if [[ $local_host = decalpha ]]
999          then
1000                # DECALPHA BENUTZT BEI NICHTANGABE DES VOLLSTï¿œNDIGEN PFADES
1001                # IRGENDEIN ANDERES SCP (WAS NICHT FUNKTIONIERT). AUSSERDEM
1002                # KOENNEN DOLLAR-ZEICHEN NICHT BENUTZT WERDEN
1003             remote_md=`echo $remote_md | sed 's/\$HOME\///'`
1004             /bin/scp  ${local_source_path}/${mainprog}_sources.tar  ${remote_username}@${remote_addres}:${remote_md}/${mainprog}_sources.tar
1005          else
1006             scp  ${local_source_path}/${mainprog}_sources.tar  ${remote_username}@${remote_addres}:${remote_md}/${mainprog}_sources.tar
1007          fi
[1]1008
1009
1010
[475]1011             # FALLS VORHANDEN, LETZTE VERSION AUF DEM REMOTE-RECHNER AUSPACKEN
1012          echo "  *** untar previous update on remote host, if existing"
1013          if [[ $remote_host != lctit ]]
1014          then
1015             ssh  ${remote_username}@${remote_addres}  "cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]]  &&  tar -xf  ${mainprog}_current_version.tar"
1016          else
1017                # TIT ERLAUBT NUR DIE AUSFï¿œHRUNG GANZ BESTIMMTER KOMMANDOS
1018                # MIT SSH, DESHALB AUFRUF PER PIPE
1019             print  "cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]]  &&  tar -xf  ${mainprog}_current_version.tar"  |  ssh  ${remote_username}@${remote_addres}  2>&1
1020          fi
[1]1021
1022
[475]1023             # AKTUELLE QUELLTEXTVERSION AUF REMOTE-RECHNER AUSPACKEN
1024          echo "  *** untar actual sources on remote host"
1025          if [[ $remote_host != lctit ]]
1026          then
1027             ssh  ${remote_username}@${remote_addres}  "cd ${remote_md}; tar -xf  ${mainprog}_sources.tar"
1028          else
1029                # TIT ERLAUBT NUR DIE AUSFï¿œHRUNG GANZ BESTIMMTER KOMMANDOS
1030                # MIT SSH, DESHALB AUFRUF PER PIPE
1031             print  "cd ${remote_md}; tar -xf  ${mainprog}_sources.tar"  |  ssh  ${remote_username}@${remote_addres}  2>&1
1032          fi
[1]1033
1034
[475]1035             # MAKE MIT ZUVOR ERMITTELTEN OPTIONEN AUF REMOTE RECHNER AUSFUEHREN
1036             # KOMMANDOUEBERGABE AN SSH PER PIPE, DA SO DIE SYSTEM- UND
1037             # BENUTZERPROFILE VOLLSTAENDIG AUSGEFUEHRT WERDEN (SONST FEHLEN MAKE
1038             # Z.B. DIE PFADE ZUM COMPILER)
1039          echo "  *** execute \"make\" on remote host"
[1]1040
[493]1041
1042             # generate make call with make options
[475]1043          if [[ $remote_host = nech ]]
1044          then
1045             make_call_string="sxmake  $make_options  PROG=$mainprog  F90=$compiler_name  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$loader_options\" "
1046          else
1047             make_call_string="make  $make_options  PROG=$mainprog  F90=$compiler_name  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$loader_options\" "
1048          fi
[1]1049
[493]1050             # generate command to load modules, if modules are given
1051          if [[ "$modules" != "" ]]
1052          then
[678]1053             if [[ $remote_host = lctit ]]
1054             then
1055                module_calls=". $modules"
1056             else
1057                module_calls="module load ${modules};"
1058             fi
[555]1059
1060                # bugfix for wrong netcdf module
1061             if [[ $remote_host = lcsgib  ||  $remote_host = lcsgih ]]
1062             then
1063                if [[ $(echo $module_calls | grep -c netcdf/3.6.3-intel) != 0 ]]
1064                then
1065                   module_calls="$module_calls export LD_LIBRARY_PATH=/sw/dataformats/netcdf/3.6.3-intel/lib:\$LD_LIBRARY_PATH;"
1066                fi
1067             fi
[503]1068          else
1069             module_calls=""
[493]1070          fi
1071
[693]1072          if [[ $remote_host = ibmkisti  ||  $remote_host = ibms  ||  $remote_host = ibmy ]]
[475]1073          then
[1]1074
[493]1075             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]1076
[475]1077          elif [[ $remote_host = ibmh ]]
1078          then
[1]1079
[493]1080             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]1081
[475]1082          elif [[ $remote_host = lcsgib  ||  $remote_host = lcsgih ]]
1083          then
[1]1084
[622]1085#             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
1086             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]1087
[475]1088          elif [[ $remote_host = lctit ]]
1089          then
[1]1090
[475]1091             echo  " "  >  ${remote_host}_last_make_protokoll
1092             while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]]
1093             do
1094                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
1095             done
[1]1096
[475]1097          elif [[ $remote_host = lcxt4 ]]
[1]1098          then
1099
[691]1100             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]1101
[475]1102          else
[1]1103
[493]1104             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]1105
[475]1106          fi
[1]1107
[475]1108          if [[ $(grep -c MAKE_ERROR ${remote_host}_last_make_protokoll) != 0 ]]
1109          then
1110             printf "\a\n  +++ error(s) occurred during compiling or linking on host \"$remote_host\" "
1111             if [[ $silent = false ]]
[40]1112             then
[475]1113                answer=dummy
1114                printf "\n"
1115                while [[ "$answer" != c  &&  "$answer" != k ]]
[40]1116                do
[475]1117                   printf "  >>> continue / list errors / kill mbuild (c/l/k) ? "
1118                   read  answer
1119                   if [[ "$answer" = l ]]
1120                   then
1121                      more ${remote_host}_last_make_protokoll
1122                   fi
[40]1123                done
[475]1124                if [[ $answer = k ]]
[40]1125                then
[475]1126                   locat=user_abort; exit
[1]1127                fi
1128             fi
[475]1129          fi
[1]1130
1131
1132
[475]1133             # NEUE VERSION AUF REMOTE-RECHNER ZUSAMMENPACKEN
1134          printf "\n  *** tar update on remote host ..."
1135          if [[ $remote_host != lctit ]]
1136          then
1137             ssh  ${remote_username}@${remote_addres}  "cd ${remote_md}; chmod u+w *; tar -cf  ${mainprog}_current_version.tar  ${mainprog}  *.f90 *.o *.mod"
1138          else
1139                # TIT ERLAUBT NUR DIE AUSFï¿œHRUNG GANZ BESTIMMTER KOMMANDOS
1140                # MIT SSH, DESHALB AUFRUF PER PIPE
1141             print  "cd ${remote_md}; chmod u+w *; tar -cf  ${mainprog}_current_version.tar  ${mainprog}  *.f90 *.o *.mod"  |  ssh  ${remote_username}@${remote_addres}  2>&1
1142          fi
[1]1143
1144
[475]1145             # AKTUELLES VERSIONSVERZEICHNIS AUF REMOTE-RECHNER BEREINIGEN
1146#          printf "\n  *** \"make clean\" on remote host ..."
1147#          ssh  ${remote_username}@${remote_addres}  "cd ${remote_md}; make clean; rm ${mainprog}_sources.tar; rm *.f90 Makefile"
1148#          printf "\n"
[1]1149
1150
[25]1151
1152
[475]1153          # GLEICHE AKTIONEN FUER DIE UTILITY-PROGRAMME DURCHFUEHREN
1154          # AKTUELLE QUELLTEXTVERSION INS REMOTE-QUELLTEXTVERZEICHNIS KOPIEREN
1155          # FALLS DIESES NOCH NICHT EXISTIERT, WIRD ES ERZEUGT
1156       elif [[ $compile_utility_programs = true ]]
1157       then
1158
1159          printf "\n\n"
1160          echo "  *** copying scripts and utility programs to \"${remote_addres}:${remote_ud}/\" "
1161          cd  ${local_source_path}/../SCRIPTS
1162
1163          if [[ $remote_host != lctit ]]
[22]1164          then
[475]1165             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)"
1166          else
[503]1167                # TIT ERLAUBT NUR DIE AUSFUEHRUNG GANZ BESTIMMTER KOMMANDOS
[475]1168                # MIT SSH, DESHALB AUFRUF PER PIPE
1169             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
1170          fi
[22]1171
[475]1172             # KOPIEREN DER SCRIPTE
1173          if [[ $local_host = decalpha ]]
1174          then
[503]1175                # DECALPHA BENUTZT BEI NICHTANGABE DES VOLLSTAENDIGEN PFADES
[475]1176                # IRGENDEIN ANDERES SCP (WAS NICHT FUNKTIONIERT). AUSSERDEM
1177                # KOENNEN DOLLAR-ZEICHEN NICHT BENUTZT WERDEN
1178             remote_ud=`echo $remote_ud | sed 's/\$HOME\///'`
1179             /bin/scp  batch_scp mbuild mrun process_dvr_output .dvrserver.config subjob  ${remote_username}@${remote_addres}:${remote_ud}/../SCRIPTS  >  /dev/null
1180          else
1181             scp  batch_scp mbuild mrun process_dvr_output .dvrserver.config subjob  ${remote_username}@${remote_addres}:${remote_ud}/../SCRIPTS  >  /dev/null
1182          fi
[22]1183
[475]1184          cd  -  > /dev/null
1185          cd  ${local_source_path}/../UTIL
[22]1186
[27]1187
[475]1188             # KOPIEREN DER UTILITY-PROGRAMME
1189          if [[ $local_host = decalpha ]]
1190          then
1191                # DECALPHA BENUTZT BEI NICHTANGABE DES VOLLSTï¿œNDIGEN PFADES
1192                # IRGENDEIN ANDERES SCP (WAS NICHT FUNKTIONIERT). AUSSERDEM
1193                # KOENNEN DOLLAR-ZEICHEN NICHT BENUTZT WERDEN
1194             remote_ud=`echo $remote_ud | sed 's/\$HOME\///'`
1195             /bin/scp  Makefile  *.f90  ${remote_username}@${remote_addres}:${remote_ud}  >  /dev/null
1196          else
1197             scp  Makefile  *.f90  ${remote_username}@${remote_addres}:${remote_ud}  >  /dev/null
1198          fi
[27]1199
1200
[22]1201
[475]1202             # MAKE MIT ZUVOR ERMITTELTEN OPTIONEN AUF REMOTE RECHNER AUSFUEHREN
1203             # KOMMANDOUEBERGABE AN SSH PER PIPE, DA SO DIE SYSTEM- UND
1204             # BENUTZERPROFILE VOLLSTAENDIG AUSGEFUEHRT WERDEN (SONST FEHLEN MAKE
1205             # Z.B. DIE PFADE ZUM COMPILER)
1206          echo "  *** execute \"make\" on remote host"
[22]1207
[475]1208          if [[ $remote_host = nech ]]
1209          then
[503]1210             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]1211          else
[503]1212             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]1213          fi
[22]1214
[493]1215             # generate command to load modules, if modules are given
1216          if [[ "$modules" != "" ]]
1217          then
[678]1218             if [[ $remote_host = lctit ]]
1219             then
1220                module_calls=". $modules"
1221             else
1222                module_calls="module load ${modules};"
1223             fi
[562]1224
1225                # bugfix for wrong netcdf module
1226             if [[ $remote_host = lcsgib  ||  $remote_host = lcsgih ]]
1227             then
1228                if [[ $(echo $module_calls | grep -c netcdf/3.6.3-intel) != 0 ]]
1229                then
1230                   module_calls="$module_calls export LD_LIBRARY_PATH=/sw/dataformats/netcdf/3.6.3-intel/lib:\$LD_LIBRARY_PATH;"
1231                fi
1232             fi
[503]1233          else
1234             module_calls=""
[493]1235          fi
1236
[475]1237          if [[ $remote_host = ibms  ||  $remote_host = ibmy ]]
1238          then
[22]1239
[493]1240             ssh  ${remote_username}@${remote_addres}  "$module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR"
[22]1241
[475]1242          elif [[ $remote_host = ibmh ]]
1243          then
[22]1244
[493]1245             print "$module_calls export OBJECT_MODE=64; cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres}
[22]1246
[475]1247          elif [[ $remote_host = lctit ]]
1248          then
[22]1249
[475]1250             echo  " "  >  ${remote_host}_last_make_protokoll
1251             while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]]
1252             do
[493]1253                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]1254             done
[22]1255
[475]1256          elif [[ $remote_host = lcxt4 ]]
1257          then
[22]1258
[691]1259             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]1260
[475]1261          else
[407]1262
[493]1263             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]1264
[475]1265          fi
[22]1266
[475]1267       fi    # ENDE UEBERSETZUNG DER UTILITY-PROGRAMME
[22]1268
[475]1269       rm -rf  ${remote_host}_last_make_protokoll
[22]1270
[475]1271       # make on local host
1272    else
[22]1273
[544]1274          # workaround for lcxt4
1275       if [[ $remote_host = lcxt4 ]]
1276       then
1277          . /opt/modules/default/init/ksh
1278       fi
1279
1280       # first load modules, if given
1281       if [[ "$modules" != "" ]]
1282       then
[678]1283          if [[ $remote_host = lctit ]]
1284          then
1285             . $modules
1286          else
1287             module load ${modules}
1288          fi
[544]1289       fi
1290
1291
[475]1292       if [[ $compile_utility_programs = false ]]
1293       then
[22]1294
[475]1295             # DEPOSITORY VERZEICHNIS ERZEUGEN, FALLS NOCH NICHT VORHANDEN
1296          eval remote_md=$remote_md
1297          if [[ ! -d $remote_md ]]
[40]1298          then
[475]1299             if  mkdir $remote_md
[215]1300             then
[475]1301                printf "\n\n  *** directory for make depository:"
1302                printf "\n           $remote_md"
1303                printf "\n      was created\n"
1304             else
1305                printf "\n  +++ directory for make depository:"
1306                printf "\n           $remote_md"
1307                printf "\n      cannot be created"
1308                locat=local_depository_path; exit
[215]1309             fi
[475]1310          fi
[215]1311
[475]1312             # QUELLTEXT-DATEIEN AUS REPOSITORY INS DEPOSITORY KOPIEREN
1313          echo " "
1314          echo "  *** updating sources in $remote_md"
1315          cd  $remote_md
1316          cp  $local_source_path/${mainprog}_sources.tar  .
1317          tar xf  ${mainprog}_sources.tar
[215]1318
[475]1319             # MAKE MIT ZUVOR ERMITTELTEN OPTIONEN AUF LOKALEM RECHNER AUSFUEHREN
1320          echo " "
1321          echo "  *** execute \"make\" on local host"
[1]1322
[475]1323          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]1324
[475]1325          if [[ $? != 0 ]]
1326          then
1327             printf "\a\n  +++ error(s) occurred during compiling or linking on host \"$remote_host\" "
1328             if [[ $silent = false ]]
[1]1329             then
[475]1330                answer=dummy
1331                printf "\n"
1332                while [[ "$answer" != c  &&  "$answer" != k ]]
1333                do
1334                   printf "  >>> continue / list errors / kill mbuild (c/l/k) ? "
1335                   read  answer
1336                   if [[ "$answer" = l ]]
[1]1337                   then
[475]1338                      more ${remote_host}_last_make_protokoll
[1]1339                   fi
[475]1340                done
1341                if [[ $answer = k ]]
1342                then
1343                   locat=user_abort; exit
[1]1344                fi
1345             fi
[475]1346          fi
[1]1347
1348
[503]1349             # TAR NEW VERSION ON LOCAL HOST
[475]1350          printf "\n  *** tar update on local host ..."
1351          tar -cf  ${mainprog}_current_version.tar  *.$suf *.o *.mod
[1]1352
[22]1353
[475]1354          # COMPILE THE UTILITY PROGRAMS
1355       elif [[ $compile_utility_programs = true ]]
1356       then
1357          printf "\n\n"
1358          echo "  *** compiling the utility programs ..."
1359          cd ${local_source_path}/../UTIL
[503]1360
1361             # TOUCH FILES IN ORDER TO FORCE COMPILATION FOR EVERY BLOCK
1362          touch  *.f90
1363          make  $make_options  BLOCK=$block  F90=$compiler_name  F90_SER=$compiler_name_ser  COPT="$cpp_options"  F90FLAGS="$compiler_options"  LDFLAGS="$loader_options"
[475]1364          cd  -  > /dev/null
[1]1365       fi
1366
1367    fi
[475]1368
[1]1369 done
1370
1371
1372 if [[ $host_found = false ]]
1373 then
1374    if [[ $host = all ]]
1375    then
1376       printf "\n  +++ no hosts found in configuration file"
1377    else
1378       printf "\n  +++ host \"$host\" not found in configuration file"
1379    fi
1380    locat=config_file; exit
1381 fi
1382
1383
1384
[503]1385    # FINAL WORK
[1]1386 rm -f  hosts_found_in_config_file
1387
Note: See TracBrowser for help on using the repository browser.