source: palm/trunk/SCRIPTS/mbuild @ 1817

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

further modularization of land surface model

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