source: palm/trunk/SCRIPTS/mbuild @ 1217

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

last commit documented

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