source: palm/trunk/SCRIPTS/mbuild @ 1046

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

put scripts and utilities under GPL

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