source: palm/trunk/SCRIPTS/mbuild @ 1468

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

New flag files allow to force unscheduled termination/restarts of batch jobs, progress output is made for batch runs, small adjustments for lxce6 and lccrayh/lccrayb

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