source: palm/trunk/SCRIPTS/palmbuild @ 2834

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

fname renamed jobname

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