1 | #!/bin/bash |
---|
2 | |
---|
3 | # palmbuild - script for compiling the PALM code and its utility programs |
---|
4 | |
---|
5 | #------------------------------------------------------------------------------# |
---|
6 | # This file is part of PALM. |
---|
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 Leibniz Universitaet Hannover |
---|
20 | #------------------------------------------------------------------------------# |
---|
21 | # |
---|
22 | # Current revisions: |
---|
23 | # ------------------ |
---|
24 | # |
---|
25 | # |
---|
26 | # Former revisions: |
---|
27 | # ----------------- |
---|
28 | # $Id: palmbuild 2422 2017-09-08 08:25:41Z gronemeier $ |
---|
29 | # initial revision |
---|
30 | # |
---|
31 | #------------------------------------------------------------------------------# |
---|
32 | # palmbuild - script for compiling the PALM code and its utility programs |
---|
33 | # |
---|
34 | # Procedure to compile code on local and remote hosts using the |
---|
35 | # make-mechanism. The source code must be provided on the local host. |
---|
36 | # |
---|
37 | # @note This script does not work on MAC OS |
---|
38 | #------------------------------------------------------------------------------# |
---|
39 | |
---|
40 | |
---|
41 | # VARIABLE DECLARATIONS + DEFAULT VALUES |
---|
42 | calltime="" |
---|
43 | column1="" |
---|
44 | column2="" |
---|
45 | host_identifier=default |
---|
46 | locat=normal |
---|
47 | makefile="" |
---|
48 | make_options="" |
---|
49 | module_commands="" |
---|
50 | program_name=palm |
---|
51 | remote_ip="" |
---|
52 | silent=false |
---|
53 | ssh_key="" |
---|
54 | suf=f90 |
---|
55 | version="palmbuild 1.0 Rev$Rev: 2316 $" |
---|
56 | working_directory=`pwd` |
---|
57 | |
---|
58 | |
---|
59 | |
---|
60 | # ERROR HANDLING |
---|
61 | # IN CASE OF EXIT: |
---|
62 | trap 'if [[ $locat != normal ]] |
---|
63 | then |
---|
64 | printf "\n\n +++ palmbuild killed \n\n" |
---|
65 | exit 1 |
---|
66 | else |
---|
67 | printf "\n\n *** palmbuild finished \n\n" |
---|
68 | exit 0 |
---|
69 | fi' exit |
---|
70 | |
---|
71 | |
---|
72 | # IN CASE OF TERMINAL-BREAK: |
---|
73 | trap 'printf "\n\n +++ palmbuild killed by \"^C\" \n\n" |
---|
74 | exit |
---|
75 | ' 2 |
---|
76 | |
---|
77 | |
---|
78 | |
---|
79 | # READ SHELLSCRIPT-OPTIONS |
---|
80 | while getopts :d:h:m:s:S:uv option |
---|
81 | do |
---|
82 | case $option in |
---|
83 | (d) fname=$OPTARG;; |
---|
84 | (h) host_identifier=$OPTARG;; |
---|
85 | (m) makefile=$OPTARG;; |
---|
86 | (s) suf=$OPTARG;; |
---|
87 | (S) source_list="$OPTARG";; |
---|
88 | (v) silent=true;; |
---|
89 | (\?) printf "\n +++ unknown option $OPTARG \n"; |
---|
90 | locat=parameter; exit;; |
---|
91 | esac |
---|
92 | done |
---|
93 | |
---|
94 | |
---|
95 | # BUILD THE CONFIGURATION-FILE NAME |
---|
96 | config_file=.palm.config.$host_identifier |
---|
97 | |
---|
98 | |
---|
99 | # CHECK, IF CONFIGURATION-FILE EXISTS |
---|
100 | if [[ ! -f $config_file ]] |
---|
101 | then |
---|
102 | printf "\n +++ configuration file: " |
---|
103 | printf "\n $config_file" |
---|
104 | printf "\n does not exist" |
---|
105 | locat=configuration; exit |
---|
106 | fi |
---|
107 | |
---|
108 | |
---|
109 | # ### is this really required? |
---|
110 | config_file=$PWD/$config_file |
---|
111 | |
---|
112 | |
---|
113 | # READ VARIABLE SETTINGS FROM CONFIG FILE LINE BY LINE |
---|
114 | while read line |
---|
115 | do |
---|
116 | |
---|
117 | # FIRST REPLACE ENVIRONMENT-VARIABLES BY THEIR RESPECTIVE VALUES |
---|
118 | eval line=\"$line\" |
---|
119 | |
---|
120 | |
---|
121 | # INTERPRET THE LINE |
---|
122 | if [[ "$(echo $line)" = "" ]] |
---|
123 | then |
---|
124 | |
---|
125 | # EMPTY LINE, NO ACTION |
---|
126 | continue |
---|
127 | |
---|
128 | elif [[ "$(echo $line | cut -c1)" = "#" ]] |
---|
129 | then |
---|
130 | |
---|
131 | # LINE IS A COMMENT LINE |
---|
132 | continue |
---|
133 | |
---|
134 | elif [[ "$(echo $line | cut -c1)" = "%" ]] |
---|
135 | then |
---|
136 | |
---|
137 | # LINE DEFINES AN ENVIRONMENT-VARIABLE |
---|
138 | var=`echo $line | cut -d" " -s -f1 | cut -c2-` |
---|
139 | value=`echo $line | cut -d" " -s -f2-` |
---|
140 | |
---|
141 | # REPLACE ":" BY " " IN COMPILER- CPP- OR LINKER-OPTIONS, |
---|
142 | # "::" IS REPLACED BY ":". |
---|
143 | #value=`echo $value | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` |
---|
144 | |
---|
145 | |
---|
146 | # VALUE FROM THE CONFIGURATION-FILE IS ASSIGNED TO THE |
---|
147 | # ENVIRONMENT-VARIABLE, BUT ONLY IF NO VALUE HAS BEEN ALREADY |
---|
148 | # ASSIGNED WITHIN THIS SCRIPT (E.G. BY SCRIPT-OPTIONS). |
---|
149 | # NON-ASSIGNED VARIABLES HAVE VALUE "" OR 0 (IN CASE OF INTEGER). |
---|
150 | # HENCE THE GENERAL RULE IS: SCRIPT-OPTION OVERWRITES THE |
---|
151 | # CONFIGURATION-FILE. |
---|
152 | if [[ "$(eval echo \$$var)" = "" || "$(eval echo \$$var)" = "0" ]] |
---|
153 | then |
---|
154 | eval export $var="\$value" |
---|
155 | |
---|
156 | # TERMINAL OUTPUT OF ENVIRONMENT-VARIABLES, IF TRACEBACK IS SWITCHED on |
---|
157 | if [[ $do_trace = true ]] |
---|
158 | then |
---|
159 | printf "\n*** ENVIRONMENT-VARIABLE $var = $value" |
---|
160 | fi |
---|
161 | fi |
---|
162 | |
---|
163 | else |
---|
164 | |
---|
165 | # SKIP ALL OTHER LINES |
---|
166 | continue |
---|
167 | |
---|
168 | fi |
---|
169 | |
---|
170 | done < $config_file |
---|
171 | |
---|
172 | |
---|
173 | # CHECK, IF THE BASE DIRECTORY PATH HAS BEEN GIVEN |
---|
174 | if [[ "$base_directory" = "" ]] |
---|
175 | then |
---|
176 | printf "\n +++ no base directory found in configuration file" |
---|
177 | locat=config_file; exit |
---|
178 | else |
---|
179 | if [[ ! -d $base_directory ]] |
---|
180 | then |
---|
181 | printf "\n\n +++ base directory \"$base_directory\" " |
---|
182 | printf "\n does not exist" |
---|
183 | locat=source_path; exit |
---|
184 | fi |
---|
185 | fi |
---|
186 | |
---|
187 | |
---|
188 | # CHECK SOURCE-CODE PATH |
---|
189 | if [[ "$source_path" = "" ]] |
---|
190 | then |
---|
191 | printf "\n +++ no source path found in configuration file" |
---|
192 | locat=config_file; exit |
---|
193 | else |
---|
194 | if [[ ! -d $source_path ]] |
---|
195 | then |
---|
196 | printf "\n\n +++ source path \"$source_path\" " |
---|
197 | printf "\n does not exist" |
---|
198 | locat=source_path; exit |
---|
199 | fi |
---|
200 | fi |
---|
201 | |
---|
202 | |
---|
203 | # CHECK MAKEFILE |
---|
204 | [[ "$makefile" = "" ]] && makefile=$source_path/Makefile |
---|
205 | if [[ ! -f $makefile ]] |
---|
206 | then |
---|
207 | printf "\n +++ makefile: " |
---|
208 | printf "\n $makefile" |
---|
209 | printf "\n does not exist" |
---|
210 | locat=makefile; exit |
---|
211 | fi |
---|
212 | |
---|
213 | |
---|
214 | # CHECK COMPILERNAME |
---|
215 | if [[ "$compiler_name" = "" ]] |
---|
216 | then |
---|
217 | printf "\n +++ no compiler name found in configuration file" |
---|
218 | locat=config_file; exit |
---|
219 | fi |
---|
220 | |
---|
221 | |
---|
222 | # CHECK SERIAL COMPILERNAME |
---|
223 | if [[ "$compiler_name_ser" = "" ]] |
---|
224 | then |
---|
225 | printf "\n +++ no compiler name for serial compilation in configuration file" |
---|
226 | locat=config_file; exit |
---|
227 | fi |
---|
228 | |
---|
229 | |
---|
230 | # DETERMINE SSH-KEY TO BE USED |
---|
231 | if [[ "$ssh_key" != "" ]] |
---|
232 | then |
---|
233 | ssh_key="-i $HOME/.ssh/`echo $line | cut -d" " -s -f2`" |
---|
234 | fi |
---|
235 | |
---|
236 | |
---|
237 | #CHECK CPP-OPTIONS |
---|
238 | if [[ "$cpp_options" = "" ]] |
---|
239 | then |
---|
240 | printf "\n +++ WARNING: no cpp-options found in configuration file" |
---|
241 | fi |
---|
242 | |
---|
243 | |
---|
244 | # CHECK SETTINGS IN CASE OF COMPILING ON REMOTE MACHINE |
---|
245 | if [[ "$remote_ip" != "" ]] |
---|
246 | then |
---|
247 | |
---|
248 | if [[ "$remote_username" = "" ]] |
---|
249 | then |
---|
250 | printf "\n +++ no user name given in configuration file" |
---|
251 | locat=config_file; exit |
---|
252 | fi |
---|
253 | |
---|
254 | # GET SOURCE AND DEPOSITORY PATH ON THE REMOTE MACHINE WITHOUT EVALUATING |
---|
255 | # THE $ |
---|
256 | # IF NOT GIVEN, USE THE LOCAL SOURCE AND DEPOSITORY PATH |
---|
257 | line=`grep %remote_source_path $config_file` |
---|
258 | if [[ "$line" != "" ]] |
---|
259 | then |
---|
260 | remote_source_path=`echo $line | cut -d" " -s -f2` |
---|
261 | else |
---|
262 | line=`grep %source_path $config_file` |
---|
263 | remote_source_path=`echo $line | cut -d" " -s -f2` |
---|
264 | fi |
---|
265 | |
---|
266 | line=`grep %base_directory $config_file` |
---|
267 | make_depository=`echo $line | cut -d" " -s -f2`/MAKE_DEPOSITORY_${host_identifier} |
---|
268 | |
---|
269 | else |
---|
270 | |
---|
271 | make_depository=${base_directory}/MAKE_DEPOSITORY_${host_identifier} |
---|
272 | |
---|
273 | fi |
---|
274 | |
---|
275 | # HEADER-OUTPUT (PART1: MESSAGES CONCERNING THE LOCAL HOST) |
---|
276 | calltime=$(date) |
---|
277 | printf "\n" |
---|
278 | printf "#------------------------------------------------------------------------# \n" |
---|
279 | printf "| %-40s%30s | \n" "$version" "$calltime" |
---|
280 | printf "| | \n" |
---|
281 | printf "| %-13s%-57s | \n" "called on:" "$(hostname) (IP:$local_ip)" |
---|
282 | column2=$(echo $config_file | cut -c1-57 ) |
---|
283 | printf "| %-13s%-57s | \n" "config file:" "$column2" |
---|
284 | line=$(echo "$config_file" | cut -c58-) |
---|
285 | while [[ "$line" != "" ]] |
---|
286 | do |
---|
287 | column1="" |
---|
288 | column2=$(echo $line | cut -c1-57 ) |
---|
289 | printf "| %-13s%-57s | \n" "$column1" "$column2" |
---|
290 | line=$(echo "$line" | cut -c58-) |
---|
291 | done |
---|
292 | column2=$(echo $makefile | cut -c1-57 ) |
---|
293 | printf "| %-13s%-57s | \n" "makefile:" "$column2" |
---|
294 | line=$(echo "$makefile" | cut -c58-) |
---|
295 | while [[ "$line" != "" ]] |
---|
296 | do |
---|
297 | column1="" |
---|
298 | column2=$(echo $line | cut -c1-57 ) |
---|
299 | printf "| %-13s%-57s | \n" "$column1" "$column2" |
---|
300 | line=$(echo "$line" | cut -c58-) |
---|
301 | done |
---|
302 | column2=$(echo $source_path | cut -c1-57 ) |
---|
303 | printf "| %-13s%-57s | \n" "source path:" "$column2" |
---|
304 | line=$(echo "$source_path" | cut -c58-) |
---|
305 | while [[ "$line" != "" ]] |
---|
306 | do |
---|
307 | column1="" |
---|
308 | column2=$(echo $line | cut -c1-57 ) |
---|
309 | printf "| %-13s%-57s | \n" "$column1" "$column2" |
---|
310 | line=$(echo "$line" | cut -c58-) |
---|
311 | done |
---|
312 | printf "#------------------------------------------------------------------------# \n" |
---|
313 | |
---|
314 | |
---|
315 | |
---|
316 | # TAR THE SOURCES AND MAKEFILES |
---|
317 | # UTILITIES ARE TEMPORARILY COPIED TO THE SOURCE DIRECTORY IN ORDER TO TAR |
---|
318 | # THEM TOO |
---|
319 | cd $source_path |
---|
320 | printf "\n\n *** tar of makefile and source files in" |
---|
321 | printf "\n $source_path" |
---|
322 | cp -p ../UTIL/combine_plot_fields.f90 . |
---|
323 | cp -p ../UTIL/compare_palm_logs.f90 . |
---|
324 | cp -p ../UTIL/Makefile_utilities . |
---|
325 | tar -cf ${program_name}_sources.tar Makefile* *.$suf |
---|
326 | rm combine_plot_fields.f90 compare_palm_logs.f90 Makefile_utilities |
---|
327 | printf "\n" |
---|
328 | |
---|
329 | |
---|
330 | |
---|
331 | # GET CONFIRMATION TO CONTINUE |
---|
332 | printf "\n *** update will be made for host \"$host_identifier\" " |
---|
333 | |
---|
334 | |
---|
335 | if [[ $silent = false ]] |
---|
336 | then |
---|
337 | answer=dummy |
---|
338 | printf "\n\n" |
---|
339 | while [[ "$answer" != y && "$answer" != Y && "$answer" != n && "$answer" != N ]] |
---|
340 | do |
---|
341 | printf " >>> continue (y/n) ? " |
---|
342 | read answer |
---|
343 | done |
---|
344 | if [[ $answer = n || $answer = N ]] |
---|
345 | then |
---|
346 | locat=user_abort; exit |
---|
347 | fi |
---|
348 | fi |
---|
349 | |
---|
350 | |
---|
351 | |
---|
352 | |
---|
353 | printf "\n\n#------------------------------------------------------------------------# \n" |
---|
354 | |
---|
355 | if [[ "$remote_ip" != "" ]] |
---|
356 | then |
---|
357 | column2="$host_identifier" |
---|
358 | printf "| %-20s%-50s | \n" "host identifier:" "$column2" |
---|
359 | printf "| | \n" |
---|
360 | column2=$(echo "$make_depository" | cut -c1-50 ) |
---|
361 | printf "| %-20s%-50s | \n" "remote depository:" "$column2" |
---|
362 | else |
---|
363 | column2="$host_identifier" |
---|
364 | printf "| %-20s%-50s | \n" "host identifier:" "$column2" |
---|
365 | printf "| | \n" |
---|
366 | column2=$(echo "$make_depository" | cut -c1-50 ) |
---|
367 | printf "| %-20s%-50s | \n" "local depository:" "$column2" |
---|
368 | fi |
---|
369 | line=$(echo "$make_depository" | cut -c51-) |
---|
370 | while [[ "$line" != "" ]] |
---|
371 | do |
---|
372 | column1="" |
---|
373 | column2=$(echo "$line" | cut -c1-50 ) |
---|
374 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
375 | line=$(echo "$line" | cut -c51-) |
---|
376 | done |
---|
377 | |
---|
378 | if [[ "$remote_ip" != "" ]] |
---|
379 | then |
---|
380 | printf "| %-20s%-50s | \n" "remote username:" "$remote_username" |
---|
381 | printf "| %-20s%-50s | \n" "remote address:" "$remote_ip" |
---|
382 | else |
---|
383 | printf "| %-20s%-50s | \n" "username:" "$local_username" |
---|
384 | printf "| %-20s%-50s | \n" "address:" "$local_ip" |
---|
385 | fi |
---|
386 | |
---|
387 | printf "| %-20s%-50s | \n" "compiler:" "$compiler_name" |
---|
388 | printf "| %-20s%-50s | \n" "serial compiler:" "$compiler_name_ser" |
---|
389 | |
---|
390 | if [[ "$make_options" != "" ]] |
---|
391 | then |
---|
392 | printf "| %-20s%-50s | \n" "make options:" "$make_options" |
---|
393 | fi |
---|
394 | column2=$(echo "$cpp_options" | cut -c1-50 ) |
---|
395 | printf "| %-20s%-50s | \n" "cpp options:" "$column2" |
---|
396 | line=$(echo "$cpp_options" | cut -c51-) |
---|
397 | while [[ "$line" != "" ]] |
---|
398 | do |
---|
399 | column1="" |
---|
400 | column2=$(echo "$line" | cut -c1-50 ) |
---|
401 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
402 | line=$(echo "$line" | cut -c51-) |
---|
403 | done |
---|
404 | column2=$(echo "$compiler_options" | cut -c1-50 ) |
---|
405 | printf "| %-20s%-50s | \n" "compiler options:" "$column2" |
---|
406 | line=$(echo "$compiler_options" | cut -c51-) |
---|
407 | while [[ "$line" != "" ]] |
---|
408 | do |
---|
409 | column1="" |
---|
410 | column2=$(echo "$line" | cut -c1-50 ) |
---|
411 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
412 | line=$(echo "$line" | cut -c51-) |
---|
413 | done |
---|
414 | column2=$(echo "$linker_options" | cut -c1-50 ) |
---|
415 | printf "| %-20s%-50s | \n" "linker options:" "$column2" |
---|
416 | line=$(echo "$linker_options" | cut -c51-) |
---|
417 | while [[ "$line" != "" ]] |
---|
418 | do |
---|
419 | column1="" |
---|
420 | column2=$(echo "$line" | cut -c1-50 ) |
---|
421 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
422 | line=$(echo "$line" | cut -c51-) |
---|
423 | done |
---|
424 | if [[ "$login_init_cmd" != "" ]] |
---|
425 | then |
---|
426 | column2=$(echo "$login_init_cmd" | cut -c1-50 ) |
---|
427 | printf "| %-20s%-50s | \n" "login init command:" "$column2" |
---|
428 | line=$(echo "$login_init_cmd" | 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 | fi |
---|
437 | if [[ "$module_commands" != "" ]] |
---|
438 | then |
---|
439 | column2=$(echo "$module_commands" | cut -c1-50 ) |
---|
440 | printf "| %-20s%-50s | \n" "module command(s):" "$column2" |
---|
441 | line=$(echo "$module_commands" | cut -c51-) |
---|
442 | while [[ "$line" != "" ]] |
---|
443 | do |
---|
444 | column1="" |
---|
445 | column2=$(echo "$line" | cut -c1-50 ) |
---|
446 | printf "| %-20s%-50s | \n" "$column1" "$column2" |
---|
447 | line=$(echo "$line" | cut -c51-) |
---|
448 | done |
---|
449 | fi |
---|
450 | printf "#------------------------------------------------------------------------# \n" |
---|
451 | |
---|
452 | if [[ $silent = false ]] |
---|
453 | then |
---|
454 | answer=dummy |
---|
455 | printf "\n\n" |
---|
456 | while [[ "$answer" != y && "$answer" != Y && "$answer" != c && "$answer" != C && "$answer" != s && "$answer" != S && "$answer" != a && "$answer" != A ]] |
---|
457 | do |
---|
458 | printf " >>> continue (y(es)/c(ontinue)/a(bort)) ? " |
---|
459 | read answer |
---|
460 | done |
---|
461 | if [[ $answer = a || $answer = A ]] |
---|
462 | then |
---|
463 | locat=user_abort; exit |
---|
464 | fi |
---|
465 | if [[ $answer = c || $answer = C ]] |
---|
466 | then |
---|
467 | silent=true |
---|
468 | fi |
---|
469 | fi |
---|
470 | |
---|
471 | |
---|
472 | # MAKE ON REMOTE HOST |
---|
473 | if [[ "$remote_ip" != "" ]] |
---|
474 | then |
---|
475 | |
---|
476 | # NEXT IS THE BRANCH FOR CREATING THE MAKE_DEPOSITORY_... |
---|
477 | if [[ "$fname" = "" ]] |
---|
478 | then |
---|
479 | |
---|
480 | # COPY CURRENT SOURCE CODE TO SOURCE-CODE DIRECTORY ON THE REMOTE HOST |
---|
481 | # CREATE THIS DIRECTORY, IF IT DOES NOT EXIST |
---|
482 | echo " *** copying \"${program_name}_sources.tar\" to \"${remote_ip}:${make_depository}/\" " |
---|
483 | echo "[[ ! -d ${make_depository} ]] && (echo \" *** ${make_depository} will be created\"; mkdir -p ${make_depository})" | ssh -q $ssh_key ${remote_username}@${remote_ip} 2>&1 |
---|
484 | |
---|
485 | scp $ssh_key ${source_path}/${program_name}_sources.tar ${remote_username}@${remote_ip}:${make_depository}/${program_name}_sources.tar |
---|
486 | |
---|
487 | |
---|
488 | |
---|
489 | # UNTAR PREVIOUS UPDATE ON REMOTE HOST, IF EXISTING |
---|
490 | echo " *** untar previous update on remote host, if existing" |
---|
491 | 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 |
---|
492 | |
---|
493 | |
---|
494 | # UNTAR CURRENT SOURCES ON REMOTE HOST |
---|
495 | echo " *** untar current sources on remote host" |
---|
496 | echo "cd ${make_depository}; tar -xf ${program_name}_sources.tar" | ssh -q $ssh_key ${remote_username}@${remote_ip} 2>&1 |
---|
497 | |
---|
498 | |
---|
499 | # CREATE INIT AND MODULE COAMMNDS |
---|
500 | [[ "$login_init_cmd" != "" ]] && login_init_cmd=${login_init_cmd}";" |
---|
501 | [[ "$module_commands" != "" ]] && module_commands=${module_commands}";" |
---|
502 | |
---|
503 | |
---|
504 | # FIRST CREATE EXECUTABLES FOR THE UTILITY ROUTINES |
---|
505 | echo " " |
---|
506 | echo " *** creating utilities on remote host" |
---|
507 | 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\" " |
---|
508 | 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 ${host_identifier}_last_make_protokoll |
---|
509 | |
---|
510 | if [[ $(grep -c MAKE_ERROR ${host_identifier}_last_make_protokoll) != 0 ]] |
---|
511 | then |
---|
512 | printf "\a\n +++ error(s) occurred during compiling or linking of utilities" |
---|
513 | printf "\n for host \"$host_identifier\" " |
---|
514 | if [[ $silent = false ]] |
---|
515 | then |
---|
516 | answer=dummy |
---|
517 | printf "\n" |
---|
518 | while [[ "$answer" != c && "$answer" != k ]] |
---|
519 | do |
---|
520 | printf " >>> continue / list errors / kill palmbuild (c/l/k) ? " |
---|
521 | read answer |
---|
522 | if [[ "$answer" = l ]] |
---|
523 | then |
---|
524 | more ${host_identifier}_last_make_protokoll |
---|
525 | fi |
---|
526 | done |
---|
527 | if [[ $answer = k ]] |
---|
528 | then |
---|
529 | locat=user_abort; exit |
---|
530 | fi |
---|
531 | fi |
---|
532 | fi |
---|
533 | |
---|
534 | |
---|
535 | # NOW COMPILE THE PALM CODE |
---|
536 | # COMMANDS WILL BE COMMUNICATED TO SSH VIA PIPE, SINCE THIS WAY THE SYSTEM- AND |
---|
537 | # USER-PROFILES OF THE SHELL ARE COMPLETELY EXECUTED (OTHERWISE, MAKE |
---|
538 | # MAY E.G. MISS THE COMPILER-PATHS) |
---|
539 | echo " " |
---|
540 | echo " *** compile PALM sources on remote host" |
---|
541 | make_call_string="make $make_options PROG=$program_name F90=$compiler_name COPT=\"$cpp_options\" F90FLAGS=\"$compiler_options\" LDFLAGS=\"$linker_options\" " |
---|
542 | 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 ${host_identifier}_last_make_protokoll |
---|
543 | |
---|
544 | if [[ $(grep -c MAKE_ERROR ${host_identifier}_last_make_protokoll) != 0 ]] |
---|
545 | then |
---|
546 | printf "\a\n +++ error(s) occurred during compiling or linking for host \"$host_identifier\" " |
---|
547 | if [[ $silent = false ]] |
---|
548 | then |
---|
549 | answer=dummy |
---|
550 | printf "\n" |
---|
551 | while [[ "$answer" != c && "$answer" != k ]] |
---|
552 | do |
---|
553 | printf " >>> continue / list errors / kill palmbuild (c/l/k) ? " |
---|
554 | read answer |
---|
555 | if [[ "$answer" = l ]] |
---|
556 | then |
---|
557 | more ${host_identifier}_last_make_protokoll |
---|
558 | fi |
---|
559 | done |
---|
560 | if [[ $answer = k ]] |
---|
561 | then |
---|
562 | locat=user_abort; exit |
---|
563 | fi |
---|
564 | fi |
---|
565 | fi |
---|
566 | |
---|
567 | # TAR UPDATED VERSION ON THE REMOTE HOST |
---|
568 | printf "\n *** tar update on remote host ..." |
---|
569 | 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 |
---|
570 | |
---|
571 | |
---|
572 | # NOW COMES THE BRANCH FOR CREATING THE EXECUTABLE FOR THE CURRENT RUN |
---|
573 | # INCLUDING E.G. USER-INTERFACE ROUTINES. ALSO ADD OTHER UTILITY EXECUTABLES. EVERYTHING IS |
---|
574 | # COLLECTED IN DIRECTORY SOURCES_FOR_RUN_... |
---|
575 | elif [[ "$fname" != "" ]] |
---|
576 | then |
---|
577 | |
---|
578 | # FIRST CHECK, IF A DEPOSITORY EXISTS ON THE REMOTE MACHINE |
---|
579 | echo "[[ ! -d ${make_depository} ]] && echo depository not found" | ssh -q $ssh_key ${remote_username}@${remote_ip} 2>&1 | tee ${host_identifier}_last_make_protokoll |
---|
580 | |
---|
581 | |
---|
582 | # COPY MAKE DEPOSITORY ON REMOTE MACHINE TO SOURCES_FOR_RUN_... |
---|
583 | printf "\n *** copy MAKE_DEPOSITORY_${host_identifier} on remote host to SOURCES_FOR_RUN_$fname \n" |
---|
584 | echo "rm -rf $fast_io_catalog/SOURCES_FOR_RUN_$fname; mkdir -p $fast_io_catalog/SOURCES_FOR_RUN_$fname; cp ${make_depository}/${program_name}_current_version.tar $fast_io_catalog/SOURCES_FOR_RUN_$fname; cd $fast_io_catalog/SOURCES_FOR_RUN_$fname; tar xf ${program_name}_current_version.tar" | ssh -q $ssh_key ${remote_username}@${remote_ip} 2>&1 |
---|
585 | |
---|
586 | |
---|
587 | # COPY CONTENTS OF SOURCES_FOR_RUN_... TO SOURCES_FOR_RUN_... ON THE REMOTE MACHINE |
---|
588 | printf "\n *** copy $base_directory/SOURCES_FOR_RUN_$fname" |
---|
589 | printf "\n to SOURCES_FOR_RUN_$fname on remote host \n" |
---|
590 | scp -q $ssh_key $base_directory/SOURCES_FOR_RUN_$fname/{*,.[!.]*} ${remote_username}@${remote_ip}:${fast_io_catalog}/SOURCES_FOR_RUN_$fname |
---|
591 | |
---|
592 | |
---|
593 | # CREATE EXECUTABLE FROM THE NEW/MODIFIED SOURCE FILES, IF THERE ARE ANY |
---|
594 | if [[ $(ls -1 $base_directory/SOURCES_FOR_RUN_$fname/ | grep -c .$suf) != 0 ]] |
---|
595 | then |
---|
596 | |
---|
597 | make_call_string="make $make_options PROG=$program_name F90=$compiler_name COPT=\"$cpp_options\" F90FLAGS=\"$compiler_options\" LDFLAGS=\"$linker_options\" " |
---|
598 | [[ "$login_init_cmd" != "" ]] && login_init_cmd=${login_init_cmd}";" |
---|
599 | [[ "$module_commands" != "" ]] && module_commands=${module_commands}";" |
---|
600 | echo " *** execute \"make\" on remote host" |
---|
601 | echo "$login_init_cmd $module_commands cd ${fast_io_catalog}/SOURCES_FOR_RUN_$fname; 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 ${host_identifier}_last_make_protokoll |
---|
602 | |
---|
603 | if [[ $(grep -c MAKE_ERROR ${host_identifier}_last_make_protokoll) != 0 ]] |
---|
604 | then |
---|
605 | printf "\a\n +++ error(s) occurred during compiling or linking for host \"$host_identifier\" " |
---|
606 | if [[ $silent = false ]] |
---|
607 | then |
---|
608 | answer=dummy |
---|
609 | printf "\n" |
---|
610 | while [[ "$answer" != c && "$answer" != k ]] |
---|
611 | do |
---|
612 | printf " >>> continue / list errors / kill palmbuild (c/l/k) ? " |
---|
613 | read answer |
---|
614 | if [[ "$answer" = l ]] |
---|
615 | then |
---|
616 | more ${host_identifier}_last_make_protokoll |
---|
617 | fi |
---|
618 | done |
---|
619 | if [[ $answer = k ]] |
---|
620 | then |
---|
621 | locat=user_abort; exit |
---|
622 | fi |
---|
623 | fi |
---|
624 | fi |
---|
625 | |
---|
626 | else |
---|
627 | |
---|
628 | echo " *** nothing to compile for this run" |
---|
629 | |
---|
630 | fi |
---|
631 | |
---|
632 | fi |
---|
633 | |
---|
634 | rm -rf ${host_identifier}_last_make_protokoll |
---|
635 | |
---|
636 | |
---|
637 | # MAKE ON LOCAL HOST |
---|
638 | else |
---|
639 | |
---|
640 | |
---|
641 | # NEXT IS THE BRANCH FOR CREATING THE MAKE_DEPOSITORY_... ON THE |
---|
642 | # LOCAL HOST |
---|
643 | if [[ "$fname" = "" ]] |
---|
644 | then |
---|
645 | |
---|
646 | # SET THE ENVIRONMENT (EXECUTE INIT AND MODULE COMMANDS) |
---|
647 | if [[ "$login_init_cmd" != "" ]] |
---|
648 | then |
---|
649 | $login_init_cmd |
---|
650 | fi |
---|
651 | |
---|
652 | if [[ "$module_commands" != "" ]] |
---|
653 | then |
---|
654 | $module_commands |
---|
655 | fi |
---|
656 | |
---|
657 | |
---|
658 | # CREATE MAKE-DEPOSITORY, IF IT DOES NOT EXIST |
---|
659 | eval make_depository=$make_depository |
---|
660 | if [[ ! -d $make_depository ]] |
---|
661 | then |
---|
662 | if mkdir -p $make_depository |
---|
663 | then |
---|
664 | printf "\n\n *** directory for local make depository:" |
---|
665 | printf "\n $make_depository" |
---|
666 | printf "\n was created\n" |
---|
667 | else |
---|
668 | printf "\n +++ directory for local make depository:" |
---|
669 | printf "\n $make_depository" |
---|
670 | printf "\n cannot be created" |
---|
671 | locat=local_depository; exit |
---|
672 | fi |
---|
673 | fi |
---|
674 | |
---|
675 | # COPY SOURCE-CODE FROM REPOSITORY TO MAKE-DEPOSITORY |
---|
676 | echo " " |
---|
677 | echo " *** untar current source sources on local host in" |
---|
678 | echo " $make_depository" |
---|
679 | cd $make_depository |
---|
680 | cp $source_path/${program_name}_sources.tar . |
---|
681 | tar xf ${program_name}_sources.tar |
---|
682 | |
---|
683 | |
---|
684 | # FIRST CREATE EXECUTABLES FOR THE UTILITY ROUTINES |
---|
685 | echo " " |
---|
686 | echo " *** creating utilities on local host" |
---|
687 | make -f Makefile_utilities $make_options F90=$compiler_name F90_SER=$compiler_name_ser COPT="$cpp_options" F90FLAGS="$compiler_options" LDFLAGS="$linker_options" |
---|
688 | |
---|
689 | |
---|
690 | # CALL MAKE ON LOCAL HOST USING THE OPTIONS DETERMINED FURTHER ABOVE |
---|
691 | echo " " |
---|
692 | echo " *** compile PALM sources on local host" |
---|
693 | |
---|
694 | make $make_options PROG=$program_name F90=$compiler_name COPT="$cpp_options" F90FLAGS="$compiler_options" LDFLAGS="$linker_options" 2>&1 | tee ${host_identifier}_last_make_protokoll |
---|
695 | |
---|
696 | if [[ $? != 0 ]] |
---|
697 | then |
---|
698 | printf "\a\n +++ error(s) occurred during compiling or linking for host \"$host_identifier\" " |
---|
699 | if [[ $silent = false ]] |
---|
700 | then |
---|
701 | answer=dummy |
---|
702 | printf "\n" |
---|
703 | while [[ "$answer" != c && "$answer" != k ]] |
---|
704 | do |
---|
705 | printf " >>> continue / list errors / kill palmbuild (c/l/k) ? " |
---|
706 | read answer |
---|
707 | if [[ "$answer" = l ]] |
---|
708 | then |
---|
709 | more ${host_identifier}_last_make_protokoll |
---|
710 | fi |
---|
711 | done |
---|
712 | if [[ $answer = k ]] |
---|
713 | then |
---|
714 | locat=user_abort; exit |
---|
715 | fi |
---|
716 | fi |
---|
717 | fi |
---|
718 | |
---|
719 | |
---|
720 | # TAR NEW VERSION ON LOCAL HOST |
---|
721 | printf "\n *** tar update on local host ..." |
---|
722 | tar -cf ${program_name}_current_version.tar ${program_name} *.$suf *.o *.mod *.x |
---|
723 | |
---|
724 | else |
---|
725 | |
---|
726 | # NOW COMES THE BRANCH FOR CREATING THE EXECUTABLE FOR THE CURRENT RUN |
---|
727 | # INCLUDING E.G. USER-INTERFACE ROUTINES. ALSO ADD OTHER UTILITY EXECUTABLES. EVERYTHING IS |
---|
728 | # COLLECTED IN DIRECTORY SOURCES_FOR_RUN_... |
---|
729 | |
---|
730 | # FIRST CHECK, IF A DEPOSITORY EXISTS ON THE LOCAL MACHINE |
---|
731 | if [[ ! -d ${make_depository} ]] |
---|
732 | then |
---|
733 | printf "\n +++ directory for local make depository:" |
---|
734 | printf "\n $make_depository" |
---|
735 | printf "\n not found. Please run \"palmbuild -h $host_identifier\" " |
---|
736 | locat=make_depository; exit |
---|
737 | fi |
---|
738 | |
---|
739 | |
---|
740 | # COPY MAKE DEPOSITORY ON LOCAL MACHINE TO SOURCES_FOR_RUN_... |
---|
741 | printf "\n *** copy MAKE_DEPOSITORY_${host_identifier} on local host to " |
---|
742 | printf "\n $fast_io_catalog/SOURCES_FOR_RUN_$fname \n" |
---|
743 | rm -rf $fast_io_catalog/SOURCES_FOR_RUN_$fname |
---|
744 | mkdir -p $fast_io_catalog/SOURCES_FOR_RUN_$fname |
---|
745 | cp ${make_depository}/${program_name}_current_version.tar $fast_io_catalog/SOURCES_FOR_RUN_$fname |
---|
746 | cd $fast_io_catalog/SOURCES_FOR_RUN_$fname |
---|
747 | tar xf ${program_name}_current_version.tar |
---|
748 | |
---|
749 | |
---|
750 | # COPY CONTENTS OF SOURCES_FOR_RUN_... TO SOURCES_FOR_RUN_... |
---|
751 | # IN THE FAST_IO_CATALOG ON THE LOCAL MACHINE |
---|
752 | printf "\n *** copy $base_directory/SOURCES_FOR_RUN_$fname to" |
---|
753 | printf "\n $fast_io_catalog/SOURCES_FOR_RUN_$fname on local host \n" |
---|
754 | cp $base_directory/SOURCES_FOR_RUN_$fname/{*,.[!.]*} ${fast_io_catalog}/SOURCES_FOR_RUN_$fname |
---|
755 | |
---|
756 | |
---|
757 | # CREATE EXECUTABLE FROM THE NEW/MODIFIED SOURCE FILES, IF THERE ARE ANY |
---|
758 | if [[ $(ls -1 $base_directory/SOURCES_FOR_RUN_$fname/ | grep -c .$suf) != 0 ]] |
---|
759 | then |
---|
760 | |
---|
761 | echo " *** execute \"make\" on local host" |
---|
762 | [[ "$login_init_cmd" != "" ]] && $login_init_cmd |
---|
763 | [[ "$module_commands" != "" ]] && $module_commands |
---|
764 | |
---|
765 | make $make_options PROG=$program_name F90=$compiler_name COPT="$cpp_options" F90FLAGS="$compiler_options" LDFLAGS="$linker_options" |
---|
766 | |
---|
767 | if [[ \$? != 0 ]] |
---|
768 | then |
---|
769 | |
---|
770 | printf "\a\n +++ error(s) occurred during compiling or linking for host \"$host_identifier\" " |
---|
771 | if [[ $silent = false ]] |
---|
772 | then |
---|
773 | answer=dummy |
---|
774 | printf "\n" |
---|
775 | while [[ "$answer" != c && "$answer" != k ]] |
---|
776 | do |
---|
777 | printf " >>> continue / list errors / kill palmbuild (c/k) ? " |
---|
778 | read answer |
---|
779 | done |
---|
780 | if [[ $answer = k ]] |
---|
781 | then |
---|
782 | locat=user_abort; exit |
---|
783 | fi |
---|
784 | fi |
---|
785 | fi |
---|
786 | |
---|
787 | else |
---|
788 | |
---|
789 | echo " *** nothing to compile for this run" |
---|
790 | |
---|
791 | fi |
---|
792 | |
---|
793 | fi |
---|
794 | fi |
---|