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