source: palm/trunk/SCRIPTS/mbuild @ 1069

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

allow usage of topography in combination with cloud physics, allow usage of topography in coupled ocean model, minor changes in mbuild and mrun

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