source: palm/trunk/SCRIPTS/mbuild @ 1836

Last change on this file since 1836 was 1827, checked in by maronga, 9 years ago

last commit documented

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