source: palm/tags/release-4.0/SCRIPTS/mbuild @ 4239

Last change on this file since 4239 was 1488, checked in by raasch, 9 years ago

last commit documented

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