source: palm/trunk/SCRIPTS/mbuild @ 1944

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

adjustments for using HLRN ssh-keys

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