source: palm/trunk/SCRIPTS/mbuild @ 1413

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

last commit documented

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