source: palm/trunk/SCRIPTS/mbuild @ 1350

Last change on this file since 1350 was 1350, checked in by maronga, 11 years ago

updates for lcxe6

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