source: palm/trunk/SCRIPTS/mbuild @ 1085

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

last commit documented

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