source: palm/trunk/SCRIPTS/mbuild @ 1482

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

last commit documented

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