source: palm/trunk/SCRIPTS/mbuild @ 1229

Last change on this file since 1229 was 1229, checked in by raasch, 11 years ago

further adjustments for lccrayb

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