source: palm/trunk/SCRIPTS/mbuild @ 2124

Last change on this file since 2124 was 1945, checked in by raasch, 8 years ago

last commit documented

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