source: palm/trunk/SCRIPTS/mbuild @ 1279

Last change on this file since 1279 was 1275, checked in by heinze, 11 years ago

last commit documented

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