source: palm/trunk/SCRIPTS/mbuild @ 1308

Last change on this file since 1308 was 1290, checked in by raasch, 11 years ago

last commit documented
fimm-, scirocco-, ibmy-, nech-, and sgi-specific code removed from scripts

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