source: palm/trunk/SCRIPTS/palmbuild @ 3497

Last change on this file since 3497 was 3494, checked in by suehring, 6 years ago

Surface output revised and some bugs are fixed + new post-processing tool to convert binary surface output to Paraview readable VTK files

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