source: palm/trunk/SCRIPTS/mbuild @ 1652

Last change on this file since 1652 was 1652, checked in by raasch, 6 years ago

bugfix in calculation of vertical profile of energy production by turbulent transport of TKE
bugfix for output of configuration settings (mbuild)
output of login init command (mbuild)

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