source: palm/trunk/SCRIPTS/palmbuild @ 2489

Last change on this file since 2489 was 2489, checked in by raasch, 4 years ago

ask for compilation, if SOURCES_FOR_RUN_... exists

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