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