source: palm/trunk/SCRIPTS/mbuild @ 795

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

GUI for mrun added

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