source: palm/trunk/SCRIPTS/mbuild @ 1487

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

bash compatibility adjustments

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