source: palm/trunk/SCRIPTS/mbuild @ 807

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

new utility check_namelist_files implemented

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