source: palm/trunk/SCRIPTS/palmbuild @ 3784

Last change on this file since 3784 was 3756, checked in by suehring, 6 years ago

Disable compilation of postprocessing tool for surface output, until crashes with unexpected segmentation faults with intel compiler are solved.

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