source: palm/trunk/SCRIPTS/mbuild @ 695

Last change on this file since 695 was 693, checked in by raasch, 14 years ago

New:
---
adjustments for ibmkisti (pres, batch_scp, mbuild, mrun, subjob)

new default configuration files .mrun.config.yonsei2011 and .config_block_for_ibmkisti

Changed:


Errors:


bugfix: weighting coefficient added to ibm branch (pres)

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