source: palm/trunk/SCRIPTS/mbuild @ 687

Last change on this file since 687 was 678, checked in by raasch, 14 years ago

New:
---

further adjustments on Tsubame and concerning openMP usage
(mrun, mbuild, subjob)

Changed:


Errors:


Bugfix in calculation of divergence of vertical flux of resolved scale
energy, pressure fluctuations, and flux of pressure fluctuation itself
(flow statistics)

Bugfix: module pegrid was missing. (user_statistics)

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