source: palm/trunk/SCRIPTS/mbuild @ 1055

Last change on this file since 1055 was 1047, checked in by maronga, 12 years ago

last commit documented / added nc2vdf

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