source: palm/trunk/SCRIPTS/mbuild @ 1649

Last change on this file since 1649 was 1649, checked in by knoop, 9 years ago

Latex lecture update for PALM seminar in Hong Kong

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