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