source: palm/trunk/SCRIPTS/palmbuild @ 3469

Last change on this file since 3469 was 3455, checked in by raasch, 6 years ago

options -h and -d renamed -c and -r, respectively, job_queue renamed job_logfiles in sveral configuration files

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