1 | #!/bin/ksh |
---|
2 | # mbuild - script for compiling the PALM code and its utility programs |
---|
3 | # $Id: mbuild 508 2010-03-12 00:28:28Z heinze $ |
---|
4 | |
---|
5 | # Procedure to compile code on local and remote hosts using the |
---|
6 | # make-mechanism. The source code must be provided on the local host. |
---|
7 | |
---|
8 | # Last changes: |
---|
9 | # 06/05/02 - Siggi - start development |
---|
10 | # 12/06/02 - Siggi - first version finished |
---|
11 | # 12/09/02 - Siggi - ibmh (hanni.hlrn.de) included |
---|
12 | # 19/12/02 - Siggi - ibmb included |
---|
13 | # 05/02/03 - Siggi - hostname nobela included |
---|
14 | # 04/03/03 - Siggi - host nech included |
---|
15 | # 06/03/03 - Siggi - make_call_string is echoed without '' to |
---|
16 | # file LAST_MAKE_CALL (otherwise error on NEC, because |
---|
17 | # '' are part of compiler options |
---|
18 | # 16/03/03 - Siggi - Two underscores are placed in front of every define |
---|
19 | # string, in case that palm.f90 version contains |
---|
20 | # such strings |
---|
21 | # 16/04/03 - Siggi - First extensions for linux machines |
---|
22 | # 24/06/03 - Siggi - host orkan included |
---|
23 | # 17/07/03 - Siggi - IP adress set to new "cross" machine at DKRZ |
---|
24 | # 24/07/03 - Siggi - host maestro admitted |
---|
25 | # 06/08/03 - Siggi - host gregale admitted |
---|
26 | # 05/11/03 - Siggi - hosts irifi and quanero are now belonging to lcmuk |
---|
27 | # 19/11/03 - Heiko - on lcmuk, mbuild does not tar the *.i files |
---|
28 | # 08/01/04 - Siggi - additional preprocessor directive for ibm included |
---|
29 | # (-D$OMP=OMP) in order to avoid problems with |
---|
30 | # OMP_NUM_THREADS |
---|
31 | # 09/01/04 - Siggi - action above cancelled |
---|
32 | # 28/01/04 - Siggi - action above re-cancelled |
---|
33 | # 08/03/04 - Siggi - host scirocco admitted |
---|
34 | # 26/03/04 - Siggi - .o and .mod files are also deleted in depository, if |
---|
35 | # the respective .f90 file is not listed in the makefile |
---|
36 | # and deletion is demanded by the user |
---|
37 | # 12/04/04 - Siggi - scp2 instead of scp used for transfer from decalpha |
---|
38 | # due to error in ssh installation (otherwise a prompt |
---|
39 | # for the password appears) |
---|
40 | # 23/07/04 - Siggi - changes due to the new berni configuration |
---|
41 | # (federation switch) |
---|
42 | # 08/09/04 - Siggi - hanni IP address changed to 130.75.4.10 |
---|
43 | # 23/09/04 - Joerg - correction of IP-Address for 'cross' (DKRZ) |
---|
44 | # 09/03/05 - Siggi - on nech, mbuild does not tar the *.i files |
---|
45 | # 31/03/05 - Siggi - mbuild does not tar *.i files any more |
---|
46 | # 24/04/05 - Siggi - netcdf support on lcmuk |
---|
47 | # 25/04/05 - Siggi - netcdf support on gfdl3 (decalpha) |
---|
48 | # 12/05/05 - Siggi - netcdf support on ibm |
---|
49 | # set OBJECT_MODE=64 for compiling on ibmb, ibmh |
---|
50 | # 18/05/05 - Siggi - netcdf support on nec |
---|
51 | # 19/05/05 - Siggi - IP addres 134.75.155.74 changed to 165.132.26.56 |
---|
52 | # 23/05/05 - Siggi - netcdf support on ibms |
---|
53 | # 01/06/05 - Siggi - reset of cpp_options to "" on lcmuk |
---|
54 | # 30/06/05 - Siggi - netcdf support on bora |
---|
55 | # 20/10/05 - Siggi - update of netcdf-version on decalpha (gfdl3) |
---|
56 | # 04/11/05 - Siggi - netcdf 3.6.0-p1 on ibmh/ibmb |
---|
57 | # 30/12/05 - Siggi - change of IP adresses in subnet 130.75.105 |
---|
58 | # host gfdl5 (ibmy) admitted |
---|
59 | # 10/01/06 - Siggi - cpp directive for NetCDF 64bit support |
---|
60 | # 20/01/06 - Siggi - cpp directive for ibmy |
---|
61 | # 09/02/06 - Marcus- compile only once on lcmuk (as on ibmh/ibmb) |
---|
62 | # 10/02/06 - Siggi - modifications for scp on decalpha |
---|
63 | # 13/04/06 - Siggi - ostria admitted |
---|
64 | # 19/04/06 - Siggi - preprocessor directive -D$OMP=OMP for ibm removed |
---|
65 | # 23/05/05 - Siggi - lctit (SUN Fire X4600) admitted |
---|
66 | # 29/05/05 - Siggi - atmos (lcide) admitted |
---|
67 | # 23/08/06 - Siggi - netcdf support for scirocco (notebook) |
---|
68 | # 24/11/06 - Siggi - breva and levanto admitted |
---|
69 | # 07/02/07 - Siggi - adapted for RIAM (neck) |
---|
70 | # 10/02/07 - Siggi - all hpmuk-related code removed |
---|
71 | # 02/03/07 - Siggi - compilation of utility programs and transfer of |
---|
72 | # scripts to remote hosts added (option -u) |
---|
73 | # 14/03/07 - Siggi - fimm admitted, revision number added to terminal |
---|
74 | # output |
---|
75 | # 16/03/07 - Siggi - adjustments (netcdf) for lctit |
---|
76 | # adjustments for running under pdksh, local ip-addres |
---|
77 | # is not determined any more |
---|
78 | # 30/03/07 - Siggi - cpp-directives/options + netcdf-options are read |
---|
79 | # from configuration file |
---|
80 | # host identifier (local_host) is read from config file |
---|
81 | # 10/10/07 - Siggi - bugfix: handling of comment lines |
---|
82 | # 18/07/08 - Siggi - adapted for lcsgih |
---|
83 | # 21/07/08 - Siggi - mainprog (executable) is added to the tar-file |
---|
84 | # ({mainprog}_current_version) |
---|
85 | # 02/10/08 - Siggi - adapted for lcxt4 |
---|
86 | # 14/11/08 - Siggi - update mechanism completely revised: source tarfile |
---|
87 | # remains in source directory, one depository per block |
---|
88 | # (given in the config-file) is created, allways all |
---|
89 | # files from the source directory are copied to the |
---|
90 | # respective depository, no additional file checks are |
---|
91 | # done any more (version 2.1) |
---|
92 | # 13/01/09 - Marcus- re-enable compilation more than once on lcmuk (as on |
---|
93 | # other machines) |
---|
94 | # 21/03/09 - Siggi - -u copies also copies process_dvr_output and |
---|
95 | # .dvrserver.config |
---|
96 | # 21/04/09 - Siggi - adjustments for new IBM at DKRZ, which is now ibmh |
---|
97 | # 25/08/09 - BjornM- adapted for lck |
---|
98 | # 01/12/09 - BjornM- re-adjustments for lcxt4 |
---|
99 | # 01/02/10 - Siggi - adjustments for lcxt5m |
---|
100 | # 03/02/10 - Siggi - make options (mopts) to be set by configuration file |
---|
101 | # implemented, remoted mode option -r completely |
---|
102 | # removed, t3e related parts removed |
---|
103 | # 26/02/10 - BjornM- re-adjustments for lcxt4 (new modules) |
---|
104 | # 01/03/10 - Siggi - mpilib replaced by modules: explicit module settings |
---|
105 | # removed; modules should now be given in the |
---|
106 | # configuration file |
---|
107 | # 02/03/10 - Siggi - utility programs are created separately for each |
---|
108 | # block in the configuration file, |
---|
109 | # parallel make for utility programs |
---|
110 | # 12/03/10 - Siggi - bugfix: remode_md was given a wrong value |
---|
111 | |
---|
112 | |
---|
113 | |
---|
114 | # VARIABLE DECLARATIONS + DEFAULT VALUES |
---|
115 | compile_utility_programs=false |
---|
116 | config_file=.mrun.config |
---|
117 | fimm=false |
---|
118 | host=all |
---|
119 | host_found=false |
---|
120 | locat=normal |
---|
121 | makefile="" |
---|
122 | module_calls="" |
---|
123 | scirocco=false |
---|
124 | silent=false |
---|
125 | suf=f90 |
---|
126 | update=false |
---|
127 | working_directory=`pwd` |
---|
128 | |
---|
129 | typeset -i ih ihost=0 |
---|
130 | |
---|
131 | typeset -R30 calltime |
---|
132 | typeset -L20 column1 |
---|
133 | typeset -L50 column2 |
---|
134 | typeset -L70 column3 |
---|
135 | typeset -L40 version="MBUILD 2.1 Rev$Rev: 508 $" |
---|
136 | |
---|
137 | # ERROR HANDLING |
---|
138 | # IN CASE OF EXIT: |
---|
139 | trap 'rm -rf $working_directory/tmp_mbuild |
---|
140 | if [[ $locat != normal ]] |
---|
141 | then |
---|
142 | printf "\n\n +++ mbuild killed \n\n" |
---|
143 | else |
---|
144 | printf "\n\n *** mbuild finished \n\n" |
---|
145 | fi' exit |
---|
146 | |
---|
147 | |
---|
148 | # IN CASE OF TERMINAL-BREAK: |
---|
149 | trap 'rm -rf $working_directory/tmp_mbuild |
---|
150 | printf "\n\n +++ mbuild killed by \"^C\" \n\n" |
---|
151 | exit |
---|
152 | ' 2 |
---|
153 | |
---|
154 | |
---|
155 | tmp_mbuild=${working_directory}/tmp_mbuild |
---|
156 | |
---|
157 | # READ SHELLSCRIPT-OPTIONS |
---|
158 | while getopts :c:h:m:s:u option |
---|
159 | do |
---|
160 | case $option in |
---|
161 | (c) config_file=$OPTARG;; |
---|
162 | (h) host=$OPTARG;; |
---|
163 | (m) makefile=$OPTARG;; |
---|
164 | (s) suf=$OPTARG;; |
---|
165 | (u) compile_utility_programs=true;; |
---|
166 | (\?) printf "\n +++ unknown option $OPTARG \n"; |
---|
167 | locat=parameter; exit;; |
---|
168 | esac |
---|
169 | done |
---|
170 | |
---|
171 | |
---|
172 | |
---|
173 | # CHECK, IF CONFIGURATION-FILE EXISTS |
---|
174 | if [[ ! -f $config_file ]] |
---|
175 | then |
---|
176 | printf "\n +++ configuration file: " |
---|
177 | printf "\n $config_file" |
---|
178 | printf "\n does not exist" |
---|
179 | locat=configuration; exit |
---|
180 | fi |
---|
181 | |
---|
182 | |
---|
183 | |
---|
184 | # DETERMINE THE LOCAL HOST |
---|
185 | local_host_real_name=$(hostname) |
---|
186 | # local_addres=$(nslookup `hostname` 2>&1 | grep "Address:" | tail -1 | awk '{print $2}') |
---|
187 | |
---|
188 | |
---|
189 | |
---|
190 | # DETERMINE HOST-IDENTIFIER (local_host) FROM THE CONFIG-FILE |
---|
191 | line="" |
---|
192 | grep "%host_identifier" $config_file > $tmp_mbuild |
---|
193 | while read line |
---|
194 | do |
---|
195 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
196 | then |
---|
197 | HOSTNAME=`echo $line | cut -d" " -s -f2` |
---|
198 | host_identifier=`echo $line | cut -d" " -s -f3` |
---|
199 | if [[ $local_host_real_name = $HOSTNAME ]] |
---|
200 | then |
---|
201 | local_host=$host_identifier |
---|
202 | break |
---|
203 | fi |
---|
204 | fi |
---|
205 | done < $tmp_mbuild |
---|
206 | |
---|
207 | if [[ "$local_host" = "" ]] |
---|
208 | then |
---|
209 | printf "\n +++ no host identifier found in configuration file \"$config_file\"" |
---|
210 | printf "\n for local host \"$local_host_real_name\"." |
---|
211 | printf "\n Please add line" |
---|
212 | printf "\n \"\%host_identifier $local_host_real_name <identifier>\"" |
---|
213 | printf "\n to the configuration file." |
---|
214 | locat=local_host; exit |
---|
215 | fi |
---|
216 | |
---|
217 | |
---|
218 | |
---|
219 | [[ $local_host_real_name = scirocco ]] && scirocco=true |
---|
220 | [[ $local_host_real_name = fimm.bccs.uib.no ]] && fimm=true |
---|
221 | |
---|
222 | |
---|
223 | |
---|
224 | if [[ $local_host != ibms ]] |
---|
225 | then |
---|
226 | config_file=$PWD/$config_file |
---|
227 | else |
---|
228 | config_file=`pwd`/$config_file |
---|
229 | fi |
---|
230 | |
---|
231 | |
---|
232 | |
---|
233 | # DETERMINE USER NAME ON LOCAL HOST FROM THE CONFIG-FILE |
---|
234 | line="" |
---|
235 | grep " $local_host" $config_file | grep "%remote_username" > $tmp_mbuild |
---|
236 | while read line |
---|
237 | do |
---|
238 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
239 | then |
---|
240 | local_username=`echo $line | cut -d" " -s -f2` |
---|
241 | fi |
---|
242 | done < $tmp_mbuild |
---|
243 | |
---|
244 | |
---|
245 | if [[ "$local_username" = "" ]] |
---|
246 | then |
---|
247 | printf "\n +++ no user name found in configuration file" |
---|
248 | printf "\n for local host \"$local_host\" " |
---|
249 | locat=config_file; exit |
---|
250 | fi |
---|
251 | |
---|
252 | |
---|
253 | # DETERMINE LOCAL SOURCE-CODE PATH. |
---|
254 | # FIRST CHECK, IF A GLOBAL SOURCE-CODE PATH HAS BEEN DECLARED FOR ALL HOSTS. |
---|
255 | # THEREFORE, FIRST SET ALL GLOBAL VARIABLES DECLARED IN THE CONFIG-FILE, |
---|
256 | # BECAUSE THEY MAY BE USED AS PART OF THE PATH NAME. |
---|
257 | line="" |
---|
258 | grep "%" $config_file > $tmp_mbuild |
---|
259 | while read line |
---|
260 | do |
---|
261 | if [[ "$line" != "" && "$(echo $line | cut -d" " -s -f3)" = "" && $(echo $line | cut -c1) != "#" ]] |
---|
262 | then |
---|
263 | var=`echo $line | cut -d" " -s -f1 | cut -c2-` |
---|
264 | value=`echo $line | cut -d" " -s -f2` |
---|
265 | eval export $var=\$value |
---|
266 | fi |
---|
267 | done < $tmp_mbuild |
---|
268 | |
---|
269 | # NOW CHECK, IF A GLOBAL SOURCE-CODE-PATH HAS BEEN DECLARED |
---|
270 | line="" |
---|
271 | grep "%source_path" $config_file > $tmp_mbuild |
---|
272 | while read line |
---|
273 | do |
---|
274 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
275 | then |
---|
276 | if [[ "$(echo $line | cut -d" " -s -f3)" = "" ]] |
---|
277 | then |
---|
278 | global_source_path=`echo $line | cut -d" " -s -f2` |
---|
279 | fi |
---|
280 | fi |
---|
281 | done < $tmp_mbuild |
---|
282 | |
---|
283 | line="" |
---|
284 | grep " $local_host" $config_file | grep "%source_path" > $tmp_mbuild |
---|
285 | while read line |
---|
286 | do |
---|
287 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
288 | then |
---|
289 | local_source_path=`echo $line | cut -d" " -s -f2` |
---|
290 | fi |
---|
291 | done < $tmp_mbuild |
---|
292 | |
---|
293 | if [[ "$local_source_path" = "" ]] |
---|
294 | then |
---|
295 | if [[ "$global_source_path" != "" ]] |
---|
296 | then |
---|
297 | local_source_path=$global_source_path |
---|
298 | else |
---|
299 | printf "\n +++ no source path found in configuration file" |
---|
300 | printf "\n for local host \"$local_host\" " |
---|
301 | printf "\n please set \"\%source_path\" in configuration file" |
---|
302 | locat=config_file; exit |
---|
303 | fi |
---|
304 | fi |
---|
305 | eval local_source_path=$local_source_path |
---|
306 | eval local_source_path=$local_source_path |
---|
307 | |
---|
308 | |
---|
309 | |
---|
310 | # DETERMINE GLOBAL DEPOSITORY-PATH |
---|
311 | line="" |
---|
312 | grep "%depository_path" $config_file > $tmp_mbuild |
---|
313 | while read line |
---|
314 | do |
---|
315 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
316 | then |
---|
317 | if [[ "$(echo $line | cut -d" " -s -f3)" = "" ]] |
---|
318 | then |
---|
319 | global_depository_path=`echo $line | cut -d" " -s -f2` |
---|
320 | fi |
---|
321 | fi |
---|
322 | done < $tmp_mbuild |
---|
323 | |
---|
324 | |
---|
325 | |
---|
326 | # CHECK, IF A MAIN PROGRAM HAS BEEN DEFINED IN THE CONFIG-FILE |
---|
327 | if [[ $(grep -c "%mainprog" $config_file) != 1 ]] |
---|
328 | then |
---|
329 | printf "\n +++ no main program or more than one main program defined" |
---|
330 | printf "\n in configuration file" |
---|
331 | locat=configuration; exit |
---|
332 | else |
---|
333 | line=`grep "%mainprog" $config_file` |
---|
334 | if [[ "$line" = "" || $(echo $line | cut -c1) = "#" ]] |
---|
335 | then |
---|
336 | printf "\n +++ no main program defined in configuration file" |
---|
337 | locat=configuration; exit |
---|
338 | fi |
---|
339 | mainprog=`echo $line | cut -d" " -s -f2 | cut -d"." -f1` |
---|
340 | fi |
---|
341 | |
---|
342 | |
---|
343 | |
---|
344 | # CHECK IF MAKEFILE EXITS |
---|
345 | [[ "$makefile" = "" ]] && makefile=$local_source_path/Makefile |
---|
346 | if [[ ! -f $makefile ]] |
---|
347 | then |
---|
348 | printf "\n +++ makefile: " |
---|
349 | printf "\n $makefile" |
---|
350 | printf "\n does not exist" |
---|
351 | locat=makefile; exit |
---|
352 | fi |
---|
353 | |
---|
354 | |
---|
355 | # HEADER-OUTPUT (PART1: MESSAGES CONCERNING THE LOCAL HOST) |
---|
356 | calltime=$(date) |
---|
357 | printf "\n" |
---|
358 | printf "#------------------------------------------------------------------------# \n" |
---|
359 | printf "| $version$calltime | \n" |
---|
360 | printf "| | \n" |
---|
361 | column1="called on:"; column2=$local_host_real_name |
---|
362 | printf "| $column1$column2 | \n" |
---|
363 | column1="local username:"; column2=$local_username |
---|
364 | printf "| $column1$column2 | \n" |
---|
365 | column1="local IP-addres:"; column2=$local_addres |
---|
366 | printf "| $column1$column2 | \n" |
---|
367 | column1="config file:"; column2=$config_file |
---|
368 | printf "| $column1$column2 | \n" |
---|
369 | column1="makefile:"; column2=$makefile |
---|
370 | printf "| $column1$column2 | \n" |
---|
371 | column1="local source path:"; column2=$local_source_path |
---|
372 | printf "| $column1$column2 | \n" |
---|
373 | printf "#------------------------------------------------------------------------# \n" |
---|
374 | |
---|
375 | # printf "| | \n" |
---|
376 | |
---|
377 | |
---|
378 | if [[ $compile_utility_programs = false ]] |
---|
379 | then |
---|
380 | |
---|
381 | # IN ANY CASE, GIVE ALL FILES WRITE-PERMIT, IN ORDER TO AVOID PROBLEMS |
---|
382 | # WITH OVERWRITING FILES ON THE REMOTE HOST |
---|
383 | cd $local_source_path |
---|
384 | printf "\n\n *** tar of makefile and source files in $local_source_path" |
---|
385 | tar -cf ${mainprog}_sources.tar Makefile *.$suf |
---|
386 | printf "\n" |
---|
387 | |
---|
388 | fi |
---|
389 | |
---|
390 | |
---|
391 | |
---|
392 | # GET CONFIRMATION TO CONTINUE |
---|
393 | if [[ $host = all ]] |
---|
394 | then |
---|
395 | printf "\n *** updates will be made for ALL hosts found in" |
---|
396 | printf "\n the configuration file" |
---|
397 | else |
---|
398 | printf "\n *** update will be made for host \"$host\" " |
---|
399 | fi |
---|
400 | |
---|
401 | if [[ $silent = false ]] |
---|
402 | then |
---|
403 | answer=dummy |
---|
404 | printf "\n\n" |
---|
405 | while [[ "$answer" != y && "$answer" != Y && "$answer" != n && "$answer" != N ]] |
---|
406 | do |
---|
407 | printf " >>> continue (y/n) ? " |
---|
408 | read answer |
---|
409 | done |
---|
410 | if [[ $answer = n || $answer = N ]] |
---|
411 | then |
---|
412 | locat=user_abort; exit |
---|
413 | fi |
---|
414 | fi |
---|
415 | |
---|
416 | |
---|
417 | |
---|
418 | |
---|
419 | # GENERIERUNG DER AKTUELLEN MODELLVERSION FUER ALLE RECHNER-/UEBERSETZUNGS- |
---|
420 | # VERSIONEN, DIE IN DER KONFIGURATIONSDATEI GEFUNDEN WERDEN |
---|
421 | printf "\n *** scanning configuration file for host(s) ..." |
---|
422 | |
---|
423 | grep %fopts $config_file > $tmp_mbuild |
---|
424 | while read line |
---|
425 | do |
---|
426 | # KOMMENTARZEILEN UEBERSPRINGEN |
---|
427 | [[ $(echo $line | cut -c1) = "#" ]] && continue |
---|
428 | (( ihost = ihost + 1 )) |
---|
429 | hostline[$ihost]="$line" |
---|
430 | done < $tmp_mbuild |
---|
431 | |
---|
432 | |
---|
433 | while (( ih < ihost )) |
---|
434 | do |
---|
435 | |
---|
436 | (( ih = ih + 1 )) |
---|
437 | |
---|
438 | # REMOTE-RECHNER UND UEBERSETZUNGS-VERSION FESTSTELLEN |
---|
439 | # NUR WEITERMACHEN, WENN ENTSPRECHENDER REMOTE-RECHNER MITTELS |
---|
440 | # SHELLSCRIPT-OPTION AUCH AUSGEWAEHLT WURDE |
---|
441 | remote_host_string=`echo ${hostline[$ih]} | cut -d" " -s -f3-` |
---|
442 | remote_host=`echo $remote_host_string | cut -d" " -f1` |
---|
443 | if [[ $host != all ]] |
---|
444 | then |
---|
445 | [[ $remote_host != $host ]] && continue |
---|
446 | fi |
---|
447 | host_found=true |
---|
448 | condition1=`echo $remote_host_string | cut -d" " -s -f2` |
---|
449 | if [[ $condition1 = $remote_host ]] |
---|
450 | then |
---|
451 | condition1="" |
---|
452 | else |
---|
453 | condition2=`echo $remote_host_string | cut -d" " -s -f3` |
---|
454 | fi |
---|
455 | |
---|
456 | modules="" |
---|
457 | netcdf_inc="" |
---|
458 | netcdf_lib="" |
---|
459 | |
---|
460 | # IP-ADRESSE DES REMOTE-RECHNERS BESTIMMEN |
---|
461 | case $remote_host in |
---|
462 | (lcmuk) remote_addres=130.75.105.2;; |
---|
463 | (lcsgib) remote_addres=130.73.232.102;; |
---|
464 | (lcsgih) remote_addres=130.75.4.102;; |
---|
465 | (lck) remote_addres=165.132.26.61;; |
---|
466 | (lctit) remote_addres=172.17.75.161;; |
---|
467 | (lcxt4) remote_addres=129.177.20.113;; |
---|
468 | (lcxt5m) remote_addres=193.166.211.144;; |
---|
469 | (decalpha) remote_addres=165.132.26.56;; |
---|
470 | (ibmh) remote_addres=136.172.40.15;; |
---|
471 | (ibms) remote_addres=150.183.5.101;; |
---|
472 | (ibmy) remote_addres=165.132.26.58;; |
---|
473 | (nech) remote_addres=136.172.44.192;; |
---|
474 | (neck) remote_addres=133.5.178.11;; |
---|
475 | (ground.yonsei.ac.kr) remote_addres=134.75.155.33;; |
---|
476 | (*) if [[ $local_host != $remote_host ]] |
---|
477 | then |
---|
478 | printf "\n +++ remote host \"$remote_host\" unknown"; |
---|
479 | printf "\n please inform PALM group support!" |
---|
480 | fi;; |
---|
481 | esac |
---|
482 | |
---|
483 | |
---|
484 | # REMOTE-USERNAMEN ERMITTELN |
---|
485 | line="" |
---|
486 | found=false |
---|
487 | grep "$remote_host_string" $config_file | grep "%remote_username" > $tmp_mbuild |
---|
488 | while read line1 |
---|
489 | do |
---|
490 | |
---|
491 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
492 | then |
---|
493 | line="$line1" |
---|
494 | fi |
---|
495 | |
---|
496 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
497 | then |
---|
498 | remote_username=`echo $line | cut -d" " -s -f2` |
---|
499 | found=true |
---|
500 | fi |
---|
501 | |
---|
502 | done < $tmp_mbuild |
---|
503 | |
---|
504 | if [[ $found = false ]] |
---|
505 | then |
---|
506 | printf "\n +++ no remote username found in configuration file" |
---|
507 | printf "\n for \"$remote_host_string\" " |
---|
508 | locat=config_file; exit |
---|
509 | fi |
---|
510 | |
---|
511 | |
---|
512 | # REMOTE-QUELLTEXTPFAD ERMITTELN |
---|
513 | line="" |
---|
514 | remote_source_path="" |
---|
515 | grep "$remote_host_string" $config_file | grep "%source_path" > $tmp_mbuild |
---|
516 | while read line1 |
---|
517 | do |
---|
518 | |
---|
519 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
520 | then |
---|
521 | line="$line1" |
---|
522 | fi |
---|
523 | |
---|
524 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
525 | then |
---|
526 | remote_source_path=`echo $line | cut -d" " -s -f2` |
---|
527 | fi |
---|
528 | |
---|
529 | done < $tmp_mbuild |
---|
530 | |
---|
531 | if [[ "$remote_source_path" = "" ]] |
---|
532 | then |
---|
533 | if [[ "$global_source_path" != "" ]] |
---|
534 | then |
---|
535 | remote_source_path=$global_source_path |
---|
536 | else |
---|
537 | printf "\n +++ no source path found in configuration file" |
---|
538 | printf "\n for \"$remote_host_string\" " |
---|
539 | locat=config_file; exit |
---|
540 | fi |
---|
541 | fi |
---|
542 | |
---|
543 | remote_ud=${remote_source_path}/../UTIL |
---|
544 | remote_ud=$(eval echo $remote_ud) |
---|
545 | |
---|
546 | |
---|
547 | # REMOTE-PFAD FUER MAKE-DEPOSITORY ERMITTELN |
---|
548 | remote_md="" |
---|
549 | line="" |
---|
550 | grep "$remote_host_string" $config_file | grep "%depository_path" > $tmp_mbuild |
---|
551 | while read line1 |
---|
552 | do |
---|
553 | |
---|
554 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
555 | then |
---|
556 | line="$line1" |
---|
557 | fi |
---|
558 | |
---|
559 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
560 | then |
---|
561 | remote_md=`echo $line | cut -d" " -s -f2` |
---|
562 | fi |
---|
563 | |
---|
564 | done < $tmp_mbuild |
---|
565 | |
---|
566 | if [[ "$remote_md" = "" ]] |
---|
567 | then |
---|
568 | if [[ "$global_depository_path" != "" ]] |
---|
569 | then |
---|
570 | remote_md=$global_depository_path |
---|
571 | else |
---|
572 | printf "\n +++ no depository path found in configuration file" |
---|
573 | printf "\n for \"$remote_host_string\" " |
---|
574 | printf "\n please set \"\%depository_path\" in configuration file" |
---|
575 | locat=config_file; exit |
---|
576 | fi |
---|
577 | fi |
---|
578 | |
---|
579 | remote_md=$(eval echo $remote_md) |
---|
580 | block="" |
---|
581 | [[ "$condition1" != "" ]] && block=_$condition1 |
---|
582 | [[ "$condition2" != "" ]] && block=${block}_$condition2 |
---|
583 | remote_md=${remote_md}$block |
---|
584 | |
---|
585 | |
---|
586 | # COMPILERNAMEN ERMITTELN |
---|
587 | line="" |
---|
588 | found=false |
---|
589 | grep "$remote_host_string" $config_file | grep "%compiler_name " > $tmp_mbuild |
---|
590 | while read line1 |
---|
591 | do |
---|
592 | |
---|
593 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
594 | then |
---|
595 | line="$line1" |
---|
596 | fi |
---|
597 | |
---|
598 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
599 | then |
---|
600 | compiler_name=`echo $line | cut -d" " -s -f2` |
---|
601 | found=true |
---|
602 | fi |
---|
603 | |
---|
604 | done < $tmp_mbuild |
---|
605 | |
---|
606 | if [[ $found = false ]] |
---|
607 | then |
---|
608 | printf "\n +++ no compiler name found in configuration file" |
---|
609 | printf "\n for \"$remote_host_string\" " |
---|
610 | locat=config_file; exit |
---|
611 | fi |
---|
612 | |
---|
613 | |
---|
614 | # BEI BENUTZUNG EINES PARALLELEN COMPILERS MUSS AUCH EIN |
---|
615 | # SERIELLER COMPILERNAME ERMITTELT WERDEN |
---|
616 | if [[ $(echo $remote_host_string | grep -c parallel) = 1 ]] |
---|
617 | then |
---|
618 | line="" |
---|
619 | found=false |
---|
620 | grep "$remote_host_string" $config_file | grep "%compiler_name_ser" > $tmp_mbuild |
---|
621 | while read line1 |
---|
622 | do |
---|
623 | |
---|
624 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
625 | then |
---|
626 | line="$line1" |
---|
627 | fi |
---|
628 | |
---|
629 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
630 | then |
---|
631 | compiler_name_ser=`echo $line | cut -d" " -s -f2` |
---|
632 | found=true |
---|
633 | fi |
---|
634 | |
---|
635 | done < $tmp_mbuild |
---|
636 | |
---|
637 | if [[ $found = false ]] |
---|
638 | then |
---|
639 | printf "\n +++ no serial compiler name found in configuration file" |
---|
640 | printf "\n for \"$remote_host_string\" " |
---|
641 | locat=config_file; exit |
---|
642 | fi |
---|
643 | else |
---|
644 | compiler_name_ser=$compiler_name |
---|
645 | fi |
---|
646 | |
---|
647 | |
---|
648 | |
---|
649 | # PRAEPROZESSOR-OPTIONEN/DIREKTIVEN ERMITTELN |
---|
650 | line="" |
---|
651 | found=false |
---|
652 | grep "$remote_host_string" $config_file | grep "%cpp_options" > $tmp_mbuild |
---|
653 | while read line1 |
---|
654 | do |
---|
655 | |
---|
656 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
657 | then |
---|
658 | line="$line1" |
---|
659 | fi |
---|
660 | |
---|
661 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
662 | then |
---|
663 | # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING ENTFERNEN |
---|
664 | cpp_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` |
---|
665 | found=true |
---|
666 | fi |
---|
667 | |
---|
668 | done < $tmp_mbuild |
---|
669 | |
---|
670 | if [[ $found = false ]] |
---|
671 | then |
---|
672 | printf "\n +++ no preprocessor options found in configuration file" |
---|
673 | printf "\n for \"$remote_host_string\" " |
---|
674 | locat=config_file; exit |
---|
675 | fi |
---|
676 | |
---|
677 | |
---|
678 | # RECHNERSPEZIFISCHE CPP-DIREKTIVEN HINZUFUEGEN |
---|
679 | for string in $remote_host_string |
---|
680 | do |
---|
681 | if [[ $(echo $remote_host | cut -c1-2) = lc && $(echo $string | cut -c1-2) = lc ]] |
---|
682 | then |
---|
683 | cpp_options="$cpp_options -D__lc " |
---|
684 | elif [[ $(echo $remote_host | cut -c1-3) = ibm && $(echo $string | cut -c1-3) = ibm ]] |
---|
685 | then |
---|
686 | cpp_options="${cpp_options},-D__ibm" |
---|
687 | elif [[ $(echo $remote_host | cut -c1-3) = nec && $(echo $string | cut -c1-3) = nec ]] |
---|
688 | then |
---|
689 | cpp_options="${cpp_options} -D__nec" |
---|
690 | else |
---|
691 | if [[ $(echo $remote_host | cut -c1-3) = ibm ]] |
---|
692 | then |
---|
693 | cpp_options="${cpp_options},-D__$string" |
---|
694 | else |
---|
695 | cpp_options="$cpp_options -D__$string " |
---|
696 | fi |
---|
697 | fi |
---|
698 | done |
---|
699 | |
---|
700 | |
---|
701 | |
---|
702 | # NETCDF-OPTIONEN ERMITTELN |
---|
703 | line="" |
---|
704 | grep "$remote_host_string" $config_file | grep "%netcdf_inc" > $tmp_mbuild |
---|
705 | while read line1 |
---|
706 | do |
---|
707 | |
---|
708 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
709 | then |
---|
710 | line="$line1" |
---|
711 | fi |
---|
712 | |
---|
713 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
714 | then |
---|
715 | # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING ENTFERNEN |
---|
716 | netcdf_inc=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` |
---|
717 | fi |
---|
718 | |
---|
719 | done < $tmp_mbuild |
---|
720 | |
---|
721 | line="" |
---|
722 | grep "$remote_host_string" $config_file | grep "%netcdf_lib" > $tmp_mbuild |
---|
723 | while read line1 |
---|
724 | do |
---|
725 | |
---|
726 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
727 | then |
---|
728 | line="$line1" |
---|
729 | fi |
---|
730 | |
---|
731 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
732 | then |
---|
733 | # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING ENTFERNEN |
---|
734 | netcdf_lib=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` |
---|
735 | fi |
---|
736 | |
---|
737 | done < $tmp_mbuild |
---|
738 | |
---|
739 | |
---|
740 | |
---|
741 | # get make options |
---|
742 | line="" |
---|
743 | found=false |
---|
744 | grep "$remote_host_string" $config_file | grep "%mopts" > $tmp_mbuild |
---|
745 | while read line1 |
---|
746 | do |
---|
747 | |
---|
748 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
749 | then |
---|
750 | line="$line1" |
---|
751 | fi |
---|
752 | |
---|
753 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
754 | then |
---|
755 | # remove colons from directive string |
---|
756 | make_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` |
---|
757 | |
---|
758 | fi |
---|
759 | |
---|
760 | done < $tmp_mbuild |
---|
761 | |
---|
762 | |
---|
763 | |
---|
764 | # COMPILEROPTIONEN ERMITTELN |
---|
765 | line="" |
---|
766 | found=false |
---|
767 | grep "$remote_host_string" $config_file | grep "%fopts" > $tmp_mbuild |
---|
768 | while read line1 |
---|
769 | do |
---|
770 | |
---|
771 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
772 | then |
---|
773 | line="$line1" |
---|
774 | fi |
---|
775 | |
---|
776 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
777 | then |
---|
778 | # EVENTUELLE DOPPELPUNKTE AUS DIREKTIVENSTRING ENTFERNEN |
---|
779 | compiler_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` |
---|
780 | found=true |
---|
781 | |
---|
782 | # NETCDF-INCLUDEVERZEICHNIS HINZUFUEGEN |
---|
783 | compiler_options="$compiler_options $netcdf_inc" |
---|
784 | fi |
---|
785 | |
---|
786 | done < $tmp_mbuild |
---|
787 | |
---|
788 | if [[ $found = false ]] |
---|
789 | then |
---|
790 | printf "\n +++ no compiler options found in configuration file" |
---|
791 | printf "\n for \"$remote_host_string\" " |
---|
792 | locat=config_file; exit |
---|
793 | fi |
---|
794 | |
---|
795 | |
---|
796 | |
---|
797 | # get modules to be loaded |
---|
798 | line="" |
---|
799 | grep "$remote_host_string" $config_file | grep "%modules" > $tmp_mbuild |
---|
800 | while read line1 |
---|
801 | do |
---|
802 | |
---|
803 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
804 | then |
---|
805 | line="$line1" |
---|
806 | fi |
---|
807 | |
---|
808 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
809 | then |
---|
810 | # EVENTUELLE DOPPELPUNKTE AUS DIREKTIVENSTRING ENTFERNEN |
---|
811 | modules=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` |
---|
812 | fi |
---|
813 | |
---|
814 | done < $tmp_mbuild |
---|
815 | |
---|
816 | |
---|
817 | |
---|
818 | |
---|
819 | # LADER-OPTIONEN ERMITTELN |
---|
820 | line="" |
---|
821 | found=false |
---|
822 | grep "$remote_host_string" $config_file | grep "%lopts" > $tmp_mbuild |
---|
823 | while read line1 |
---|
824 | do |
---|
825 | |
---|
826 | if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] |
---|
827 | then |
---|
828 | line="$line1" |
---|
829 | fi |
---|
830 | |
---|
831 | if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] |
---|
832 | then |
---|
833 | # EVENTUELLE DOPPELPUNKTE AUS DIREKTIVENSTRING ENTFERNEN |
---|
834 | loader_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` |
---|
835 | found=true |
---|
836 | |
---|
837 | # NETCDF-LIBRARY HINZUFUEGEN |
---|
838 | loader_options="$loader_options $netcdf_lib" |
---|
839 | fi |
---|
840 | |
---|
841 | done < $tmp_mbuild |
---|
842 | |
---|
843 | if [[ $found = false ]] |
---|
844 | then |
---|
845 | printf "\n +++ no loader options found in configuration file" |
---|
846 | printf "\n for \"$remote_host_string\" " |
---|
847 | locat=config_file; exit |
---|
848 | fi |
---|
849 | |
---|
850 | |
---|
851 | printf "\n\n#------------------------------------------------------------------------# \n" |
---|
852 | if [[ $remote_host = $local_host ]] |
---|
853 | then |
---|
854 | column1="remote_host:"; column2="$remote_host (= local host!)" |
---|
855 | else |
---|
856 | column1="remote_host:"; column2=$remote_host |
---|
857 | fi |
---|
858 | printf "| $column1$column2 | \n" |
---|
859 | printf "| | \n" |
---|
860 | column1="conditions:"; column2="$condition1 $condition2" |
---|
861 | printf "| $column1$column2 | \n" |
---|
862 | column1="make depository:"; column2=$remote_md |
---|
863 | printf "| $column1$column2 | \n" |
---|
864 | line=$(echo "$remote_md" | cut -c51-) |
---|
865 | while [[ "$line" != "" ]] |
---|
866 | do |
---|
867 | column1="" |
---|
868 | column2=$line |
---|
869 | printf "| $column1$column2 | \n" |
---|
870 | line=$(echo "$line" | cut -c51-) |
---|
871 | done |
---|
872 | if [[ $compile_utility_programs = true ]] |
---|
873 | then |
---|
874 | column1="utility directory:"; column2=$remote_ud |
---|
875 | printf "| $column1$column2 | \n" |
---|
876 | fi |
---|
877 | column1="username:"; column2=$remote_username |
---|
878 | printf "| $column1$column2 | \n" |
---|
879 | column1="addres:"; column2=$remote_addres |
---|
880 | printf "| $column1$column2 | \n" |
---|
881 | column1="compiler:"; column2=$compiler_name |
---|
882 | printf "| $column1$column2 | \n" |
---|
883 | if [[ $compile_utility_programs = true ]] |
---|
884 | then |
---|
885 | column1="serial compiler:"; column2=$compiler_name_ser |
---|
886 | printf "| $column1$column2 | \n" |
---|
887 | fi |
---|
888 | if [[ "$make_options" != "" ]] |
---|
889 | then |
---|
890 | column1="make options:"; column2=$make_options |
---|
891 | printf "| $column1$column2 | \n" |
---|
892 | fi |
---|
893 | column1="cpp options:"; column2=$cpp_options |
---|
894 | printf "| $column1$column2 | \n" |
---|
895 | line=$(echo "$cpp_options" | cut -c51-) |
---|
896 | while [[ "$line" != "" ]] |
---|
897 | do |
---|
898 | column1="" |
---|
899 | column2=$line |
---|
900 | printf "| $column1$column2 | \n" |
---|
901 | line=$(echo "$line" | cut -c51-) |
---|
902 | done |
---|
903 | column1="compiler options:"; column2=$compiler_options |
---|
904 | printf "| $column1$column2 | \n" |
---|
905 | line=$(echo "$compiler_options" | cut -c51-) |
---|
906 | while [[ "$line" != "" ]] |
---|
907 | do |
---|
908 | column1="" |
---|
909 | column2=$line |
---|
910 | printf "| $column1$column2 | \n" |
---|
911 | line=$(echo "$line" | cut -c51-) |
---|
912 | done |
---|
913 | column1="loader options:"; column2=$loader_options |
---|
914 | printf "| $column1$column2 | \n" |
---|
915 | line=$(echo "$loader_options" | cut -c51-) |
---|
916 | while [[ "$line" != "" ]] |
---|
917 | do |
---|
918 | column1="" |
---|
919 | column2=$line |
---|
920 | printf "| $column1$column2 | \n" |
---|
921 | line=$(echo "$line" | cut -c51-) |
---|
922 | done |
---|
923 | if [[ $modules != "" ]] |
---|
924 | then |
---|
925 | column1="modules to be load:"; column2=$modules |
---|
926 | printf "| $column1$column2 | \n" |
---|
927 | line=$(echo "$modules" | cut -c51-) |
---|
928 | while [[ "$line" != "" ]] |
---|
929 | do |
---|
930 | column1="" |
---|
931 | column2=$line |
---|
932 | printf "| $column1$column2 | \n" |
---|
933 | line=$(echo "$line" | cut -c51-) |
---|
934 | done |
---|
935 | fi |
---|
936 | printf "#------------------------------------------------------------------------# \n" |
---|
937 | |
---|
938 | if [[ $silent = false ]] |
---|
939 | then |
---|
940 | answer=dummy |
---|
941 | printf "\n\n" |
---|
942 | while [[ "$answer" != y && "$answer" != Y && "$answer" != c && "$answer" != C && "$answer" != s && "$answer" != S && "$answer" != a && "$answer" != A ]] |
---|
943 | do |
---|
944 | printf " >>> continue (y(es)/c(ontinue)/a(bort)/s(skip)) ? " |
---|
945 | read answer |
---|
946 | done |
---|
947 | if [[ $answer = a || $answer = A ]] |
---|
948 | then |
---|
949 | locat=user_abort; exit |
---|
950 | fi |
---|
951 | if [[ $answer = c || $answer = C ]] |
---|
952 | then |
---|
953 | silent=true |
---|
954 | fi |
---|
955 | if [[ $answer = s || $answer = S ]] |
---|
956 | then |
---|
957 | continue |
---|
958 | fi |
---|
959 | fi |
---|
960 | |
---|
961 | |
---|
962 | # make on remote host |
---|
963 | if [[ $remote_host != $local_host ]] |
---|
964 | then |
---|
965 | |
---|
966 | if [[ $compile_utility_programs = false ]] |
---|
967 | then |
---|
968 | |
---|
969 | # AKTUELLE QUELLTEXTVERSION INS REMOTE-QUELLTEXTVERZEICHNIS KOPIEREN |
---|
970 | # FALLS DIESES NOCH NICHT EXISTIERT, WIRD ES ERZEUGT |
---|
971 | echo " *** copying \"${mainprog}_sources.tar\" to \"${remote_addres}:${remote_md}/\" " |
---|
972 | if [[ $remote_host != lctit ]] |
---|
973 | then |
---|
974 | ssh ${remote_username}@${remote_addres} "[[ ! -d ${remote_md} ]] && (echo \" *** ${remote_md} will be created\"; mkdir -p ${remote_md})" |
---|
975 | else |
---|
976 | # TIT ERLAUBT NUR DIE AUSFï¿œHRUNG GANZ BESTIMMTER KOMMANDOS |
---|
977 | # MIT SSH, DESHALB AUFRUF PER PIPE |
---|
978 | print "[[ ! -d ${remote_md} ]] && (echo \" *** ${remote_md} will be created\"; mkdir -p ${remote_md})" | ssh ${remote_username}@${remote_addres} 2>&1 |
---|
979 | fi |
---|
980 | if [[ $local_host = decalpha ]] |
---|
981 | then |
---|
982 | # DECALPHA BENUTZT BEI NICHTANGABE DES VOLLSTï¿œNDIGEN PFADES |
---|
983 | # IRGENDEIN ANDERES SCP (WAS NICHT FUNKTIONIERT). AUSSERDEM |
---|
984 | # KOENNEN DOLLAR-ZEICHEN NICHT BENUTZT WERDEN |
---|
985 | remote_md=`echo $remote_md | sed 's/\$HOME\///'` |
---|
986 | /bin/scp ${local_source_path}/${mainprog}_sources.tar ${remote_username}@${remote_addres}:${remote_md}/${mainprog}_sources.tar |
---|
987 | else |
---|
988 | scp ${local_source_path}/${mainprog}_sources.tar ${remote_username}@${remote_addres}:${remote_md}/${mainprog}_sources.tar |
---|
989 | fi |
---|
990 | |
---|
991 | |
---|
992 | |
---|
993 | # FALLS VORHANDEN, LETZTE VERSION AUF DEM REMOTE-RECHNER AUSPACKEN |
---|
994 | echo " *** untar previous update on remote host, if existing" |
---|
995 | if [[ $remote_host != lctit ]] |
---|
996 | then |
---|
997 | ssh ${remote_username}@${remote_addres} "cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]] && tar -xf ${mainprog}_current_version.tar" |
---|
998 | else |
---|
999 | # TIT ERLAUBT NUR DIE AUSFï¿œHRUNG GANZ BESTIMMTER KOMMANDOS |
---|
1000 | # MIT SSH, DESHALB AUFRUF PER PIPE |
---|
1001 | print "cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]] && tar -xf ${mainprog}_current_version.tar" | ssh ${remote_username}@${remote_addres} 2>&1 |
---|
1002 | fi |
---|
1003 | |
---|
1004 | |
---|
1005 | # AKTUELLE QUELLTEXTVERSION AUF REMOTE-RECHNER AUSPACKEN |
---|
1006 | echo " *** untar actual sources on remote host" |
---|
1007 | if [[ $remote_host != lctit ]] |
---|
1008 | then |
---|
1009 | ssh ${remote_username}@${remote_addres} "cd ${remote_md}; tar -xf ${mainprog}_sources.tar" |
---|
1010 | else |
---|
1011 | # TIT ERLAUBT NUR DIE AUSFï¿œHRUNG GANZ BESTIMMTER KOMMANDOS |
---|
1012 | # MIT SSH, DESHALB AUFRUF PER PIPE |
---|
1013 | print "cd ${remote_md}; tar -xf ${mainprog}_sources.tar" | ssh ${remote_username}@${remote_addres} 2>&1 |
---|
1014 | fi |
---|
1015 | |
---|
1016 | |
---|
1017 | # MAKE MIT ZUVOR ERMITTELTEN OPTIONEN AUF REMOTE RECHNER AUSFUEHREN |
---|
1018 | # KOMMANDOUEBERGABE AN SSH PER PIPE, DA SO DIE SYSTEM- UND |
---|
1019 | # BENUTZERPROFILE VOLLSTAENDIG AUSGEFUEHRT WERDEN (SONST FEHLEN MAKE |
---|
1020 | # Z.B. DIE PFADE ZUM COMPILER) |
---|
1021 | echo " *** execute \"make\" on remote host" |
---|
1022 | |
---|
1023 | |
---|
1024 | # generate make call with make options |
---|
1025 | if [[ $remote_host = nech ]] |
---|
1026 | then |
---|
1027 | make_call_string="sxmake $make_options PROG=$mainprog F90=$compiler_name COPT=\"$cpp_options\" F90FLAGS=\"$compiler_options\" LDFLAGS=\"$loader_options\" " |
---|
1028 | else |
---|
1029 | make_call_string="make $make_options PROG=$mainprog F90=$compiler_name COPT=\"$cpp_options\" F90FLAGS=\"$compiler_options\" LDFLAGS=\"$loader_options\" " |
---|
1030 | fi |
---|
1031 | |
---|
1032 | # generate command to load modules, if modules are given |
---|
1033 | if [[ "$modules" != "" ]] |
---|
1034 | then |
---|
1035 | module_calls="module load ${modules};" |
---|
1036 | else |
---|
1037 | module_calls="" |
---|
1038 | fi |
---|
1039 | |
---|
1040 | if [[ $remote_host = ibms || $remote_host = ibmy ]] |
---|
1041 | then |
---|
1042 | |
---|
1043 | ssh ${remote_username}@${remote_addres} "$module_calls cd ${remote_md}; echo '$make_call_string' > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" 2>&1 | tee ${remote_host}_last_make_protokoll |
---|
1044 | |
---|
1045 | elif [[ $remote_host = ibmh ]] |
---|
1046 | then |
---|
1047 | |
---|
1048 | print "$module_calls export OBJECT_MODE=64; cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll |
---|
1049 | |
---|
1050 | elif [[ $remote_host = lcsgib || $remote_host = lcsgih ]] |
---|
1051 | then |
---|
1052 | |
---|
1053 | print ". /usr/share/modules/init/bash; $module_calls cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll |
---|
1054 | |
---|
1055 | elif [[ $remote_host = lctit ]] |
---|
1056 | then |
---|
1057 | |
---|
1058 | echo " " > ${remote_host}_last_make_protokoll |
---|
1059 | while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]] |
---|
1060 | do |
---|
1061 | print "cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll |
---|
1062 | done |
---|
1063 | |
---|
1064 | elif [[ $remote_host = lcxt4 ]] |
---|
1065 | then |
---|
1066 | |
---|
1067 | print ". /opt/modules/default/init/ksh; $module_calls cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll |
---|
1068 | |
---|
1069 | else |
---|
1070 | |
---|
1071 | print "cd $module_calls ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll |
---|
1072 | |
---|
1073 | fi |
---|
1074 | |
---|
1075 | if [[ $(grep -c MAKE_ERROR ${remote_host}_last_make_protokoll) != 0 ]] |
---|
1076 | then |
---|
1077 | printf "\a\n +++ error(s) occurred during compiling or linking on host \"$remote_host\" " |
---|
1078 | if [[ $silent = false ]] |
---|
1079 | then |
---|
1080 | answer=dummy |
---|
1081 | printf "\n" |
---|
1082 | while [[ "$answer" != c && "$answer" != k ]] |
---|
1083 | do |
---|
1084 | printf " >>> continue / list errors / kill mbuild (c/l/k) ? " |
---|
1085 | read answer |
---|
1086 | if [[ "$answer" = l ]] |
---|
1087 | then |
---|
1088 | more ${remote_host}_last_make_protokoll |
---|
1089 | fi |
---|
1090 | done |
---|
1091 | if [[ $answer = k ]] |
---|
1092 | then |
---|
1093 | locat=user_abort; exit |
---|
1094 | fi |
---|
1095 | fi |
---|
1096 | fi |
---|
1097 | |
---|
1098 | |
---|
1099 | |
---|
1100 | # NEUE VERSION AUF REMOTE-RECHNER ZUSAMMENPACKEN |
---|
1101 | printf "\n *** tar update on remote host ..." |
---|
1102 | if [[ $remote_host != lctit ]] |
---|
1103 | then |
---|
1104 | ssh ${remote_username}@${remote_addres} "cd ${remote_md}; chmod u+w *; tar -cf ${mainprog}_current_version.tar ${mainprog} *.f90 *.o *.mod" |
---|
1105 | else |
---|
1106 | # TIT ERLAUBT NUR DIE AUSFï¿œHRUNG GANZ BESTIMMTER KOMMANDOS |
---|
1107 | # MIT SSH, DESHALB AUFRUF PER PIPE |
---|
1108 | print "cd ${remote_md}; chmod u+w *; tar -cf ${mainprog}_current_version.tar ${mainprog} *.f90 *.o *.mod" | ssh ${remote_username}@${remote_addres} 2>&1 |
---|
1109 | fi |
---|
1110 | |
---|
1111 | |
---|
1112 | # AKTUELLES VERSIONSVERZEICHNIS AUF REMOTE-RECHNER BEREINIGEN |
---|
1113 | # printf "\n *** \"make clean\" on remote host ..." |
---|
1114 | # ssh ${remote_username}@${remote_addres} "cd ${remote_md}; make clean; rm ${mainprog}_sources.tar; rm *.f90 Makefile" |
---|
1115 | # printf "\n" |
---|
1116 | |
---|
1117 | |
---|
1118 | |
---|
1119 | |
---|
1120 | # GLEICHE AKTIONEN FUER DIE UTILITY-PROGRAMME DURCHFUEHREN |
---|
1121 | # AKTUELLE QUELLTEXTVERSION INS REMOTE-QUELLTEXTVERZEICHNIS KOPIEREN |
---|
1122 | # FALLS DIESES NOCH NICHT EXISTIERT, WIRD ES ERZEUGT |
---|
1123 | elif [[ $compile_utility_programs = true ]] |
---|
1124 | then |
---|
1125 | |
---|
1126 | printf "\n\n" |
---|
1127 | echo " *** copying scripts and utility programs to \"${remote_addres}:${remote_ud}/\" " |
---|
1128 | cd ${local_source_path}/../SCRIPTS |
---|
1129 | |
---|
1130 | if [[ $remote_host != lctit ]] |
---|
1131 | then |
---|
1132 | ssh ${remote_username}@${remote_addres} "[[ ! -d ${remote_ud} ]] && (echo \" *** ${remote_ud} will be created\"; mkdir -p ${remote_ud}); [[ ! -d ${remote_ud}/../SCRIPTS ]] && (echo \" *** ${remote_ud}/../SCRIPTS will be created\"; mkdir -p ${remote_ud}/../SCRIPTS)" |
---|
1133 | else |
---|
1134 | # TIT ERLAUBT NUR DIE AUSFUEHRUNG GANZ BESTIMMTER KOMMANDOS |
---|
1135 | # MIT SSH, DESHALB AUFRUF PER PIPE |
---|
1136 | print "[[ ! -d ${remote_ud} ]] && (echo \" *** ${remote_ud} will be created\"; mkdir -p ${remote_ud}); [[ ! -d ${remote_ud}/../SCRIPTS ]] && (echo \" *** ${remote_ud}/../SCRIPTS will be created\"; mkdir -p ${remote_ud}/../SCRIPTS)" | ssh ${remote_username}@${remote_addres} 2>&1 |
---|
1137 | fi |
---|
1138 | |
---|
1139 | # KOPIEREN DER SCRIPTE |
---|
1140 | if [[ $local_host = decalpha ]] |
---|
1141 | then |
---|
1142 | # DECALPHA BENUTZT BEI NICHTANGABE DES VOLLSTAENDIGEN PFADES |
---|
1143 | # IRGENDEIN ANDERES SCP (WAS NICHT FUNKTIONIERT). AUSSERDEM |
---|
1144 | # KOENNEN DOLLAR-ZEICHEN NICHT BENUTZT WERDEN |
---|
1145 | remote_ud=`echo $remote_ud | sed 's/\$HOME\///'` |
---|
1146 | /bin/scp batch_scp mbuild mrun process_dvr_output .dvrserver.config subjob ${remote_username}@${remote_addres}:${remote_ud}/../SCRIPTS > /dev/null |
---|
1147 | else |
---|
1148 | scp batch_scp mbuild mrun process_dvr_output .dvrserver.config subjob ${remote_username}@${remote_addres}:${remote_ud}/../SCRIPTS > /dev/null |
---|
1149 | fi |
---|
1150 | |
---|
1151 | cd - > /dev/null |
---|
1152 | cd ${local_source_path}/../UTIL |
---|
1153 | |
---|
1154 | |
---|
1155 | # KOPIEREN DER UTILITY-PROGRAMME |
---|
1156 | if [[ $local_host = decalpha ]] |
---|
1157 | then |
---|
1158 | # DECALPHA BENUTZT BEI NICHTANGABE DES VOLLSTï¿œNDIGEN PFADES |
---|
1159 | # IRGENDEIN ANDERES SCP (WAS NICHT FUNKTIONIERT). AUSSERDEM |
---|
1160 | # KOENNEN DOLLAR-ZEICHEN NICHT BENUTZT WERDEN |
---|
1161 | remote_ud=`echo $remote_ud | sed 's/\$HOME\///'` |
---|
1162 | /bin/scp Makefile *.f90 ${remote_username}@${remote_addres}:${remote_ud} > /dev/null |
---|
1163 | else |
---|
1164 | scp Makefile *.f90 ${remote_username}@${remote_addres}:${remote_ud} > /dev/null |
---|
1165 | fi |
---|
1166 | |
---|
1167 | |
---|
1168 | |
---|
1169 | # MAKE MIT ZUVOR ERMITTELTEN OPTIONEN AUF REMOTE RECHNER AUSFUEHREN |
---|
1170 | # KOMMANDOUEBERGABE AN SSH PER PIPE, DA SO DIE SYSTEM- UND |
---|
1171 | # BENUTZERPROFILE VOLLSTAENDIG AUSGEFUEHRT WERDEN (SONST FEHLEN MAKE |
---|
1172 | # Z.B. DIE PFADE ZUM COMPILER) |
---|
1173 | echo " *** execute \"make\" on remote host" |
---|
1174 | |
---|
1175 | if [[ $remote_host = nech ]] |
---|
1176 | then |
---|
1177 | make_call_string="sxmake $make_options BLOCK=$block F90=$compiler_name F90_SER=$compiler_name_ser COPT=\"$cpp_options\" F90FLAGS=\"$compiler_options\" LDFLAGS=\"$loader_options\" " |
---|
1178 | else |
---|
1179 | make_call_string="make $make_options BLOCK=$block F90=$compiler_name F90_SER=$compiler_name_ser COPT=\"$cpp_options\" F90FLAGS=\"$compiler_options\" LDFLAGS=\"$loader_options\" " |
---|
1180 | fi |
---|
1181 | |
---|
1182 | # generate command to load modules, if modules are given |
---|
1183 | if [[ "$modules" != "" ]] |
---|
1184 | then |
---|
1185 | module_calls="module load ${modules};" |
---|
1186 | else |
---|
1187 | module_calls="" |
---|
1188 | fi |
---|
1189 | |
---|
1190 | if [[ $remote_host = ibms || $remote_host = ibmy ]] |
---|
1191 | then |
---|
1192 | |
---|
1193 | ssh ${remote_username}@${remote_addres} "$module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" |
---|
1194 | |
---|
1195 | elif [[ $remote_host = ibmh ]] |
---|
1196 | then |
---|
1197 | |
---|
1198 | print "$module_calls export OBJECT_MODE=64; cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh ${remote_username}@${remote_addres} |
---|
1199 | |
---|
1200 | elif [[ $remote_host = lctit ]] |
---|
1201 | then |
---|
1202 | |
---|
1203 | echo " " > ${remote_host}_last_make_protokoll |
---|
1204 | while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]] |
---|
1205 | do |
---|
1206 | print "$module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll |
---|
1207 | done |
---|
1208 | |
---|
1209 | elif [[ $remote_host = lcxt4 ]] |
---|
1210 | then |
---|
1211 | |
---|
1212 | print ". /opt/modules/default/init/ksh; $module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll |
---|
1213 | |
---|
1214 | else |
---|
1215 | |
---|
1216 | print "$module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll |
---|
1217 | |
---|
1218 | fi |
---|
1219 | |
---|
1220 | fi # ENDE UEBERSETZUNG DER UTILITY-PROGRAMME |
---|
1221 | |
---|
1222 | rm -rf ${remote_host}_last_make_protokoll |
---|
1223 | |
---|
1224 | # make on local host |
---|
1225 | else |
---|
1226 | |
---|
1227 | if [[ $compile_utility_programs = false ]] |
---|
1228 | then |
---|
1229 | |
---|
1230 | # DEPOSITORY VERZEICHNIS ERZEUGEN, FALLS NOCH NICHT VORHANDEN |
---|
1231 | eval remote_md=$remote_md |
---|
1232 | if [[ ! -d $remote_md ]] |
---|
1233 | then |
---|
1234 | if mkdir $remote_md |
---|
1235 | then |
---|
1236 | printf "\n\n *** directory for make depository:" |
---|
1237 | printf "\n $remote_md" |
---|
1238 | printf "\n was created\n" |
---|
1239 | else |
---|
1240 | printf "\n +++ directory for make depository:" |
---|
1241 | printf "\n $remote_md" |
---|
1242 | printf "\n cannot be created" |
---|
1243 | locat=local_depository_path; exit |
---|
1244 | fi |
---|
1245 | fi |
---|
1246 | |
---|
1247 | # QUELLTEXT-DATEIEN AUS REPOSITORY INS DEPOSITORY KOPIEREN |
---|
1248 | echo " " |
---|
1249 | echo " *** updating sources in $remote_md" |
---|
1250 | cd $remote_md |
---|
1251 | cp $local_source_path/${mainprog}_sources.tar . |
---|
1252 | tar xf ${mainprog}_sources.tar |
---|
1253 | |
---|
1254 | # MAKE MIT ZUVOR ERMITTELTEN OPTIONEN AUF LOKALEM RECHNER AUSFUEHREN |
---|
1255 | echo " " |
---|
1256 | echo " *** execute \"make\" on local host" |
---|
1257 | |
---|
1258 | # first load modules, if given |
---|
1259 | if [[ "$modules" != "" ]] |
---|
1260 | then |
---|
1261 | module load ${modules} |
---|
1262 | fi |
---|
1263 | |
---|
1264 | make $make_options PROG=$mainprog F90=$compiler_name COPT="$cpp_options" F90FLAGS="$compiler_options" LDFLAGS="$loader_options" 2>&1 | tee ${remote_host}_last_make_protokoll |
---|
1265 | |
---|
1266 | if [[ $? != 0 ]] |
---|
1267 | then |
---|
1268 | printf "\a\n +++ error(s) occurred during compiling or linking on host \"$remote_host\" " |
---|
1269 | if [[ $silent = false ]] |
---|
1270 | then |
---|
1271 | answer=dummy |
---|
1272 | printf "\n" |
---|
1273 | while [[ "$answer" != c && "$answer" != k ]] |
---|
1274 | do |
---|
1275 | printf " >>> continue / list errors / kill mbuild (c/l/k) ? " |
---|
1276 | read answer |
---|
1277 | if [[ "$answer" = l ]] |
---|
1278 | then |
---|
1279 | more ${remote_host}_last_make_protokoll |
---|
1280 | fi |
---|
1281 | done |
---|
1282 | if [[ $answer = k ]] |
---|
1283 | then |
---|
1284 | locat=user_abort; exit |
---|
1285 | fi |
---|
1286 | fi |
---|
1287 | fi |
---|
1288 | |
---|
1289 | |
---|
1290 | # TAR NEW VERSION ON LOCAL HOST |
---|
1291 | printf "\n *** tar update on local host ..." |
---|
1292 | tar -cf ${mainprog}_current_version.tar *.$suf *.o *.mod |
---|
1293 | |
---|
1294 | |
---|
1295 | # COMPILE THE UTILITY PROGRAMS |
---|
1296 | elif [[ $compile_utility_programs = true ]] |
---|
1297 | then |
---|
1298 | printf "\n\n" |
---|
1299 | echo " *** compiling the utility programs ..." |
---|
1300 | cd ${local_source_path}/../UTIL |
---|
1301 | |
---|
1302 | # TOUCH FILES IN ORDER TO FORCE COMPILATION FOR EVERY BLOCK |
---|
1303 | touch *.f90 |
---|
1304 | make $make_options BLOCK=$block F90=$compiler_name F90_SER=$compiler_name_ser COPT="$cpp_options" F90FLAGS="$compiler_options" LDFLAGS="$loader_options" |
---|
1305 | cd - > /dev/null |
---|
1306 | fi |
---|
1307 | |
---|
1308 | fi |
---|
1309 | |
---|
1310 | done |
---|
1311 | |
---|
1312 | |
---|
1313 | if [[ $host_found = false ]] |
---|
1314 | then |
---|
1315 | if [[ $host = all ]] |
---|
1316 | then |
---|
1317 | printf "\n +++ no hosts found in configuration file" |
---|
1318 | else |
---|
1319 | printf "\n +++ host \"$host\" not found in configuration file" |
---|
1320 | fi |
---|
1321 | locat=config_file; exit |
---|
1322 | fi |
---|
1323 | |
---|
1324 | |
---|
1325 | |
---|
1326 | # FINAL WORK |
---|
1327 | rm -f hosts_found_in_config_file |
---|
1328 | |
---|