source: palm/trunk/SCRIPTS/mbuild @ 785

Last change on this file since 785 was 784, checked in by raasch, 12 years ago

Bugfix for make options setting (-j)

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