source: palm/trunk/SCRIPTS/mbuild @ 1481

Last change on this file since 1481 was 1469, checked in by maronga, 10 years ago

last commit documented

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