source: palm/trunk/SCRIPTS/mbuild @ 1944

Last change on this file since 1944 was 1944, checked in by raasch, 8 years ago

adjustments for using HLRN ssh-keys

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