source: palm/trunk/SCRIPTS/palmbuild @ 3556

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

ssh-call for submitting batch jobs on remote systems modified to avoid output of login messages on specific systems, ssh-calls for compilations on remote systems modified to avoid output of login messages on specific systems, english translation of german comments / variable names

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