source: palm/trunk/SCRIPTS/mbuild @ 1082

Last change on this file since 1082 was 1082, checked in by maronga, 11 years ago

last commit documented

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