source: palm/trunk/SCRIPTS/mbuild @ 1388

Last change on this file since 1388 was 1388, checked in by maronga, 10 years ago

adjustments for lcxe6

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