source: palm/trunk/SCRIPTS/mbuild @ 2262

Last change on this file since 2262 was 2257, checked in by witha, 7 years ago

Bugfix in PALM-WTM, modifications for lceddy

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