source: palm/trunk/SCRIPTS/mbuild @ 1256

Last change on this file since 1256 was 1256, checked in by raasch, 10 years ago

last commit documented

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