source: palm/trunk/SCRIPTS/mbuild @ 1622

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

last commit documented

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