source: palm/trunk/SCRIPTS/mbuild @ 529

Last change on this file since 529 was 508, checked in by raasch, 15 years ago

bugfix in mbuild: remode_md was given a wrong value

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