source: palm/trunk/SCRIPTS/mbuild @ 1937

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

last commit documented

  • Property svn:keywords set to Id Rev
File size: 47.0 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 1842 2016-04-07 19:24:16Z suehring $
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: 1842 $"
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       # IN CASE OF PARALLEL EXECUTION (COMPILER FOR PARALLEL EXECUTION),
685       # A SERIAL COMPILERNAME MUST BE DETERMINED ALSO
686    if [[ $(echo $remote_host_string | grep -c parallel) = 1 ]]
687    then
688       line=""
689       found=false
690       grep  "$remote_host_string" $config_file | grep "%compiler_name_ser"  >  $tmp_mbuild
691       while read line1
692       do
693
694          if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
695          then
696             line="$line1"
697          fi
698
699          if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
700          then
701             compiler_name_ser=`echo $line | cut -d" " -s -f2`
702             found=true
703          fi
704
705       done < $tmp_mbuild
706
707       if [[ $found = false ]]
708       then
709          printf "\n  +++ no serial compiler name found in configuration file"
710          printf "\n      for \"$remote_host_string\" "
711          locat=config_file; exit
712       fi
713    else
714       compiler_name_ser=$compiler_name
715    fi
716
717
718
719       # DETERMINE PREPROCESSOR-OPTIONS AND DIRECTIVES
720    line=""
721    found=false
722    grep  "$remote_host_string" $config_file | grep "%cpp_options"  >  $tmp_mbuild
723    while read line1
724    do
725
726       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
727       then
728          line="$line1"
729       fi
730
731       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
732       then
733             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
734          cpp_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
735          found=true
736       fi
737
738    done < $tmp_mbuild
739
740    if [[ $found = false ]]
741    then
742       printf "\n  +++ no preprocessor options found in configuration file"
743       printf "\n      for \"$remote_host_string\" "
744       locat=config_file; exit
745    fi
746
747
748       # ADD HOST-SPECIFIC PREPROCESSOR-DIRECTIVES
749    for  string  in  $remote_host_string
750    do
751       if [[ $(echo $remote_host | cut -c1-2) = lc  &&  $(echo $string | cut -c1-2) = lc ]]
752       then
753          cpp_options="$cpp_options -D__lc "
754       elif [[ $(echo $remote_host | cut -c1-3) = ibm  &&  $(echo $string | cut -c1-3) = ibm ]]
755       then
756          cpp_options="${cpp_options},-D__ibm"
757       elif [[ $(echo $remote_host | cut -c1-3) = nec  &&  $(echo $string | cut -c1-3) = nec ]]
758       then
759          cpp_options="${cpp_options} -D__nec"
760       else
761          if [[ $(echo $remote_host | cut -c1-3) = ibm ]]
762          then
763             cpp_options="${cpp_options},-D__$string"
764          else
765             cpp_options="$cpp_options -D__$string "
766          fi
767       fi
768    done
769
770
771
772       # GET netCDF OPTIONS
773    line=""
774    grep  "$remote_host_string" $config_file | grep "%netcdf_inc"  >  $tmp_mbuild
775    while read line1
776    do
777
778       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
779       then
780          line="$line1"
781       fi
782
783       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
784       then
785             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
786          netcdf_inc=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
787       fi
788
789    done < $tmp_mbuild
790
791    line=""
792    grep  "$remote_host_string" $config_file | grep "%netcdf_lib"  >  $tmp_mbuild
793    while read line1
794    do
795
796       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
797       then
798          line="$line1"
799       fi
800
801       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
802       then
803             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
804          netcdf_lib=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
805       fi
806
807    done < $tmp_mbuild
808
809
810
811       # GET FFTW OPTIONS
812    line=""
813    grep  "$remote_host_string" $config_file | grep "%fftw_inc"  >  $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          fftw_inc=`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    line=""
831    grep  "$remote_host_string" $config_file | grep "%fftw_lib"  >  $tmp_mbuild
832    while read line1
833    do
834
835       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
836       then
837          line="$line1"
838       fi
839
840       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
841       then
842             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
843          fftw_lib=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
844       fi
845
846    done < $tmp_mbuild
847
848
849
850       # GET MAKE OPTIONS
851    line=""
852    found=false
853    grep  "$remote_host_string" $config_file | grep "%mopts"  >  $tmp_mbuild
854    while read line1
855    do
856
857       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
858       then
859          line="$line1"
860       fi
861
862       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
863       then
864             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
865          make_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
866
867       fi
868
869    done < $tmp_mbuild
870
871
872
873       # GET COMPILER OPTIONS
874    line=""
875    found=false
876    grep  "$remote_host_string" $config_file | grep "%fopts"  >  $tmp_mbuild
877    while read line1
878    do
879
880       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
881       then
882          line="$line1"
883       fi
884
885       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
886       then
887             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
888          compiler_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
889          found=true
890
891             # ADD INCLUDE PATHS FOR netCDF AND FFTW
892          compiler_options="$compiler_options $netcdf_inc $fftw_inc"
893       fi
894
895    done < $tmp_mbuild
896
897    if [[ $found = false ]]
898    then
899       printf "\n  +++ no compiler options found in configuration file"
900       printf "\n      for \"$remote_host_string\" "
901       locat=config_file; exit
902    fi
903
904
905       # GET LOGIN INIT COMMANDS
906    line=""
907    grep  "$remote_host_string" $config_file | grep "%login_init_cmd"  >  $tmp_mbuild
908    while read line1
909    do
910
911       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
912       then
913          line="$line1"
914       fi
915
916       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
917       then
918             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
919          init_cmds=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
920          init_cmds="${init_cmds};"
921       fi
922    done < $tmp_mbuild
923
924
925       # GET MODULES TO BE LOADED
926    line=""
927    grep  "$remote_host_string" $config_file | grep "%modules"  >  $tmp_mbuild
928    while read line1
929    do
930
931       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
932       then
933          line="$line1"
934       fi
935
936       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
937       then
938             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
939          modules=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
940       fi
941
942    done < $tmp_mbuild
943
944
945       # GET LINKER OPTIONS
946    line=""
947    found=false
948    grep  "$remote_host_string" $config_file | grep "%lopts"  >  $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          loader_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
961          found=true
962
963             # ADD netCDF- AND FFTW-LIBRARY
964          loader_options="$loader_options $netcdf_lib $fftw_lib"
965       fi
966
967    done < $tmp_mbuild
968
969    if [[ $found = false ]]
970    then
971       printf "\n  +++ no loader options found in configuration file"
972       printf "\n      for \"$remote_host_string\" "
973       locat=config_file; exit
974    fi
975
976
977    printf "\n\n#------------------------------------------------------------------------# \n"
978    if [[ $remote_host = $local_host ]]
979    then
980       column2="$remote_host (= local host!)"
981    else
982       column2=$remote_host
983    fi
984    printf "| %-20s%-50s | \n" "remote_host:" "$column2"
985    printf "|                                                                        | \n"
986    printf "| %-20s%-50s | \n" "conditions:" "$condition1 $condition2"
987    column2=$(echo "$remote_md" | cut -c1-50 )
988    printf "| %-20s%-50s | \n" "make depository:" "$column2"
989    line=$(echo "$remote_md" | cut -c51-)
990    while [[ "$line" != "" ]]
991    do
992       column1=""
993       column2=$(echo "$line" | cut -c1-50 )
994       printf "| %-20s%-50s | \n" "$column1" "$column2"
995       line=$(echo "$line" | cut -c51-)
996    done
997    if [[ $compile_utility_programs = true ]]
998    then
999       column2=$(echo "$remote_ud" | cut -c1-50 )
1000       printf "| %-20s%-50s | \n" "utility directory:" "$column2"
1001       line=$(echo "$remote_ud" | cut -c51-)
1002       while [[ "$line" != "" ]]
1003       do
1004          column1=""
1005          column2=$(echo "$line" | cut -c1-50 )
1006          printf "| %-20s%-50s | \n" "$column1" "$column2"
1007          line=$(echo "$line" | cut -c51-)
1008       done
1009    fi
1010    printf "| %-20s%-50s | \n" "username:" "$remote_username"
1011    printf "| %-20s%-50s | \n" "address:" "$remote_address"
1012    printf "| %-20s%-50s | \n" "compiler:" "$compiler_name"
1013    if [[ $compile_utility_programs = true ]]
1014    then
1015       printf "| %-20s%-50s | \n" "serial compiler:" "$compiler_name_ser"
1016    fi
1017    if [[ "$make_options" != "" ]]
1018    then
1019       printf "| %-20s%-50s | \n" "make options:" "$make_options"
1020    fi
1021    column2=$(echo $cpp_options | cut -c1-50 )
1022    printf "| %-20s%-50s | \n" "cpp options:" "$column2"
1023    line=$(echo "$cpp_options" | cut -c51-)
1024    while [[ "$line" != "" ]]
1025    do
1026       column1=""
1027       column2=$(echo $line | cut -c1-50 )
1028       printf "| %-20s%-50s | \n" "$column1" "$column2"
1029       line=$(echo "$line" | cut -c51-)
1030    done
1031    column2=$(echo $compiler_options | cut -c1-50 )
1032    printf "| %-20s%-50s | \n" "compiler options:" "$column2"
1033    line=$(echo "$compiler_options" | cut -c51-)
1034    while [[ "$line" != "" ]]
1035    do
1036       column1=""
1037       column2=$(echo $line | cut -c1-50 )
1038       printf "| %-20s%-50s | \n" "$column1" "$column2"
1039       line=$(echo "$line" | cut -c51-)
1040    done
1041    column2=$(echo $loader_options | cut -c1-50 )
1042    printf "| %-20s%-50s | \n" "loader options:" "$column2"
1043    line=$(echo "$loader_options" | cut -c51-)
1044    while [[ "$line" != "" ]]
1045    do
1046       column1=""
1047       column2=$(echo $line | cut -c1-50 )
1048       printf "| %-20s%-50s | \n" "$column1" "$column2"
1049       line=$(echo "$line" | cut -c51-)
1050    done
1051    if [[ $init_cmds != "" ]]
1052    then
1053       column2=$(echo $init_cmds | cut -c1-50 )
1054       printf "| %-20s%-50s | \n" "login init command:" "$column2"
1055       line=$(echo "$init_cmds" | cut -c51-)
1056       while [[ "$line" != "" ]]
1057       do
1058          column1=""
1059          column2=$(echo $line | cut -c1-50 )
1060          printf "| %-20s%-50s | \n" "$column1" "$column2"
1061          line=$(echo "$line" | cut -c51-)
1062       done
1063    fi
1064    if [[ $modules != "" ]]
1065    then
1066       column2=$(echo $modules | cut -c1-50 )
1067       printf "| %-20s%-50s | \n" "modules to be load:" "$column2"
1068       line=$(echo "$modules" | cut -c51-)
1069       while [[ "$line" != "" ]]
1070       do
1071          column1=""
1072          column2=$(echo $line | cut -c1-50 )
1073          printf "| %-20s%-50s | \n" "$column1" "$column2"
1074          line=$(echo "$line" | cut -c51-)
1075       done
1076    fi
1077    printf "#------------------------------------------------------------------------# \n"
1078
1079    if [[ $silent = false ]]
1080    then
1081       answer=dummy
1082       printf "\n\n"
1083       while [[ "$answer" != y  &&  "$answer" != Y  && "$answer" != c  &&  "$answer" != C  && "$answer" != s  &&  "$answer" != S  &&  "$answer" != a  &&  "$answer" != A ]]
1084       do
1085          printf " >>> continue (y(es)/c(ontinue)/a(bort)/s(skip)) ?  "
1086          read  answer
1087       done
1088       if [[ $answer = a  ||  $answer = A ]]
1089       then
1090          locat=user_abort; exit
1091       fi
1092       if [[ $answer = c  ||  $answer = C ]]
1093       then
1094          silent=true
1095       fi
1096       if [[ $answer = s  ||  $answer = S ]]
1097       then
1098          continue
1099       fi
1100    fi
1101
1102
1103       # MAKE ON REMOTE HOST
1104    if [[ $remote_host != $local_host ]]
1105    then
1106       if [[ $compile_utility_programs = false ]]
1107       then
1108
1109             # COPY CURRENT SOURCE CODE TO SOURCE-CODE DIRECTORY ON THE REMOTE HOST
1110             # CREATE THIS DIRECTORY, IF IT DOES NOT EXIST
1111          echo "  *** copying \"${mainprog}_sources.tar\" to \"${remote_address}:${remote_md}/\" "
1112          if [[ $remote_host != lctit ]]
1113          then
1114             ssh  ${remote_username}@${remote_address} "[[ ! -d ${remote_md} ]]  &&  (echo \"  *** ${remote_md} will be created\"; mkdir -p  ${remote_md})"
1115          else
1116                # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS
1117             echo "[[ ! -d ${remote_md} ]]  &&  (echo \"  *** ${remote_md} will be created\"; mkdir -p  ${remote_md})"  |  ssh ${remote_username}@${remote_address}  2>&1
1118          fi
1119
1120          scp  ${local_source_path}/${mainprog}_sources.tar  ${remote_username}@${remote_address}:${remote_md}/${mainprog}_sources.tar
1121
1122
1123
1124             # UNTAR PREVIOUS UPDATE ON REMOTE HOST, IF EXISTING
1125          echo "  *** untar previous update on remote host, if existing"
1126          if [[ $remote_host != lctit ]]
1127          then
1128             ssh  ${remote_username}@${remote_address}  "cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]]  &&  tar -xf  ${mainprog}_current_version.tar"
1129          else
1130                # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS
1131             echo "cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]]  &&  tar -xf  ${mainprog}_current_version.tar"  |  ssh  ${remote_username}@${remote_address}  2>&1
1132          fi
1133
1134
1135             # UNTAR CURRENT SOURCES ON REMOTE HOST
1136          echo "  *** untar current sources on remote host"
1137          if [[ $remote_host != lctit ]]
1138          then
1139             ssh  ${remote_username}@${remote_address}  "cd ${remote_md}; tar -xf  ${mainprog}_sources.tar"
1140          else
1141                # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS
1142             echo  "cd ${remote_md}; tar -xf  ${mainprog}_sources.tar"  |  ssh  ${remote_username}@${remote_address}  2>&1
1143          fi
1144
1145
1146             # EXECUTE MAKE WITH THOSE OPTIONS DETERMINED ABOVE
1147             # COMMANDS WILL BE COMMUNICATED TO SSH VIA PIPE, SINCE THIS WAY THE SYSTEM- AND
1148             # USER-PROFILES OF THE SHELL ARE COMPLETELY EXECUTED (OTHERWISE, MAKE
1149             # WILL E.G. MISS THE COMPILER-PATHS)
1150          echo "  *** execute \"make\" on remote host"
1151
1152
1153             # GENERATE MAKE CALL WITH MAKE OPTIONS
1154          if [[ $remote_host = nech ]]
1155          then
1156             make_call_string="sxmake  $make_options  PROG=$mainprog  F90=$compiler_name  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$loader_options\" "
1157          else
1158             make_call_string="make  $make_options  PROG=$mainprog  F90=$compiler_name  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$loader_options\" "
1159          fi
1160
1161             # GENERATE COMMAND TO LOAD MODULES, IF MODULES ARE GIVEN
1162          if [[ "$modules" != "" ]]
1163          then
1164             if [[ $remote_host = lctit ]]
1165             then
1166                module_calls=". $modules"
1167             else
1168                module_calls="module load ${modules};"
1169             fi
1170          else
1171             module_calls=""
1172          fi
1173
1174          if [[ $remote_host = ibmkisti  ||  $remote_host = ibms ]]
1175          then
1176
1177             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
1178
1179          elif [[ $remote_host = ibmh ]]
1180          then
1181
1182             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
1183
1184          elif [[ $remote_host = lctit ]]
1185          then
1186
1187             echo  " "  >  ${remote_host}_last_make_protokoll
1188             while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]]
1189             do
1190                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
1191             done
1192
1193          elif [[ $remote_host = lcxe6 ]]
1194          then
1195
1196             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
1197
1198          else
1199
1200             echo "$init_cmds $module_calls cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll
1201
1202          fi
1203
1204          if [[ $(grep -c MAKE_ERROR ${remote_host}_last_make_protokoll) != 0 ]]
1205          then
1206             printf "\a\n  +++ error(s) occurred during compiling or linking on host \"$remote_host\" "
1207             if [[ $silent = false ]]
1208             then
1209                answer=dummy
1210                printf "\n"
1211                while [[ "$answer" != c  &&  "$answer" != k ]]
1212                do
1213                   printf "  >>> continue / list errors / kill mbuild (c/l/k) ? "
1214                   read  answer
1215                   if [[ "$answer" = l ]]
1216                   then
1217                      more ${remote_host}_last_make_protokoll
1218                   fi
1219                done
1220                if [[ $answer = k ]]
1221                then
1222                   locat=user_abort; exit
1223                fi
1224             fi
1225          fi
1226
1227
1228
1229             # TAR UPDATED VERSION ON THE REMOTE HOST
1230          printf "\n  *** tar update on remote host ..."
1231          if [[ $remote_host != lctit ]]
1232          then
1233             ssh  ${remote_username}@${remote_address}  "cd ${remote_md}; chmod u+w *; tar -cf  ${mainprog}_current_version.tar  ${mainprog}  *.f90 *.o *.mod"
1234          else
1235                # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS
1236             echo  "cd ${remote_md}; chmod u+w *; tar -cf  ${mainprog}_current_version.tar  ${mainprog}  *.f90 *.o *.mod"  |  ssh  ${remote_username}@${remote_address}  2>&1
1237          fi
1238
1239
1240
1241          # DO THE SAME THINGS FOR THE UTILITY-ROUTINES:
1242          # COPY CURRENT SOURCE CODE TO SOURCE-CODE DIRECTORY ON THE REMOTE HOST
1243          # CREATE THIS DIRECTORY, IF IT DOES NOT EXIST
1244       elif [[ $compile_utility_programs = true ]]
1245       then
1246
1247          printf "\n\n"
1248          echo "  *** copying scripts and utility programs to \"${remote_address}:${remote_ud}/\" "
1249          cd  ${local_source_path}/../SCRIPTS
1250
1251          if [[ $remote_host != lctit ]]
1252          then
1253             ssh  ${remote_username}@${remote_address} "[[ ! -d ${remote_ud} ]]  &&  (echo \"  *** ${remote_ud} will be created\"; mkdir -p  ${remote_ud}); [[ ! -d ${remote_ud}/../SCRIPTS ]]  &&  (echo \"  *** ${remote_ud}/../SCRIPTS will be created\"; mkdir -p ${remote_ud}/../SCRIPTS)"
1254          else
1255                # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS
1256             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
1257          fi
1258
1259             # COPY SHELL-SCRIPTS
1260          scp  batch_scp mbuild mrun process_dvr_output .dvrserver.config subjob ${remote_username}@${remote_address}:${remote_ud}/../SCRIPTS  >  /dev/null
1261
1262          cd  -  > /dev/null
1263          cd  ${local_source_path}/../UTIL
1264
1265
1266             # COPY UTILITY-ROUTINES
1267          scp  Makefile  *.f90  ${remote_username}@${remote_address}:${remote_ud}  >  /dev/null
1268
1269
1270
1271             # EXECUTE MAKE WITH THOSE OPTIONS DETERMINED ABOVE
1272             # COMMANDS WILL BE COMMUNICATED TO SSH VIA PIPE, SINCE THIS WAY THE SYSTEM- AND
1273             # USER-PROFILES OF THE SHELL ARE COMPLETELY EXECUTED (OTHERWISE, MAKE
1274             # WILL E.G. MISS THE COMPILER-PATHS)
1275          echo "  *** execute \"make\" on remote host"
1276
1277          if [[ $remote_host = nech ]]
1278          then
1279             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\" "
1280          else
1281             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\" "
1282          fi
1283
1284             # GENERATE COMMAND TO LOAD MODULES, IF MODULES ARE GIVEN
1285          if [[ "$modules" != "" ]]
1286          then
1287             if [[ $remote_host = lctit ]]
1288             then
1289                module_calls=". $modules"
1290             else
1291                module_calls="module load ${modules};"
1292             fi
1293          else
1294             module_calls=""
1295          fi
1296
1297
1298          if [[ $remote_host = ibms ]]
1299          then
1300
1301             ssh  ${remote_username}@${remote_address}  "$init_cmds $module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR"
1302
1303          elif [[ $remote_host = ibmh ]]
1304          then
1305
1306             echo "$init_cmds $module_calls export OBJECT_MODE=64; cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_address}
1307
1308          elif [[ $remote_host = lctit ]]
1309          then
1310
1311             echo  " "  >  ${remote_host}_last_make_protokoll
1312             while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]]
1313             do
1314                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
1315             done
1316
1317          elif [[ $remote_host = lcxe6 ]]
1318          then
1319
1320             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
1321
1322          else
1323
1324             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
1325
1326          fi
1327
1328       fi    # END OF COMPILING UTILITY-ROUTINES
1329
1330       rm -rf  ${remote_host}_last_make_protokoll
1331
1332       # MAKE ON LOCAL HOST
1333    else
1334
1335          # INIT WORKAROUND FOR lcxe6
1336       if [[ $remote_host = lcxe6  ||  $remote_host = lccrayb  ||  $remote_host = lccrayf ||  $remote_host = lccrayh ]]
1337       then
1338
1339          eval $init_cmds  >  /dev/null  2>&1
1340
1341       fi
1342
1343       # FIRST LOAD MODULES, IF GIVEN
1344       if [[ "$modules" != "" ]]
1345       then
1346          if [[ $remote_host = lctit ]]
1347          then
1348             . $modules
1349          elif [[ $remote_host = lcflow ]]
1350          then
1351             eval `$MODULESHOME/bin/modulecmd ksh load ${modules}`
1352          else
1353             eval init_cmds=$init_cmds
1354             module load ${modules}
1355          fi
1356       fi
1357
1358
1359       if [[ $compile_utility_programs = false ]]
1360       then
1361
1362             # CREATE MAKE-DEPOSITORY, IF IT DOES NOT EXIST
1363          eval remote_md=$remote_md
1364          if [[ ! -d $remote_md ]]
1365          then
1366             if  mkdir $remote_md
1367             then
1368                printf "\n\n  *** directory for make depository:"
1369                printf "\n           $remote_md"
1370                printf "\n      was created\n"
1371             else
1372                printf "\n  +++ directory for make depository:"
1373                printf "\n           $remote_md"
1374                printf "\n      cannot be created"
1375                locat=local_depository_path; exit
1376             fi
1377          fi
1378
1379             # COPY SOURCE-CODE FROM REPOSITORY TO MAKE-DEPOSITORY
1380          echo " "
1381          echo "  *** updating sources in $remote_md"
1382          cd  $remote_md
1383          cp  $local_source_path/${mainprog}_sources.tar  .
1384          tar xf  ${mainprog}_sources.tar
1385
1386             # CALL MAKE ON LOCAL HOST USING THE  OPTIONS DETERMINED FURTHER ABOVE
1387          echo " "
1388          echo "  *** execute \"make\" on local host"
1389
1390          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
1391
1392          if [[ $? != 0 ]]
1393          then
1394             printf "\a\n  +++ error(s) occurred during compiling or linking on host \"$remote_host\" "
1395             if [[ $silent = false ]]
1396             then
1397                answer=dummy
1398                printf "\n"
1399                while [[ "$answer" != c  &&  "$answer" != k ]]
1400                do
1401                   printf "  >>> continue / list errors / kill mbuild (c/l/k) ? "
1402                   read  answer
1403                   if [[ "$answer" = l ]]
1404                   then
1405                      more ${remote_host}_last_make_protokoll
1406                   fi
1407                done
1408                if [[ $answer = k ]]
1409                then
1410                   locat=user_abort; exit
1411                fi
1412             fi
1413          fi
1414
1415
1416             # TAR NEW VERSION ON LOCAL HOST
1417          printf "\n  *** tar update on local host ..."
1418          tar -cf  ${mainprog}_current_version.tar  *.$suf *.o *.mod
1419
1420
1421          # COMPILE THE UTILITY PROGRAMS
1422       elif [[ $compile_utility_programs = true ]]
1423       then
1424          printf "\n\n"
1425          echo "  *** compiling the utility programs ..."
1426          cd ${local_source_path}/../UTIL
1427
1428             # TOUCH FILES IN ORDER TO FORCE COMPILATION FOR EVERY BLOCK
1429          touch  *.f90
1430          eval init_cmds=$init_cmds
1431          make  $make_options  BLOCK=$block  F90=$compiler_name  F90_SER=$compiler_name_ser  COPT="$cpp_options"  F90FLAGS="$compiler_options"  LDFLAGS="$loader_options"
1432
1433             # CHECK IF QMAKE IS AVAILABLE AND COMPILE MRUNGUI
1434          if [[ $util_compiled_localhost == false ]]
1435          then
1436             printf "\n\n"
1437             echo "  *** compiling the mrun GUI"
1438             if which qmake >/dev/null; then
1439                cd mrungui
1440                touch *
1441                qmake
1442                make
1443                make clean
1444                rm Makefile
1445                cd ..
1446             else
1447                echo "  +++ no qmake found. The (optional) GUI will not be compiled."
1448             fi
1449          else
1450             cd $check_depository_path
1451             printf "\n\n"
1452             echo "  *** skipped compilation of mrun GUI."           
1453          fi
1454
1455       fi
1456    fi
1457 done
1458
1459
1460 if [[ $host_found = false ]]
1461 then
1462    if [[ $host = all ]]
1463    then
1464       printf "\n  +++ no hosts found in configuration file"
1465    else
1466       printf "\n  +++ host \"$host\" not found in configuration file"
1467    fi
1468    locat=config_file; exit
1469 fi
1470
1471 if [[ "$block_conditions" != none  &&  $block_conditions_found = false ]]
1472 then
1473    printf "\n  +++ block conditions \"$block_conditions\" not found for host \"$host\""
1474 fi
1475
1476
1477    # FINAL WORK
1478 rm -f  hosts_found_in_config_file
Note: See TracBrowser for help on using the repository browser.