source: palm/trunk/SCRIPTS/mbuild @ 1241

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

last commit documented

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