source: palm/trunk/SCRIPTS/palmbuild @ 3725

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

modifications to avoid compiler warnings about unused variables, temperton-fft: GOTO statements replaced, file re-formatted corresponding to coding standards, ssh-calls for compilations on remote systems modified to avoid output of login messages on specific systems changed again (palmbuild, reverted as before r3549), error messages for failed restarts extended (palmrun)

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