source: palm/trunk/SCRIPTS/mbuild @ 1350

Last change on this file since 1350 was 1350, checked in by maronga, 11 years ago

updates for lcxe6

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