source: palm/trunk/SCRIPTS/mbuild @ 807

Last change on this file since 807 was 807, checked in by maronga, 12 years ago

new utility check_namelist_files implemented

  • Property svn:keywords set to Id Rev
File size: 50.6 KB
Line 
1#!/bin/ksh
2# mbuild - script for compiling the PALM code and its utility programs
3# $Id: mbuild 807 2012-01-25 11:53:51Z maronga $
4
5     # Procedure to compile code on local and remote hosts using the
6     # make-mechanism. The source code must be provided on the local host.
7
8     # Last changes:
9     # 06/05/02 - Siggi - start development
10     # 12/06/02 - Siggi - first version finished
11     # 12/09/02 - Siggi - ibmh (hanni.hlrn.de) included
12     # 19/12/02 - Siggi - ibmb included
13     # 05/02/03 - Siggi - hostname nobela included
14     # 04/03/03 - Siggi - host nech included
15     # 06/03/03 - Siggi - make_call_string is echoed without '' to
16     #                    file LAST_MAKE_CALL (otherwise error on NEC, because
17     #                    '' are part of compiler options
18     # 16/03/03 - Siggi - Two underscores are placed in front of every define
19     #                    string, in case that palm.f90 version contains
20     #                    such strings
21     # 16/04/03 - Siggi - First extensions for linux machines
22     # 24/06/03 - Siggi - host orkan included
23     # 17/07/03 - Siggi - IP adress set to new "cross" machine at DKRZ
24     # 24/07/03 - Siggi - host maestro admitted
25     # 06/08/03 - Siggi - host gregale admitted
26     # 05/11/03 - Siggi - hosts irifi and quanero are now belonging to lcmuk
27     # 19/11/03 - Heiko - on lcmuk, mbuild does not tar the *.i files
28     # 08/01/04 - Siggi - additional preprocessor directive for ibm included
29     #                    (-D$OMP=OMP) in order to avoid problems with
30     #                    OMP_NUM_THREADS
31     # 09/01/04 - Siggi - action above cancelled
32     # 28/01/04 - Siggi - action above re-cancelled
33     # 08/03/04 - Siggi - host scirocco admitted
34     # 26/03/04 - Siggi - .o and .mod files are also deleted in depository, if
35     #                    the respective .f90 file is not listed in the makefile
36     #                    and deletion is demanded by the user
37     # 12/04/04 - Siggi - scp2 instead of scp used for transfer from decalpha
38     #                    due to error in ssh installation (otherwise a prompt
39     #                    for the password appears)
40     # 23/07/04 - Siggi - changes due to the new berni configuration
41     #                    (federation switch)
42     # 08/09/04 - Siggi - hanni IP address changed to 130.75.4.10
43     # 23/09/04 - Joerg - correction of IP-Address for 'cross' (DKRZ)
44     # 09/03/05 - Siggi - on nech, mbuild does not tar the *.i files
45     # 31/03/05 - Siggi - mbuild does not tar *.i files any more
46     # 24/04/05 - Siggi - netcdf support on lcmuk
47     # 25/04/05 - Siggi - netcdf support on gfdl3 (decalpha)
48     # 12/05/05 - Siggi - netcdf support on ibm
49     #                    set OBJECT_MODE=64 for compiling on ibmb, ibmh
50     # 18/05/05 - Siggi - netcdf support on nec
51     # 19/05/05 - Siggi - IP addres 134.75.155.74 changed to 165.132.26.56
52     # 23/05/05 - Siggi - netcdf support on ibms
53     # 01/06/05 - Siggi - reset of cpp_options to "" on lcmuk
54     # 30/06/05 - Siggi - netcdf support on bora
55     # 20/10/05 - Siggi - update of netcdf-version on decalpha (gfdl3)
56     # 04/11/05 - Siggi - netcdf 3.6.0-p1 on ibmh/ibmb
57     # 30/12/05 - Siggi - change of IP adresses in subnet 130.75.105
58     #                    host gfdl5 (ibmy) admitted
59     # 10/01/06 - Siggi - cpp directive for NetCDF 64bit support
60     # 20/01/06 - Siggi - cpp directive for ibmy
61     # 09/02/06 - Marcus- compile only once on lcmuk (as on ibmh/ibmb)
62     # 10/02/06 - Siggi - modifications for scp on decalpha
63     # 13/04/06 - Siggi - ostria admitted
64     # 19/04/06 - Siggi - preprocessor directive -D$OMP=OMP for ibm removed
65     # 23/05/05 - Siggi - lctit (SUN Fire X4600) admitted
66     # 29/05/05 - Siggi - atmos (lcide) admitted
67     # 23/08/06 - Siggi - netcdf support for scirocco (notebook)
68     # 24/11/06 - Siggi - breva and levanto admitted
69     # 07/02/07 - Siggi - adapted for RIAM (neck)
70     # 10/02/07 - Siggi - all hpmuk-related code removed
71     # 02/03/07 - Siggi - compilation of utility programs and transfer of
72     #                    scripts to remote hosts added (option -u)
73     # 14/03/07 - Siggi - fimm admitted, revision number added to terminal
74     #                    output
75     # 16/03/07 - Siggi - adjustments (netcdf) for lctit
76     #                    adjustments for running under pdksh, local ip-addres
77     #                    is not determined any more
78     # 30/03/07 - Siggi - cpp-directives/options + netcdf-options are read
79     #                    from configuration file
80     #                    host identifier (local_host) is read from config file
81     # 10/10/07 - Siggi - bugfix: handling of comment lines
82     # 18/07/08 - Siggi - adapted for lcsgih
83     # 21/07/08 - Siggi - mainprog (executable) is added to the tar-file
84     #                    ({mainprog}_current_version)
85     # 02/10/08 - Siggi - adapted for lcxt4
86     # 14/11/08 - Siggi - update mechanism completely revised: source tarfile
87     #                    remains in source directory, one depository per block
88     #                    (given in the config-file) is created, allways all
89     #                    files from the source directory are copied to the
90     #                    respective depository, no additional file checks are
91     #                    done any more (version 2.1)
92     # 13/01/09 - Marcus- re-enable compilation more than once on lcmuk (as on
93     #                    other machines)
94     # 21/03/09 - Siggi - -u copies also copies process_dvr_output and
95     #                    .dvrserver.config
96     # 21/04/09 - Siggi - adjustments for new IBM at DKRZ, which is now ibmh
97     # 25/08/09 - BjornM- adapted for lck
98     # 01/12/09 - BjornM- re-adjustments for lcxt4
99     # 01/02/10 - Siggi - adjustments for lcxt5m
100     # 03/02/10 - Siggi - make options (mopts) to be set by configuration file
101     #                    implemented, remoted mode option -r completely
102     #                    removed, t3e related parts removed
103     # 26/02/10 - BjornM- re-adjustments for lcxt4 (new modules)
104     # 01/03/10 - Siggi - mpilib replaced by modules: explicit module settings
105     #                    removed; modules should now be given in the
106     #                    configuration file
107     # 02/03/10 - Siggi - utility programs are created separately for each
108     #                    block in the configuration file,
109     #                    parallel make for utility programs
110     # 12/03/10 - Siggi - bugfix: remode_md was given a wrong value
111     # 16/08/10 - BjornM- bugfix: call of modules on local host, new workaround
112     #                    for lcxt4
113     # 07/09/10 - Siggi - bugfix for wrong netcdf/3.6.3 module on lcsgi
114     # 08/12/10 - Siggi - initialization of the module command changed for
115     #                    SGI-ICE/lcsgi
116     #                    adjustments for Kyushu Univ. (lcrte, ibmku)
117     # 14/12/10 - Siggi - adjustments for new Tsubame system at Tokyo
118     #                    institute of technology (lctit)
119     # 04/03/11 - BjornM- re-adjustments for lcxt4
120     # 06/03/11 - Siggi - adjustments for ibmkisti
121     # 03/04/11 - Micha - added lckordi
122     # 17/08/11 - Siggi - HLRN access via hicegate0 (130.75.4.101)
123     # 27/11/11 - Siggi - Bugfix for make options setting (-j)
124     # 12/12/11 - BjornM- added mrun GUI to ulitity programs
125     # 25/01/12 - BjornM- compilation of check_namelist_files (namelist file
126     #                    check program) has been added to the utility branch),
127     #                    modfified the compilation of mrungui
128
129
130
131    # VARIABLE DECLARATIONS + DEFAULT VALUES
132 compile_utility_programs=false
133 config_file=.mrun.config
134 fimm=false
135 host=all
136 host_found=false
137 locat=normal
138 makefile=""
139 module_calls=""
140 scirocco=false
141 silent=false
142 suf=f90
143 update=false
144 working_directory=`pwd`
145
146 typeset -i  ih ihost=0
147
148 typeset  -R30 calltime
149 typeset  -L20 column1
150 typeset  -L50 column2
151 typeset  -L70 column3
152 typeset  -L40 version="MBUILD  2.1  Rev$Rev: 807 $"
153
154    # ERROR HANDLING
155    # IN CASE OF EXIT:
156 trap 'rm -rf  $working_directory/tmp_mbuild
157       if [[ $locat != normal ]]
158       then
159          printf "\n\n +++ mbuild killed \n\n"
160       else
161          printf "\n\n *** mbuild finished \n\n"
162       fi' exit
163
164
165    # IN CASE OF TERMINAL-BREAK:
166 trap 'rm -rf  $working_directory/tmp_mbuild
167       printf "\n\n +++ mbuild killed by \"^C\" \n\n"
168       exit
169      ' 2
170
171
172 tmp_mbuild=${working_directory}/tmp_mbuild
173
174    # READ SHELLSCRIPT-OPTIONS
175 while  getopts  :c:h:m:s:u  option
176 do
177   case  $option  in
178       (c)   config_file=$OPTARG;;
179       (h)   host=$OPTARG;;
180       (m)   makefile=$OPTARG;;
181       (s)   suf=$OPTARG;;
182       (u)   compile_utility_programs=true;;
183       (\?)  printf "\n  +++ unknown option $OPTARG \n";
184             locat=parameter; exit;;
185   esac
186 done
187
188
189
190    # CHECK, IF CONFIGURATION-FILE EXISTS
191 if [[ ! -f $config_file ]]
192 then
193    printf "\n  +++ configuration file: "
194    printf "\n           $config_file"
195    printf "\n      does not exist"
196    locat=configuration; exit 
197 fi
198
199
200
201    # DETERMINE THE LOCAL HOST
202 local_host_real_name=$(hostname)
203# local_addres=$(nslookup `hostname` 2>&1 | grep "Address:" | tail -1 | awk '{print $2}')
204
205
206
207    # DETERMINE HOST-IDENTIFIER (local_host) FROM THE CONFIG-FILE
208 line=""
209 grep  "%host_identifier"  $config_file  >  $tmp_mbuild
210 while read line
211 do
212    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
213    then
214       HOSTNAME=`echo $line | cut -d" " -s -f2`
215       host_identifier=`echo $line | cut -d" " -s -f3`
216       if [[ $local_host_real_name = $HOSTNAME ]]
217       then
218          local_host=$host_identifier
219          break
220       fi
221    fi
222 done < $tmp_mbuild
223
224 if [[ "$local_host" = "" ]]
225 then
226    printf "\n  +++ no host identifier found in configuration file \"$config_file\""
227    printf "\n      for local host \"$local_host_real_name\"."
228    printf "\n      Please add line"
229    printf "\n      \"\%host_identifier $local_host_real_name <identifier>\""
230    printf "\n      to the configuration file."
231    locat=local_host; exit
232 fi
233
234
235
236 [[ $local_host_real_name = scirocco ]]  &&  scirocco=true
237 [[ $local_host_real_name = fimm.bccs.uib.no ]]  &&  fimm=true
238
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 
250    # DETERMINE USER NAME ON LOCAL HOST FROM THE CONFIG-FILE
251 line=""
252 grep  " $local_host" $config_file | grep "%remote_username"  >  $tmp_mbuild
253 while read line
254 do
255    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
256    then
257       local_username=`echo $line | cut -d" " -s -f2`
258    fi
259 done < $tmp_mbuild
260
261
262 if [[ "$local_username" = "" ]]
263 then
264    printf "\n  +++ no user name found in configuration file"
265    printf "\n      for local host \"$local_host\" "
266    locat=config_file; exit
267 fi
268
269
270    # DETERMINE LOCAL SOURCE-CODE PATH.
271    # FIRST CHECK, IF A GLOBAL SOURCE-CODE PATH HAS BEEN DECLARED FOR ALL HOSTS.
272    # THEREFORE, FIRST SET ALL GLOBAL VARIABLES DECLARED IN THE CONFIG-FILE,
273    # BECAUSE THEY MAY BE USED AS PART OF THE PATH NAME.
274 line=""
275 grep "%" $config_file  >  $tmp_mbuild
276 while read line
277 do
278    if [[ "$line" != ""  &&  "$(echo $line | cut -d" " -s -f3)" = ""  &&  $(echo $line | cut -c1) != "#" ]]
279    then
280       var=`echo $line | cut -d" " -s -f1 | cut -c2-`
281       value=`echo $line | cut -d" " -s -f2`
282       eval export $var=\$value
283    fi
284 done < $tmp_mbuild
285
286    # NOW CHECK, IF A GLOBAL SOURCE-CODE-PATH HAS BEEN DECLARED
287 line=""
288 grep "%source_path" $config_file  >  $tmp_mbuild
289 while read line
290 do
291    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
292    then
293       if [[ "$(echo $line | cut -d" " -s -f3)" = "" ]]
294       then
295          global_source_path=`echo $line | cut -d" " -s -f2`
296       fi
297    fi
298 done < $tmp_mbuild
299
300 line=""
301 grep  " $local_host" $config_file | grep "%source_path"  >  $tmp_mbuild
302 while read line
303 do
304    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
305    then
306       local_source_path=`echo $line | cut -d" " -s -f2`
307    fi
308 done < $tmp_mbuild
309
310 if [[ "$local_source_path" = "" ]]
311 then
312    if [[ "$global_source_path" != "" ]]
313    then
314       local_source_path=$global_source_path
315    else
316       printf "\n  +++ no source path found in configuration file"
317       printf "\n      for local host \"$local_host\" "
318       printf "\n      please set \"\%source_path\" in configuration file"
319       locat=config_file; exit
320    fi
321 fi
322 eval local_source_path=$local_source_path
323 eval local_source_path=$local_source_path
324
325
326
327    # DETERMINE GLOBAL DEPOSITORY-PATH
328 line=""
329 grep "%depository_path" $config_file  >  $tmp_mbuild
330 while read line
331 do
332    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
333    then
334       if [[ "$(echo $line | cut -d" " -s -f3)" = "" ]]
335       then
336          global_depository_path=`echo $line | cut -d" " -s -f2`
337       fi
338    fi
339 done < $tmp_mbuild
340
341 if [[ $found = false ]]
342 then
343    printf "\n  +++ no \%depository_path found in" 
344    printf "\n                            $config_file"
345    locat=depository_path; exit
346  fi
347
348    # CHECK, IF A MAIN PROGRAM HAS BEEN DEFINED IN THE CONFIG-FILE
349 if [[ $(grep -c "%mainprog" $config_file) != 1 ]]
350 then
351    printf "\n  +++ no main program or more than one main program defined"
352    printf "\n      in configuration file"
353    locat=configuration; exit
354 else
355    line=`grep "%mainprog" $config_file`
356    if [[ "$line" = ""  ||  $(echo $line | cut -c1) = "#" ]]
357    then
358       printf "\n  +++ no main program defined in configuration file"
359       locat=configuration; exit
360    fi
361    mainprog=`echo $line | cut -d" " -s -f2 | cut -d"." -f1`
362 fi
363
364
365
366    # CHECK IF MAKEFILE EXITS
367 [[ "$makefile" = "" ]]  &&  makefile=$local_source_path/Makefile
368 if [[ ! -f $makefile ]]
369 then
370    printf "\n  +++ makefile: "
371    printf "\n           $makefile"
372    printf "\n      does not exist"
373    locat=makefile; exit 
374 fi
375
376
377    # HEADER-OUTPUT (PART1: MESSAGES CONCERNING THE LOCAL HOST)
378 calltime=$(date)
379 printf "\n"
380 printf "#------------------------------------------------------------------------# \n"
381 printf "| $version$calltime | \n"
382 printf "|                                                                        | \n"
383 column1="called on:"; column2=$local_host_real_name
384 printf "| $column1$column2 | \n"
385 column1="local username:"; column2=$local_username
386 printf "| $column1$column2 | \n"
387 column1="local IP-addres:"; column2=$local_addres
388 printf "| $column1$column2 | \n"
389 column1="config file:"; column2=$config_file
390 printf "| $column1$column2 | \n"
391 column1="makefile:"; column2=$makefile
392 printf "| $column1$column2 | \n"
393 column1="local source path:"; column2=$local_source_path
394 printf "| $column1$column2 | \n"
395 printf "#------------------------------------------------------------------------# \n"
396
397# printf "|                                                                        | \n"
398
399
400 if [[ $compile_utility_programs = false ]]
401 then
402
403       # IN ANY CASE, GIVE ALL FILES WRITE-PERMIT, IN ORDER TO AVOID PROBLEMS
404       # WITH OVERWRITING FILES ON THE REMOTE HOST
405    cd  $local_source_path
406    printf "\n\n  *** tar of makefile and source files in $local_source_path" 
407    tar -cf  ${mainprog}_sources.tar  Makefile  *.$suf
408    printf "\n"
409
410 else
411    cd  $local_source_path
412    printf "\n\n  *** tar of makefile and source files in $local_source_path" 
413 
414    cat Makefile_check|while read line
415    do
416       line=$(echo $line|grep RCS)
417       if [[ $line == *"RCS"* ]]
418       then
419          line=$(echo $line|sed 's/RCS = //g')
420          break
421       fi
422    done
423
424    tar -cf  ${mainprog}_sources_check.tar  Makefile_check  $line
425    printf "\n"
426
427 fi
428
429
430
431    # GET CONFIRMATION TO CONTINUE
432 if [[ $host = all ]]
433 then
434    printf "\n  *** updates will be made for ALL hosts found in"
435    printf "\n      the configuration file"
436 else
437    printf "\n  *** update will be made for host \"$host\" "
438 fi
439
440 if [[ $silent = false ]]
441 then
442    answer=dummy
443    printf "\n\n"
444    while [[ "$answer" != y  &&  "$answer" != Y  &&  "$answer" != n  &&  "$answer" != N ]]
445    do
446       printf " >>> continue (y/n) ?  "
447       read  answer
448    done
449    if [[ $answer = n  ||  $answer = N ]]
450    then
451       locat=user_abort; exit
452    fi
453 fi
454 
455 
456
457   
458    # GENERIERUNG DER AKTUELLEN MODELLVERSION FUER ALLE RECHNER-/UEBERSETZUNGS-
459    # VERSIONEN, DIE IN DER KONFIGURATIONSDATEI GEFUNDEN WERDEN
460 printf "\n  *** scanning configuration file for host(s) ..."
461
462 grep  %fopts  $config_file  >  $tmp_mbuild
463 while read line
464 do
465       # KOMMENTARZEILEN UEBERSPRINGEN
466    [[ $(echo $line | cut -c1) = "#" ]]  &&  continue
467    (( ihost = ihost + 1 ))
468    hostline[$ihost]="$line"
469 done < $tmp_mbuild
470
471 
472 while (( ih < ihost ))
473 do
474
475    (( ih = ih + 1 ))
476
477       # REMOTE-RECHNER UND UEBERSETZUNGS-VERSION FESTSTELLEN
478       # NUR WEITERMACHEN, WENN ENTSPRECHENDER REMOTE-RECHNER MITTELS
479       # SHELLSCRIPT-OPTION AUCH AUSGEWAEHLT WURDE
480    remote_host_string=`echo ${hostline[$ih]} | cut -d" " -s -f3-`
481    remote_host=`echo $remote_host_string | cut -d" " -f1`
482    if [[ $host != all ]]
483    then
484       [[ $remote_host != $host ]]  &&  continue
485    fi
486    host_found=true
487    condition1=`echo $remote_host_string | cut -d" " -s -f2`
488    if [[ $condition1 = $remote_host ]]
489    then
490       condition1=""
491    else
492       condition2=`echo $remote_host_string | cut -d" " -s -f3`
493    fi
494
495    modules=""
496    netcdf_inc=""
497    netcdf_lib=""
498    make_options=""
499
500       # IP-ADRESSE DES REMOTE-RECHNERS BESTIMMEN
501    case  $remote_host  in
502        (lckordi)          remote_adress=210.219.61.8;;
503        (lcmuk)          remote_addres=130.75.105.2;;
504        (lcrte)          remote_addres=133.5.185.60;;
505        (lcsgib)         remote_addres=130.73.232.102;;
506        (lcsgih)         remote_addres=130.75.4.101;;
507        (lck)            remote_addres=165.132.26.61;;
508        (lctit)          remote_addres=10.1.6.170;;
509        (lcxt4)          remote_addres=129.177.20.113;;
510        (lcxt5m)         remote_addres=193.166.211.144;;
511        (decalpha)       remote_addres=165.132.26.56;;
512        (ibmh)           remote_addres=136.172.40.15;;
513        (ibmkisti)       remote_addres=150.183.146.24;;
514        (ibmku)          remote_addres=133.5.4.129;;
515        (ibms)           remote_addres=150.183.5.101;;
516        (ibmy)           remote_addres=165.132.26.58;;
517        (nech)           remote_addres=136.172.44.192;;
518        (neck)           remote_addres=133.5.178.11;;
519        (ground.yonsei.ac.kr) remote_addres=134.75.155.33;;
520        (*)              if [[ $local_host != $remote_host ]]
521                         then
522                            printf "\n  +++ remote host \"$remote_host\" unknown";
523                            printf "\n      please inform PALM group support!"
524                         fi;;
525    esac
526
527
528       # REMOTE-USERNAMEN ERMITTELN
529    line=""
530    found=false
531    grep  "$remote_host_string" $config_file | grep "%remote_username"  >  $tmp_mbuild
532    while read line1
533    do
534
535       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
536       then
537          line="$line1"
538       fi
539
540       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
541       then
542          remote_username=`echo $line | cut -d" " -s -f2`
543          found=true
544       fi
545
546    done < $tmp_mbuild
547
548    if [[ $found = false ]]
549    then
550       printf "\n  +++ no remote username found in configuration file"
551       printf "\n      for \"$remote_host_string\" "
552       locat=config_file; exit
553    fi
554
555
556       # REMOTE-QUELLTEXTPFAD ERMITTELN
557    line=""
558    remote_source_path=""
559    grep  "$remote_host_string" $config_file | grep "%source_path"  >  $tmp_mbuild
560    while read line1
561    do
562
563       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
564       then
565          line="$line1"
566       fi
567
568       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
569       then
570          remote_source_path=`echo $line | cut -d" " -s -f2`
571       fi
572
573    done < $tmp_mbuild
574
575    if [[ "$remote_source_path" = "" ]]
576    then
577       if [[ "$global_source_path" != "" ]]
578       then
579          remote_source_path=$global_source_path
580       else
581          printf "\n  +++ no source path found in configuration file"
582          printf "\n      for \"$remote_host_string\" "
583          locat=config_file; exit
584       fi
585    fi
586
587    remote_ud=${remote_source_path}/../UTIL
588    remote_ud=$(eval echo $remote_ud)
589
590
591       # REMOTE-PFAD FUER MAKE-DEPOSITORY ERMITTELN
592    remote_md=""
593    line=""
594    grep  "$remote_host_string" $config_file | grep "%depository_path"  >  $tmp_mbuild
595    while read line1
596    do
597
598       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
599       then
600          line="$line1"
601       fi
602
603       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
604       then
605          remote_md=`echo $line | cut -d" " -s -f2`
606       fi
607
608    done < $tmp_mbuild
609
610    if [[ "$remote_md" = "" ]]
611    then
612       if [[ "$global_depository_path" != "" ]]
613       then
614          remote_md=$global_depository_path
615       else
616          printf "\n  +++ no depository path found in configuration file"
617          printf "\n      for \"$remote_host_string\" "
618          printf "\n      please set \"\%depository_path\" in configuration file"
619          locat=config_file; exit
620       fi
621    fi
622
623    remote_md=$(eval echo $remote_md)
624    block=""
625    [[ "$condition1" != "" ]]  &&  block=_$condition1
626    [[ "$condition2" != "" ]]  &&  block=${block}_$condition2
627    remote_md=${remote_md}$block
628
629
630       # COMPILERNAMEN ERMITTELN
631    line=""
632    found=false
633    grep  "$remote_host_string" $config_file | grep "%compiler_name "  >  $tmp_mbuild
634    while read line1
635    do
636
637       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
638       then
639          line="$line1"
640       fi
641
642       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
643       then
644          compiler_name=`echo $line | cut -d" " -s -f2`
645          found=true
646       fi
647
648    done < $tmp_mbuild
649
650    if [[ $found = false ]]
651    then
652       printf "\n  +++ no compiler name found in configuration file"
653       printf "\n      for \"$remote_host_string\" "
654       locat=config_file; exit
655    fi
656
657
658       # BEI BENUTZUNG EINES PARALLELEN COMPILERS MUSS AUCH EIN
659       # SERIELLER COMPILERNAME ERMITTELT WERDEN
660    if [[ $(echo $remote_host_string | grep -c parallel) = 1 ]]
661    then
662       line=""
663       found=false
664       grep  "$remote_host_string" $config_file | grep "%compiler_name_ser"  >  $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_ser=`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 serial compiler name found in configuration file"
684          printf "\n      for \"$remote_host_string\" "
685          locat=config_file; exit
686       fi
687    else
688       compiler_name_ser=$compiler_name
689    fi
690
691
692
693       # PRAEPROZESSOR-OPTIONEN/DIREKTIVEN ERMITTELN
694    line=""
695    found=false
696    grep  "$remote_host_string" $config_file | grep "%cpp_options"  >  $tmp_mbuild
697    while read line1
698    do
699
700       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
701       then
702          line="$line1"
703       fi
704
705       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
706       then
707             # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING ENTFERNEN
708          cpp_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
709          found=true
710       fi
711
712    done < $tmp_mbuild
713
714    if [[ $found = false ]]
715    then
716       printf "\n  +++ no preprocessor options found in configuration file"
717       printf "\n      for \"$remote_host_string\" "
718       locat=config_file; exit
719    fi
720
721
722       # RECHNERSPEZIFISCHE CPP-DIREKTIVEN HINZUFUEGEN
723    for  string  in  $remote_host_string
724    do
725       if [[ $(echo $remote_host | cut -c1-2) = lc  &&  $(echo $string | cut -c1-2) = lc ]]
726       then
727          cpp_options="$cpp_options -D__lc "
728       elif [[ $(echo $remote_host | cut -c1-3) = ibm  &&  $(echo $string | cut -c1-3) = ibm ]]
729       then
730          cpp_options="${cpp_options},-D__ibm"
731       elif [[ $(echo $remote_host | cut -c1-3) = nec  &&  $(echo $string | cut -c1-3) = nec ]]
732       then
733          cpp_options="${cpp_options} -D__nec"
734       else
735          if [[ $(echo $remote_host | cut -c1-3) = ibm ]]
736          then
737             cpp_options="${cpp_options},-D__$string"
738          else
739             cpp_options="$cpp_options -D__$string "
740          fi
741       fi
742    done
743
744
745
746       # NETCDF-OPTIONEN ERMITTELN
747    line=""
748    grep  "$remote_host_string" $config_file | grep "%netcdf_inc"  >  $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             # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING ENTFERNEN
760          netcdf_inc=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
761       fi
762
763    done < $tmp_mbuild
764
765    line=""
766    grep  "$remote_host_string" $config_file | grep "%netcdf_lib"  >  $tmp_mbuild
767    while read line1
768    do
769
770       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
771       then
772          line="$line1"
773       fi
774
775       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
776       then
777             # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING ENTFERNEN
778          netcdf_lib=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
779       fi
780
781    done < $tmp_mbuild
782
783
784
785       # get make options
786    line=""
787    found=false
788    grep  "$remote_host_string" $config_file | grep "%mopts"  >  $tmp_mbuild
789    while read line1
790    do
791
792       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
793       then
794          line="$line1"
795       fi
796
797       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
798       then
799             # remove colons from directive string
800          make_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
801
802       fi
803
804    done < $tmp_mbuild
805
806
807
808       # COMPILEROPTIONEN ERMITTELN
809    line=""
810    found=false
811    grep  "$remote_host_string" $config_file | grep "%fopts"  >  $tmp_mbuild
812    while read line1
813    do
814
815       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
816       then
817          line="$line1"
818       fi
819
820       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
821       then
822             # EVENTUELLE DOPPELPUNKTE AUS DIREKTIVENSTRING ENTFERNEN
823          compiler_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
824          found=true
825
826             # NETCDF-INCLUDEVERZEICHNIS HINZUFUEGEN
827          compiler_options="$compiler_options $netcdf_inc"
828       fi
829
830    done < $tmp_mbuild
831
832    if [[ $found = false ]]
833    then
834       printf "\n  +++ no compiler options found in configuration file"
835       printf "\n      for \"$remote_host_string\" "
836       locat=config_file; exit
837    fi
838
839
840
841       # get modules to be loaded
842    line=""
843    grep  "$remote_host_string" $config_file | grep "%modules"  >  $tmp_mbuild
844    while read line1
845    do
846
847       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
848       then
849          line="$line1"
850       fi
851
852       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
853       then
854             # EVENTUELLE DOPPELPUNKTE AUS DIREKTIVENSTRING ENTFERNEN
855          modules=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
856       fi
857
858    done < $tmp_mbuild
859
860
861
862
863       # LADER-OPTIONEN ERMITTELN
864    line=""
865    found=false
866    grep  "$remote_host_string" $config_file | grep "%lopts"  >  $tmp_mbuild
867    while read line1
868    do
869
870       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
871       then
872          line="$line1"
873       fi
874
875       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
876       then
877             # EVENTUELLE DOPPELPUNKTE AUS DIREKTIVENSTRING ENTFERNEN
878          loader_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
879          found=true
880
881             # NETCDF-LIBRARY HINZUFUEGEN
882          loader_options="$loader_options $netcdf_lib"
883       fi
884
885    done < $tmp_mbuild
886
887    if [[ $found = false ]]
888    then
889       printf "\n  +++ no loader options found in configuration file"
890       printf "\n      for \"$remote_host_string\" "
891       locat=config_file; exit
892    fi
893
894
895    printf "\n\n#------------------------------------------------------------------------# \n"
896    if [[ $remote_host = $local_host ]]
897    then
898       column1="remote_host:"; column2="$remote_host (= local host!)"
899    else
900       column1="remote_host:"; column2=$remote_host
901    fi
902    printf "| $column1$column2 | \n"
903    printf "|                                                                        | \n"
904    column1="conditions:"; column2="$condition1 $condition2"
905    printf "| $column1$column2 | \n"
906    column1="make depository:"; column2=$remote_md
907    printf "| $column1$column2 | \n"
908    line=$(echo "$remote_md" | cut -c51-)
909    while [[ "$line" != "" ]]
910    do
911       column1=""
912       column2=$line
913       printf "| $column1$column2 | \n"
914       line=$(echo "$line" | cut -c51-)
915    done
916    if [[ $compile_utility_programs = true ]]
917    then
918       column1="utility directory:"; column2=$remote_ud
919       printf "| $column1$column2 | \n"
920    fi
921    column1="username:"; column2=$remote_username
922    printf "| $column1$column2 | \n"
923    column1="addres:"; column2=$remote_addres
924    printf "| $column1$column2 | \n"
925    column1="compiler:"; column2=$compiler_name
926    printf "| $column1$column2 | \n"
927    if [[ $compile_utility_programs = true ]]
928    then
929       column1="serial compiler:"; column2=$compiler_name_ser
930       printf "| $column1$column2 | \n"
931    fi
932    if [[ "$make_options" != "" ]]
933    then
934       column1="make options:"; column2=$make_options
935       printf "| $column1$column2 | \n"
936    fi
937    column1="cpp options:"; column2=$cpp_options
938    printf "| $column1$column2 | \n"
939    line=$(echo "$cpp_options" | cut -c51-)
940    while [[ "$line" != "" ]]
941    do
942       column1=""
943       column2=$line
944       printf "| $column1$column2 | \n"
945       line=$(echo "$line" | cut -c51-)
946    done
947    column1="compiler options:"; column2=$compiler_options
948    printf "| $column1$column2 | \n"
949    line=$(echo "$compiler_options" | cut -c51-)
950    while [[ "$line" != "" ]]
951    do
952       column1=""
953       column2=$line
954       printf "| $column1$column2 | \n"
955       line=$(echo "$line" | cut -c51-)
956    done
957    column1="loader options:"; column2=$loader_options
958    printf "| $column1$column2 | \n"
959    line=$(echo "$loader_options" | cut -c51-)
960    while [[ "$line" != "" ]]
961    do
962       column1=""
963       column2=$line
964       printf "| $column1$column2 | \n"
965       line=$(echo "$line" | cut -c51-)
966    done
967    if [[ $modules != "" ]]
968    then
969       column1="modules to be load:"; column2=$modules
970       printf "| $column1$column2 | \n"
971       line=$(echo "$modules" | cut -c51-)
972       while [[ "$line" != "" ]]
973       do
974          column1=""
975          column2=$line
976          printf "| $column1$column2 | \n"
977          line=$(echo "$line" | cut -c51-)
978       done
979    fi
980    printf "#------------------------------------------------------------------------# \n"
981
982    if [[ $silent = false ]]
983    then
984       answer=dummy
985       printf "\n\n"
986       while [[ "$answer" != y  &&  "$answer" != Y  && "$answer" != c  &&  "$answer" != C  && "$answer" != s  &&  "$answer" != S  &&  "$answer" != a  &&  "$answer" != A ]]
987       do
988          printf " >>> continue (y(es)/c(ontinue)/a(bort)/s(skip)) ?  "
989          read  answer
990       done
991       if [[ $answer = a  ||  $answer = A ]]
992       then
993          locat=user_abort; exit
994       fi
995       if [[ $answer = c  ||  $answer = C ]]
996       then
997          silent=true
998       fi
999       if [[ $answer = s  ||  $answer = S ]]
1000       then
1001          continue
1002       fi
1003    fi
1004
1005
1006       # make on remote host
1007    if [[ $remote_host != $local_host ]]
1008    then
1009
1010       if [[ $compile_utility_programs = false ]]
1011       then
1012
1013             # AKTUELLE QUELLTEXTVERSION INS REMOTE-QUELLTEXTVERZEICHNIS KOPIEREN
1014             # FALLS DIESES NOCH NICHT EXISTIERT, WIRD ES ERZEUGT
1015          echo "  *** copying \"${mainprog}_sources.tar\" to \"${remote_addres}:${remote_md}/\" "
1016          if [[ $remote_host != lctit ]]
1017          then
1018             ssh  ${remote_username}@${remote_addres} "[[ ! -d ${remote_md} ]]  &&  (echo \"  *** ${remote_md} will be created\"; mkdir -p  ${remote_md})"
1019          else
1020                # TIT ERLAUBT NUR DIE AUSFï¿œHRUNG GANZ BESTIMMTER KOMMANDOS
1021                # MIT SSH, DESHALB AUFRUF PER PIPE
1022             print "[[ ! -d ${remote_md} ]]  &&  (echo \"  *** ${remote_md} will be created\"; mkdir -p  ${remote_md})"  |  ssh ${remote_username}@${remote_addres}  2>&1
1023          fi
1024          if [[ $local_host = decalpha ]]
1025          then
1026                # DECALPHA BENUTZT BEI NICHTANGABE DES VOLLSTï¿œNDIGEN PFADES
1027                # IRGENDEIN ANDERES SCP (WAS NICHT FUNKTIONIERT). AUSSERDEM
1028                # KOENNEN DOLLAR-ZEICHEN NICHT BENUTZT WERDEN
1029             remote_md=`echo $remote_md | sed 's/\$HOME\///'`
1030             /bin/scp  ${local_source_path}/${mainprog}_sources.tar  ${remote_username}@${remote_addres}:${remote_md}/${mainprog}_sources.tar
1031          else
1032             scp  ${local_source_path}/${mainprog}_sources.tar  ${remote_username}@${remote_addres}:${remote_md}/${mainprog}_sources.tar
1033          fi
1034
1035
1036
1037             # FALLS VORHANDEN, LETZTE VERSION AUF DEM REMOTE-RECHNER AUSPACKEN
1038          echo "  *** untar previous update on remote host, if existing"
1039          if [[ $remote_host != lctit ]]
1040          then
1041             ssh  ${remote_username}@${remote_addres}  "cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]]  &&  tar -xf  ${mainprog}_current_version.tar"
1042          else
1043                # TIT ERLAUBT NUR DIE AUSFï¿œHRUNG GANZ BESTIMMTER KOMMANDOS
1044                # MIT SSH, DESHALB AUFRUF PER PIPE
1045             print  "cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]]  &&  tar -xf  ${mainprog}_current_version.tar"  |  ssh  ${remote_username}@${remote_addres}  2>&1
1046          fi
1047
1048
1049             # AKTUELLE QUELLTEXTVERSION AUF REMOTE-RECHNER AUSPACKEN
1050          echo "  *** untar actual sources on remote host"
1051          if [[ $remote_host != lctit ]]
1052          then
1053             ssh  ${remote_username}@${remote_addres}  "cd ${remote_md}; tar -xf  ${mainprog}_sources.tar"
1054          else
1055                # TIT ERLAUBT NUR DIE AUSFï¿œHRUNG GANZ BESTIMMTER KOMMANDOS
1056                # MIT SSH, DESHALB AUFRUF PER PIPE
1057             print  "cd ${remote_md}; tar -xf  ${mainprog}_sources.tar"  |  ssh  ${remote_username}@${remote_addres}  2>&1
1058          fi
1059
1060
1061             # MAKE MIT ZUVOR ERMITTELTEN OPTIONEN AUF REMOTE RECHNER AUSFUEHREN
1062             # KOMMANDOUEBERGABE AN SSH PER PIPE, DA SO DIE SYSTEM- UND
1063             # BENUTZERPROFILE VOLLSTAENDIG AUSGEFUEHRT WERDEN (SONST FEHLEN MAKE
1064             # Z.B. DIE PFADE ZUM COMPILER)
1065          echo "  *** execute \"make\" on remote host"
1066
1067
1068             # generate make call with make options
1069          if [[ $remote_host = nech ]]
1070          then
1071             make_call_string="sxmake  $make_options  PROG=$mainprog  F90=$compiler_name  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$loader_options\" "
1072          else
1073             make_call_string="make  $make_options  PROG=$mainprog  F90=$compiler_name  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$loader_options\" "
1074          fi
1075
1076             # generate command to load modules, if modules are given
1077          if [[ "$modules" != "" ]]
1078          then
1079             if [[ $remote_host = lctit ]]
1080             then
1081                module_calls=". $modules"
1082             else
1083                module_calls="module load ${modules};"
1084             fi
1085
1086                # bugfix for wrong netcdf module
1087             if [[ $remote_host = lcsgib  ||  $remote_host = lcsgih ]]
1088             then
1089                if [[ $(echo $module_calls | grep -c netcdf/3.6.3-intel) != 0 ]]
1090                then
1091                   module_calls="$module_calls export LD_LIBRARY_PATH=/sw/dataformats/netcdf/3.6.3-intel/lib:\$LD_LIBRARY_PATH;"
1092                fi
1093             fi
1094          else
1095             module_calls=""
1096          fi
1097
1098          if [[ $remote_host = ibmkisti  ||  $remote_host = ibms  ||  $remote_host = ibmy ]]
1099          then
1100
1101             ssh  ${remote_username}@${remote_addres}  "$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
1102
1103          elif [[ $remote_host = ibmh ]]
1104          then
1105
1106             print "$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_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
1107
1108          elif [[ $remote_host = lcsgib  ||  $remote_host = lcsgih ]]
1109          then
1110
1111#             print ". /usr/share/modules/init/bash; $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_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
1112             print "eval \`/sw/swdist/bin/modulesinit\`; $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_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
1113
1114          elif [[ $remote_host = lctit ]]
1115          then
1116
1117             echo  " "  >  ${remote_host}_last_make_protokoll
1118             while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]]
1119             do
1120                print "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_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
1121             done
1122
1123          elif [[ $remote_host = lcxt4 ]]
1124          then
1125
1126             ssh  ${remote_username}@${remote_addres} ". /opt/modules/default/init/ksh; $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
1127
1128          else
1129
1130             print "cd $module_calls ${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_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
1131
1132          fi
1133
1134          if [[ $(grep -c MAKE_ERROR ${remote_host}_last_make_protokoll) != 0 ]]
1135          then
1136             printf "\a\n  +++ error(s) occurred during compiling or linking on host \"$remote_host\" "
1137             if [[ $silent = false ]]
1138             then
1139                answer=dummy
1140                printf "\n"
1141                while [[ "$answer" != c  &&  "$answer" != k ]]
1142                do
1143                   printf "  >>> continue / list errors / kill mbuild (c/l/k) ? "
1144                   read  answer
1145                   if [[ "$answer" = l ]]
1146                   then
1147                      more ${remote_host}_last_make_protokoll
1148                   fi
1149                done
1150                if [[ $answer = k ]]
1151                then
1152                   locat=user_abort; exit
1153                fi
1154             fi
1155          fi
1156
1157
1158
1159             # NEUE VERSION AUF REMOTE-RECHNER ZUSAMMENPACKEN
1160          printf "\n  *** tar update on remote host ..."
1161          if [[ $remote_host != lctit ]]
1162          then
1163             ssh  ${remote_username}@${remote_addres}  "cd ${remote_md}; chmod u+w *; tar -cf  ${mainprog}_current_version.tar  ${mainprog}  *.f90 *.o *.mod"
1164          else
1165                # TIT ERLAUBT NUR DIE AUSFï¿œHRUNG GANZ BESTIMMTER KOMMANDOS
1166                # MIT SSH, DESHALB AUFRUF PER PIPE
1167             print  "cd ${remote_md}; chmod u+w *; tar -cf  ${mainprog}_current_version.tar  ${mainprog}  *.f90 *.o *.mod"  |  ssh  ${remote_username}@${remote_addres}  2>&1
1168          fi
1169
1170
1171             # AKTUELLES VERSIONSVERZEICHNIS AUF REMOTE-RECHNER BEREINIGEN
1172#          printf "\n  *** \"make clean\" on remote host ..."
1173#          ssh  ${remote_username}@${remote_addres}  "cd ${remote_md}; make clean; rm ${mainprog}_sources.tar; rm *.f90 Makefile"
1174#          printf "\n"
1175
1176
1177
1178
1179          # GLEICHE AKTIONEN FUER DIE UTILITY-PROGRAMME DURCHFUEHREN
1180          # AKTUELLE QUELLTEXTVERSION INS REMOTE-QUELLTEXTVERZEICHNIS KOPIEREN
1181          # FALLS DIESES NOCH NICHT EXISTIERT, WIRD ES ERZEUGT
1182       elif [[ $compile_utility_programs = true ]]
1183       then
1184
1185          printf "\n\n"
1186          echo "  *** copying scripts and utility programs to \"${remote_addres}:${remote_ud}/\" "
1187          cd  ${local_source_path}/../SCRIPTS
1188
1189          if [[ $remote_host != lctit ]]
1190          then
1191             ssh  ${remote_username}@${remote_addres} "[[ ! -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)"
1192          else
1193                # TIT ERLAUBT NUR DIE AUSFUEHRUNG GANZ BESTIMMTER KOMMANDOS
1194                # MIT SSH, DESHALB AUFRUF PER PIPE
1195             print "[[ ! -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_addres}  2>&1
1196          fi
1197
1198             # KOPIEREN DER SCRIPTE
1199          if [[ $local_host = decalpha ]]
1200          then
1201                # DECALPHA BENUTZT BEI NICHTANGABE DES VOLLSTAENDIGEN PFADES
1202                # IRGENDEIN ANDERES SCP (WAS NICHT FUNKTIONIERT). AUSSERDEM
1203                # KOENNEN DOLLAR-ZEICHEN NICHT BENUTZT WERDEN
1204             remote_ud=`echo $remote_ud | sed 's/\$HOME\///'`
1205             /bin/scp  batch_scp mbuild mrun process_dvr_output .dvrserver.config subjob  ${remote_username}@${remote_addres}:${remote_ud}/../SCRIPTS  >  /dev/null
1206          else
1207             scp  batch_scp mbuild mrun process_dvr_output .dvrserver.config subjob  ${remote_username}@${remote_addres}:${remote_ud}/../SCRIPTS  >  /dev/null
1208          fi
1209
1210          cd  -  > /dev/null
1211          cd  ${local_source_path}/../UTIL
1212
1213
1214             # KOPIEREN DER UTILITY-PROGRAMME
1215          if [[ $local_host = decalpha ]]
1216          then
1217                # DECALPHA BENUTZT BEI NICHTANGABE DES VOLLSTï¿œNDIGEN PFADES
1218                # IRGENDEIN ANDERES SCP (WAS NICHT FUNKTIONIERT). AUSSERDEM
1219                # KOENNEN DOLLAR-ZEICHEN NICHT BENUTZT WERDEN
1220             remote_ud=`echo $remote_ud | sed 's/\$HOME\///'`
1221             /bin/scp  Makefile  *.f90  ${remote_username}@${remote_addres}:${remote_ud}  >  /dev/null
1222          else
1223             scp  Makefile  *.f90  ${remote_username}@${remote_addres}:${remote_ud}  >  /dev/null
1224          fi
1225
1226
1227
1228             # MAKE MIT ZUVOR ERMITTELTEN OPTIONEN AUF REMOTE RECHNER AUSFUEHREN
1229             # KOMMANDOUEBERGABE AN SSH PER PIPE, DA SO DIE SYSTEM- UND
1230             # BENUTZERPROFILE VOLLSTAENDIG AUSGEFUEHRT WERDEN (SONST FEHLEN MAKE
1231             # Z.B. DIE PFADE ZUM COMPILER)
1232          echo "  *** execute \"make\" on remote host"
1233
1234          if [[ $remote_host = nech ]]
1235          then
1236             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\" "
1237          else
1238             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\" "
1239          fi
1240
1241             # generate command to load modules, if modules are given
1242          if [[ "$modules" != "" ]]
1243          then
1244             if [[ $remote_host = lctit ]]
1245             then
1246                module_calls=". $modules"
1247             else
1248                module_calls="module load ${modules};"
1249             fi
1250
1251                # bugfix for wrong netcdf module
1252             if [[ $remote_host = lcsgib  ||  $remote_host = lcsgih ]]
1253             then
1254                if [[ $(echo $module_calls | grep -c netcdf/3.6.3-intel) != 0 ]]
1255                then
1256                   module_calls="$module_calls export LD_LIBRARY_PATH=/sw/dataformats/netcdf/3.6.3-intel/lib:\$LD_LIBRARY_PATH;"
1257                fi
1258             fi
1259          else
1260             module_calls=""
1261          fi
1262
1263          if [[ $remote_host = ibms  ||  $remote_host = ibmy ]]
1264          then
1265
1266             ssh  ${remote_username}@${remote_addres}  "$module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR"
1267
1268          elif [[ $remote_host = ibmh ]]
1269          then
1270
1271             print "$module_calls export OBJECT_MODE=64; cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres}
1272
1273          elif [[ $remote_host = lctit ]]
1274          then
1275
1276             echo  " "  >  ${remote_host}_last_make_protokoll
1277             while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]]
1278             do
1279                print "$module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
1280             done
1281
1282          elif [[ $remote_host = lcxt4 ]]
1283          then
1284
1285             ssh  ${remote_username}@${remote_addres} ". /opt/modules/default/init/ksh; $module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" 2>&1 | tee ${remote_host}_last_make_protokoll
1286
1287          else
1288
1289             print "$module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
1290
1291          fi
1292
1293       fi    # ENDE UEBERSETZUNG DER UTILITY-PROGRAMME
1294
1295       rm -rf  ${remote_host}_last_make_protokoll
1296
1297       # make on local host
1298    else
1299
1300          # workaround for lcxt4
1301       if [[ $remote_host = lcxt4 ]]
1302       then
1303          . /opt/modules/default/init/ksh
1304       fi
1305
1306       # first load modules, if given
1307       if [[ "$modules" != "" ]]
1308       then
1309          if [[ $remote_host = lctit ]]
1310          then
1311             . $modules
1312          else
1313             module load ${modules}
1314          fi
1315       fi
1316
1317
1318       if [[ $compile_utility_programs = false ]]
1319       then
1320
1321             # DEPOSITORY VERZEICHNIS ERZEUGEN, FALLS NOCH NICHT VORHANDEN
1322          eval remote_md=$remote_md
1323          if [[ ! -d $remote_md ]]
1324          then
1325             if  mkdir $remote_md
1326             then
1327                printf "\n\n  *** directory for make depository:"
1328                printf "\n           $remote_md"
1329                printf "\n      was created\n"
1330             else
1331                printf "\n  +++ directory for make depository:"
1332                printf "\n           $remote_md"
1333                printf "\n      cannot be created"
1334                locat=local_depository_path; exit
1335             fi
1336          fi
1337
1338             # QUELLTEXT-DATEIEN AUS REPOSITORY INS DEPOSITORY KOPIEREN
1339          echo " "
1340          echo "  *** updating sources in $remote_md"
1341          cd  $remote_md
1342          cp  $local_source_path/${mainprog}_sources.tar  .
1343          tar xf  ${mainprog}_sources.tar
1344
1345             # MAKE MIT ZUVOR ERMITTELTEN OPTIONEN AUF LOKALEM RECHNER AUSFUEHREN
1346          echo " "
1347          echo "  *** execute \"make\" on local host"
1348
1349          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
1350
1351          if [[ $? != 0 ]]
1352          then
1353             printf "\a\n  +++ error(s) occurred during compiling or linking on host \"$remote_host\" "
1354             if [[ $silent = false ]]
1355             then
1356                answer=dummy
1357                printf "\n"
1358                while [[ "$answer" != c  &&  "$answer" != k ]]
1359                do
1360                   printf "  >>> continue / list errors / kill mbuild (c/l/k) ? "
1361                   read  answer
1362                   if [[ "$answer" = l ]]
1363                   then
1364                      more ${remote_host}_last_make_protokoll
1365                   fi
1366                done
1367                if [[ $answer = k ]]
1368                then
1369                   locat=user_abort; exit
1370                fi
1371             fi
1372          fi
1373
1374
1375             # TAR NEW VERSION ON LOCAL HOST
1376          printf "\n  *** tar update on local host ..."
1377          tar -cf  ${mainprog}_current_version.tar  *.$suf *.o *.mod
1378
1379
1380          # COMPILE THE UTILITY PROGRAMS
1381       elif [[ $compile_utility_programs = true ]]
1382       then
1383          printf "\n\n"
1384          echo "  *** compiling the utility programs ..."
1385          cd ${local_source_path}/../UTIL
1386
1387             # TOUCH FILES IN ORDER TO FORCE COMPILATION FOR EVERY BLOCK
1388          touch  *.f90
1389          make  $make_options  BLOCK=$block  F90=$compiler_name  F90_SER=$compiler_name_ser  COPT="$cpp_options"  F90FLAGS="$compiler_options"  LDFLAGS="$loader_options"
1390
1391             # CHECK IF QMAKE IS AVAILABLE AND COMPILE MRUNGUI
1392          printf "\n\n"
1393          echo "  *** compiling the mrun GUI"
1394          if which qmake >/dev/null; then
1395             cd mrungui
1396             touch *
1397             qmake
1398             make
1399             make clean
1400             rm Makefile
1401             cd ..
1402          else
1403             echo "  +++ no qmake found. The (optional) GUI will not be compiled."
1404          fi
1405
1406             # COMPILE CHECK_NAMELIST_FILES
1407          printf "\n\n"
1408          echo "  *** compiling check_namelist_files ..."
1409
1410          check_depository_path=${local_source_path}/../UTIL
1411          cd $check_depository_path
1412          mkdir check_tmp
1413          mv ${local_source_path}/${mainprog}_sources_check.tar ./check_tmp
1414          cd check_tmp
1415          tar -xf  ${mainprog}_sources_check.tar
1416          rm -rf ${mainprog}_sources_check.tar
1417
1418          copts_check="-cpp -D_parallel -D__check"
1419          make  -f Makefile_check $make_options F90=$compiler_name_ser  COPT="$copts_check"
1420
1421          tar -cf  check_namelist_files.tar Makefile_check check_namelist_files.x *.f90 *.o *.mod
1422          mv check_namelist_files.tar $check_depository_path
1423          mv check_namelist_files.x $PALM_BIN
1424          cd $check_depository_path
1425          rm -rf check_tmp
1426
1427       fi
1428    fi
1429 done
1430
1431
1432 if [[ $host_found = false ]]
1433 then
1434    if [[ $host = all ]]
1435    then
1436       printf "\n  +++ no hosts found in configuration file"
1437    else
1438       printf "\n  +++ host \"$host\" not found in configuration file"
1439    fi
1440    locat=config_file; exit
1441 fi
1442
1443
1444
1445    # FINAL WORK
1446 rm -f  hosts_found_in_config_file
1447
Note: See TracBrowser for help on using the repository browser.