source: palm/trunk/SCRIPTS/mbuild @ 1243

Last change on this file since 1243 was 1230, checked in by raasch, 11 years ago

last commit documented

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