source: palm/trunk/SCRIPTS/mbuild @ 624

Last change on this file since 624 was 622, checked in by raasch, 14 years ago

New:
---

Optional barriers included in order to speed up collective operations
MPI_ALLTOALL and MPI_ALLREDUCE. This feature is controlled with new initial
parameter collective_wait. Default is .FALSE, but .TRUE. on SGI-type
systems. (advec_particles, advec_s_bc, buoyancy, check_for_restart,
cpu_statistics, data_output_2d, data_output_ptseries, flow_statistics,
global_min_max, inflow_turbulence, init_3d_model, init_particles, init_pegrid,
init_slope, parin, pres, poismg, set_particle_attributes, timestep,
read_var_list, user_statistics, write_compressed, write_var_list)

Adjustments for Kyushu Univ. (lcrte, ibmku). Concerning hybrid
(MPI/openMP) runs, the number of openMP threads per MPI tasks can now
be given as an argument to mrun-option -O. (mbuild, mrun, subjob)

Changed:


Initialization of the module command changed for SGI-ICE/lcsgi (mbuild, subjob)

Errors:


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