source: palm/trunk/SCRIPTS/mbuild @ 1652

Last change on this file since 1652 was 1652, checked in by raasch, 9 years ago

bugfix in calculation of vertical profile of energy production by turbulent transport of TKE
bugfix for output of configuration settings (mbuild)
output of login init command (mbuild)

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