source: palm/trunk/SCRIPTS/palmbuild @ 2487

Last change on this file since 2487 was 2487, checked in by raasch, 7 years ago

bugfix: abort in case of compiling/linking errors in silent mode

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