source: palm/trunk/SCRIPTS/mbuild @ 1620

Last change on this file since 1620 was 1620, checked in by heinze, 9 years ago

adjustments for Mistral at DKRZ Hamburg (lcbullhh)

  • Property svn:keywords set to Id Rev
File size: 48.6 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# adjustments for Mistral at DKRZ Hamburg (lcbullhh)
25#
26# Former revisions:
27# -----------------
28# $Id: mbuild 1620 2015-07-17 11:37:41Z heinze $
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: 1620 $"
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        (lcbullhh)       remote_address=136.172.50.13;;
519        (lccrayb)        remote_address=130.73.233.1;;
520        (lccrayh)        remote_address=130.75.4.1;;
521        (lcflow)         remote_address="flow02.hpc.uni-oldenburg.de";;
522        (lckordi)        remote_adress=210.219.61.8;;
523        (lcmuk)          remote_address=130.75.105.2;;
524        (lcrte)          remote_address=133.5.185.60;;
525        (lcsb)           remote_address=147.46.30.151;;
526        (lck)            remote_address=165.132.26.61;;
527        (lckiaps)        remote_address=118.128.66.223;;
528        (lckyut)         remote_address=133.5.4.37;;
529        (lctit)          remote_address=10.1.6.170;;
530        (lcxe6)          remote_address=129.177.20.113;;
531        (lcxt5m)         remote_address=193.166.211.144;;
532        (ibmh)           remote_address=136.172.40.15;;
533        (ibmkisti)       remote_address=150.183.146.24;;
534        (ibmku)          remote_address=133.5.4.129;;
535        (ibms)           remote_address=150.183.5.101;;
536        (nech)           remote_address=136.172.44.192;;
537        (neck)           remote_address=133.5.178.11;;
538        (ground.yonsei.ac.kr) remote_address=134.75.155.33;;
539        (*)              if [[ $local_host != $remote_host ]]
540                         then
541                            printf "\n  +++ remote host \"$remote_host\" unknown";
542                            printf "\n      please inform PALM group support!"
543                            locat=remote_host; exit
544                         fi;;
545    esac
546
547
548       # DETERMINE REMOTE-USERNAME
549    line=""
550    found=false
551    grep  "$remote_host_string" $config_file | grep "%remote_username"  >  $tmp_mbuild
552    while read line1
553    do
554
555       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
556       then
557          line="$line1"
558       fi
559
560       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
561       then
562          remote_username=`echo $line | cut -d" " -s -f2`
563          found=true
564       fi
565
566    done < $tmp_mbuild
567
568    if [[ $found = false ]]
569    then
570       printf "\n  +++ no remote username found in configuration file"
571       printf "\n      for \"$remote_host_string\" "
572       locat=config_file; exit
573    fi
574
575
576       # DETERMINE REMOTE-SOURCE-CODE-PATH
577    line=""
578    remote_source_path=""
579    grep  "$remote_host_string" $config_file | grep "%source_path"  >  $tmp_mbuild
580    while read line1
581    do
582
583       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
584       then
585          line="$line1"
586       fi
587
588       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
589       then
590          remote_source_path=`echo $line | cut -d" " -s -f2`
591       fi
592
593    done < $tmp_mbuild
594
595    if [[ "$remote_source_path" = "" ]]
596    then
597       if [[ "$global_source_path" != "" ]]
598       then
599          remote_source_path=$global_source_path
600       else
601          printf "\n  +++ no source path found in configuration file"
602          printf "\n      for \"$remote_host_string\" "
603          locat=config_file; exit
604       fi
605    fi
606
607    remote_ud=${remote_source_path}/../UTIL
608    remote_ud=$(eval echo $remote_ud)
609
610
611       # DETERMINE REMOTE-PATH FOR MAKE-DEPOSITORY
612    remote_md=""
613    line=""
614    grep  "$remote_host_string" $config_file | grep "%depository_path"  >  $tmp_mbuild
615    while read line1
616    do
617
618       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
619       then
620          line="$line1"
621       fi
622
623       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
624       then
625          remote_md=`echo $line | cut -d" " -s -f2`
626       fi
627
628    done < $tmp_mbuild
629
630    if [[ "$remote_md" = "" ]]
631    then
632       if [[ "$global_depository_path" != "" ]]
633       then
634          remote_md=$global_depository_path
635       else
636          printf "\n  +++ no depository path found in configuration file"
637          printf "\n      for \"$remote_host_string\" "
638          printf "\n      please set \"\%depository_path\" in configuration file"
639          locat=config_file; exit
640       fi
641    fi
642
643    remote_md=$(eval echo $remote_md)
644    block=""
645    [[ "$condition1" != "" ]]  &&  block=_$condition1
646    [[ "$condition2" != "" ]]  &&  block=${block}_$condition2
647    remote_md=${remote_md}$block
648
649
650       # DETERMINE COMPILERNAME
651    line=""
652    found=false
653    grep  "$remote_host_string" $config_file | grep "%compiler_name "  >  $tmp_mbuild
654    while read line1
655    do
656
657       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
658       then
659          line="$line1"
660       fi
661
662       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
663       then
664          compiler_name=`echo $line | cut -d" " -s -f2`
665          found=true
666       fi
667
668    done < $tmp_mbuild
669
670    if [[ $found = false ]]
671    then
672       printf "\n  +++ no compiler name found in configuration file"
673       printf "\n      for \"$remote_host_string\" "
674       locat=config_file; exit
675    fi
676
677
678       # IN CASE OF PARALLEL EXECUTION (COMPILER FOR PARALLEL EXECUTION),
679       # A SERIAL COMPILERNAME MUST BE DETERMINED ALSO
680    if [[ $(echo $remote_host_string | grep -c parallel) = 1 ]]
681    then
682       line=""
683       found=false
684       grep  "$remote_host_string" $config_file | grep "%compiler_name_ser"  >  $tmp_mbuild
685       while read line1
686       do
687
688          if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
689          then
690             line="$line1"
691          fi
692
693          if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
694          then
695             compiler_name_ser=`echo $line | cut -d" " -s -f2`
696             found=true
697          fi
698
699       done < $tmp_mbuild
700
701       if [[ $found = false ]]
702       then
703          printf "\n  +++ no serial compiler name found in configuration file"
704          printf "\n      for \"$remote_host_string\" "
705          locat=config_file; exit
706       fi
707    else
708       compiler_name_ser=$compiler_name
709    fi
710
711
712
713       # DETERMINE PREPROCESSOR-OPTIONS AND DIRECTIVES
714    line=""
715    found=false
716    grep  "$remote_host_string" $config_file | grep "%cpp_options"  >  $tmp_mbuild
717    while read line1
718    do
719
720       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
721       then
722          line="$line1"
723       fi
724
725       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
726       then
727             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
728          cpp_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
729          found=true
730       fi
731
732    done < $tmp_mbuild
733
734    if [[ $found = false ]]
735    then
736       printf "\n  +++ no preprocessor options found in configuration file"
737       printf "\n      for \"$remote_host_string\" "
738       locat=config_file; exit
739    fi
740
741
742       # ADD HOST-SPECIFIC PREPROCESSOR-DIRECTIVES
743    for  string  in  $remote_host_string
744    do
745       if [[ $(echo $remote_host | cut -c1-2) = lc  &&  $(echo $string | cut -c1-2) = lc ]]
746       then
747          cpp_options="$cpp_options -D__lc "
748       elif [[ $(echo $remote_host | cut -c1-3) = ibm  &&  $(echo $string | cut -c1-3) = ibm ]]
749       then
750          cpp_options="${cpp_options},-D__ibm"
751       elif [[ $(echo $remote_host | cut -c1-3) = nec  &&  $(echo $string | cut -c1-3) = nec ]]
752       then
753          cpp_options="${cpp_options} -D__nec"
754       else
755          if [[ $(echo $remote_host | cut -c1-3) = ibm ]]
756          then
757             cpp_options="${cpp_options},-D__$string"
758          else
759             cpp_options="$cpp_options -D__$string "
760          fi
761       fi
762    done
763
764
765
766       # GET netCDF OPTIONS
767    line=""
768    grep  "$remote_host_string" $config_file | grep "%netcdf_inc"  >  $tmp_mbuild
769    while read line1
770    do
771
772       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
773       then
774          line="$line1"
775       fi
776
777       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
778       then
779             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
780          netcdf_inc=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
781       fi
782
783    done < $tmp_mbuild
784
785    line=""
786    grep  "$remote_host_string" $config_file | grep "%netcdf_lib"  >  $tmp_mbuild
787    while read line1
788    do
789
790       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
791       then
792          line="$line1"
793       fi
794
795       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
796       then
797             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
798          netcdf_lib=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
799       fi
800
801    done < $tmp_mbuild
802
803
804
805       # GET FFTW OPTIONS
806    line=""
807    grep  "$remote_host_string" $config_file | grep "%fftw_inc"  >  $tmp_mbuild
808    while read line1
809    do
810
811       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
812       then
813          line="$line1"
814       fi
815
816       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
817       then
818             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
819          fftw_inc=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
820       fi
821
822    done < $tmp_mbuild
823
824    line=""
825    grep  "$remote_host_string" $config_file | grep "%fftw_lib"  >  $tmp_mbuild
826    while read line1
827    do
828
829       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
830       then
831          line="$line1"
832       fi
833
834       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
835       then
836             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
837          fftw_lib=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
838       fi
839
840    done < $tmp_mbuild
841
842
843
844       # GET MAKE OPTIONS
845    line=""
846    found=false
847    grep  "$remote_host_string" $config_file | grep "%mopts"  >  $tmp_mbuild
848    while read line1
849    do
850
851       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
852       then
853          line="$line1"
854       fi
855
856       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
857       then
858             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
859          make_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
860
861       fi
862
863    done < $tmp_mbuild
864
865
866
867       # GET COMPILER OPTIONS
868    line=""
869    found=false
870    grep  "$remote_host_string" $config_file | grep "%fopts"  >  $tmp_mbuild
871    while read line1
872    do
873
874       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
875       then
876          line="$line1"
877       fi
878
879       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
880       then
881             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
882          compiler_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
883          found=true
884
885             # ADD INCLUDE PATHS FOR netCDF AND FFTW
886          compiler_options="$compiler_options $netcdf_inc $fftw_inc"
887       fi
888
889    done < $tmp_mbuild
890
891    if [[ $found = false ]]
892    then
893       printf "\n  +++ no compiler options found in configuration file"
894       printf "\n      for \"$remote_host_string\" "
895       locat=config_file; exit
896    fi
897
898
899       # GET LOGIN INIT COMMANDS
900    line=""
901    grep  "$remote_host_string" $config_file | grep "%login_init_cmd"  >  $tmp_mbuild
902    while read line1
903    do
904
905       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
906       then
907          line="$line1"
908       fi
909
910       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
911       then
912             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
913          init_cmds=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
914          init_cmds="${init_cmds};"
915       fi
916    done < $tmp_mbuild
917
918
919       # GET MODULES TO BE LOADED
920    line=""
921    grep  "$remote_host_string" $config_file | grep "%modules"  >  $tmp_mbuild
922    while read line1
923    do
924
925       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
926       then
927          line="$line1"
928       fi
929
930       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
931       then
932             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
933          modules=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
934       fi
935
936    done < $tmp_mbuild
937
938
939       # GET LINKER OPTIONS
940    line=""
941    found=false
942    grep  "$remote_host_string" $config_file | grep "%lopts"  >  $tmp_mbuild
943    while read line1
944    do
945
946       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
947       then
948          line="$line1"
949       fi
950
951       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
952       then
953             # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
954          loader_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
955          found=true
956
957             # ADD netCDF- AND FFTW-LIBRARY
958          loader_options="$loader_options $netcdf_lib $fftw_lib"
959       fi
960
961    done < $tmp_mbuild
962
963    if [[ $found = false ]]
964    then
965       printf "\n  +++ no loader options found in configuration file"
966       printf "\n      for \"$remote_host_string\" "
967       locat=config_file; exit
968    fi
969
970
971    printf "\n\n#------------------------------------------------------------------------# \n"
972    if [[ $remote_host = $local_host ]]
973    then
974       column2="$remote_host (= local host!)"
975    else
976       column2=$remote_host
977    fi
978    printf "| %-20s%-50s | \n" "remote_host:" "$column2"
979    printf "|                                                                        | \n"
980    printf "| %-20s%-50s | \n" "conditions:" "$condition1 $condition2"
981    column2=$(echo "$remote_md" | cut -c1-50 )
982    printf "| %-20s%-50s | \n" "make depository:" "$column2"
983    line=$(echo "$remote_md" | cut -c51-)
984    while [[ "$line" != "" ]]
985    do
986       column1=""
987       column2=$(echo "$line" | cut -c1-50 )
988       printf "| %-20s%-50s | \n" "$column1" "$column2"
989       line=$(echo "$line" | cut -c51-)
990    done
991    if [[ $compile_utility_programs = true ]]
992    then
993       column2=$(echo "$remote_ud" | cut -c1-50 )
994       printf "| $column1$column2 | \n"
995       printf "| %-20s%-50s | \n" "utility directory:" "$column2"
996       line=$(echo "$remote_ud" | cut -c51-)
997       while [[ "$line" != "" ]]
998       do
999          column1=""
1000          column2=$(echo "$line" | cut -c1-50 )
1001          printf "| %-20s%-50s | \n" "$column1" "$column2"
1002          line=$(echo "$line" | cut -c51-)
1003       done
1004    fi
1005    printf "| %-20s%-50s | \n" "username:" "$remote_username"
1006    printf "| %-20s%-50s | \n" "address:" "$remote_address"
1007    printf "| %-20s%-50s | \n" "compiler:" "$compiler_name"
1008    if [[ $compile_utility_programs = true ]]
1009    then
1010       printf "| %-20s%-50s | \n" "serial compiler:" "$compiler_name_ser"
1011    fi
1012    if [[ "$make_options" != "" ]]
1013    then
1014       printf "| %-20s%-50s | \n" "make options:" "$make_options"
1015    fi
1016    column2=$(echo $cpp_options | cut -c1-50 )
1017    printf "| %-20s%-50s | \n" "cpp options:" "$column2"
1018    line=$(echo "$cpp_options" | cut -c51-)
1019    while [[ "$line" != "" ]]
1020    do
1021       column1=""
1022       column2=$(echo $line | cut -c1-50 )
1023       printf "| %-20s%-50s | \n" "$column1" "$column2"
1024       line=$(echo "$line" | cut -c51-)
1025    done
1026    column2=$(echo $compiler_options | cut -c1-50 )
1027    printf "| %-20s%-50s | \n" "compiler options:" "$column2"
1028    line=$(echo "$compiler_options" | cut -c51-)
1029    while [[ "$line" != "" ]]
1030    do
1031       column1=""
1032       column2=$(echo $line | cut -c1-50 )
1033       printf "| %-20s%-50s | \n" "$column1" "$column2"
1034       line=$(echo "$line" | cut -c51-)
1035    done
1036    column2=$(echo $loader_options | cut -c1-50 )
1037    printf "| %-20s%-50s | \n" "loader options:" "$column2"
1038    line=$(echo "$loader_options" | cut -c51-)
1039    while [[ "$line" != "" ]]
1040    do
1041       column1=""
1042       column2=$(echo $line | cut -c1-50 )
1043       printf "| %-20s%-50s | \n" "$column1" "$column2"
1044       line=$(echo "$line" | cut -c51-)
1045    done
1046    if [[ $modules != "" ]]
1047    then
1048       column2=$(echo $modules | cut -c1-50 )
1049       printf "| %-20s%-50s | \n" "modules to be load:" "$column2"
1050       line=$(echo "$modules" | cut -c51-)
1051       while [[ "$line" != "" ]]
1052       do
1053          column1=""
1054          column2=$(echo $line | cut -c1-50 )
1055          printf "| %-20s%-50s | \n" "$column1" "$column2"
1056          line=$(echo "$line" | cut -c51-)
1057       done
1058    fi
1059    printf "#------------------------------------------------------------------------# \n"
1060
1061    if [[ $silent = false ]]
1062    then
1063       answer=dummy
1064       printf "\n\n"
1065       while [[ "$answer" != y  &&  "$answer" != Y  && "$answer" != c  &&  "$answer" != C  && "$answer" != s  &&  "$answer" != S  &&  "$answer" != a  &&  "$answer" != A ]]
1066       do
1067          printf " >>> continue (y(es)/c(ontinue)/a(bort)/s(skip)) ?  "
1068          read  answer
1069       done
1070       if [[ $answer = a  ||  $answer = A ]]
1071       then
1072          locat=user_abort; exit
1073       fi
1074       if [[ $answer = c  ||  $answer = C ]]
1075       then
1076          silent=true
1077       fi
1078       if [[ $answer = s  ||  $answer = S ]]
1079       then
1080          continue
1081       fi
1082    fi
1083
1084
1085       # MAKE ON REMOTE HOST
1086    if [[ $remote_host != $local_host ]]
1087    then
1088       if [[ $compile_utility_programs = false ]]
1089       then
1090
1091             # COPY CURRENT SOURCE CODE TO SOURCE-CODE DIRECTORY ON THE REMOTE HOST
1092             # CREATE THIS DIRECTORY, IF IT DOES NOT EXIST
1093          echo "  *** copying \"${mainprog}_sources.tar\" to \"${remote_address}:${remote_md}/\" "
1094          if [[ $remote_host != lctit ]]
1095          then
1096             ssh  ${remote_username}@${remote_address} "[[ ! -d ${remote_md} ]]  &&  (echo \"  *** ${remote_md} will be created\"; mkdir -p  ${remote_md})"
1097          else
1098                # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS
1099             echo "[[ ! -d ${remote_md} ]]  &&  (echo \"  *** ${remote_md} will be created\"; mkdir -p  ${remote_md})"  |  ssh ${remote_username}@${remote_address}  2>&1
1100          fi
1101
1102          scp  ${local_source_path}/${mainprog}_sources.tar  ${remote_username}@${remote_address}:${remote_md}/${mainprog}_sources.tar
1103
1104
1105
1106             # UNTAR PREVIOUS UPDATE ON REMOTE HOST, IF EXISTING
1107          echo "  *** untar previous update on remote host, if existing"
1108          if [[ $remote_host != lctit ]]
1109          then
1110             ssh  ${remote_username}@${remote_address}  "cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]]  &&  tar -xf  ${mainprog}_current_version.tar"
1111          else
1112                # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS
1113             echo "cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]]  &&  tar -xf  ${mainprog}_current_version.tar"  |  ssh  ${remote_username}@${remote_address}  2>&1
1114          fi
1115
1116
1117             # UNTAR CURRENT SOURCES ON REMOTE HOST
1118          echo "  *** untar current sources on remote host"
1119          if [[ $remote_host != lctit ]]
1120          then
1121             ssh  ${remote_username}@${remote_address}  "cd ${remote_md}; tar -xf  ${mainprog}_sources.tar"
1122          else
1123                # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS
1124             echo  "cd ${remote_md}; tar -xf  ${mainprog}_sources.tar"  |  ssh  ${remote_username}@${remote_address}  2>&1
1125          fi
1126
1127
1128             # EXECUTE MAKE WITH THOSE OPTIONS DETERMINED ABOVE
1129             # COMMANDS WILL BE COMMUNICATED TO SSH VIA PIPE, SINCE THIS WAY THE SYSTEM- AND
1130             # USER-PROFILES OF THE SHELL ARE COMPLETELY EXECUTED (OTHERWISE, MAKE
1131             # WILL E.G. MISS THE COMPILER-PATHS)
1132          echo "  *** execute \"make\" on remote host"
1133
1134
1135             # GENERATE MAKE CALL WITH MAKE OPTIONS
1136          if [[ $remote_host = nech ]]
1137          then
1138             make_call_string="sxmake  $make_options  PROG=$mainprog  F90=$compiler_name  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$loader_options\" "
1139          else
1140             make_call_string="make  $make_options  PROG=$mainprog  F90=$compiler_name  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$loader_options\" "
1141          fi
1142
1143             # GENERATE COMMAND TO LOAD MODULES, IF MODULES ARE GIVEN
1144          if [[ "$modules" != "" ]]
1145          then
1146             if [[ $remote_host = lctit ]]
1147             then
1148                module_calls=". $modules"
1149             else
1150                module_calls="module load ${modules};"
1151             fi
1152          else
1153             module_calls=""
1154          fi
1155
1156          if [[ $remote_host = ibmkisti  ||  $remote_host = ibms ]]
1157          then
1158
1159             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
1160
1161          elif [[ $remote_host = ibmh ]]
1162          then
1163
1164             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
1165
1166          elif [[ $remote_host = lctit ]]
1167          then
1168
1169             echo  " "  >  ${remote_host}_last_make_protokoll
1170             while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]]
1171             do
1172                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
1173             done
1174
1175          elif [[ $remote_host = lcxe6 ]]
1176          then
1177
1178             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
1179
1180          else
1181
1182             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
1183
1184          fi
1185
1186          if [[ $(grep -c MAKE_ERROR ${remote_host}_last_make_protokoll) != 0 ]]
1187          then
1188             printf "\a\n  +++ error(s) occurred during compiling or linking on host \"$remote_host\" "
1189             if [[ $silent = false ]]
1190             then
1191                answer=dummy
1192                printf "\n"
1193                while [[ "$answer" != c  &&  "$answer" != k ]]
1194                do
1195                   printf "  >>> continue / list errors / kill mbuild (c/l/k) ? "
1196                   read  answer
1197                   if [[ "$answer" = l ]]
1198                   then
1199                      more ${remote_host}_last_make_protokoll
1200                   fi
1201                done
1202                if [[ $answer = k ]]
1203                then
1204                   locat=user_abort; exit
1205                fi
1206             fi
1207          fi
1208
1209
1210
1211             # TAR UPDATED VERSION ON THE REMOTE HOST
1212          printf "\n  *** tar update on remote host ..."
1213          if [[ $remote_host != lctit ]]
1214          then
1215             ssh  ${remote_username}@${remote_address}  "cd ${remote_md}; chmod u+w *; tar -cf  ${mainprog}_current_version.tar  ${mainprog}  *.f90 *.o *.mod"
1216          else
1217                # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS
1218             echo  "cd ${remote_md}; chmod u+w *; tar -cf  ${mainprog}_current_version.tar  ${mainprog}  *.f90 *.o *.mod"  |  ssh  ${remote_username}@${remote_address}  2>&1
1219          fi
1220
1221
1222
1223          # DO THE SAME THINGS FOR THE UTILITY-ROUTINES:
1224          # COPY CURRENT SOURCE CODE TO SOURCE-CODE DIRECTORY ON THE REMOTE HOST
1225          # CREATE THIS DIRECTORY, IF IT DOES NOT EXIST
1226       elif [[ $compile_utility_programs = true ]]
1227       then
1228
1229          printf "\n\n"
1230          echo "  *** copying scripts and utility programs to \"${remote_address}:${remote_ud}/\" "
1231          cd  ${local_source_path}/../SCRIPTS
1232
1233          if [[ $remote_host != lctit ]]
1234          then
1235             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)"
1236          else
1237                # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS
1238             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
1239          fi
1240
1241             # COPY SHELL-SCRIPTS
1242          scp  batch_scp mbuild mrun process_dvr_output .dvrserver.config subjob ${remote_username}@${remote_address}:${remote_ud}/../SCRIPTS  >  /dev/null
1243
1244          cd  -  > /dev/null
1245          cd  ${local_source_path}/../UTIL
1246
1247
1248             # COPY UTILITY-ROUTINES
1249          scp  Makefile  *.f90  ${remote_username}@${remote_address}:${remote_ud}  >  /dev/null
1250
1251
1252
1253             # EXECUTE MAKE WITH THOSE OPTIONS DETERMINED ABOVE
1254             # COMMANDS WILL BE COMMUNICATED TO SSH VIA PIPE, SINCE THIS WAY THE SYSTEM- AND
1255             # USER-PROFILES OF THE SHELL ARE COMPLETELY EXECUTED (OTHERWISE, MAKE
1256             # WILL E.G. MISS THE COMPILER-PATHS)
1257          echo "  *** execute \"make\" on remote host"
1258
1259          if [[ $remote_host = nech ]]
1260          then
1261             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\" "
1262          else
1263             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\" "
1264          fi
1265
1266             # GENERATE COMMAND TO LOAD MODULES, IF MODULES ARE GIVEN
1267          if [[ "$modules" != "" ]]
1268          then
1269             if [[ $remote_host = lctit ]]
1270             then
1271                module_calls=". $modules"
1272             else
1273                module_calls="module load ${modules};"
1274             fi
1275          else
1276             module_calls=""
1277          fi
1278
1279
1280          if [[ $remote_host = ibms ]]
1281          then
1282
1283             ssh  ${remote_username}@${remote_address}  "$init_cmds $module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR"
1284
1285          elif [[ $remote_host = ibmh ]]
1286          then
1287
1288             echo "$init_cmds $module_calls export OBJECT_MODE=64; cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_address}
1289
1290          elif [[ $remote_host = lctit ]]
1291          then
1292
1293             echo  " "  >  ${remote_host}_last_make_protokoll
1294             while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]]
1295             do
1296                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
1297             done
1298
1299          elif [[ $remote_host = lcxe6 ]]
1300          then
1301
1302             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
1303
1304          else
1305
1306             echo "$init_cmds $module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll
1307
1308          fi
1309
1310       fi    # END OF COMPILING UTILITY-ROUTINES
1311
1312       rm -rf  ${remote_host}_last_make_protokoll
1313
1314       # MAKE ON LOCAL HOST
1315    else
1316
1317          # INIT WORKAROUND FOR lcxe6
1318       if [[ $remote_host = lcxe6  ||  $remote_host = lccrayb  ||  $remote_host = lccrayf ||  $remote_host = lccrayh ]]
1319       then
1320
1321          eval $init_cmds  >  /dev/null  2>&1
1322
1323       fi
1324
1325       # FIRST LOAD MODULES, IF GIVEN
1326       if [[ "$modules" != "" ]]
1327       then
1328          if [[ $remote_host = lctit ]]
1329          then
1330             . $modules
1331          elif [[ $remote_host = lcflow ]]
1332          then
1333             eval `$MODULESHOME/bin/modulecmd ksh load ${modules}`
1334          else
1335             eval init_cmds=$init_cmds
1336             module load ${modules}
1337          fi
1338       fi
1339
1340
1341       if [[ $compile_utility_programs = false ]]
1342       then
1343
1344             # CREATE MAKE-DEPOSITORY, IF IT DOES NOT EXIST
1345          eval remote_md=$remote_md
1346          if [[ ! -d $remote_md ]]
1347          then
1348             if  mkdir $remote_md
1349             then
1350                printf "\n\n  *** directory for make depository:"
1351                printf "\n           $remote_md"
1352                printf "\n      was created\n"
1353             else
1354                printf "\n  +++ directory for make depository:"
1355                printf "\n           $remote_md"
1356                printf "\n      cannot be created"
1357                locat=local_depository_path; exit
1358             fi
1359          fi
1360
1361             # COPY SOURCE-CODE FROM REPOSITORY TO MAKE-DEPOSITORY
1362          echo " "
1363          echo "  *** updating sources in $remote_md"
1364          cd  $remote_md
1365          cp  $local_source_path/${mainprog}_sources.tar  .
1366          tar xf  ${mainprog}_sources.tar
1367
1368             # CALL MAKE ON LOCAL HOST USING THE  OPTIONS DETERMINED FURTHER ABOVE
1369          echo " "
1370          echo "  *** execute \"make\" on local host"
1371
1372          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
1373
1374          if [[ $? != 0 ]]
1375          then
1376             printf "\a\n  +++ error(s) occurred during compiling or linking on host \"$remote_host\" "
1377             if [[ $silent = false ]]
1378             then
1379                answer=dummy
1380                printf "\n"
1381                while [[ "$answer" != c  &&  "$answer" != k ]]
1382                do
1383                   printf "  >>> continue / list errors / kill mbuild (c/l/k) ? "
1384                   read  answer
1385                   if [[ "$answer" = l ]]
1386                   then
1387                      more ${remote_host}_last_make_protokoll
1388                   fi
1389                done
1390                if [[ $answer = k ]]
1391                then
1392                   locat=user_abort; exit
1393                fi
1394             fi
1395          fi
1396
1397
1398             # TAR NEW VERSION ON LOCAL HOST
1399          printf "\n  *** tar update on local host ..."
1400          tar -cf  ${mainprog}_current_version.tar  *.$suf *.o *.mod
1401
1402
1403          # COMPILE THE UTILITY PROGRAMS
1404       elif [[ $compile_utility_programs = true ]]
1405       then
1406          printf "\n\n"
1407          echo "  *** compiling the utility programs ..."
1408          cd ${local_source_path}/../UTIL
1409
1410             # TOUCH FILES IN ORDER TO FORCE COMPILATION FOR EVERY BLOCK
1411          touch  *.f90
1412          eval init_cmds=$init_cmds
1413          make  $make_options  BLOCK=$block  F90=$compiler_name  F90_SER=$compiler_name_ser  COPT="$cpp_options"  F90FLAGS="$compiler_options"  LDFLAGS="$loader_options"
1414
1415             # CHECK IF QMAKE IS AVAILABLE AND COMPILE MRUNGUI
1416          if [[ $util_compiled_localhost == false ]]
1417          then
1418             printf "\n\n"
1419             echo "  *** compiling the mrun GUI"
1420             if which qmake >/dev/null; then
1421                cd mrungui
1422                touch *
1423                qmake
1424                make
1425                make clean
1426                rm Makefile
1427                cd ..
1428             else
1429                echo "  +++ no qmake found. The (optional) GUI will not be compiled."
1430             fi
1431
1432#                 # COMPILE CHECK_NAMELIST_FILES (ONLY FOR ONE BRANCH on LOCALHOST NEEDED)
1433#              printf "\n\n"
1434#              echo "  *** compiling check_namelist_files ..."
1435#
1436#                 # GET CHECK OPTIONS
1437#              line=""
1438#              found=false
1439#              grep  "$remote_host_string" $config_file | grep "%cpp_options"  >  $tmp_mbuild
1440#              while read line1
1441#              do
1442#
1443#                 if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
1444#                 then
1445#                    line="$line1"
1446#                 fi
1447#
1448#                 if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
1449#                 then
1450#                       # REMOVE COLONS FROM THE OPTION-STRING, IF THERE ARE ANY
1451#                    line="$line "
1452#                    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'`
1453#                    found=true
1454#                 fi
1455#
1456#              done < $tmp_mbuild
1457#              copts_check="$copts_check -D__check -D__parallel"
1458#
1459#              check_depository_path=${local_source_path}/../UTIL
1460#              cd $check_depository_path
1461#              mkdir check_tmp
1462#              cp ${local_source_path}/${mainprog}_sources_check.tar ./check_tmp
1463#              cd check_tmp
1464#              tar -xf  ${mainprog}_sources_check.tar
1465#              rm -rf ${mainprog}_sources_check.tar
1466#              make  -f Makefile_check $make_options  F90=$compiler_name_ser  COPT="$copts_check"  F90FLAGS="$compiler_options"
1467#              tar -cf  check_namelist_files.tar Makefile_check check_namelist_files.x *.f90 *.o *.mod
1468#              mv check_namelist_files.tar $check_depository_path
1469#              mv check_namelist_files.x $PALM_BIN
1470#              cd $check_depository_path
1471#              rm -rf check_tmp
1472#              util_compiled_localhost=true
1473          else
1474             cd $check_depository_path
1475             printf "\n\n"
1476             echo "  *** skipped compilation of mrun GUI."       
1477             printf "\n\n"
1478             echo "  *** skipped compilation of check_namelist_files (currently not available)."           
1479          fi
1480
1481       fi
1482    fi
1483 done
1484
1485
1486 if [[ $host_found = false ]]
1487 then
1488    if [[ $host = all ]]
1489    then
1490       printf "\n  +++ no hosts found in configuration file"
1491    else
1492       printf "\n  +++ host \"$host\" not found in configuration file"
1493    fi
1494    locat=config_file; exit
1495 fi
1496
1497 if [[ "$block_conditions" != none  &&  $block_conditions_found = false ]]
1498 then
1499    printf "\n  +++ block conditions \"$block_conditions\" not found for host \"$host\""
1500 fi
1501
1502
1503    # FINAL WORK
1504 rm -f  hosts_found_in_config_file
1505 rm -f ${local_source_path}/${mainprog}_sources_check.tar
Note: See TracBrowser for help on using the repository browser.