source: palm/trunk/SCRIPTS/mbuild @ 1261

Last change on this file since 1261 was 1256, checked in by raasch, 11 years ago

last commit documented

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