source: palm/trunk/SCRIPTS/palmbuild @ 3499

Last change on this file since 3499 was 3499, checked in by suehring, 3 years ago

Temporarily avoid compilation of post-processing tool for surface output until a workaround for compiler-specific intrinsic functions is found.

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