source: palm/trunk/SCRIPTS/mbuild @ 1289

Last change on this file since 1289 was 1289, checked in by raasch, 10 years ago

script comments translated to English
version update to 3.10

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