source: palm/trunk/SCRIPTS/mbuild @ 1082

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

last commit documented

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