source: palm/trunk/SCRIPTS/mbuild @ 1552

Last change on this file since 1552 was 1548, checked in by witha, 10 years ago

last commit documented

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