source: palm/trunk/SCRIPTS/mbuild @ 1079

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

last commit documented

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