source: palm/trunk/SCRIPTS/mbuild @ 1389

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

last commit documented

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