source: palm/trunk/SCRIPTS/mbuild @ 1653

Last change on this file since 1653 was 1653, checked in by raasch, 9 years ago

last commit documented

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