source: palm/trunk/SCRIPTS/mbuild @ 2284

Last change on this file since 2284 was 2257, checked in by witha, 8 years ago

Bugfix in PALM-WTM, modifications for lceddy

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