source: palm/trunk/SCRIPTS/palmbuild @ 2404

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

further simplifications in palmrun and palmbuild

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