source: palm/trunk/SCRIPTS/mbuild @ 1098

Last change on this file since 1098 was 1096, checked in by raasch, 12 years ago

last commit documented

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