source: palm/trunk/SCRIPTS/mbuild @ 1589

Last change on this file since 1589 was 1548, checked in by witha, 10 years ago

last commit documented

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