source: palm/trunk/SCRIPTS/mbuild @ 855

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

bugfix: namelist file check now possible for topography and re-enabled. mrungui update (-z option)

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