source: palm/trunk/SCRIPTS/mbuild @ 1289

Last change on this file since 1289 was 1289, checked in by raasch, 10 years ago

script comments translated to English
version update to 3.10

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