source: palm/trunk/SCRIPTS/mbuild @ 1616

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

last commit documented

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