source: palm/trunk/SCRIPTS/mbuild @ 1779

Last change on this file since 1779 was 1653, checked in by raasch, 9 years ago

last commit documented

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