source: palm/trunk/SCRIPTS/mbuild @ 1067

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

last commit documented / added nc2vdf

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