source: palm/trunk/SCRIPTS/mbuild @ 2479

Last change on this file since 2479 was 2365, checked in by kanani, 7 years ago

Vertical nesting implemented (SadiqHuq?)

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