source: palm/trunk/SCRIPTS/mbuild @ 1621

Last change on this file since 1621 was 1621, checked in by heinze, 9 years ago

last commit documented

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