source: palm/trunk/SCRIPTS/mbuild @ 1043

Last change on this file since 1043 was 1040, checked in by raasch, 12 years ago

script adjustments for lckiaps

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