source: palm/trunk/SCRIPTS/mbuild @ 1823

Last change on this file since 1823 was 1818, checked in by maronga, 8 years ago

last commit documented / copyright update

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