source: palm/trunk/SCRIPTS/mbuild @ 1818

Last change on this file since 1818 was 1818, checked in by maronga, 8 years ago

last commit documented / copyright update

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