source: palm/trunk/SCRIPTS/mbuild @ 691

Last change on this file since 691 was 691, checked in by maronga, 13 years ago

Bugfix for precursor atmosphere/ocean runs, re-adjustments for lcxt4

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