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