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