source: palm/trunk/SCRIPTS/mbuild @ 1493

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

last commit documented

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