source: palm/trunk/SCRIPTS/mbuild @ 1619

Last change on this file since 1619 was 1614, checked in by maronga, 9 years ago

last commit documented

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