source: palm/trunk/SCRIPTS/palmbuild @ 2411

Last change on this file since 2411 was 2410, checked in by Giersch, 7 years ago

Revise error message PA0462 and change lclocal to lcmuk in testsuite

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 27.7 KB
Line 
1#!/bin/bash
2
3# palmbuild - 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 2017  Leibniz Universitaet Hannover
20#------------------------------------------------------------------------------#
21#
22# Current revisions:
23# ------------------
24#
25#
26# Former revisions:
27# -----------------
28# $Id: palmbuild 2410 2017-09-06 08:16:30Z raasch $
29# Initial revision
30#
31# 2404 2017-09-05 09:33:14Z raasch
32#
33#------------------------------------------------------------------------------#
34# palmbuild - script for compiling the PALM code and its utility programs
35#
36# Procedure to compile code on local and remote hosts using the
37# make-mechanism. The source code must be provided on the local host.
38#
39# @note This script does not work on MAC OS
40#------------------------------------------------------------------------------#
41
42
43    # VARIABLE DECLARATIONS + DEFAULT VALUES
44 calltime=""
45 column1=""
46 column2=""
47 config_file=.palm.config
48 host=default
49 host_found=false
50 locat=normal
51 makefile=""
52 make_options=""
53 module_commands=""
54 program_name=palm
55 remote_ip=""
56 silent=false
57 ssh_key=""
58 suf=f90
59 version="palmbuild  0.1  Rev$Rev: 2316 $"
60 working_directory=`pwd`
61
62
63
64    # ERROR HANDLING
65    # IN CASE OF EXIT:
66 trap 'if [[ $locat != normal ]]
67       then
68          printf "\n\n +++ palmbuild killed \n\n"
69          exit 1
70       else
71          printf "\n\n *** palmbuild finished \n\n"
72          exit 0
73       fi' exit
74
75
76    # IN CASE OF TERMINAL-BREAK:
77 trap 'printf "\n\n +++ palmbuild killed by \"^C\" \n\n"
78       exit
79      ' 2
80
81
82
83    # READ SHELLSCRIPT-OPTIONS
84 while  getopts  :d:h:m:s:S:uv  option
85 do
86   case  $option  in
87       (d)   fname=$OPTARG;;
88       (h)   host=$OPTARG;;
89       (m)   makefile=$OPTARG;;
90       (s)   suf=$OPTARG;;
91       (S)   source_list="$OPTARG";;
92       (v)   silent=true;;
93       (\?)  printf "\n  +++ unknown option $OPTARG \n";
94             locat=parameter; exit;;
95   esac
96 done
97
98
99    # BUILD THE CONFIGURATION-FILE NAME
100 config_file=${config_file}.$host
101
102
103    # CHECK, IF CONFIGURATION-FILE EXISTS
104 if [[ ! -f $config_file ]]
105 then
106    printf "\n  +++ configuration file: "
107    printf "\n           $config_file"
108    printf "\n      does not exist"
109    locat=configuration; exit 
110 fi
111
112
113    # ### is this really required?
114 config_file=$PWD/$config_file
115
116
117    # READ VARIABLE SETTINGS FROM CONFIG FILE LINE BY LINE
118 while  read line
119 do
120
121       # FIRST REPLACE ENVIRONMENT-VARIABLES BY THEIR RESPECTIVE VALUES
122    eval  line=\"$line\"
123
124
125       # INTERPRET THE LINE
126    if [[ "$(echo $line)" = "" ]]
127    then
128
129          # EMPTY LINE, NO ACTION
130       continue
131
132    elif [[ "$(echo $line | cut -c1)"  =  "#" ]]
133    then
134
135          # LINE IS A COMMENT LINE
136       continue
137
138    elif [[ "$(echo $line | cut -c1)"  =  "%" ]]
139    then
140
141          # LINE DEFINES AN ENVIRONMENT-VARIABLE
142       var=`echo $line | cut -d" " -s -f1 | cut -c2-`
143       value=`echo $line | cut -d" " -s -f2-`
144
145          # REPLACE ":" BY " " IN COMPILER- CPP- OR LINKER-OPTIONS,
146          # "::" IS REPLACED BY ":".
147       #value=`echo $value | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
148
149
150          # VALUE FROM THE CONFIGURATION-FILE IS ASSIGNED TO THE
151          # ENVIRONMENT-VARIABLE, BUT ONLY IF NO VALUE HAS BEEN ALREADY
152          # ASSIGNED WITHIN THIS SCRIPT (E.G. BY SCRIPT-OPTIONS).
153          # NON-ASSIGNED VARIABLES HAVE VALUE "" OR 0 (IN CASE OF INTEGER).
154          # HENCE THE GENERAL RULE IS: SCRIPT-OPTION OVERWRITES THE
155          # CONFIGURATION-FILE.
156       if [[ "$(eval echo \$$var)" = ""  ||  "$(eval echo \$$var)" = "0" ]]
157       then
158          eval  export  $var="\$value"
159
160             # TERMINAL OUTPUT OF ENVIRONMENT-VARIABLES, IF TRACEBACK IS SWITCHED on
161          if [[ $do_trace = true ]]
162          then
163             printf "\n*** ENVIRONMENT-VARIABLE $var = $value"
164          fi
165       fi
166
167    else
168
169          # SKIP ALL OTHER LINES
170       continue
171
172    fi
173
174 done < $config_file
175
176 
177    # CHECK, IF THE BASE DIRECTORY PATH HAS BEEN GIVEN
178 if [[ "$base_directory" = "" ]]
179 then
180    printf "\n  +++ no base directory found in configuration file"
181    locat=config_file; exit
182 else
183    if [[ ! -d $base_directory ]]
184    then
185       printf "\n\n  +++ base directory \"$base_directory\" "
186       printf "\n      does not exist"
187       locat=source_path; exit
188    fi
189 fi
190
191
192    # CHECK SOURCE-CODE PATH
193 if [[ "$source_path" = "" ]]
194 then
195    printf "\n  +++ no source path found in configuration file"
196    locat=config_file; exit
197 else
198    if [[ ! -d $source_path ]]
199    then
200       printf "\n\n  +++ source path \"$source_path\" "
201       printf "\n      does not exist"
202       locat=source_path; exit
203    fi
204 fi
205
206
207    # CHECK MAKEFILE
208 [[ "$makefile" = "" ]]  &&  makefile=$source_path/Makefile
209 if [[ ! -f $makefile ]]
210 then
211    printf "\n  +++ makefile: "
212    printf "\n           $makefile"
213    printf "\n      does not exist"
214    locat=makefile; exit 
215 fi
216
217
218    # CHECK COMPILERNAME
219 if [[ "$compiler_name" = "" ]]
220 then
221    printf "\n  +++ no compiler name found in configuration file"
222    locat=config_file; exit
223 fi
224
225
226    # CHECK SERIAL COMPILERNAME
227 if [[ "$compiler_name_ser" = "" ]]
228 then
229    printf "\n  +++ no compiler name for serial compilation in configuration file"
230    locat=config_file; exit
231 fi
232
233
234    # DETERMINE SSH-KEY TO BE USED
235 if [[ "$ssh_key" != "" ]]
236 then
237    ssh_key="-i $HOME/.ssh/`echo $line | cut -d" " -s -f2`"
238 fi
239
240
241    #CHECK CPP-OPTIONS
242 if [[ "$cpp_options" = "" ]]
243 then
244    printf "\n  +++ WARNING: no cpp-options found in configuration file"
245 fi
246
247
248    # CHECK SETTINGS IN CASE OF COMPILING ON REMOTE MACHINE
249 if [[ "$remote_ip" != "" ]]
250 then
251 
252    if [[ "$remote_username" = "" ]]
253    then
254       printf "\n  +++ no user name given in configuration file"
255       locat=config_file; exit
256    fi
257
258    [[ "$remote_hostname" = "" ]]  &&  remote_hostname=$remote_ip 
259
260
261       # GET SOURCE AND DEPOSITORY PATH ON THE REMOTE MACHINE WITHOUT EVALUATING
262       # THE $
263       # IF NOT GIVEN, USE THE LOCAL SOURCE AND DEPOSITORY PATH
264    line=`grep %remote_source_path $config_file`
265    if [[ "$line" != "" ]]
266    then
267       remote_source_path=`echo $line | cut -d" " -s -f2`
268    else
269       line=`grep %source_path $config_file`
270       remote_source_path=`echo $line | cut -d" " -s -f2`
271    fi
272
273    line=`grep %base_directory $config_file`
274    make_depository=`echo $line | cut -d" " -s -f2`/MAKE_DEPOSITORY_${host}
275
276 else
277
278    make_depository=${base_directory}/MAKE_DEPOSITORY_${host}
279
280 fi
281
282    # HEADER-OUTPUT (PART1: MESSAGES CONCERNING THE LOCAL HOST)
283 calltime=$(date)
284 printf "\n"
285 printf "#------------------------------------------------------------------------# \n"
286 printf "| %-40s%30s | \n" "$version" "$calltime"
287 printf "|                                                                        | \n"
288 printf "| %-13s%-57s | \n" "called on:" "$local_hostname"
289 column2=$(echo $config_file | cut -c1-57 )
290 printf "| %-13s%-57s | \n" "config file:" "$column2"
291 line=$(echo "$config_file" | cut -c58-)
292 while [[ "$line" != "" ]]
293 do
294    column1=""
295    column2=$(echo $line | cut -c1-57 )
296    printf "| %-13s%-57s | \n" "$column1" "$column2"
297    line=$(echo "$line" | cut -c58-)
298 done
299 column2=$(echo $makefile | cut -c1-57 )
300 printf "| %-13s%-57s | \n" "makefile:" "$column2"
301 line=$(echo "$makefile" | cut -c58-)
302 while [[ "$line" != "" ]]
303 do
304    column1=""
305    column2=$(echo $line | cut -c1-57 )
306    printf "| %-13s%-57s | \n" "$column1" "$column2"
307    line=$(echo "$line" | cut -c58-)
308 done
309 column2=$(echo $source_path | cut -c1-57 )
310 printf "| %-13s%-57s | \n" "source path:" "$column2"
311 line=$(echo "$source_path" | cut -c58-)
312 while [[ "$line" != "" ]]
313 do
314    column1=""
315    column2=$(echo $line | cut -c1-57 )
316    printf "| %-13s%-57s | \n" "$column1" "$column2"
317    line=$(echo "$line" | cut -c58-)
318 done
319 printf "#------------------------------------------------------------------------# \n"
320
321
322
323    # TAR THE SOURCES AND MAKEFILES
324    # UTILITIES ARE TEMPORARILY COPIED TO THE SOURCE DIRECTORY IN ORDER TO TAR
325    # THEM TOO
326 cd  $source_path
327 printf "\n\n  *** tar of makefile and source files in"
328 printf "\n      $source_path"
329 cp -p  ../UTIL/combine_plot_fields.f90  .
330 cp -p  ../UTIL/compare_palm_logs.f90  .
331 cp -p  ../UTIL/Makefile_utilities  .
332 tar -cf  ${program_name}_sources.tar  Makefile*  *.$suf
333 rm  combine_plot_fields.f90  compare_palm_logs.f90  Makefile_utilities
334 printf "\n"
335
336
337
338    # GET CONFIRMATION TO CONTINUE
339 printf "\n  *** update will be made for host \"$host\" "
340
341
342 if [[ $silent = false ]]
343 then
344    answer=dummy
345    printf "\n\n"
346    while [[ "$answer" != y  &&  "$answer" != Y  &&  "$answer" != n  &&  "$answer" != N ]]
347    do
348       printf " >>> continue (y/n) ?  "
349       read  answer
350    done
351    if [[ $answer = n  ||  $answer = N ]]
352    then
353       locat=user_abort; exit
354    fi
355 fi
356
357
358
359
360    printf "\n\n#------------------------------------------------------------------------# \n"
361
362    if [[ "$remote_ip" != "" ]]
363    then
364       column2=$remote_hostname
365       printf "| %-20s%-50s | \n" "remote host:" "$column2"
366       printf "|                                                                        | \n"
367       column2=$(echo "$make_depository" | cut -c1-50 )
368       printf "| %-20s%-50s | \n" "remote depository:" "$column2"
369    else
370       column2=$local_hostname
371       printf "| %-20s%-50s | \n" "local host:" "$column2"
372       printf "|                                                                        | \n"
373       column2=$(echo "$make_depository" | cut -c1-50 )
374       printf "| %-20s%-50s | \n" "local depository:" "$column2"
375    fi
376    line=$(echo "$make_depository" | cut -c51-)
377    while [[ "$line" != "" ]]
378    do
379       column1=""
380       column2=$(echo "$line" | cut -c1-50 )
381       printf "| %-20s%-50s | \n" "$column1" "$column2"
382       line=$(echo "$line" | cut -c51-)
383    done
384
385    if [[ "$remote_ip" != "" ]]
386    then
387       printf "| %-20s%-50s | \n" "remote username:" "$remote_username"
388       printf "| %-20s%-50s | \n" "remote address:" "$remote_ip"
389    else
390       printf "| %-20s%-50s | \n" "username:" "$local_username"
391       printf "| %-20s%-50s | \n" "address:" "$local_ip"
392    fi
393
394    printf "| %-20s%-50s | \n" "compiler:" "$compiler_name"
395    printf "| %-20s%-50s | \n" "serial compiler:" "$compiler_name_ser"
396
397    if [[ "$make_options" != "" ]]
398    then
399       printf "| %-20s%-50s | \n" "make options:" "$make_options"
400    fi
401    column2=$(echo "$cpp_options" | cut -c1-50 )
402    printf "| %-20s%-50s | \n" "cpp options:" "$column2"
403    line=$(echo "$cpp_options" | cut -c51-)
404    while [[ "$line" != "" ]]
405    do
406       column1=""
407       column2=$(echo "$line" | cut -c1-50 )
408       printf "| %-20s%-50s | \n" "$column1" "$column2"
409       line=$(echo "$line" | cut -c51-)
410    done
411    column2=$(echo "$compiler_options" | cut -c1-50 )
412    printf "| %-20s%-50s | \n" "compiler options:" "$column2"
413    line=$(echo "$compiler_options" | cut -c51-)
414    while [[ "$line" != "" ]]
415    do
416       column1=""
417       column2=$(echo "$line" | cut -c1-50 )
418       printf "| %-20s%-50s | \n" "$column1" "$column2"
419       line=$(echo "$line" | cut -c51-)
420    done
421    column2=$(echo "$linker_options" | cut -c1-50 )
422    printf "| %-20s%-50s | \n" "linker options:" "$column2"
423    line=$(echo "$linker_options" | cut -c51-)
424    while [[ "$line" != "" ]]
425    do
426       column1=""
427       column2=$(echo "$line" | cut -c1-50 )
428       printf "| %-20s%-50s | \n" "$column1" "$column2"
429       line=$(echo "$line" | cut -c51-)
430    done
431    if [[ "$login_init_cmd" != "" ]]
432    then
433       column2=$(echo "$login_init_cmd" | cut -c1-50 )
434       printf "| %-20s%-50s | \n" "login init command:" "$column2"
435       line=$(echo "$login_init_cmd" | cut -c51-)
436       while [[ "$line" != "" ]]
437       do
438          column1=""
439          column2=$(echo "$line" | cut -c1-50 )
440          printf "| %-20s%-50s | \n" "$column1" "$column2"
441          line=$(echo "$line" | cut -c51-)
442       done
443    fi
444    if [[ "$module_commands" != "" ]]
445    then
446       column2=$(echo "$module_commands" | cut -c1-50 )
447       printf "| %-20s%-50s | \n" "module command(s):" "$column2"
448       line=$(echo "$module_commands" | cut -c51-)
449       while [[ "$line" != "" ]]
450       do
451          column1=""
452          column2=$(echo "$line" | cut -c1-50 )
453          printf "| %-20s%-50s | \n" "$column1" "$column2"
454          line=$(echo "$line" | cut -c51-)
455       done
456    fi
457    printf "#------------------------------------------------------------------------# \n"
458
459    if [[ $silent = false ]]
460    then
461       answer=dummy
462       printf "\n\n"
463       while [[ "$answer" != y  &&  "$answer" != Y  && "$answer" != c  &&  "$answer" != C  && "$answer" != s  &&  "$answer" != S  &&  "$answer" != a  &&  "$answer" != A ]]
464       do
465          printf " >>> continue (y(es)/c(ontinue)/a(bort)/s(skip)) ?  "
466          read  answer
467       done
468       if [[ $answer = a  ||  $answer = A ]]
469       then
470          locat=user_abort; exit
471       fi
472       if [[ $answer = c  ||  $answer = C ]]
473       then
474          silent=true
475       fi
476       if [[ $answer = s  ||  $answer = S ]]
477       then
478          continue
479       fi
480    fi
481
482
483       # MAKE ON REMOTE HOST
484    if [[ "$remote_ip" != "" ]]
485    then
486
487          # NEXT IS THE BRANCH FOR CREATING THE MAKE_DEPOSITORY_...
488       if [[ "$fname" = "" ]]
489       then
490
491             # COPY CURRENT SOURCE CODE TO SOURCE-CODE DIRECTORY ON THE REMOTE HOST
492             # CREATE THIS DIRECTORY, IF IT DOES NOT EXIST
493          echo "  *** copying \"${program_name}_sources.tar\" to \"${remote_ip}:${make_depository}/\" "
494          echo "[[ ! -d ${make_depository} ]]  &&  (echo \"  *** ${make_depository} will be created\"; mkdir -p  ${make_depository})"  |  ssh  -q  $ssh_key ${remote_username}@${remote_ip}  2>&1
495
496          scp  $ssh_key ${source_path}/${program_name}_sources.tar  ${remote_username}@${remote_ip}:${make_depository}/${program_name}_sources.tar
497
498
499
500             # UNTAR PREVIOUS UPDATE ON REMOTE HOST, IF EXISTING
501          echo "  *** untar previous update on remote host, if existing"
502          echo "cd ${make_depository}; [[ -f ${program_name}_current_version.tar ]]  &&  tar -xf  ${program_name}_current_version.tar"  |  ssh  -q  $ssh_key  ${remote_username}@${remote_ip}  2>&1
503
504
505             # UNTAR CURRENT SOURCES ON REMOTE HOST
506          echo "  *** untar current sources on remote host"
507          echo  "cd ${make_depository}; tar -xf  ${program_name}_sources.tar"  |  ssh  -q  $ssh_key  ${remote_username}@${remote_ip}  2>&1
508
509
510             # CREATE INIT AND MODULE COAMMNDS
511          [[ "$login_init_cmd" != "" ]]   &&  login_init_cmd=${login_init_cmd}";"
512          [[ "$module_commands" != "" ]]  &&  module_commands=${module_commands}";"
513
514
515             # FIRST CREATE EXECUTABLES FOR THE UTILITY ROUTINES
516          echo " "
517          echo "  *** creating utilities on remote host"
518          make_call_string="make  -f Makefile_utilities  $make_options  F90=$compiler_name  F90_SER=$compiler_name_ser  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$linker_options\" "
519          echo "$login_init_cmd $module_commands cd ${make_depository}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  -q  $ssh_key  ${remote_username}@${remote_ip} 2>&1 | tee ${remote_hostname}_last_make_protokoll
520
521          if [[ $(grep -c MAKE_ERROR ${remote_hostname}_last_make_protokoll) != 0 ]]
522          then
523             printf "\a\n  +++ error(s) occurred during compiling or linking of utilities"
524             printf "\n      on host \"$remote_hostname\" "
525             if [[ $silent = false ]]
526             then
527                answer=dummy
528                printf "\n"
529                while [[ "$answer" != c  &&  "$answer" != k ]]
530                do
531                   printf "  >>> continue / list errors / kill palmbuild (c/l/k) ? "
532                   read  answer
533                   if [[ "$answer" = l ]]
534                   then
535                      more ${remote_hostname}_last_make_protokoll
536                   fi
537                done
538                if [[ $answer = k ]]
539                then
540                   locat=user_abort; exit
541                fi
542             fi
543          fi
544
545
546             # NOW COMPILE THE PALM CODE
547             # COMMANDS WILL BE COMMUNICATED TO SSH VIA PIPE, SINCE THIS WAY THE SYSTEM- AND
548             # USER-PROFILES OF THE SHELL ARE COMPLETELY EXECUTED (OTHERWISE, MAKE
549             # MAY E.G. MISS THE COMPILER-PATHS)
550          echo " "
551          echo "  *** compile PALM sources on remote host"
552          make_call_string="make  $make_options  PROG=$program_name  F90=$compiler_name  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$linker_options\" "
553          echo "$login_init_cmd $module_commands cd ${make_depository}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  -q  $ssh_key  ${remote_username}@${remote_ip} 2>&1 | tee ${remote_hostname}_last_make_protokoll
554
555          if [[ $(grep -c MAKE_ERROR ${remote_hostname}_last_make_protokoll) != 0 ]]
556          then
557             printf "\a\n  +++ error(s) occurred during compiling or linking on host \"$remote_hostname\" "
558             if [[ $silent = false ]]
559             then
560                answer=dummy
561                printf "\n"
562                while [[ "$answer" != c  &&  "$answer" != k ]]
563                do
564                   printf "  >>> continue / list errors / kill palmbuild (c/l/k) ? "
565                   read  answer
566                   if [[ "$answer" = l ]]
567                   then
568                      more ${remote_hostname}_last_make_protokoll
569                   fi
570                done
571                if [[ $answer = k ]]
572                then
573                   locat=user_abort; exit
574                fi
575             fi
576          fi
577
578             # TAR UPDATED VERSION ON THE REMOTE HOST
579          printf "\n  *** tar update on remote host ..."
580          echo  "cd ${make_depository}; chmod u+w *; tar -cf  ${program_name}_current_version.tar  ${program_name}  *.f90 *.o *.mod *.x"  |  ssh  -q  $ssh_key  ${remote_username}@${remote_ip}  2>&1
581
582
583          # NOW COMES THE BRANCH FOR CREATING THE EXECUTABLE FOR THE CURRENT RUN
584          # INCLUDING E.G. USER-INTERFACE ROUTINES. ALSO ADD OTHER UTILITY EXECUTABLES. EVERYTHING IS
585          # COLLECTED IN DIRECTORY SOURCES_FOR_RUN_...
586       elif [[ "$fname" != "" ]]
587       then
588
589             # FIRST CHECK, IF A DEPOSITORY EXISTS ON THE REMOTE MACHINE
590          echo  "[[ ! -d ${make_depository} ]]  &&  echo depository not found" | ssh  -q  $ssh_key  ${remote_username}@${remote_ip} 2>&1 | tee ${remote_hostname}_last_make_protokoll
591
592
593             # COPY MAKE DEPOSITORY ON REMOTE MACHINE TO SOURCES_FOR_RUN_...
594          printf "\n  *** copy MAKE_DEPOSITORY_${host} on remote host to SOURCES_FOR_RUN_$fname \n"
595          echo  "rm -rf $fast_io_catalog/SOURCES_FOR_RUN_$fname; mkdir -p $fast_io_catalog/SOURCES_FOR_RUN_$fname; cp ${make_depository}/${program_name}_current_version.tar  $fast_io_catalog/SOURCES_FOR_RUN_$fname; cd $fast_io_catalog/SOURCES_FOR_RUN_$fname; tar xf ${program_name}_current_version.tar"  |  ssh  -q  $ssh_key  ${remote_username}@${remote_ip}  2>&1
596
597
598             # COPY CONTENTS OF SOURCES_FOR_RUN_... TO SOURCES_FOR_RUN_... ON THE REMOTE MACHINE
599          printf "\n  *** copy $base_directory/SOURCES_FOR_RUN_$fname to SOURCES_FOR_RUN_$fname on remote host \n"
600          scp  -q  $ssh_key  $base_directory/SOURCES_FOR_RUN_$fname/{*,.[!.]*}  ${remote_username}@${remote_ip}:${fast_io_catalog}/SOURCES_FOR_RUN_$fname
601
602
603             # CREATE EXECUTABLE FROM THE NEW/MODIFIED SOURCE FILES, IF THERE ARE ANY
604          if [[ $(ls -1 $base_directory/SOURCES_FOR_RUN_$fname/ | grep -c .$suf) != 0 ]]
605          then
606
607             make_call_string="make  $make_options  PROG=$program_name  F90=$compiler_name  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$linker_options\" "
608             [[ "$login_init_cmd" != "" ]]   &&  login_init_cmd=${login_init_cmd}";"
609             [[ "$module_commands" != "" ]]  &&  module_commands=${module_commands}";"
610             echo "  *** execute \"make\" on remote host"
611             echo "$login_init_cmd $module_commands cd ${fast_io_catalog}/SOURCES_FOR_RUN_$fname; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  -q  $ssh_key  ${remote_username}@${remote_ip} 2>&1 | tee ${remote_hostname}_last_make_protokoll
612
613             if [[ $(grep -c MAKE_ERROR ${remote_hostname}_last_make_protokoll) != 0 ]]
614             then
615                printf "\a\n  +++ error(s) occurred during compiling or linking on host \"$remote_hostname\" "
616                if [[ $silent = false ]]
617                then
618                   answer=dummy
619                   printf "\n"
620                   while [[ "$answer" != c  &&  "$answer" != k ]]
621                   do
622                      printf "  >>> continue / list errors / kill palmbuild (c/l/k) ? "
623                      read  answer
624                      if [[ "$answer" = l ]]
625                      then
626                         more ${remote_hostname}_last_make_protokoll
627                      fi
628                   done
629                   if [[ $answer = k ]]
630                   then
631                      locat=user_abort; exit
632                   fi
633                fi
634             fi
635
636          else
637
638             echo "  *** nothing to compile for this run"
639
640          fi
641
642       fi
643
644       rm -rf  ${remote_hostname}_last_make_protokoll
645
646
647       # MAKE ON LOCAL HOST
648    else
649
650
651          # NEXT IS THE BRANCH FOR CREATING THE MAKE_DEPOSITORY_... ON THE
652          # LOCAL HOST
653       if [[ "$fname" = "" ]]
654       then
655
656             # SET THE ENVIRONMENT (EXECUTE INIT AND MODULE COMMANDS)
657          if [[ "$login_init_cmd" != "" ]]
658          then
659             $login_init_cmd
660          fi
661
662          if [[ "$module_commands" != "" ]]
663          then
664             $module_commands
665          fi
666
667
668             # CREATE MAKE-DEPOSITORY, IF IT DOES NOT EXIST
669          eval make_depository=$make_depository
670          if [[ ! -d $make_depository ]]
671          then
672             if  mkdir -p $make_depository
673             then
674                printf "\n\n  *** directory for local make depository:"
675                printf "\n           $make_depository"
676                printf "\n      was created\n"
677             else
678                printf "\n  +++ directory for local make depository:"
679                printf "\n           $make_depository"
680                printf "\n      cannot be created"
681                locat=local_depository; exit
682             fi
683          fi
684
685             # COPY SOURCE-CODE FROM REPOSITORY TO MAKE-DEPOSITORY
686          echo " "
687          echo "  *** untar current source sources on local host in"
688          echo "      $make_depository"
689          cd  $make_depository
690          cp  $source_path/${program_name}_sources.tar  .
691          tar xf  ${program_name}_sources.tar
692
693
694             # FIRST CREATE EXECUTABLES FOR THE UTILITY ROUTINES
695          echo " "
696          echo "  *** creating utilities on local host"
697          make  -f Makefile_utilities  $make_options  F90=$compiler_name  F90_SER=$compiler_name_ser  COPT="$cpp_options"  F90FLAGS="$compiler_options"  LDFLAGS="$linker_options"
698
699
700             # CALL MAKE ON LOCAL HOST USING THE  OPTIONS DETERMINED FURTHER ABOVE
701          echo " "
702          echo "  *** compile PALM sources on local host"
703
704          make  $make_options  PROG=$program_name  F90=$compiler_name  COPT="$cpp_options"  F90FLAGS="$compiler_options"  LDFLAGS="$linker_options"  2>&1 | tee ${local_hostname}_last_make_protokoll
705
706          if [[ $? != 0 ]]
707          then
708             printf "\a\n  +++ error(s) occurred during compiling or linking on host \"$local_hostname\" "
709             if [[ $silent = false ]]
710             then
711                answer=dummy
712                printf "\n"
713                while [[ "$answer" != c  &&  "$answer" != k ]]
714                do
715                   printf "  >>> continue / list errors / kill palmbuild (c/l/k) ? "
716                   read  answer
717                   if [[ "$answer" = l ]]
718                   then
719                      more ${local_hostname}_last_make_protokoll
720                   fi
721                done
722                if [[ $answer = k ]]
723                then
724                   locat=user_abort; exit
725                fi
726             fi
727          fi
728
729
730             # TAR NEW VERSION ON LOCAL HOST
731          printf "\n  *** tar update on local host ..."
732          tar -cf  ${program_name}_current_version.tar  ${program_name} *.$suf *.o *.mod *.x
733
734       else
735
736             # NOW COMES THE BRANCH FOR CREATING THE EXECUTABLE FOR THE CURRENT RUN
737             # INCLUDING E.G. USER-INTERFACE ROUTINES. ALSO ADD OTHER UTILITY EXECUTABLES. EVERYTHING IS
738             # COLLECTED IN DIRECTORY SOURCES_FOR_RUN_...
739
740             # FIRST CHECK, IF A DEPOSITORY EXISTS ON THE LOCAL MACHINE
741          if [[ ! -d ${make_depository} ]]
742          then
743             printf "\n  +++ directory for local make depository:"
744             printf "\n           $make_depository"
745             printf "\n      not found. Please run \"palmbuild -h $host\" "
746             locat=make_depository; exit
747          fi
748
749
750             # COPY MAKE DEPOSITORY ON LOCAL MACHINE TO SOURCES_FOR_RUN_...
751          printf "\n  *** copy MAKE_DEPOSITORY_${host} on local host to "
752          printf "\n      $fast_io_catalog/SOURCES_FOR_RUN_$fname \n"
753          rm -rf $fast_io_catalog/SOURCES_FOR_RUN_$fname
754          mkdir -p $fast_io_catalog/SOURCES_FOR_RUN_$fname
755          cp ${make_depository}/${program_name}_current_version.tar  $fast_io_catalog/SOURCES_FOR_RUN_$fname
756          cd $fast_io_catalog/SOURCES_FOR_RUN_$fname
757          tar xf ${program_name}_current_version.tar
758
759
760             # COPY CONTENTS OF SOURCES_FOR_RUN_... TO SOURCES_FOR_RUN_...
761             # IN THE FAST_IO_CATALOG ON THE LOCAL MACHINE
762          printf "\n  *** copy $base_directory/SOURCES_FOR_RUN_$fname to"
763          printf "\n      $fast_io_catalog/SOURCES_FOR_RUN_$fname on local host \n"
764          cp  $base_directory/SOURCES_FOR_RUN_$fname/{*,.[!.]*}  ${}/SOURCES_FOR_RUN_$fname
765
766
767             # CREATE EXECUTABLE FROM THE NEW/MODIFIED SOURCE FILES, IF THERE ARE ANY
768          if [[ $(ls -1 $base_directory/SOURCES_FOR_RUN_$fname/ | grep -c .$suf) != 0 ]]
769          then
770
771             echo "  *** execute \"make\" on local host"
772             [[ "$login_init_cmd" != "" ]]   &&  $login_init_cmd
773             [[ "$module_commands" != "" ]]  &&  $module_commands
774
775             make  $make_options  PROG=$program_name  F90=$compiler_name  COPT="$cpp_options"  F90FLAGS="$compiler_options"  LDFLAGS="$linker_options"
776
777             if [[ \$? != 0 ]]
778             then
779
780                printf "\a\n  +++ error(s) occurred during compiling or linking on host \"$local_hostname\" "
781                if [[ $silent = false ]]
782                then
783                   answer=dummy
784                   printf "\n"
785                   while [[ "$answer" != c  &&  "$answer" != k ]]
786                   do
787                      printf "  >>> continue / list errors / kill palmbuild (c/k) ? "
788                      read  answer
789                   done
790                   if [[ $answer = k ]]
791                   then
792                      locat=user_abort; exit
793                   fi
794                fi
795             fi
796
797          else
798
799             echo "  *** nothing to compile for this run"
800
801          fi
802
803       fi
804    fi
Note: See TracBrowser for help on using the repository browser.