source: palm/trunk/SCRIPTS/mbuild @ 1390

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

disabled compilation of parameter file check, adjustments for lcxe6

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