source: palm/trunk/SCRIPTS/mbuild @ 1649

Last change on this file since 1649 was 1649, checked in by knoop, 9 years ago

Latex lecture update for PALM seminar in Hong Kong

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