source: palm/trunk/SCRIPTS/mbuild @ 1319

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

update of GPL copyright

  • 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#
[1310]19# Copyright 1997-2014  Leibniz Universitaet Hannover
[1046]20#--------------------------------------------------------------------------------#
21#
22# Current revisions:
[1090]23# ------------------
[1290]24#
[1046]25#
26# Former revisions:
27# -----------------
[1047]28# $Id: mbuild 1310 2014-03-14 08:01:56Z raasch $
29#
[1290]30# 1289 2014-03-04 07:12:34Z raasch
31# comments translated from German to English
32# fimm-, scirocco-, ibmy-, and sgi-specific code removed
33#
[1275]34# 1274 2014-01-09 13:14:54Z heinze
35# adjustments for lccrayh
36#
[1256]37# 1255 2013-11-07 14:43:35Z raasch
38# further adjustments for lccrayb remote access
39#
[1230]40# 1229 2013-09-20 06:55:19Z raasch
41# adjustments for lccrayb
42#
[1217]43# 1216 2013-08-26 09:31:42Z raasch
[1230]44# RCS renamed SOURCES
[1217]45#
[1211]46# 1210 2013-08-14 10:58:20Z raasch
47# fftw support added
48#
[1210]49# 1197 2013-07-04 06:19:45Z raasch
50# adjustments for CSC Helsinki (lccrayf)
51#
[1100]52# 1099 2013-02-10 01:47:43Z raasch
53# adjustments for Forwind cluster (lcflow)
54#
[1096]55# 1096 2013-02-03 01:52:12Z raasch
56# decalpha parts (yonsei) removed
57#
[1091]58# 2013-02-02 07:06:13Z raasch
59# adjustments for Kyushu-University computing center (lckyut)
60# old changelog messages removed
61#
[1084]62# 1083 2013-01-04 10:22:09Z maronga
63# bugfix in parameter file check (in case that no preprocessor flag, i.e. -cpp was
64# set in %cpp_options, the last directive in the variable was processed.
65#
66# 1081 2013-01-03 08:44:36Z maronga
[1082]67# loader options set for parameter file check_depository_path
68#
[1070]69# 1069 2012-11-28 16:18:43Z maronga
70# added copy of nc2vdf tools to remote host_found
71#
[1047]72# 1046 2012-11-09 14:38:45Z maronga
73# code put under GPL (PALM 3.9)
74#
[1090]75# 12/06/02 - Siggi - first version finished
76# 06/05/02 - Siggi - script development started
77#
78#--------------------------------------------------------------------------------#
[503]79# mbuild - script for compiling the PALM code and its utility programs
[1090]80#
81# Procedure to compile code on local and remote hosts using the
82# make-mechanism. The source code must be provided on the local host.
83#--------------------------------------------------------------------------------#
[1]84
85
[503]86    # VARIABLE DECLARATIONS + DEFAULT VALUES
[936]87 block_conditions=none
88 block_conditions_found=false
[22]89 compile_utility_programs=false
[1]90 config_file=.mrun.config
91 host=all
92 host_found=false
93 locat=normal
94 makefile=""
[493]95 module_calls=""
[811]96 util_compiled_localhost=false
[1]97 silent=false
98 suf=f90
99 update=false
[83]100 working_directory=`pwd`
[1]101
102 typeset -i  ih ihost=0
103
[66]104 typeset  -R30 calltime
[1]105 typeset  -L20 column1
106 typeset  -L50 column2
107 typeset  -L70 column3
[215]108 typeset  -L40 version="MBUILD  2.1  Rev$Rev: 1310 $"
[1]109
[503]110    # ERROR HANDLING
111    # IN CASE OF EXIT:
[83]112 trap 'rm -rf  $working_directory/tmp_mbuild
[69]113       if [[ $locat != normal ]]
[1]114       then
115          printf "\n\n +++ mbuild killed \n\n"
116       else
117          printf "\n\n *** mbuild finished \n\n"
118       fi' exit
119
120
[503]121    # IN CASE OF TERMINAL-BREAK:
[83]122 trap 'rm -rf  $working_directory/tmp_mbuild
[69]123       printf "\n\n +++ mbuild killed by \"^C\" \n\n"
[1]124       exit
125      ' 2
126
127
[215]128 tmp_mbuild=${working_directory}/tmp_mbuild
[1]129
[503]130    # READ SHELLSCRIPT-OPTIONS
[936]131 while  getopts  :c:h:K:m:s:uv  option
[1]132 do
133   case  $option  in
134       (c)   config_file=$OPTARG;;
135       (h)   host=$OPTARG;;
[936]136       (K)   block_conditions=$OPTARG;;
[1]137       (m)   makefile=$OPTARG;;
138       (s)   suf=$OPTARG;;
[22]139       (u)   compile_utility_programs=true;;
[935]140       (v)   silent=true;;
[1]141       (\?)  printf "\n  +++ unknown option $OPTARG \n";
142             locat=parameter; exit;;
143   esac
144 done
145
146
147
[503]148    # CHECK, IF CONFIGURATION-FILE EXISTS
[82]149 if [[ ! -f $config_file ]]
150 then
151    printf "\n  +++ configuration file: "
152    printf "\n           $config_file"
153    printf "\n      does not exist"
154    locat=configuration; exit 
155 fi
156
157
158
[503]159    # DETERMINE THE LOCAL HOST
[1]160 local_host_real_name=$(hostname)
[69]161# local_addres=$(nslookup `hostname` 2>&1 | grep "Address:" | tail -1 | awk '{print $2}')
162
[1]163
[82]164
[503]165    # DETERMINE HOST-IDENTIFIER (local_host) FROM THE CONFIG-FILE
[82]166 line=""
[215]167 grep  "%host_identifier"  $config_file  >  $tmp_mbuild
[82]168 while read line
169 do
[116]170    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
[82]171    then
172       HOSTNAME=`echo $line | cut -d" " -s -f2`
173       host_identifier=`echo $line | cut -d" " -s -f3`
[83]174       if [[ $local_host_real_name = $HOSTNAME ]]
[82]175       then
176          local_host=$host_identifier
177          break
178       fi
179    fi
[215]180 done < $tmp_mbuild
[82]181
182 if [[ "$local_host" = "" ]]
183 then
184    printf "\n  +++ no host identifier found in configuration file \"$config_file\""
185    printf "\n      for local host \"$local_host_real_name\"."
186    printf "\n      Please add line"
187    printf "\n      \"\%host_identifier $local_host_real_name <identifier>\""
188    printf "\n      to the configuration file."
189    locat=local_host; exit
190 fi
191
192
[1]193 if [[ $local_host != ibms ]]
194 then
195    config_file=$PWD/$config_file
196 else
197    config_file=`pwd`/$config_file
198 fi
199
200
[1289]201    # DETERMINE THE BLOCK CONDITIONS
[936]202 if [[ $block_conditions != none ]]
203 then
204    block_condition1=`echo $block_conditions | cut -d" " -f1`
205    block_condition2=`echo $block_conditions | cut -d" " -f2`
206    if [[ "$block_condition2" = "$block_condition1" ]]
207    then
208       block_condition2=""
209    fi
210 fi
211
[1]212 
[503]213    # DETERMINE USER NAME ON LOCAL HOST FROM THE CONFIG-FILE
[1]214 line=""
[215]215 grep  " $local_host" $config_file | grep "%remote_username"  >  $tmp_mbuild
[69]216 while read line
[1]217 do
[116]218    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
[1]219    then
220       local_username=`echo $line | cut -d" " -s -f2`
221    fi
[215]222 done < $tmp_mbuild
[1]223
[82]224
[1]225 if [[ "$local_username" = "" ]]
226 then
227    printf "\n  +++ no user name found in configuration file"
228    printf "\n      for local host \"$local_host\" "
229    locat=config_file; exit
230 fi
231
232
[503]233    # DETERMINE LOCAL SOURCE-CODE PATH.
234    # FIRST CHECK, IF A GLOBAL SOURCE-CODE PATH HAS BEEN DECLARED FOR ALL HOSTS.
235    # THEREFORE, FIRST SET ALL GLOBAL VARIABLES DECLARED IN THE CONFIG-FILE,
236    # BECAUSE THEY MAY BE USED AS PART OF THE PATH NAME.
[5]237 line=""
[215]238 grep "%" $config_file  >  $tmp_mbuild
[69]239 while read line
[5]240 do
[116]241    if [[ "$line" != ""  &&  "$(echo $line | cut -d" " -s -f3)" = ""  &&  $(echo $line | cut -c1) != "#" ]]
[1]242    then
[5]243       var=`echo $line | cut -d" " -s -f1 | cut -c2-`
244       value=`echo $line | cut -d" " -s -f2`
[8]245       eval export $var=\$value
[1]246    fi
[215]247 done < $tmp_mbuild
[1]248
[503]249    # NOW CHECK, IF A GLOBAL SOURCE-CODE-PATH HAS BEEN DECLARED
[1]250 line=""
[215]251 grep "%source_path" $config_file  >  $tmp_mbuild
[69]252 while read line
[1]253 do
254    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
255    then
256       if [[ "$(echo $line | cut -d" " -s -f3)" = "" ]]
257       then
258          global_source_path=`echo $line | cut -d" " -s -f2`
259       fi
260    fi
[215]261 done < $tmp_mbuild
[1]262
263 line=""
[215]264 grep  " $local_host" $config_file | grep "%source_path"  >  $tmp_mbuild
[69]265 while read line
[1]266 do
267    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
268    then
269       local_source_path=`echo $line | cut -d" " -s -f2`
270    fi
[215]271 done < $tmp_mbuild
[1]272
273 if [[ "$local_source_path" = "" ]]
274 then
275    if [[ "$global_source_path" != "" ]]
276    then
277       local_source_path=$global_source_path
278    else
279       printf "\n  +++ no source path found in configuration file"
280       printf "\n      for local host \"$local_host\" "
281       printf "\n      please set \"\%source_path\" in configuration file"
282       locat=config_file; exit
283    fi
284 fi
285 eval local_source_path=$local_source_path
[8]286 eval local_source_path=$local_source_path
[1]287
288
[215]289
[503]290    # DETERMINE GLOBAL DEPOSITORY-PATH
[1]291 line=""
[215]292 grep "%depository_path" $config_file  >  $tmp_mbuild
[69]293 while read line
[1]294 do
295    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
296    then
297       if [[ "$(echo $line | cut -d" " -s -f3)" = "" ]]
298       then
299          global_depository_path=`echo $line | cut -d" " -s -f2`
300       fi
301    fi
[215]302 done < $tmp_mbuild
[1]303
[807]304 if [[ $found = false ]]
305 then
306    printf "\n  +++ no \%depository_path found in" 
307    printf "\n                            $config_file"
308    locat=depository_path; exit
309  fi
[1]310
[503]311    # CHECK, IF A MAIN PROGRAM HAS BEEN DEFINED IN THE CONFIG-FILE
[5]312 if [[ $(grep -c "%mainprog" $config_file) != 1 ]]
313 then
314    printf "\n  +++ no main program or more than one main program defined"
315    printf "\n      in configuration file"
316    locat=configuration; exit
317 else
318    line=`grep "%mainprog" $config_file`
319    if [[ "$line" = ""  ||  $(echo $line | cut -c1) = "#" ]]
320    then
321       printf "\n  +++ no main program defined in configuration file"
322       locat=configuration; exit
323    fi
324    mainprog=`echo $line | cut -d" " -s -f2 | cut -d"." -f1`
325 fi
326
327
328
[503]329    # CHECK IF MAKEFILE EXITS
[1]330 [[ "$makefile" = "" ]]  &&  makefile=$local_source_path/Makefile
331 if [[ ! -f $makefile ]]
332 then
333    printf "\n  +++ makefile: "
334    printf "\n           $makefile"
335    printf "\n      does not exist"
336    locat=makefile; exit 
337 fi
338
339
[503]340    # HEADER-OUTPUT (PART1: MESSAGES CONCERNING THE LOCAL HOST)
[1]341 calltime=$(date)
342 printf "\n"
343 printf "#------------------------------------------------------------------------# \n"
344 printf "| $version$calltime | \n"
345 printf "|                                                                        | \n"
346 column1="called on:"; column2=$local_host_real_name
347 printf "| $column1$column2 | \n"
348 column1="local username:"; column2=$local_username
349 printf "| $column1$column2 | \n"
350 column1="local IP-addres:"; column2=$local_addres
351 printf "| $column1$column2 | \n"
352 column1="config file:"; column2=$config_file
353 printf "| $column1$column2 | \n"
354 column1="makefile:"; column2=$makefile
355 printf "| $column1$column2 | \n"
356 column1="local source path:"; column2=$local_source_path
357 printf "| $column1$column2 | \n"
358 printf "#------------------------------------------------------------------------# \n"
359
360# printf "|                                                                        | \n"
361
362
[40]363 if [[ $compile_utility_programs = false ]]
364 then
[1]365
[503]366       # IN ANY CASE, GIVE ALL FILES WRITE-PERMIT, IN ORDER TO AVOID PROBLEMS
367       # WITH OVERWRITING FILES ON THE REMOTE HOST
[215]368    cd  $local_source_path
369    printf "\n\n  *** tar of makefile and source files in $local_source_path" 
[40]370    tar -cf  ${mainprog}_sources.tar  Makefile  *.$suf
371    printf "\n"
[1]372
[807]373 else
374    cd  $local_source_path
375    printf "\n\n  *** tar of makefile and source files in $local_source_path" 
376 
377    cat Makefile_check|while read line
378    do
[1216]379       line=$(echo $line|grep SOURCES)
380       if [[ $line == *"SOURCES"* ]]
[807]381       then
[1216]382          line=$(echo $line|sed 's/SOURCES = //g')
[807]383          break
384       fi
385    done
386
387    tar -cf  ${mainprog}_sources_check.tar  Makefile_check  $line
388    printf "\n"
[40]389 fi
[1]390
391
[40]392
[503]393    # GET CONFIRMATION TO CONTINUE
[1]394 if [[ $host = all ]]
395 then
396    printf "\n  *** updates will be made for ALL hosts found in"
397    printf "\n      the configuration file"
398 else
399    printf "\n  *** update will be made for host \"$host\" "
400 fi
401
402 if [[ $silent = false ]]
403 then
404    answer=dummy
405    printf "\n\n"
406    while [[ "$answer" != y  &&  "$answer" != Y  &&  "$answer" != n  &&  "$answer" != N ]]
407    do
408       printf " >>> continue (y/n) ?  "
409       read  answer
410    done
411    if [[ $answer = n  ||  $answer = N ]]
412    then
413       locat=user_abort; exit
414    fi
415 fi
416 
417 
418
419   
[1289]420    # GENERATE MODEL-VERSIONS FOR ALL HOST-BLOCKS
421    # FOUND IN THE CONFIGURATION-FILE
[1]422 printf "\n  *** scanning configuration file for host(s) ..."
423
[215]424 grep  %fopts  $config_file  >  $tmp_mbuild
[69]425 while read line
[1]426 do
[1289]427       # SKIP COMMENT-LINES
[1]428    [[ $(echo $line | cut -c1) = "#" ]]  &&  continue
429    (( ihost = ihost + 1 ))
430    hostline[$ihost]="$line"
[215]431 done < $tmp_mbuild
[1]432
433 
434 while (( ih < ihost ))
435 do
436
437    (( ih = ih + 1 ))
438
[1289]439       # DETERMINE REMOTE HOST AND CONDITIONS FOR THE RESPECTIVE BLOCK
440       # CONTINUE, ONLY IF THIS HOST HAS BEEN CHOSEN VIA -h OPTION AND IF
441       # CONDITIONS HAVE BEEN CHOSEN VIA -K OPTION
[1]442    remote_host_string=`echo ${hostline[$ih]} | cut -d" " -s -f3-`
443    remote_host=`echo $remote_host_string | cut -d" " -f1`
444    if [[ $host != all ]]
445    then
446       [[ $remote_host != $host ]]  &&  continue
447    fi
448    host_found=true
449    condition1=`echo $remote_host_string | cut -d" " -s -f2`
450    if [[ $condition1 = $remote_host ]]
451    then
452       condition1=""
453    else
454       condition2=`echo $remote_host_string | cut -d" " -s -f3`
455    fi
456
[936]457    if [[ $block_conditions != none ]]
458    then
459       if [[ "$condition1" != "$block_condition1"  || "$condition2" != "$block_condition2" ]]
460       then
461          continue
462       fi
463       block_conditions_found=true
464    fi
465
[1210]466    fftw_inc=""
467    fftw_lib=""
[493]468    modules=""
[82]469    netcdf_inc=""
470    netcdf_lib=""
[784]471    make_options=""
[1]472
[1289]473       # DETERMINE IP-ADDRES OF THE REMOTE-HOST
[1]474    case  $remote_host  in
[1255]475        (lccrayb)        remote_addres=130.73.233.1;;
[1274]476        (lccrayh)        remote_addres=130.75.4.1;;
[1099]477        (lcflow)         remote_addres="flow.hpc.uni-oldenburg.de";;
[980]478        (lckordi)        remote_adress=210.219.61.8;;
[116]479        (lcmuk)          remote_addres=130.75.105.2;;
[622]480        (lcrte)          remote_addres=133.5.185.60;;
[1099]481        (lcsb)           remote_addres=147.46.30.151;;
[367]482        (lck)            remote_addres=165.132.26.61;;
[1040]483        (lckiaps)        remote_addres=118.128.66.223;;
[1090]484        (lckyut)         remote_addres=133.5.4.37;;
[635]485        (lctit)          remote_addres=10.1.6.170;;
[892]486        (lcxe6)          remote_addres=129.177.20.113;;
[437]487        (lcxt5m)         remote_addres=193.166.211.144;;
[305]488        (ibmh)           remote_addres=136.172.40.15;;
[693]489        (ibmkisti)       remote_addres=150.183.146.24;;
[622]490        (ibmku)          remote_addres=133.5.4.129;;
[83]491        (ibms)           remote_addres=150.183.5.101;;
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
[1289]504       # DETERMINE REMOTE-USERNAME
[1]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
[1289]532       # DETERMINE REMOTE-SOURCE-CODE-PATH
[1]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
[1289]567       # DETERMINE REMOTE-PATH FOR MAKE-DEPOSITORY
[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
[1289]606       # DETERMINE COMPILERNAME
[1]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
[1289]634       # IN CASE OF PARALLEL EXECUTION (COMPILER FOR PARALLEL EXECUTION),
635       # A SERIAL COMPILERNAME MUST BE DETERMINED ALSO
[27]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
[1289]669       # DETERMINE PREPROCESSOR-OPTIONS AND DIRECTIVES
[82]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
[1289]683             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
[116]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
[1289]698       # ADD HOST-SPECIFIC PREPROCESSOR-DIRECTIVES
[82]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
[1289]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
[1289]735             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
[116]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
[1289]753             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
[116]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
[1289]761       # GET FFTW OPTIONS
[1210]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
[1289]774             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
[1210]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
[1289]792             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
[1210]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
[1289]800       # GET MAKE OPTIONS
[475]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
[1289]814             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
[475]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
[1289]823       # GET COMPILER OPTIONS
[1]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
[1289]837             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
[116]838          compiler_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
839          found=true
840
[1289]841             # ADD INCLUDE PATHS FOR netCDF AND FFTW
[1210]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
[1289]855       # GET LOGIN INIT COMMANDS
[892]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
[1289]868             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
[892]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
[1289]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
[1289]888             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
[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
[1289]895       # GET LINKER OPTIONS
[1]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
[1289]909             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
[116]910          loader_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
911          found=true
912
[1289]913             # ADD netCDF- AND FFTW-LIBRARY
[1210]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
[1289]1038       # MAKE ON REMOTE HOST
[475]1039    if [[ $remote_host != $local_host ]]
[1]1040    then
[475]1041       if [[ $compile_utility_programs = false ]]
[1]1042       then
1043
[1289]1044             # COPY CURRENT SOURCE CODE TO SOURCE-CODE DIRECTORY ON THE REMOTE HOST
1045             # CREATE THIS DIRECTORY, IF IT DOES NOT EXIST
[475]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
[1289]1051                # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS
[475]1052             print "[[ ! -d ${remote_md} ]]  &&  (echo \"  *** ${remote_md} will be created\"; mkdir -p  ${remote_md})"  |  ssh ${remote_username}@${remote_addres}  2>&1
1053          fi
[1]1054
[1096]1055          scp  ${local_source_path}/${mainprog}_sources.tar  ${remote_username}@${remote_addres}:${remote_md}/${mainprog}_sources.tar
[1]1056
1057
[1096]1058
[1289]1059             # UNTAR PREVIOUS UPDATE ON REMOTE HOST, IF EXISTING
[475]1060          echo "  *** untar previous update on remote host, if existing"
1061          if [[ $remote_host != lctit ]]
1062          then
1063             ssh  ${remote_username}@${remote_addres}  "cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]]  &&  tar -xf  ${mainprog}_current_version.tar"
1064          else
[1289]1065                # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS
[475]1066             print  "cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]]  &&  tar -xf  ${mainprog}_current_version.tar"  |  ssh  ${remote_username}@${remote_addres}  2>&1
1067          fi
[1]1068
1069
[1289]1070             # UNTAR CURRENT SOURCES ON REMOTE HOST
1071          echo "  *** untar current sources on remote host"
[475]1072          if [[ $remote_host != lctit ]]
1073          then
1074             ssh  ${remote_username}@${remote_addres}  "cd ${remote_md}; tar -xf  ${mainprog}_sources.tar"
1075          else
[1289]1076                # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS
[475]1077             print  "cd ${remote_md}; tar -xf  ${mainprog}_sources.tar"  |  ssh  ${remote_username}@${remote_addres}  2>&1
1078          fi
[1]1079
1080
[1289]1081             # EXECUTE MAKE WITH THOSE OPTIONS DETERMINED ABOVE
1082             # COMMANDS WILL BE COMMUNICATED TO SSH VIA PIPE, SINCE THIS WAY THE SYSTEM- AND
1083             # USER-PROFILES OF THE SHELL ARE COMPLETELY EXECUTED (OTHERWISE, MAKE
1084             # WILL E.G. MISS THE COMPILER-PATHS)
[475]1085          echo "  *** execute \"make\" on remote host"
[1]1086
[493]1087
[1289]1088             # GENERATE MAKE CALL WITH MAKE OPTIONS
[475]1089          if [[ $remote_host = nech ]]
1090          then
1091             make_call_string="sxmake  $make_options  PROG=$mainprog  F90=$compiler_name  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$loader_options\" "
1092          else
1093             make_call_string="make  $make_options  PROG=$mainprog  F90=$compiler_name  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$loader_options\" "
1094          fi
[1]1095
[1289]1096             # GENERATE COMMAND TO LOAD MODULES, IF MODULES ARE GIVEN
[493]1097          if [[ "$modules" != "" ]]
1098          then
[678]1099             if [[ $remote_host = lctit ]]
1100             then
1101                module_calls=". $modules"
1102             else
1103                module_calls="module load ${modules};"
1104             fi
[503]1105          else
1106             module_calls=""
[493]1107          fi
1108
[1289]1109          if [[ $remote_host = ibmkisti  ||  $remote_host = ibms ]]
[475]1110          then
[1]1111
[892]1112             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]1113
[475]1114          elif [[ $remote_host = ibmh ]]
1115          then
[1]1116
[892]1117             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]1118
[475]1119          elif [[ $remote_host = lctit ]]
1120          then
[1]1121
[475]1122             echo  " "  >  ${remote_host}_last_make_protokoll
1123             while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]]
1124             do
1125                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
1126             done
[1]1127
[892]1128          elif [[ $remote_host = lcxe6 ]]
[1]1129          then
1130
[892]1131             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]1132
[475]1133          else
[1]1134
[892]1135             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]1136
[475]1137          fi
[1]1138
[475]1139          if [[ $(grep -c MAKE_ERROR ${remote_host}_last_make_protokoll) != 0 ]]
1140          then
1141             printf "\a\n  +++ error(s) occurred during compiling or linking on host \"$remote_host\" "
1142             if [[ $silent = false ]]
[40]1143             then
[475]1144                answer=dummy
1145                printf "\n"
1146                while [[ "$answer" != c  &&  "$answer" != k ]]
[40]1147                do
[475]1148                   printf "  >>> continue / list errors / kill mbuild (c/l/k) ? "
1149                   read  answer
1150                   if [[ "$answer" = l ]]
1151                   then
1152                      more ${remote_host}_last_make_protokoll
1153                   fi
[40]1154                done
[475]1155                if [[ $answer = k ]]
[40]1156                then
[475]1157                   locat=user_abort; exit
[1]1158                fi
1159             fi
[475]1160          fi
[1]1161
1162
1163
[1289]1164             # TAR UPDATED VERSION ON THE REMOTE HOST
[475]1165          printf "\n  *** tar update on remote host ..."
1166          if [[ $remote_host != lctit ]]
1167          then
1168             ssh  ${remote_username}@${remote_addres}  "cd ${remote_md}; chmod u+w *; tar -cf  ${mainprog}_current_version.tar  ${mainprog}  *.f90 *.o *.mod"
1169          else
[1289]1170                # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS
[475]1171             print  "cd ${remote_md}; chmod u+w *; tar -cf  ${mainprog}_current_version.tar  ${mainprog}  *.f90 *.o *.mod"  |  ssh  ${remote_username}@${remote_addres}  2>&1
1172          fi
[1]1173
1174
1175
[1289]1176          # DO THE SAME THINGS FOR THE UTILITY-ROUTINES:
1177          # COPY CURRENT SOURCE CODE TO SOURCE-CODE DIRECTORY ON THE REMOTE HOST
1178          # CREATE THIS DIRECTORY, IF IT DOES NOT EXIST
[475]1179       elif [[ $compile_utility_programs = true ]]
1180       then
1181
1182          printf "\n\n"
1183          echo "  *** copying scripts and utility programs to \"${remote_addres}:${remote_ud}/\" "
1184          cd  ${local_source_path}/../SCRIPTS
1185
1186          if [[ $remote_host != lctit ]]
[22]1187          then
[475]1188             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)"
1189          else
[1289]1190                # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS
[475]1191             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
1192          fi
[22]1193
[1289]1194             # COPY SHELL-SCRIPTS
[1096]1195          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]1196
[475]1197          cd  -  > /dev/null
1198          cd  ${local_source_path}/../UTIL
[22]1199
[27]1200
[1289]1201             # COPY UTILITY-ROUTINES
[1096]1202          scp  Makefile  *.f90  ${remote_username}@${remote_addres}:${remote_ud}  >  /dev/null
[27]1203
1204
[22]1205
[1289]1206             # EXECUTE MAKE WITH THOSE OPTIONS DETERMINED ABOVE
1207             # COMMANDS WILL BE COMMUNICATED TO SSH VIA PIPE, SINCE THIS WAY THE SYSTEM- AND
1208             # USER-PROFILES OF THE SHELL ARE COMPLETELY EXECUTED (OTHERWISE, MAKE
1209             # WILL E.G. MISS THE COMPILER-PATHS)
[475]1210          echo "  *** execute \"make\" on remote host"
[22]1211
[475]1212          if [[ $remote_host = nech ]]
1213          then
[503]1214             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]1215          else
[503]1216             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]1217          fi
[22]1218
[1289]1219             # GENERATE COMMAND TO LOAD MODULES, IF MODULES ARE GIVEN
[493]1220          if [[ "$modules" != "" ]]
1221          then
[678]1222             if [[ $remote_host = lctit ]]
1223             then
1224                module_calls=". $modules"
1225             else
1226                module_calls="module load ${modules};"
1227             fi
[503]1228          else
1229             module_calls=""
[493]1230          fi
1231
[892]1232
[1289]1233          if [[ $remote_host = ibms ]]
[475]1234          then
[22]1235
[892]1236             ssh  ${remote_username}@${remote_addres}  "$init_cmds $module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR"
[22]1237
[475]1238          elif [[ $remote_host = ibmh ]]
1239          then
[22]1240
[892]1241             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]1242
[475]1243          elif [[ $remote_host = lctit ]]
1244          then
[22]1245
[475]1246             echo  " "  >  ${remote_host}_last_make_protokoll
1247             while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]]
1248             do
[892]1249                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]1250             done
[22]1251
[892]1252          elif [[ $remote_host = lcxe6 ]]
[475]1253          then
[22]1254
[892]1255             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]1256
[475]1257          else
[407]1258
[892]1259             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]1260
[475]1261          fi
[22]1262
[1289]1263       fi    # END OF COMPILING UTILITY-ROUTINES
[22]1264
[475]1265       rm -rf  ${remote_host}_last_make_protokoll
[22]1266
[1289]1267       # MAKE ON LOCAL HOST
[475]1268    else
[22]1269
[1289]1270          # INIT WORKAROUND FOR lcxe6
[1274]1271       if [[ $remote_host = lcxe6  ||  $remote_host = lccrayb  ||  $remote_host = lccrayf ||  $remote_host = lccrayh ]]
[544]1272       then
[920]1273
[1197]1274          eval $init_cmds  >  /dev/null  2>&1
[920]1275
[544]1276       fi
1277
[1289]1278       # FIRST LOAD MODULES, IF GIVEN
[544]1279       if [[ "$modules" != "" ]]
1280       then
[678]1281          if [[ $remote_host = lctit ]]
1282          then
1283             . $modules
[1099]1284          elif [[ $remote_host = lcflow ]]
1285          then
1286             eval `$MODULESHOME/bin/modulecmd ksh load ${modules}`
[678]1287          else
1288             module load ${modules}
1289          fi
[544]1290       fi
1291
1292
[475]1293       if [[ $compile_utility_programs = false ]]
1294       then
[22]1295
[1289]1296             # CREATE MAKE-DEPOSITORY, IF IT DOES NOT EXIST
[475]1297          eval remote_md=$remote_md
1298          if [[ ! -d $remote_md ]]
[40]1299          then
[475]1300             if  mkdir $remote_md
[215]1301             then
[475]1302                printf "\n\n  *** directory for make depository:"
1303                printf "\n           $remote_md"
1304                printf "\n      was created\n"
1305             else
1306                printf "\n  +++ directory for make depository:"
1307                printf "\n           $remote_md"
1308                printf "\n      cannot be created"
1309                locat=local_depository_path; exit
[215]1310             fi
[475]1311          fi
[215]1312
[1289]1313             # COPY SOURCE-CODE FROM REPOSITORY TO MAKE-DEPOSITORY
[475]1314          echo " "
1315          echo "  *** updating sources in $remote_md"
1316          cd  $remote_md
1317          cp  $local_source_path/${mainprog}_sources.tar  .
1318          tar xf  ${mainprog}_sources.tar
[215]1319
[1289]1320             # CALL MAKE ON LOCAL HOST USING THE  OPTIONS DETERMINED FURTHER ABOVE
[475]1321          echo " "
1322          echo "  *** execute \"make\" on local host"
[1]1323
[475]1324          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]1325
[475]1326          if [[ $? != 0 ]]
1327          then
1328             printf "\a\n  +++ error(s) occurred during compiling or linking on host \"$remote_host\" "
1329             if [[ $silent = false ]]
[1]1330             then
[475]1331                answer=dummy
1332                printf "\n"
1333                while [[ "$answer" != c  &&  "$answer" != k ]]
1334                do
1335                   printf "  >>> continue / list errors / kill mbuild (c/l/k) ? "
1336                   read  answer
1337                   if [[ "$answer" = l ]]
[1]1338                   then
[475]1339                      more ${remote_host}_last_make_protokoll
[1]1340                   fi
[475]1341                done
1342                if [[ $answer = k ]]
1343                then
1344                   locat=user_abort; exit
[1]1345                fi
1346             fi
[475]1347          fi
[1]1348
1349
[503]1350             # TAR NEW VERSION ON LOCAL HOST
[475]1351          printf "\n  *** tar update on local host ..."
1352          tar -cf  ${mainprog}_current_version.tar  *.$suf *.o *.mod
[1]1353
[22]1354
[475]1355          # COMPILE THE UTILITY PROGRAMS
1356       elif [[ $compile_utility_programs = true ]]
1357       then
1358          printf "\n\n"
1359          echo "  *** compiling the utility programs ..."
1360          cd ${local_source_path}/../UTIL
[503]1361
1362             # TOUCH FILES IN ORDER TO FORCE COMPILATION FOR EVERY BLOCK
1363          touch  *.f90
1364          make  $make_options  BLOCK=$block  F90=$compiler_name  F90_SER=$compiler_name_ser  COPT="$cpp_options"  F90FLAGS="$compiler_options"  LDFLAGS="$loader_options"
[793]1365
[807]1366             # CHECK IF QMAKE IS AVAILABLE AND COMPILE MRUNGUI
[811]1367          if [[ $util_compiled_localhost == false ]]
1368          then
1369             printf "\n\n"
1370             echo "  *** compiling the mrun GUI"
1371             if which qmake >/dev/null; then
1372                cd mrungui
1373                touch *
1374                qmake
1375                make
1376                make clean
1377                rm Makefile
1378                cd ..
1379             else
1380                echo "  +++ no qmake found. The (optional) GUI will not be compiled."
1381             fi
[793]1382
[1289]1383                # COMPILE CHECK_NAMELIST_FILES (ONLY FOR ONE BRANCH on LOCALHOST NEEDED)
[811]1384             printf "\n\n"
1385             echo "  *** compiling check_namelist_files ..."
[807]1386
[1289]1387                # GET CHECK OPTIONS
[892]1388             line=""
1389             found=false
1390             grep  "$remote_host_string" $config_file | grep "%cpp_options"  >  $tmp_mbuild
1391             while read line1
1392             do
1393
1394                if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
1395                then
1396                   line="$line1"
1397                fi
1398
1399                if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
1400                then
[1289]1401                      # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
[892]1402                   line="$line "
1403                   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'`
1404                   found=true
1405                fi
1406
1407             done < $tmp_mbuild
1408             copts_check="$copts_check -D__check -D__parallel"
1409
[811]1410             check_depository_path=${local_source_path}/../UTIL
1411             cd $check_depository_path
1412             mkdir check_tmp
1413             cp ${local_source_path}/${mainprog}_sources_check.tar ./check_tmp
1414             cd check_tmp
1415             tar -xf  ${mainprog}_sources_check.tar
1416             rm -rf ${mainprog}_sources_check.tar
[1083]1417             make  -f Makefile_check $make_options  F90=$compiler_name_ser  COPT="$copts_check"  F90FLAGS="$compiler_options"
[811]1418             tar -cf  check_namelist_files.tar Makefile_check check_namelist_files.x *.f90 *.o *.mod
1419             mv check_namelist_files.tar $check_depository_path
1420             mv check_namelist_files.x $PALM_BIN
1421             cd $check_depository_path
1422             rm -rf check_tmp
1423             util_compiled_localhost=true
1424          else
1425             cd $check_depository_path
1426             printf "\n\n"
[818]1427             echo "  *** skipped compilation of mrun GUI."       
[811]1428             printf "\n\n"
1429             echo "  *** skipped compilation of check_namelist_files."           
1430          fi
1431
[1]1432       fi
1433    fi
1434 done
1435
1436
1437 if [[ $host_found = false ]]
1438 then
1439    if [[ $host = all ]]
1440    then
1441       printf "\n  +++ no hosts found in configuration file"
1442    else
1443       printf "\n  +++ host \"$host\" not found in configuration file"
1444    fi
1445    locat=config_file; exit
1446 fi
1447
[936]1448 if [[ "$block_conditions" != none  &&  $block_conditions_found = false ]]
1449 then
1450    printf "\n  +++ block conditions \"$block_conditions\" not found for host \"$host\""
1451 fi
[1]1452
1453
[503]1454    # FINAL WORK
[1]1455 rm -f  hosts_found_in_config_file
[811]1456 rm -f ${local_source_path}/${mainprog}_sources_check.tar
Note: See TracBrowser for help on using the repository browser.