source: palm/trunk/SCRIPTS/mbuild @ 1255

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

further adjustments for lccrayb, mainly concerning remote job access

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