source: palm/trunk/SCRIPTS/mbuild @ 924

Last change on this file since 924 was 920, checked in by maronga, 12 years ago

Bugfixes for the parameter file check. New mrun option switches off combine_plot_fields

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