source: palm/trunk/SCRIPTS/mbuild @ 1468

Last change on this file since 1468 was 1468, checked in by maronga, 10 years ago

New flag files allow to force unscheduled termination/restarts of batch jobs, progress output is made for batch runs, small adjustments for lxce6 and lccrayh/lccrayb

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