source: palm/trunk/SCRIPTS/mbuild @ 2359

Last change on this file since 2359 was 2316, checked in by maronga, 7 years ago

new mrungui version based on python

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