source: palm/trunk/SCRIPTS/mrun_new @ 21

Last change on this file since 21 was 21, checked in by raasch, 17 years ago

empty lines in configuration file are allowed

File size: 147.4 KB
Line 
1#!/bin/ksh
2
3##!/home/DSRC/NC/tatuyama/pub/ksh   NEEDED ON NEC AT RIAM !!!!!!!!!!
4
5# mrun - Plot-Shellskript         Version:  @(#)MRUN 1.8   28/02/07
6
7     # Prozedur zum Starten von Modellaeufen
8
9     # letzte Aenderung:
10     # 03/03/94 - Siggi - Entwicklungsbeginn
11     # 21/03/94 - Siggi - Entwicklungsabschluss (Version 1.0)
12     # 09/12/94 - Siggi - allexport unterbunden; statt dessen werden jetzt ein-
13     #                    zelne Variable exportiert. Dies ist noetig, weil an-
14     #                    sonsten irgendein Speicher ueberlaeuft und von mrun
15     #                    aufgerufene Programme (z.B. stageout) mit Fehlern
16     #                    abbrechen (too many arguments)
17     # 20/06/95 - Siggi - noclobber muss explizit abgeschaltet, da jetzt
18     #                    defaultmaessig im RRZN-Profile eingeschaltet
19     # 10/06/97 - Siggi - Zusaetzliche Option -C bei cpp, damit // nicht
20     #                    wegfallen
21     # 25/04/00 - Siggi - Version 1.5
22     #                    remote_addres und remote_user in return_addres bzw.
23     #                    return_username umbenannt, return_username wird dem
24     #                    mrun-Aufruf im Job ueber Option -U mitgegeben.
25     #                    Neue Variable remote_username, die beim interaktiven
26     #                    mrun-Aufruf zwingend ueber die neue Option -u oder
27     #                    in der Konfigurationsdatei angegeben werden muss.
28     # 08/02/01 - Siggi - Alle mrun-Meldungen ins englische uebersetzt,
29     #                    Version 1.7
30     # 05/05/02 - Siggi - Uebersetzungen mittels make-Mechanismus moeglich
31     # 21/11/02 - Siggi - ENV-Variable XLFRTEOPTS wird vor Ausfuehrung auf
32     #                    IBM gesetzt, um Record-Laenge der NAMELIST-Dateien,
33     #                    zu bestimmen; Praeprozessoroptionen haben nun alle
34     #                    die Form -Dtext=text, weil auf IBM sonst text durch
35     #                    die leere Zeichenkette ersetzt wird
36     # 01/08/03 - Siggi  - Test of implementing dvrp+1PE on ibm
37     # 07/01/04 - Siggi  - additional preprocessor directive for ibm included
38     #                     (-D$OMP=OMP) in order to avoid problems with
39     #                     OMP_NUM_THREADS
40     # 04/01/05 - Siggi  - archiving on hanni and berni is done in separate
41     #                     tar files, one for each node used
42     # 07/01/04 - Siggi  - old code for t3e, vpp and hpcs eliminated
43     # 09/01/05 - Siggi  - workaround for getting the IP address on gfdl3
44     # 17/01/05 - Siggi  - job for data transfer to local machine now within
45     #                     job class c1 (HLRN)
46     # 27/01/05 - Siggi  - IP address workaround for gfdl3 removed
47     # 28/01/05 - Siggi  - tar-filenames on $PERM (HLRN) now include the
48     #                     base filename and cycle number
49     # 16/02/05 - Gerald - hababai validated
50     # 14/03/05 - Siggi  - abort on NEC after first runtime error (F_ERRCNT)
51     # 29/03/05 - Marcus - berni*-en0 validated
52     # 21/04/05 - Siggi  - transfer-job-protocol for avs-data is no more stored
53     # 24/04/05 - Siggi  - netcdf support on lcmuk
54     # 25/04/05 - Siggi  - netcdf support on gfld3 (decalpha)
55     # 11/05/05 - Siggi  - files with non-numeric extensions (.xxx after cycle
56     #                     number) can now be used within interactive runs
57     # 12/05/05 - Siggi  - netcdf support on ibm
58     # 13/05/05 - Siggi  - error in tar-filenames on $PERM (HLRN) removed
59     # 18/05/05 - Siggi  - netcdf support on nec
60     # 24/05/05 - Siggi  - netcdf support on ibms
61     # 14/06/05 - Siggi  - sleep interval after submit of restart job increased
62     #                     to 30 seconds
63     # 28/06/05 - Siggi  - bora adjusted to new intel compiler (LD_LIBRARY_
64     #                     PATH is temporarily set)
65     # 07/09/05 - Siggi  - setting of MP_EAGER_LIMIT switched off because it
66     #                     caused warnings in the job protocol
67     # 20/10/05 - Siggi  - update of netcdf-version on decalpha (gfdl3)
68     # 25/10/05 - Siggi  - error in listing files for getting the cycle number
69     #                     removed
70     # 26/10/05 - Siggi  - new paths for dvrp-library, transfer of catalogs
71     #                     realized by file attribute trpe
72     # 28/10/05 - Siggi  - if existing, the file extension is output in case
73     #                     of missing input file - no job abort in case of
74     #                     missing input files with file extensions
75     #                     (preliminary solution)
76     # 31/10/05 - Siggi  - data transfer from nech now within seperate job
77     # 04/11/05 - Siggi  - netcdf 3.6.0-p1 on ibmh/ibmb
78     # 07/12/05 - Siggi  - gallego and elephanta admitted
79     # 30/12/05 - Siggi  - gfdl5 (ibmy) admitted
80     # 10/01/06 - Siggi  - cpp directive for NetCDF 64bit support
81     # 20/01/06 - Siggi  - cpp directive for ibmy
82     # 09/02/06 - Siggi  - ibmy admitted for batch mode
83     # 13/04/06 - Siggi  - ostria admitted
84     # 18/04/06 - Siggi  - usage of OpenMP implemented (additional option -O)
85     # 10/05/06 - Siggi  - environment variable XLSMPOPTS set on IBM for
86     #                     optimization of OpenMP runs (option stacksize is
87     #                     necessary for large gridpoint numbers because
88     #                     otherwise a segmentation fault occurs)
89     # 23/05/05 - Siggi  - lctit (SUN Fire X4600) admitted
90     # 21/08/06 - Siggi  - standard mrun path on scirocco is as on bora
91     # 23/08/06 - Siggi  - netcdf support for scirocco (notebook)
92     # 20/09/06 - Marcus - add DVRP library on nech
93     # 24/10/06 - Siggi  - Environment variables for PALM steering are written
94     #                     on local NAMELIST file ENVPAR
95     # 24/11/06 - Siggi  - levanto admitted, maestro switched to ifc 9.1
96     # 28/11/06 - Siggi  - call to interpret_config.x_levanto because of SuSe 10
97     # 06/02/07 - Siggi  - add DVRP library on lcmuk
98     # 07/02/07 - Siggi  - revision of source code handling, source code is
99     #                     now expected in directory given by source_path and
100     #                     not in the current working directory, source code
101     #                     files provided in add_source_path are allways
102     #                     compiled, source code to be compiled is allways
103     #                     sampled in SOURCES_FOR_RUN_$fname which is a
104     #                     subdirectory of the current working directory,
105     #                     -s TEST  changed to  -s WRITE_PERMIT  or -s WP,
106     #                     adapted for RIAM (neck)
107     #                     bugfix for cycle number of output file (extout)
108     #                     all hpmuk-related code removed
109     # 14/02/07 - Siggi  - dvrp support for neck added
110     # 28/02/07 - Siggi  - empty lines in configuration file are accepted
111
112
113
114 
115    # VARIABLENVEREINBARUNGEN + DEFAULTWERTE
116
117 set +o allexport    # SICHERHEITSHALBER UNTERBINDEN, DA SONST EVTL. STAGEOUT
118                     # NICHT LAUEFT (TOO MANY ARGUMENTS - PROBLEM)
119 set +o noclobber    # EXISTIERENDE DATEIEN DUERFEN UEBERSCHRIEBEN WERDEN
120
121 AddFilenames=""
122 additional_conditions=""
123 add_source_path=""
124 afname=""
125 archive_save=true
126 archive_system=none
127 compiler_name=""
128 cond1=""
129 cond2="" 
130 config_file=.mrun.config
131 cpp_opts=""
132 cpumax=0
133 cpurest=0
134 delete_temporary_catalog=true
135 do_batch=false
136 do_compile=true
137 do_remote=false
138 do_stagein=true
139 do_stageout=true
140 do_trace=false
141 email_notification=""
142 exclude=""
143 executable=""
144 execution_error=false
145 filetransfer_protocol=""
146 fname=test
147 fromhost=""
148 host=""
149 host_file=""
150 hp=""
151 ignore_archive_error=false
152 input_list=""
153 interpreted_config_file=""
154 job_on_file=""
155 keep_data_from_previous_run=false
156 localhost_realname=$(hostname)
157 local_compile=false
158 locat=normal
159 mainprog=""
160 makefile=""
161 mc=$0
162 while [[ $(echo $mc | grep -c "/") != 0 ]]
163 do
164    mc=`echo $mc | cut -f2- -d"/"`
165 done
166 module_files=""
167 MODULE_OPTIONS=""
168 mrun_script_name=$mc
169 netcdf_support=false
170 node_usage=default
171 numprocs=""
172 OOPT=""
173 openmp=false
174 output_list=""
175 package_list=""
176 punkte="..........................................................."
177 queue=none
178 read_from_config=""
179 restart_run=false
180# return_addres=$(nslookup `hostname` 2>&1 | grep "Address:" | tail -1 | awk '{print $2}')
181return_addres=130.75.105.2
182 if [[ $return_addres = 130.75.105.158 ]]
183 then
184    return_addres=172.20.25.41
185    echo "+++ WARNING: return_addres changed to $return_addres !!!!!"
186 fi
187# if [[ $return_addres = 210.117.65.1 ]]
188# if [[ $(nslookup `hostname` 2>&1 | grep -c 210.117.65.1) = 1 ]]
189# then
190#    [[ $localhost_realname = gfdl3.yonsei.ac.kr ]]  &&  return_addres=165.132.26.56
191# fi
192 return_password=""
193 return_username=$LOGNAME
194 remotecall=false
195 remote_username=""
196 run_mode=""
197 scirocco=false
198 store_on_archive_system=true
199 striche="  ----------------------------------------------------------------------------"
200 silent=false
201 source_list=""
202 source_path=SOURCE
203 tasks_per_node=""
204 threads_per_task=1
205 tmpcreate=false
206 tmp_data_catalog=""
207 transfer_problems=false
208 usern=$LOGNAME
209 use_makefile=""
210 working_directory=`pwd`
211 TOPT=""
212 XOPT=""
213 zeit=$( date | cut -c 12-19 )
214
215 typeset -i  iec=0 iic=0 iin=0 ioc=0 iout=0 memory=0 stagein_anz=0 stageout_anz=0
216 typeset -i  cputime i ii icycle inode ival jobges jobsek maxcycle minuten nodes pes sekunden tp1
217
218 typeset  -R40 calltime
219 typeset  -L20 spalte1
220 typeset  -L40 spalte2
221 typeset  -L60 spalte3
222 typeset  -L35 string1=`date`
223 typeset  -L12 string2=$usern
224 typeset  -L12 string3=$localhost_realname
225 typeset  -L12 string4
226 typeset  -L12 string5
227 typeset  -L20 version="MRUN  1.8"
228
229
230
231    # EINZELNE VARIABLE FUER HAUPTPROGRAMM EXPORTIEREN
232 export  cpurest fname host localhost return_addres return_username remotecall tasks_per_node
233
234    # FOLGENDE VARIABLEN MUESSEN FUER DIE INTERPRETATION DER KONFIGURATIONSDATEI
235    # EXPORTIERT WERDEN
236 export  afname config_file cpp_opts cpumax do_batch do_trace fname fromhost
237 export  input_list memory numprocs output_list queue run_mode
238
239
240 
241    # FEHLERBEHANDLUNG
242    # BEI EXIT:
243 trap 'if [[ $locat != localhost ]]
244       then
245          if [[ ! -f ${mrun_path}/statistik/mrun_statistik ]]
246          then
247             cat  >  ${mrun_path}/statistik/mrun_statistik  <<  %STATEND%
248MRUN-calls on $localhost
249
250date and time                      user        localhost   remotehost  termination mrun-command
251--------------------------------------------------------------------------------------------------------------------
252%STATEND%
253             chmod  666  ${mrun_path}/statistik/mrun_statistik
254          fi
255
256             # EINTRAG IN DIE STATISTIK-DATEI
257          string4=$host
258          string5=$locat
259          if [[ "$job_on_file" = ""  &&  $locat != control_c  &&  $locat != user_abort ]]
260          then
261             if [[ $do_batch = true ]]
262             then
263                printf "$string1$string2$string3$string4$string5$mrun_com \n"  >>  ${mrun_path}/statistik/mrun_statistik
264             else
265                printf "$string1$string2$string3$string4$string5$mc \n"  >>  ${mrun_path}/statistik/mrun_statistik
266             fi
267          fi
268       fi
269
270       if [[ $locat != normal  &&  $locat != control_c  &&  $locat != local_compile ]]
271       then
272
273              # EVENTUELLE ERROR-KOMMANDOS ABARBEITEN
274          (( i = 0 ))
275          while (( i < iec ))
276          do
277             (( i = i + 1 ))
278             printf "\n  *** Execution of ERROR-command:\n"
279             printf "  >>> ${err_command[$i]}\n"
280             eval  ${err_command[$i]}
281          done
282          if [[ -n $interpreted_config_file ]]  then
283             rm -rf  $interpreted_config_file
284          fi
285          if [[ $tmpcreate = true ]]
286          then
287             printf "\n  *** Contents of \"$TEMPDIR\":\n"
288             ls -al; cd
289             [[ $delete_temporary_catalog = true ]]  &&  rm -rf $TEMPDIR
290          fi
291          if [[ -f ~/job_queue/JOBINFO.$QSUB_REQID ]]
292          then
293             rm -rf  ~/job_queue/JOBINFO.$QSUB_REQID
294          fi
295          printf "\n\n+++ MRUN killed \n\n"
296       elif [[ $locat != control_c ]]
297       then
298          printf "\n\n --> all actions finished\n\n"
299          printf "     Bye, bye $usern !!\n\n"
300       fi' exit
301
302
303    # BEI TERMINAL-BREAK:
304 trap '[[ $tmpcreate = true ]]  &&  (cd; rm -rf $TEMPDIR)
305       if [[ -f ~/job_queue/JOBINFO.$QSUB_REQID ]]
306       then
307          rm -rf  ~/job_queue/JOBINFO.$QSUB_REQID
308       fi
309       printf "\n+++ MRUN killed by \"^C\" \n\n"
310       locat=control_c
311       exit
312      ' 2
313
314
315    # EVTL. NAMEN DES LOKALEN RECHNERS MIT UEBERGREIFENDEM NAMEN VERSEHEN
316 case  $localhost_realname  in
317     (atmos)                mrun_path=/home/siggi/pub
318                            localhost=lcide;;
319     (bora|breva|elephanta|gallego|gregale|hababai|irifi|levanto|maestro|orkan|ostria|poniente|quanero|scirocco|vorias)  mrun_path=/home/raasch/pub
320                            localhost=lcmuk;;
321     (breg*-en0|berni*-en0) mrun_path=/home/b/niksiraa/pub
322                            localhost=ibmb; archive_system=tivoli;;
323     (cs*)                  mrun_path=/pf/b/b323011/pub
324                            localhost=nech; archive_system=ut;;
325     (gate|n-sx)            mrun_path=/home/DSRC/NC/tatuyama/pub
326                            PATH=$PATH:/usr/bin/nqsII:$mrun_path
327                            localhost=neck;;
328     (ground.yonsei.ac.kr)  mrun_path=/usr/users/raasch/pub
329                            localhost=decalpha;;
330     (gfdl3.yonsei.ac.kr)   mrun_path=/usr2/users/raasch/pub
331                            localhost=decalpha;;
332     (gfdl5)                mrun_path=/usr1/users/raasch/pub
333                            localhost=ibmy;;
334     (gwdk081.gwdg.de|gwdk082.gwdg.de|gwdk083.gwdg.de)  mrun_path=/usr/users/sraasch/pub
335                            localhost=ibm;;
336     (hreg*-en0|hanni*-en0) mrun_path=/home/h/niksiraa/pub
337                            localhost=ibmh; archive_system=tivoli;;
338     (nobel*)               mrun_path=/edun/z051nyg/pub
339                            localhost=ibms;;
340     (sun1|sun2)            mrun_path=/home/nhbksira/pub/
341                            localhost=unics;;
342     (tgg*)                 mrun_path=/home2/usr5/mkanda/pub
343                            localhost=lctit;;
344     (*)                    printf "\n  +++ Host \"$localhost_realname\" not admitted for mrun \n"
345                            locat=localhost; exit;;
346 esac
347
348 [[ $localhost_realname = scirocco ]]  &&  scirocco=true
349
350
351 
352    # SHELLSCRIPT-OPTIONEN EINLESEN UND KOMMANDO NEU ZUSAMMENSETZEN, FALLS ES
353    # FUER FOLGEJOBS BENOETIGT WIRD
354 while  getopts  :a:AbBc:Cd:D:f:Fh:H:i:IkK:m:M:n:o:Op:P:q:r:R:s:St:T:u:U:vxX: option
355 do
356   case  $option  in
357       (a)   afname=$OPTARG;;
358       (A)   store_on_archive_system=false; mc="$mc -A";;
359       (b)   do_batch=true; mc="$mc -b";;
360       (B)   delete_temporary_catalog=false; mc="$mc -B";;
361       (c)   config_file=$OPTARG; mc="$mc -c$OPTARG";;
362       (C)   restart_run=true; mc="$mc -C";;
363       (d)   fname=$OPTARG; mc="$mc -d$OPTARG";;
364       (D)   cpp_opts="$cpp_opts $OPTARG"; mc="$mc -D$OPTARG";;
365       (f)   filetransfer_protocol=$OPTARG; mc="$mc -f$OPTARG";;
366       (F)   job_on_file="-D"; mc="$mc -F";;
367       (h)   host=$OPTARG; mc="$mc -h$OPTARG";;
368       (H)   fromhost=$OPTARG; mc="$mc -H$OPTARG";;
369       (i)   input_list=$OPTARG; mc="$mc -i'$OPTARG'";;
370       (I)   ignore_archive_error=true; mc="$mc -I";;
371       (k)   keep_data_from_previous_run=true; mc="$mc -k";;
372       (K)   additional_conditions="$OPTARG"; mc="$mc -K$OPTARG";;
373       (m)   memory=$OPTARG; mc="$mc -m$OPTARG";;
374       (M)   makefile=$OPTARG; mc="$mc -M$OPTARG";;
375       (n)   node_usage=$OPTARG; mc="$mc -n$OPTARG";;
376       (o)   output_list=$OPTARG; mc="$mc -o'$OPTARG'";;
377       (O)   use_openmp=true; mc="$mc -O";;
378       (p)   package_list=$OPTARG; mc="$mc -p'$OPTARG'";;
379       (P)   return_password=$OPTARG; mc="$mc -P$OPTARG";;
380       (q)   queue=$OPTARG; mc="$mc -q$OPTARG";;
381       (r)   run_mode=$OPTARG; mc="$mc -r'$OPTARG'";;
382       (R)   remotecall=true;return_addres=$OPTARG; mc="$mc -R$OPTARG";;
383       (s)   source_list=$OPTARG; mc="$mc -s'$OPTARG'";;
384       (S)   read_from_config=false; mc="$mc -S";;
385       (t)   cpumax=$OPTARG; mc="$mc -t$OPTARG";;
386       (T)   tasks_per_node=$OPTARG; mc="$mc -T$OPTARG";;
387       (u)   remote_username=$OPTARG; mc="$mc -u$OPTARG";;
388       (U)   return_username=$OPTARG; mc="$mc -U$OPTARG";;
389       (v)   silent=true; mc="$mc -v";;
390       (x)   do_trace=true;set -x; mc="$mc -x";;
391       (X)   numprocs=$OPTARG; mc="$mc -X$OPTARG";;
392       (\?)  printf "\n  +++ unknown option $OPTARG \n"
393             printf "\n  --> type \"$0 ?\" for available options \n"
394             locat=parameter;exit;;
395   esac
396 done
397
398
399    # EVTL. POSITIONSPARAMETER EINLESEN
400    # ZUR ZEIT GIBT ES NUR DEN PARAMETER ? (=KURZINFO)
401 shift OPTIND-1
402
403
404    # KURZE AUFRUFBESCHREIBUNG WIRD HIER AUSGEGEBEN
405 if [[ "$1" = "?" ]]
406 then
407   (printf "\n  *** mrun can be called as follows:\n"
408    printf "\n      $mrun_script_name  -b -c.. -d.. -D.. -f.. -F -h.. -i.. -I -K.. -m.. -o.. -p.. -r.. -R -s.. -t.. -T.. -v -x -X..  <modus>\n"
409    printf "\n      Description of available options:\n"
410    printf "\n      Option  Description                              Default-Value"
411    printf "\n        -a    base name of input files                 equiv. -d"
412    printf "\n        -A    no archiving when using file-attribute fl"
413    printf "\n        -b    batch-job on local machine               ---"
414    printf "\n        -B    do not delete temporary directory at end ---"
415    printf "\n        -c    configuration file                       .mrun.config"
416    printf "\n        -d    base name of files attached to program   test"
417    printf "\n        -D    preprocessor(cpp)-directives             \"\" "
418    printf "\n        -f    filetransfer protocol (ftp or scp)       depending on -h"
419    printf "\n        -F    create remote job file only              ---"
420    printf "\n        -h    execution host                           $localhost_realname"
421    printf "\n        -i    INPUT control list                       \"\" "
422    printf "\n        -I    archiving errors of previous batch-jobs"
423    printf "\n              will be ignored"
424    printf "\n        -k    keep data from previous run"
425    printf "\n        -K    additional conditions for controling"
426    printf "\n              usage of conditional code and"
427    printf "\n              env-variables in configuration file      \"\" "
428    printf "\n        -m    memory demand in MB (batch-jobs)         0 MB"
429    printf "\n        -M    Makefile name                            Makefile"
430    printf "\n        -n    node usage (shared/not_shared)           depending on -h"
431    printf "\n        -o    OUTPUT control list                      \"\" "
432    printf "\n        -O    use OpenMP                               ---"
433    printf "\n        -p    software package list                    \"\" "
434    printf "\n        -q    queue                                    \"$queue\" "
435    printf "\n        -r    run control list (combines -i -o)        \"\" "
436    printf "\n        -s    filenames of routines to be compiled     \"\" "
437    printf "\n              must end with .f, .f90, .F, or .c !"
438    printf "\n              use \"..\" for more than one file and wildcards"
439    printf "\n              -s TEST compiles all files with w-permit"
440    printf "\n        -S    config file interpreted by shellscript   ---"
441    printf "\n        -t    allowed cpu-time in seconds (batch)      0"
442    printf "\n        -T    tasks per node                           depending on -h"
443    printf "\n        -u    username on remote machine               \"\" "
444    printf "\n        -v    no prompt for confirmation               ---"
445    printf "\n        -x    tracing of mrun for debug purposes       ---"
446    printf "\n        -X    # of processors (on parallel machines)   1"
447    printf "\n "
448    printf "\n      Possible values of positional parameter <modus>:"
449    printf "\n        \"?\"       -  this outline \n\n") | more
450    exit
451 elif [[ "$1" != "" ]]
452 then
453    printf "\n  +++ positional parameter $1 unknown \n"
454    locat=parameter; exit
455 fi
456
457
458
459    # KURZE STARTMELDUNG
460 printf "\n*** $version "
461 printf "\n    will be executed.     Please wait ..."
462
463
464    # BASISNAME DER INPUT-DATEIEN GLEICH ALLGEMEINEM BASISNAMEN SETZEN,
465    # WENN NICHT VOM BENUTZER ANDERS BESTIMMT
466 [[ "$afname" = "" ]]  &&  afname=$fname
467
468
469    # EVTL. RUN-MODUS DEN I/O-LISTEN HINZUFUEGEN
470 if [[ "$run_mode" != "" ]]
471 then
472    input_list="$input_list $run_mode"
473    output_list="$output_list $run_mode"
474 fi
475
476
477    # RECHNERNAMEN ABSPEICHERN, VON DEM AUS JOB GESTARTET WIRD,
478    # ALLERDINGS NUR DANN, WENN NICHT PER OPTION -H BEREITS EIN WERT
479    # ZUGEWIESEN WURDE (MRUN MACHT DIES IMMER, WENN ES SELBST BATCH-JOBS
480    # STARTET)
481 if [[ "$fromhost" = "" ]]
482 then
483    fromhost=$localhost
484 fi
485
486
487     # PRUEFEN, OB MRUN NUR TESTWEISE AUF DER LOKALEN MASCHINE KOMPILIEREN SOLL
488 if [[ "$source_list" = LOCAL_COMPILE_TEST ]]
489 then
490    source_list=TEST
491    local_compile=true
492    host=$localhost
493 fi
494   
495
496    # PRUEFEN, OB AUF REMOTE-MASCHINE GERECHNET WERDEN SOLL
497    # WERT VON do_remote WIRD FUER DATEIVERBINDUNGEN BENOETIGT.
498    # WENN AUF REMOTE-MASCHINE GERECHNET WIRD, IST GLEICHZEITIG KLAR,
499    # DASS EIN BATCH-JOB GESTARTET WERDEN MUSS
500 if [[ -n $host  &&  "$host" != $localhost ]]
501 then
502    do_batch=true
503    do_remote=true
504    case  $host  in
505        (ibm|ibmb|ibmh|ibms|ibmy|nech|neck|lctit|unics)  true;;
506        (*)  printf "\n"
507             printf "\n  +++ execution host \"$host\" not admitted for MRUN,"
508             printf "\n      or NQS not available on execution host!"
509             locat=nqs; (( iec = 0 )); exit;;
510    esac
511 else
512    host=$localhost
513 fi
514
515
516     # ZUSATZBEDINGUNGEN (OPTION -K) AUSWERTEN
517 if [[ -n $additional_conditions ]]
518 then
519    echo $additional_conditions | cut -d" " -f1-3 | read  cond1  cond2  dummy
520#    cond1=`echo $additional_conditions | cut -d" " -f1`
521#    cond2=`echo $additional_conditions | cut -d" " -s -f2`
522#    dummy=`echo $additional_conditions | cut -d" " -s -f3`
523    if [[ -n $dummy ]]
524    then
525       printf "\n  +++ more than 2 additional conditions given for Option \"-K\""
526       locat=options; exit
527    fi
528 fi
529
530
531    # PRUEFEN, OB EVTL. BEI VORHERGEHENDEM LAUF (KETTENJOB) EINE
532    # ARCHIVIERUNG FEHLGESCHLAGEN IST
533 if [[ -f ~/job_queue/ARCHIVE_ERROR_$fname ]]
534 then
535    if [[ $ignore_archive_error = false ]]
536    then
537       printf "\n  +++ data archiving of previous run failed"
538       printf "\n      see directory \~/job_queue on remote machine"
539       locat=archive; exit
540    else
541       printf "\n  +++ warning: data archiving in a previous run failed"
542       printf "\n      MRUN continues, trying to get backup copy"
543    fi
544 fi
545
546
547    # PRUEFEN, OB KONFIGURATIONS-DATEI VORHANDEN
548 if [[ ! -f $config_file ]]
549 then
550    printf "\n\n  +++ configuration file: "
551    printf "\n           $config_file"
552    printf "\n      does not exist"
553    locat=connect; exit 
554 fi
555
556
557
558    # LESEN UND INTERPRETIEREN DER KONFIGURATIONS-DATEI VOM SHELLSCRIPT AUS
559    # VORUEBERGEHEND ZWINGEND AUF LINUX-RECHNERN
560 if [[ "$read_from_config" = false ]]
561 then
562
563    [[ $silent = false ]]  &&  printf "\n    Reading the configuration file... "
564    while  read zeile
565    do
566        [[ $silent = false ]]  &&  printf "."
567
568
569          # ZUERST EVENTUELL VORKOMMENDE ENVIRONMENT-VARIABLEN DURCH IHRE WERTE
570          # ERSETZEN
571       eval  zeile=\"$zeile\"
572
573
574          # INTERPRETATION DER ZEILE
575       if [[ "$(echo $zeile)" = "" ]]
576       then
577             # LEERZEILE, KEINE AKTION
578          continue
579
580       elif [[ "$(echo $zeile | cut -c1)"  =  "#" ]]
581       then
582
583             # ZEILE IST KOMMENTARZEILE
584          true
585
586       elif [[ "$(echo $zeile | cut -c1)"  =  "%" ]]
587       then
588
589             # ZEILE DEFINIERT ENVIRONMENT-VARIABLE
590          zeile=$(echo $zeile | cut -c2-)
591          echo $zeile | cut -d" " -f1-5 | read  var  value  for_host  for_cond1  for_cond2
592#          var=`echo $zeile | cut -d" " -f1`
593#          value=`echo $zeile | cut -d" " -s -f2`
594#          for_host=`echo $zeile | cut -d" " -s -f3`
595#          for_cond1=`echo $zeile | cut -d" " -s -f4`
596#          for_cond2=`echo $zeile | cut -d" " -s -f5`
597
598          if [[ "$for_host" = ""  ||  ( "$for_host" = $host  &&  "$for_cond1" = "$cond1"  &&  "$for_cond2" = "$cond2" )  ||  $(echo "$input_list$output_list"|grep -c "$for_host") != 0 ]]
599          then
600
601                # BEI COMPILER- CPP- ODER LINKEROPTIONEN EVTL ":" DURCH " "
602                # ERSETZEN. "::" WIRD DURCH ":" ERSETZT.
603             value=`echo $value | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
604
605
606                # ENVIRONMENT-VARIABLE WIRD WERT AUS KONFIGURATIONSDATEI
607                # ZUGEWIESEN, WENN SIE SELBST NOCH KEINEN WERT UEBER DIE
608                # ENTSPRECHENDE SCRIPT-OPTION ERHALTEN HAT. SOLCHE
609                # VARIABLEN HAETTEN DANN DEN WERT "" ODER IM INTEGER-FALL DEN
610                # WERT 0.  ALLGEMEINE REGEL ALSO: SCRIPT-OPTION GEHT UEBER
611                # KONFIGURATIONSDATEI
612             if [[ "$(eval echo \$$var)" = ""  ||  "$(eval echo \$$var)" = "0" ]]
613             then
614                eval  $var=\$value
615
616                   # EVTL. BILDSCHIRMAUSGABEN DER ENVIRONMENT-VARIABLEN
617                if [[ $do_trace = true ]]
618                then
619                   printf "\n*** ENVIRONMENT-VARIABLE $var = $value"
620                fi
621             fi
622
623                # WENN ENVIRONMENT-VARIABLE HOST VEREINBART, DANN SOFORT AUSWERTEN
624                # WERT VON do-remote WIRD BEI DATEIVERBINDUNGEN BENOETIGT
625                # WENN AUF REMOTE-MASCHINE GERECHNET WIRD, IST GLEICHZEITIG KLAR,
626                # DASS EIN BATCH-JOB GESTARTET WERDEN MUSS
627             if [[ $var = host ]]
628             then
629                if [[ -n $host  &&  "$host" != $localhost ]]
630                then
631                   do_batch=true
632                   do_remote=true
633                   case  $host  in
634                       (ibm|ibms|ibmy|lctit|nech|neck|unics)  true;;
635                       (*)  printf "\n  +++ no queueing system available on execution host \"$host\""
636                            locat=nqs; exit;;
637                   esac
638                else
639                   host=$localhost
640                fi
641             fi
642
643                # VOM BENUTZER DEFINIERTE ENVIRONMENT VARIABLEN MUESSEN PRINZIPIELL
644                # EXPORTIERT WERDEN, DA SIE VIELLEICHT IN WEITER UNTEN AUFZURUFEN-
645                # DEN PROGRAMMEN BENOETIGT WERDEN
646             export  $var
647          fi
648
649
650
651
652       elif [[ "$(echo $zeile | cut -c1-3)" = "EC:" ]]
653       then
654
655             # ZEILE DEFINIERT ERROR-KOMMANDO
656          (( iec = iec + 1 ))
657          zeile=$(echo $zeile | cut -c4-)
658          err_command[$iec]="$zeile"
659
660       elif [[ "$(echo $zeile | cut -c1-3)" = "IC:" ]]
661       then
662
663             # ZEILE DEFINIERT INPUT-KOMMANDO
664          (( iic = iic + 1 ))
665          zeile=$(echo $zeile | cut -c4-)
666          in_command[$iic]="$zeile"
667
668       elif [[ "$(echo $zeile | cut -c1-3)" = "OC:" ]]
669       then
670
671             # ZEILE DEFINIERT OUTPUT-KOMMANDO
672          (( ioc = ioc + 1 ))
673          zeile=$(echo $zeile | cut -c4-)
674          out_command[$ioc]="$zeile"
675
676       else
677
678             # ZEILE DEFINIERT DATEIVERBINDUNG. EINLESEN DER DATEIEIGENSCHAFTEN
679             # s2a: in/out - Feld
680             # s2b: loc    - Feld (optional)
681             # s2c: tr/ar  - Feld (optional)
682          echo $zeile | cut -d" " -f1-2 | read  s1  s2
683#          s1=`echo $zeile | cut -d" " -f1`
684#          s2=`echo $zeile | cut -d" " -s -f2`
685          s2a=$(echo $s2 | cut -d":" -f1)
686          if [[ $(echo $s2 | grep -c ":") = 0 ]]
687          then
688             s2b=""
689             s2c=""
690          else
691             echo $s2 | cut -d":" -f2-3 | sed 's/:/ /g' | read  s2b  s2c
692#             s2b=`echo $s2 | cut -d":" -f2 | sed 's/:/ /g'`
693#             s2c=`echo $s2 | cut -d":" -s -f3 | sed 's/:/ /g'`
694          fi
695          echo $zeile | cut -d" " -f3-6 | read  s3  s4  s5  s6
696#          s3=`echo $zeile | cut -d" " -f3`
697#          s4=`echo $zeile | cut -d" " -s -f4`
698#          s5=`echo $zeile | cut -d" " -s -f5`
699#          s6=`echo $zeile | cut -d" " -s -f6`
700
701       
702             # ABSPEICHERN DER DATEIVERBINDUNG, FALLS IN INPUT- ODER OUTPUT-LIST
703             # VERMERKT. VARIABLE S3 KANN AUCH LISTE ENTHALTEN (FELDTRENNER ":")
704             # DATEIVERBINDUNG WIRD DANN NICHT ABGESPEICHERT UND GEPRUEFT, WENN
705             # PROGRAMMLAUF AUF REMOTE-MASCHINE ERFOLGT UND DATEI NUR LOKAL VOR-
706             # HANDEN SEIN MUSS (D.H. s2b = loc)
707          IFSALT="$IFS"; IFS="$IFS:"
708          if [[ "$s2a" = in  &&  ! ( $do_remote = true  &&  ( "$s2b" = loc  ||  "$s2b" = locopt ) ) ]]
709          then
710             found=false
711             for  actual  in  $input_list
712             do
713                for  formal  in  $s3
714                do
715                   [[ $actual = $formal  ||  "$formal" = "-" ]]  &&  found=true
716                done
717             done
718             if [[ $found = true ]]
719             then
720                (( iin = iin + 1 ))
721                localin[$iin]=$s1; transin[$iin]=$s2b; actionin[$iin]=$s2c;
722                typein[$iin]=$s3; pathin[$iin]=$s4; endin[$iin]=$s5;
723                extin[$iin]=$s6
724             fi
725          elif [[ "$s2a" = out  &&  ! ( $do_remote = true  &&  "$s2b" = loc ) ]]
726          then
727             found=false
728             for  actual  in  $output_list
729             do
730                for  formal  in  $s3 
731                do
732                   [[ $actual = $formal  ||  "$formal" = "-"  ]]  &&  found=true
733                done
734             done
735             if [[ $found = true ]]
736             then
737                (( iout = iout + 1 ))
738                localout[$iout]=$s1; actionout[$iout]=$s2c; typeout[$iout]=$s3;
739                pathout[$iout]=$s4; endout[$iout]=$s5; extout[$iout]=$s6
740             fi
741          elif [[ "$s2a" != in  &&  "$s2a" != out ]]
742          then
743             printf "\n  +++ I/O-attribute in configuration file $config_file has the invalid"
744             printf "\n      value \"$s2\". Only \"in\" and \"out\" are allowed!"
745             locat=connect; exit
746          fi
747          IFS="$IFSALT"
748       fi
749    done < $config_file
750
751 else
752
753
754       # INTERPRETATION DER KONFIGURATIONSDATEI MITTELS FORTRAN 90 - PROGRAMM
755    [[ $silent = false ]]  &&  printf "..."
756    export  cond1 cond2 config_file do_remote do_trace input_list localhost output_list
757    export  interpreted_config_file=.icf.$RANDOM
758
759    case  $localhost_realname  in
760        (caurus|twister)      interpret_config.hp;;
761        (bora|breva|elephanta|gallego|gregale|hababai|maestro|orkan|ostria)  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/muksoft/packages/intel_ifc/8.1/lib/; interpret_config_9.x;;
762        (levanto|vorias)      export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/muksoft/packages/intel/ifort/9.1.037/lib/; interpret_config_9.x_levanto;;
763        (quanero)             export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/intel_fc_80/lib; interpret_config_9.x;;
764        (*)                   interpret_config.x;;
765    esac
766
767
768       # AUSFUEHRUNG DER GENERIERTEN SHELL-KOMMANDOS IN DIESER SHELL
769    chmod  u+x  $interpreted_config_file
770    export PATH=$PATH:.
771    . $interpreted_config_file
772    rm  $interpreted_config_file
773
774 fi
775
776
777    # QUELLTEXTVERZEICHNIS AUF LOKALER MASCHINE AUS KONFIGURATIONSDATEI
778    # BESTIMMEN (WUERDE SONST EVTL. DAS VERZEICHNIS DES JEWEILS UNTER -h
779    # ANGEGEBENEN REMOTE-RECHNERS SEIN)
780    # BEI BATCH-JOBS SIND DIE ZU UEBERSETZENDEN PROGRAMMTEILE SCHON KOMPLETT
781 if [[ "$SOURCES_COMPLETE" = "" ]]
782 then
783
784       # ZUERST PRUEFEN, OB EIN GLOBALER QUELLTEXTPFAD FUER ALLE RECHNER
785       # VEREINBART WURDE
786    source_path=""
787    line=""
788    grep "%source_path" $config_file  >  tmp_mrun
789    while read line
790    do
791       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
792       then
793          if [[ "$(echo $line | cut -d" " -f3)" = "" ]]
794          then
795             global_source_path=`echo $line | cut -d" " -f2`
796          fi
797       fi
798    done  <  tmp_mrun
799
800    line=""
801    found=false
802    grep  " $localhost" $config_file | grep "%source_path"  >  tmp_mrun
803    while read line
804    do
805       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
806       then
807          if [[ $found = true ]]
808          then
809             printf "\n\n  +++ more than one source path found in configuration file"
810             printf "\n      for local host \"$localhost\" "
811             locat=source_path; exit
812          fi
813          source_path=`echo $line | cut -d" " -f2`
814          found=true
815       fi
816    done  <  tmp_mrun
817    rm  tmp_mrun
818
819    if [[ "$source_path" = "" ]]
820    then
821       if [[ "$global_source_path" != "" ]]
822       then
823          source_path=$global_source_path
824       else
825          printf "\n\n  +++ no source path found in configuration file"
826          printf "\n      for local host \"$localhost\" "
827          locat=source_path; exit
828       fi
829    fi
830    eval source_path=$source_path
831
832    if [[ ! -d $source_path ]]
833    then
834       printf "\n\n  +++ source path \"$source_path\" on local host"
835       printf "\n      \"$localhost\" does not exist"
836       locat=source_path; exit
837    fi
838
839 fi
840
841
842
843    # NOCHMAL PRUEFEN, OB AUF REMOTE-MASCHINE GERECHNET WERDEN SOLL
844    # (HOST KANN IN KONFIGURATIONSDATEI ANDERS FESTGELEGT WORDEN SEIN)
845    # WERT VON do_remote WIRD FUER DATEIVERBINDUNGEN BENOETIGT.
846    # WENN AUF REMOTE-MASCHINE GERECHNET WIRD, IST GLEICHZEITIG KLAR,
847    # DASS EIN BATCH-JOB GESTARTET WERDEN MUSS
848 if [[ -n $host  &&  "$host" != $localhost ]]
849 then
850    do_batch=true
851    do_remote=true
852    case  $host  in
853        (ibm|ibmb|ibmh|ibms|ibmy|lctit|nech|neck|unics)  true;;
854        (*)  printf "\n"
855             printf "\n  +++ execution host \"$host\" not admitted for MRUN,"
856             printf "\n      or no queueing system available on execution host!"
857             locat=nqs; (( iec = 0 )); exit;;
858    esac
859 else
860    host=$localhost
861 fi
862
863
864    # PRUEFUNG EINIGER PROZESSORZAHLANGABEN BEI RECHNUNGEN AUF PARALLELRECHNERN
865 if [[ "$cond1" = parallel  ||  "$cond2" = parallel ]]
866 then
867
868       # PRUEFEN, OB DIE ANZAHL DER ZU VERWENDENDEN PES ANGEGEBEN WURDE
869    if [[ ! -n $numprocs ]]
870    then
871       printf "\n"
872       printf "\n  +++ option \"-K parallel\" requires additional specification"
873       printf "\n      of the number of processors to be used by"
874       printf "\n      mrun-option \"-X\" or by environment-variable"
875       printf "\n      \"numprocs\" in the configuration file"
876       locat=numprocs; (( iec = 0 )); exit
877    fi
878
879       # PRUEFEN, OB DIE PROZESSORANZAHL PRO KNOTEN ANGEGEBEN WURDE (GGF.
880       # DEFAULT-WERT SETZEN) UND OB SIE EIN GANZZAHLIGER TEILER DER
881       # GESAMTPROZESSORANZAHL IST
882    if [[ $host = nech  ||  $host = neck  ||  $host = ibmh  ||  $host = ibmb  ||  $host = ibms ]]
883    then
884       [[ "$tasks_per_node" = "" ]]  &&  tasks_per_node=6
885       (( ival = $tasks_per_node ))
886       (( pes = numprocs ))
887#       if [[ $(echo $package_list | grep -c dvrp_graphics+1PE) = 1 ]]
888#       then
889#          (( pes = pes - 1 ))
890#       fi
891       (( ii = pes / ival ))
892       if (( pes - ii * ival > 0 ))
893       then
894          printf "\n"
895          printf "\n  +++ tasks per node (option \"-T\") must be an integral"
896          printf "\n      divisor of the total number of processors (option \"-X\")"
897          printf "\n      values of this mrun-call: \"-T $tasks_per_node\" \"-X $numprocs\""
898          locat=tasks_per_node; (( iec = 0 )); exit
899       fi
900    fi
901
902       # IBMY HAT NUR EINEN KNOTEN
903    if [[ $host = ibmy ]]
904    then
905       if [[ "$tasks_per_node" != ""  &&  "$tasks_per_node" != "$numprocs" ]]
906       then
907          printf "\n"
908          printf "\n  +++ on ibmy, tasks per node (option \"-T\") must be equal to the"
909          printf "\n      total number of processors (option \"-X\")"
910          printf "\n      values of this mrun-call: \"-T $tasks_per_node\" \"-X $numprocs\""
911          locat=tasks_per_node; (( iec = 0 )); exit
912       fi
913    fi
914
915       # FALLS OPENMP PARALLELISIERUNG VERWENDET WERDEN SOLL, ANZAHL VON THREADS
916       # SETZEN UND ZAHL DER TASKS PRO KNOTEN AUF 1 SETZEN
917    if [[ $use_openmp = true ]]
918    then
919       threads_per_task=$tasks_per_node
920       tasks_per_node=1
921    fi
922    OOPT="-O $threads_per_task"
923    TOPT="-T $tasks_per_node"
924
925       # GESAMTZAHL DER KNOTEN BESTIMMEN
926    if [[ "$tasks_per_node" != "" ]]
927    then
928       (( nodes = numprocs / ( tasks_per_node * threads_per_task ) ))
929    fi
930
931       # PRUEFEN, OB NODE USAGE EINEN ERLAUBTEN WERT HAT BZW. DEN DEFAULT
932       # SETZEN
933    if [[ $node_usage = default ]]
934    then
935       if [[ $host = ibms ]]
936       then
937          node_usage=shared
938       else
939          node_usage=not_shared
940       fi
941    fi
942    if [[ $node_usage != shared  &&  $node_usage != not_shared ]]
943    then
944       printf "\n"
945       printf "\n  +++ node usage (option \"-n\") is only allowed to be set"
946       printf "\n      \"shared\" or \"not_shared\""
947       locat=tasks_per_node; (( iec = 0 )); exit
948    fi
949
950 fi
951
952    # PRUEFEN, OB HOSTFILE EXISTIERT
953 if [[ -n $hostfile ]]
954 then
955    if [[ ! -f $hostfile ]]
956    then
957       printf "\n"
958       printf "\n  +++ hostfile \"$hostfile\" does not exist"
959       locat=hostfile; exit
960    fi
961 fi
962
963    # PRUEFEN, OB RHOSTS DATEI EXISTIERT. GEGEBENENFALLS ANLEGEN BZW. ERWEITERN
964 if [[ $host = ibmy  &&  $do_remote = false ]]
965 then
966    if [[ ! -f $HOME/.rhosts ]]
967    then
968       echo  "gfdl5.yonsei.ac.kr"  >  $HOME/.rhosts
969       printf "\n\n  *** file:"
970       printf "\n           $HOME/.rhosts"
971       printf "\n      was created\n"
972    fi
973    if [[ $(grep -c gfdl5.yonsei.ac.kr $HOME/.rhosts) = 0 ]]
974    then
975       echo  "gfdl5.yonsei.ac.kr"  >>  $HOME/.rhosts
976       printf "\n\n  *** file:"
977       printf "\n           $HOME/.rhosts"
978       printf "\n      was extended by the name of the current host\n"
979    fi
980 fi
981
982    # DEFAULT-DATEITRANSFER-PROTOKOLL FESTLEGEN
983 if [[ "$filetransfer_protocol" = "" ]]
984 then
985    case  $host  in
986        (nech|neck|ibm|ibmb|ibmh|ibms|ibmy|lctit)  filetransfer_protocol=scp;;
987        (*)              filetransfer_protocol=ftp;;
988    esac
989 fi
990
991    # PRUEFEN, OB ZULAESSIGES DATEITRANSFER-PROTOKOLL GEWAEHLT WURDE
992 if [[ "$filetransfer_protocol" != ftp  &&  "$filetransfer_protocol" != scp ]]
993 then
994    printf "\n"
995    printf "\n  +++ illegal value \"$filetransfer_protocol\" for Option -f"
996    printf "\n      only \"ftp\" or \"scp\" are allowed"
997    locat=options; exit
998 fi
999
1000
1001    # FALLS NICHT VORGEGEBEN, DEFAULT-QUEUE AUF DER ZIELMASCHINE FESTLEGEN
1002 if [[ $queue = none ]]
1003 then
1004    case  $host  in
1005        (ibmb)       if [[ $node_usage = shared ]]
1006                     then
1007                        queue=cshare
1008                     else
1009                        queue=csolo
1010                     fi;;
1011        (ibmh)       if [[ $node_usage = shared ]]
1012                     then
1013                        queue=cshare
1014                     else
1015                        queue=csolo
1016                     fi;;
1017        (ibmy)       queue=parallel;;
1018        (lctit)      queue=default;;
1019        (nech)       queue=none;;
1020        (neck)       queue=P;;
1021        (unics)      queue=unics;;
1022    esac
1023 fi
1024
1025
1026    # EVTL. NETCDF-UNTERSTUETZUNG SETZEN
1027 case  $host  in
1028     (decalpha)   netcdf_support=true
1029                  netcdf_path=/usr/local/netcdf-3.5.1;;
1030     (ibmb|ibmh)  netcdf_support=true
1031                  netcdf_path=/aws/dataformats/netcdf-3.6.0-p1/64-32;;
1032     (ibms)       netcdf_support=true
1033                  netcdf_path=/applic/lib/NETCDF64;;
1034     (ibmy)       netcdf_support=true
1035                  netcdf_path=/usr1/users/raasch/pub/netcdf-3.6.0-p1;;
1036     (lcmuk)      netcdf_support=true
1037                  if [[ $scirocco = true ]]
1038                  then
1039                     netcdf_path=/opt/netcdf/3.6.2-beta4
1040                  else
1041                     netcdf_path=/muksoft/packages/netcdf/linux
1042                  fi;;
1043     (lctit)      netcdf_support=true
1044                  netcdf_path=/home2/usr5/mkanda/netcdf-3.6.1;;
1045     (nech)       netcdf_support=true
1046                  netcdf_path=/pool/SX-6/netcdf/netcdf-3.6.0-p1;;
1047     (neck)       netcdf_support=true
1048                  netcdf_path=/home/DSRC/NC/tatuyama/pub/netcdf-3.6.0-p1;;
1049 esac
1050
1051
1052    # VOLLSTAENDIGE DATEINAMEN DER INPUT-FILES BILDEN,
1053    # INPUT-DATEIEN AUF VORHANDENSEIN PRUEFEN UND EVTL. HOECHSTE ZYKLUSNUMMER
1054    # ERMITTELN
1055 (( i = 0 ))
1056 while (( i < iin ))
1057 do
1058    (( i = i + 1 ))
1059    (( maxcycle = 0 ))
1060
1061       # NAMENSBILDUNG (EVTL. IST FESTER DATEINAME VORGEGEBEN)
1062    if [[ "${actionin[$i]}" = di ]]
1063    then
1064       remotepathin[$i]=${pathin[$i]}/${endin[$i]}  # REMOTE-PFAD ERST AUF
1065                                                    # REM-MASCHINE AUSWERTEN
1066       eval filename=${pathin[$i]}/${endin[$i]}
1067    else
1068       remotepathin[$i]=${pathin[$i]}/${afname}${endin[$i]}  # REMOTE-PFAD ERST AUF
1069                                                             # REM-MASCHINE AUSWERTEN
1070       eval filename=${pathin[$i]}/${afname}${endin[$i]}
1071    fi
1072
1073       # PRUEFEN AUF VORHANDENSEIN
1074    if [[ $(ls $filename* 2>&1 | grep -c "not found") = 1  || \
1075          $(ls $filename* 2>&1 | grep -c "No such file") = 1  || \
1076          $(ls $filename* 2>&1 | grep -c "does not exist") = 1 ]]
1077    then
1078          # DATEIEN MIT EXTENSION (Z.B. NC) MUESSEN NICHT ZWINGEND VORHANDEN
1079          # SEIN, DESHALB IN SOLCHEN FAELLEN KEIN ABBRUCH. DIES IST NUR EINE
1080          # VORUEBERGEHENDE LOESUNG (OKT 05). NICHT ZWINGEND BENOETIGTE
1081          # EINGABEDATEIEN SOLLTEN EINE SPEZIELLE OPTION IN DER DATEI-
1082          # VERBINDUNGSANWEISUNG BEKOMMEN (Z.B. inopt?)
1083       if [[ "${transin[$i]}" != "locopt" ]]
1084       then
1085          printf "\n\n  +++ INPUT-file: "
1086          if [[ "${extin[$i]}" = "" ]]
1087          then
1088             printf "\n           $filename"
1089          else
1090             printf "\n           $filename.${extin[$i]}"
1091          fi
1092          printf "\n      does not exist\n"
1093          locat=input; exit
1094       else
1095          transin[$i]="unavailable"
1096       fi
1097    else
1098
1099          # ZYKLUSNUMMER FESTSTELLEN
1100       ls -1 -d $filename    >   filelist  2>/dev/null
1101       ls -1 -d $filename.*  >>  filelist  2>/dev/null
1102       while  read zeile
1103       do
1104          cycle=$(print $zeile | cut -f2 -d".")
1105          if [[ "$cycle" = "$zeile" ]]
1106          then
1107             (( icycle = 0 ))
1108          elif [[ "$cycle" = "${extin[$i]}" ]]
1109          then
1110             (( icycle = 0 ))
1111          else
1112             (( icycle = $cycle ))
1113          fi
1114          if (( icycle > maxcycle ))
1115          then
1116             (( maxcycle = icycle ))
1117             file_to_be_used=$zeile
1118          fi
1119       done <filelist
1120       rm filelist
1121
1122          # EVTL. ZYKLUSNUMMER AN DATEINAMEN ANFUEGEN
1123       if (( maxcycle > 0 ))
1124       then
1125          if [[ "${extin[$i]}" != " "  &&   "${extin[$i]}" != "" ]]
1126          then
1127             filename=${filename}.$maxcycle.${extin[$i]}
1128          else
1129             filename=${filename}.$maxcycle
1130          fi
1131       else
1132          if [[ "${extin[$i]}" != " "  &&   "${extin[$i]}" != "" ]]
1133          then
1134             filename=${filename}.${extin[$i]}
1135          fi
1136       fi
1137       
1138          # DATEINAMEN OHNE PFAD ABER MIT ZYKLUSNUMMER ABSPEICHERN,
1139          # DA SPAETER BEI RUECKSPEICHERN VOM ARCHIVSYSTEM EVTL. BENOETIGT
1140       absnamein[$i]=$filename
1141       if (( maxcycle > 0 ))
1142       then
1143          if [[ "${actionin[$i]}" = di ]]
1144          then
1145             frelin[$i]=${endin[$i]}.$maxcycle
1146          else
1147             frelin[$i]=${afname}${endin[$i]}.$maxcycle
1148          fi
1149       else
1150          if [[ "${actionin[$i]}" = di ]]
1151          then
1152             frelin[$i]=${endin[$i]}
1153          else
1154             frelin[$i]=${afname}${endin[$i]}
1155          fi
1156       fi
1157
1158    fi
1159 done
1160       
1161
1162    # VOLLSTAENDIGE DATEINAMEN (OHNE $ ODER ~) DER OUTPUT-FILES BILDEN,
1163    # OUTPUT-DATEIEN AUF VORHANDENSEIN PRUEFEN UND EVTL. HOECHSTE ZYKLUSNUMMER
1164    # ERMITTELN ODER, FALLS NICHT VORHANDEN, PRUEFEN, OB SIE SICH ANLEGEN LASSEN
1165    # DIESE AKTIONEN FINDEN NICHT STATT, WENN PROGRAMM AUF REMOTE-MASCHINE
1166    # RECHNET UND DATEI ANSCHLIESSEND TRANSFERIERT WERDEN SOLL!
1167 (( i = 0 ))
1168 while (( i < iout ))
1169 do
1170    (( i = i + 1 ))
1171    if [[ ! ( $fromhost != $localhost  &&  ( "${actionout[$i]}" = tr || "${actionout[$i]}" = tra || "${actionout[$i]}" = trpe ) ) ]]
1172    then
1173       if [[ "${actionout[$i]}" = tr  ||  "${actionout[$i]}" = trpe ]]
1174       then
1175          actionout[$i]=""
1176       elif [[ "${actionout[$i]}" = tra ]]
1177       then
1178          actionout[$i]=a
1179       fi
1180       (( maxcycle = 0 ))
1181       eval filename=${pathout[$i]}/${fname}${endout[$i]}
1182       eval catalogname=${pathout[$i]}
1183       if [[ $(ls $filename* 2>&1 | grep -c "not found") = 1  || \
1184             $(ls $filename* 2>&1 | grep -c "No such file") = 1  || \
1185             $(ls $filename* 2>&1 | grep -c "does not exist") = 1 ]]
1186       then
1187     
1188             # OUTPUT-DATEI NICHT VORHANDEN. PRUEFEN, OB ANLEGEN MOEGLICH.
1189          if  cat /dev/null > $filename 
1190          then
1191             rm  $filename
1192          else
1193
1194                # PRUEFEN, OB KATALOG VORHANDEN UND EVTL. DIESEN ANLEGEN
1195             if [[ ! -d $catalogname ]]
1196             then
1197                if  mkdir -p  $catalogname
1198                then
1199                   printf "\n\n  *** directory:"
1200                   printf "\n           $catalogname"
1201                   printf "\n      was created\n"
1202                else
1203                   printf "\n\n  +++ OUTPUT-file:"
1204                   printf "\n           $filename"
1205                   printf "\n      cannot be created, because directory does not exist"
1206                   printf "\n      and cannot be created either"
1207                   printf "\n"
1208                   locat=output  ; exit
1209                fi 2>/dev/null
1210             else
1211                printf "\n\n  +++ OUTPUT-file:"
1212                printf "\n           $filename"
1213                printf "\n      cannot be created, although directory exists"
1214                printf "\n"
1215                locat=output  ; exit
1216             fi
1217          fi 2>/dev/null
1218       else
1219
1220             # ZYKLUSNUMMER FESTSTELLEN
1221          ls -1 -d $filename    >   filelist  2>/dev/null
1222          ls -1 -d $filename.*  >>  filelist  2>/dev/null
1223          while  read zeile
1224          do
1225             cycle=$(print $zeile | cut -f2 -d".")
1226             if [[ "$cycle" = "$zeile"  ||  "$cycle" = ${extout[$i]} ]]
1227             then
1228                (( icycle = 1 ))
1229             else
1230                (( icycle = $cycle + 1 ))
1231             fi
1232             if (( icycle > maxcycle ))
1233             then
1234                (( maxcycle = icycle ))
1235             fi
1236          done <filelist
1237          rm filelist
1238       fi
1239
1240          # EVTL. ZYKLUSNUMMER AN DATEINAMEN ANFUEGEN UND PRUEFEN, OB SICH
1241          # DATEI AUCH WIRKLICH ANLEGEN LAESST. IM APPEND-FALL MUSS AN DEN
1242          # HOECHSTEN VORHANDENEN ZYKLUS-ANGEHAENGT WERDEN. ANLAGEPRUEFUNG
1243          # IST DANN NATUERLICH NICHT ZULAESSIG BZW. MOEGLICH
1244       if [[ "${actionout[$i]}" != a ]]
1245       then
1246          if (( maxcycle > 0 ))
1247          then
1248             filename=${filename}.$maxcycle
1249             if  cat /dev/null > $filename 
1250             then
1251                rm  $filename
1252             else
1253                printf "\n  +++ OUTPUT-file:"
1254                printf "\n           $filename"
1255                printf "\n      cannot be created"
1256                locat=output  ; exit
1257             fi
1258          fi
1259       else
1260          (( maxcycle = maxcycle - 1 ))
1261          if (( maxcycle > 0 ))
1262          then
1263             filename=${filename}.$maxcycle
1264          fi
1265       fi
1266       
1267          # DATEINAMEN OHNE PFAD ABER MIT ZYKLUSNUMMER ABSPEICHERN,
1268          # DA SPAETER BEI ABLAGE AUF ARCHIVSYSTEM BZW. FUER
1269          # DATEI OUTPUT_FILE_CONNECTIONS EVTL. BENOETIGT
1270       pathout[$i]=$filename
1271       if (( maxcycle > 0 ))
1272       then
1273          frelout[$i]=${fname}${endout[$i]}.$maxcycle
1274       else
1275          frelout[$i]=${fname}${endout[$i]}
1276       fi
1277
1278    fi
1279 done
1280
1281
1282     # PRUEFEN, OB ENTWEDER HAUPTPROGRAMM ODER NUR EIN AUSFUEHRBARES
1283     # PROGRAMM VEREINBART WURDE (IN DIESEM FALL BRAUCHT IM WEITEREN NICHT
1284     # UEBERSETZT ZU WERDEN)
1285 if [[ "$mainprog" = ""  &&  "$executable" = "" ]]
1286 then
1287    printf "\n  +++ neither main program nor executable defined"
1288    locat=source; exit
1289 elif [[ "$mainprog" != ""  &&  "$executable" != "" ]]
1290 then
1291    printf "\n  +++ main program as well as executable defined"
1292    locat=source; exit
1293 elif [[ "$mainprog" = ""  &&  "$executable" != "" ]]
1294 then
1295    do_compile=false
1296 fi
1297
1298
1299    # ALLE ZU UEBERSETZENDEN PROGRAMMTEILE ZUSAMMENSAMMELN
1300    # BEI BATCH-JOBS IST DIES NICHT NOETIG, WEIL DIE PROGRAMMTEILE BEREITS DURCH
1301    # DEN MRUN-AUFRUF ERMITTELT SIND, DER DEN BATCH-JOB GENERIERT HAT, UND
1302    # IM VERZEICHNIS SOURCES_FOR_RUN_... ABGELEGT SIND
1303 if [[ $do_compile = true  &&  "$SOURCES_COMPLETE" = "" ]]
1304 then
1305
1306    [[ "$source_list" = LM ]]  &&  source_list=LOCALLY_MODIFIED
1307    [[ "$source_list" = WP ]]  &&  source_list=WRITE_PERMIT
1308
1309    if [[ $restart_run != true ]]
1310    then
1311       rm -rf  SOURCES_FOR_RUN_$fname
1312       mkdir   SOURCES_FOR_RUN_$fname
1313    fi
1314
1315
1316       # EVTL. ZU UEBERSETZENDE PROGRAMMTEILE DADURCH BESTIMMEN, DASS GEPRUEFT
1317       # WIRD, WELCHE DATEIEN WRITE-PERMIT BESITZEN (DATEIEN SOLLTEN DESHALB
1318       # UNTER RCS-KONTROLLE STEHEN). MIT DER VARIABLEN EXCLUDE KOENNEN
1319       # BESTIMMTE DATEIEN GRUNDSAETZLICH VON DER UEBERSETZUNG AUSGESCHLOSSEN
1320       # WERDEN. DIES IST NUR BEI MANUELLEM START VON MRUN DURCH DEN BENUTZER
1321       # MOEGLICH, DA BEI AUTOMATISCHEN RESTARTS TEST DURCH DIE TATSAECHLICH
1322       # ZU UBERSETZENDEN DATEIEN ERSETZT IST.
1323       # ALLE ERMITTELTEN DATEIEN WERDEN IM VERZEICHNIS SOURCES_FOR_RUN_...
1324       # GESAMMELT
1325    if [[ "$source_list" = WRITE_PERMIT ]]
1326    then
1327
1328       source_list=""
1329       cd  $source_path
1330
1331
1332          # ALLE MOEGLICHEN QUELLCODEDATEIEN AUFLISTEN
1333       Names=$(ls -1 *.f90 2>&1)
1334       [[ $(echo $Names | grep -c '*.f90') = 0 ]]  &&  Filenames="$Names"
1335       Names=$(ls -1 *.F90 2>&1)
1336       [[ $(echo $Names | grep -c '*.F90') = 0 ]]  &&  Filenames="$Filenames $Names"
1337       Names=$(ls -1 *.F 2>&1)
1338       [[ $(echo $Names | grep -c '*.F') = 0   ]]  &&  Filenames="$Filenames $Names"
1339       Names=$(ls -1 *.f 2>&1)
1340       [[ $(echo $Names | grep -c '*.f') = 0   ]]  &&  Filenames="$Filenames $Names"
1341       Names=$(ls -1 *.c 2>&1)
1342       [[ $(echo $Names | grep -c '*.c') = 0   ]]  &&  Filenames="$Filenames $Names"
1343
1344
1345          # DATEIEN MIT WRITE-PERMIT NACH SOURCES_FOR_RUN_... KOPIEREN
1346       for  dateiname  in  $Filenames
1347       do
1348          if [[ -w $dateiname ]]
1349          then
1350             if [[ "$exclude" = ""  ||  $(echo $exclude | grep -c $dateiname) = 0 ]]
1351             then
1352                cp  $dateiname  $working_directory/SOURCES_FOR_RUN_$fname
1353                source_list=$source_list"$dateiname "
1354             fi
1355          fi
1356       done
1357
1358       cd -  > /dev/null
1359
1360
1361    elif [[ "$source_list" = LOCALLY_MODIFIED ]]
1362    then
1363
1364          # MODIFIZIERTE DATEIEN DER SVN-ARBEITSKOPIE BESTIMMEN
1365       source_list=""
1366       cd  $source_path
1367
1368
1369          # PRUEFEN, OB VERZEICHNIS UEBERHAUPT UNTER SVN-KONTROLLE STEHT
1370       if [[ ! -d .svn ]]
1371       then
1372          printf "\n\n  +++ source directory"
1373          printf "\n         \"$source_path\" "
1374          printf "\n         is not under control of \"subversion\"."
1375          printf "\n         Please do not use mrun-option \"-s LOCALLY MODIFIED\"\n"
1376       fi
1377
1378
1379          # ALLE MODIFIZIERTEN QUELLCODEDATEIEN AUFLISTEN
1380       Filenames=""
1381       svn status  |  while  read line
1382       do
1383          firstc=`echo $line | cut -c1`
1384          if [[ $firstc = M  ||  $firstc = "?" ]]
1385          then
1386             Name=`echo "$line" | cut -c8-`
1387             extension=`echo $Name | cut -d. -f2`
1388             if [[ "$extension" = f90 || "$extension" = F90 || "$extension" = f || "$extension" = F || "$extension" = c ]]
1389             then
1390                Filenames="$Filenames "$Name
1391             fi
1392          fi
1393       done
1394
1395
1396          # DATEIEN NACH SOURCES_FOR_RUN_... KOPIEREN
1397       for  dateiname  in  $Filenames
1398       do
1399          cp  $dateiname  $working_directory/SOURCES_FOR_RUN_$fname
1400          source_list=$source_list"$dateiname "
1401       done
1402
1403       cd -  > /dev/null
1404
1405
1406       # MITTELS OPTION -s ANGEGEBENE DATEIEN NACH SOURCES_FOR_RUN_... KOPIEREN
1407       # BEI AUTOMATISCHEN FORTSETZUNGSLAEUFEN SIND DORT SCHON ALLE DATEIEN
1408       # VORHANDEN
1409    elif [[ "$source_list" != ""  &&  $restart_run != true ]]
1410    then
1411
1412       cd  $source_path
1413
1414       for  filename  in  $source_list
1415       do
1416
1417             # QUELLTEXT-DATEI DARF KEINE PFADE BEINHALTEN
1418          if [[ $(print $filename | grep -c "/") != 0 ]]
1419          then
1420             printf "\n  +++ source code file:  $filename"
1421             printf "\n      must not contain (\"/\") "
1422             locat=source; exit
1423          fi
1424
1425          if [[ ! -f $filename ]]
1426          then
1427             printf "\n  +++ source code file:  $filename"
1428             printf "\n      does not exist"
1429             locat=source; exit
1430          else
1431             cp  $filename  $working_directory/SOURCES_FOR_RUN_$fname
1432          fi
1433
1434       done
1435
1436       cd -  > /dev/null
1437
1438    fi
1439
1440
1441       # PRUEFEN, OB ENTWEDER HAUPTPROGRAMM VORHANDEN UND ES EVTL. IN DER
1442       # LISTE DER ZU UEBERSETZENDEN PROGRAMMTEILE MIT ENTHALTEN IST (WENN
1443       # NICHT, WIRD ES DIESER LISTE HINZUGEFUEGT)
1444    if [[ $restart_run != true ]]
1445    then
1446
1447       if [[ ! -f "$source_path/$mainprog" ]]
1448       then
1449          printf "\n\n  +++ main program:  $mainprog"
1450          printf "\n      does not exist in source directory"
1451          printf "\n      \"$source_path\"\n"
1452          locat=source; exit
1453       else
1454          if [[ $(echo $source_list | grep -c $mainprog) = 0 ]]
1455          then
1456             cp  $source_path/$mainprog  SOURCES_FOR_RUN_$fname
1457             source_list=${mainprog}" $source_list"
1458          fi
1459       fi
1460    fi
1461
1462
1463       # DATEIEN AUS ZUSAETZLICHEM QUELLVERZEICHNIS HINZUFUEGEN
1464    if [[ $restart_run != true  &&  "$add_source_path" != "" ]]
1465    then
1466
1467          # GIBT ES DAS VERZEICHNIS UEBERHAUPT?
1468       if [[ ! -d $add_source_path ]]
1469       then
1470          printf "\n\n  +++ WARNING: additional source code directory"
1471          printf "\n      \"$add_source_path\" "
1472          printf "\n      does not exist or is not a directory."
1473          printf "\n      No source code will be used from this directory!\n"
1474          add_source_path=""
1475          sleep 3
1476       else
1477
1478          cd $add_source_path
1479
1480          Names=$(ls -1 *.f90 2>&1)
1481          [[ $(echo $Names | grep -c '*.f90') = 0 ]]  &&  AddFilenames="$Names"
1482          Names=$(ls -1 *.F90 2>&1)
1483          [[ $(echo $Names | grep -c '*.F90') = 0 ]]  &&  AddFilenames="$AddFilenames $Names"
1484          Names=$(ls -1 *.F 2>&1)
1485          [[ $(echo $Names | grep -c '*.F') = 0   ]]  &&  AddFilenames="$AddFilenames $Names"
1486          Names=$(ls -1 *.f 2>&1)
1487          [[ $(echo $Names | grep -c '*.f') = 0   ]]  &&  AddFilenames="$AddFilenames $Names"
1488          Names=$(ls -1 *.c 2>&1)
1489          [[ $(echo $Names | grep -c '*.c') = 0   ]]  &&  AddFilenames="$AddFilenames $Names"
1490
1491          cd -  > /dev/null
1492          cd  SOURCES_FOR_RUN_$fname
1493
1494          for  dateiname  in  $AddFilenames
1495          do
1496             if [[ -f $dateiname ]]
1497             then
1498                printf "\n  +++ source code file \"$dateiname\" found in additional"
1499                printf "\n      source code directory \"$add_source_path\" "
1500                printf "\n      as well as in directory \"$source_path\"."
1501                locat=source; exit
1502             fi
1503
1504             cp  $add_source_path/$dateiname  .
1505             source_list="$source_list $dateiname"
1506
1507                # Default User-Interface von der Liste entfernen, falls Datei
1508                # ein User-Interface enthaelt
1509             if [[ $( cat $dateiname | grep -c "END SUBROUTINE user_parin" ) != 0 ]]
1510             then
1511                if [[ -f user_interface.f90 ]]
1512                then
1513                   rm -rf  user_interface.f90
1514                   source_list=`echo $source_list | sed -e 's/user_interface.f90//'`
1515                   printf "\n\n  *** \"user_interface.f90\" removed from the files to be translated"
1516                   printf "\n      since a user-interface is found in file"
1517                   printf "\n      \"$add_source_path/$dateiname\" \n"
1518                   sleep 3
1519                else
1520                   printf "\n\n  *** user-interface file \"$dateiname\" "
1521                   printf "\n      added to the files to be translated \n"
1522                   sleep 3
1523                fi
1524             fi
1525          done
1526
1527          cd -  > /dev/null
1528       fi
1529    fi
1530
1531
1532       # ALLE UNTERPROGRAMME, DIE ZU VEREINBARTEN SOFTWAREPAKETEN GEHOEREN,
1533       # DER LISTE DER ZU UEBERSETZENDEN DATEIEN HINZUFUEGEN
1534    if [[ $restart_run != true  &&  -n $package_list ]]
1535    then
1536
1537       cd  $source_path
1538
1539       for  package  in  $package_list
1540       do
1541
1542          [[ $package = "dvrp_graphics+1PE" ]]  &&  package=dvrp_graphics
1543
1544             # ERMITTELE ALLE DATEIEN, DIE ZUM PAKET GEHOEREN
1545             # FEHLERMELDUNGEN WERDEN ABGEFANGEN, DA * AUCH VERZEICHNISSNAMEN
1546             # LIEFERT
1547          package_source_list=`grep "defined( __$package " * 2>/dev/null | cut -f1 -d:`
1548
1549
1550             # FUEGE DIESE DATEIEN DER LISTE DER ZU UEBERSETZENDEN DATEIEN
1551             # HINZU, FALLS SIE NOCH NICHT DAZUGEHOEREN
1552          for  source_list_name  in  $package_source_list
1553          do
1554             if [[ $(echo $source_list | grep -c $source_list_name) = 0 ]]
1555             then
1556
1557                    # NUR DATEIEN MIT GUELTIGEN ENDUNGEN VERWENDEN
1558                ending=`echo $source_list_name | cut -f2 -d.`
1559                if [[ "$ending" = f90  ||  "$ending" = F90  ||  "$ending" = f  ||  "$ending" = F  ||  "$ending" = c ]]
1560                then
1561                   cp  $source_list_name  $working_directory/SOURCES_FOR_RUN_$fname
1562                   source_list="$source_list $source_list_name"
1563                fi
1564             fi
1565          done
1566       done
1567
1568       cd -  > /dev/null
1569    fi
1570
1571
1572       # MAKEFILE AUF VORHANDENSEIN PRUEFEN UND KOPIEREN
1573       # BEI RESTART-LAEUFEN LIEGT ES SCHON IM VERZEICHNIS SOURCES_FOR_RUN...
1574    if [[ "$use_makefile" = true  &&  "$restart_run" != true ]]
1575    then
1576       [[ "$makefile" = "" ]]  &&  makefile=$source_path/Makefile
1577       if [[ ! -f $makefile ]]
1578       then
1579          printf "\n  +++ file \"$makefile\" does not exist"
1580          printf "\n      provide this file or set \"use_makefile=false\" in configuration file\n"
1581          locat=make; exit
1582       else
1583          cp  $makefile  SOURCES_FOR_RUN_$fname/Makefile
1584       fi
1585    fi
1586
1587 fi  # do_compile=true
1588
1589
1590    # FALLS PROGRAMMTEILE UEBERSETZT WERDEN SOLLEN, FOLGEN JETZT EINIGE
1591    # UEBERPRUEFUNGEN UND DAS SETZEN DER PRAEPROZESSOR-DIREKTIVEN
1592 if [[ $do_compile = true ]]
1593 then
1594
1595       # PRAEPROZESSOR-DIREKTIVEN ZUM SELEKTIVEN AUSWAEHLEN VON CODETEILEN
1596       # ZUSAMMENSETZEN
1597    if [[ $(echo $localhost | cut -c1-3) = ibm ]]
1598    then
1599       PPOPTS=-Dibm=ibm
1600    elif [[ $(echo $localhost | cut -c1-3) = nec ]]
1601    then
1602       PPOPTS=-Dnec
1603    else
1604       PPOPTS=-D$localhost
1605    fi
1606    if [[ $(echo $localhost | cut -c1-3) = ibm ]]
1607    then
1608       [[ -n $cond1 ]]               &&  PPOPTS="$PPOPTS -D$cond1=$cond1"
1609       [[ -n $cond2 ]]               &&  PPOPTS="$PPOPTS -D$cond2=$cond2"
1610       if [[ $netcdf_support = true ]]
1611       then
1612          PPOPTS="$PPOPTS -Dnetcdf=netcdf"
1613          [[ $localhost != ibms ]]      &&  PPOPTS="$PPOPTS -Dnetcdf_64bit=netcdf_64bit"
1614       fi
1615       if [[ $localhost = ibmy ]]
1616       then
1617          PPOPTS="$PPOPTS -Dibmy_special=ibmy_special"
1618       fi
1619    else
1620       [[ -n $cond1 ]]               &&  PPOPTS="$PPOPTS -D$cond1"
1621       [[ -n $cond2 ]]               &&  PPOPTS="$PPOPTS -D$cond2"
1622       if [[ $netcdf_support = true ]]
1623       then
1624          PPOPTS="$PPOPTS -Dnetcdf"
1625          [[ $localhost != decalpha  &&  $localhost != lctit ]]  &&  PPOPTS="$PPOPTS -Dnetcdf_64bit"
1626       fi
1627    fi
1628    if [[ -n $package_list ]]
1629    then
1630       for  package  in  $package_list
1631       do
1632          if [[ $(echo $localhost | cut -c1-3) = ibm ]]
1633          then
1634             if [[ $package != "dvrp_graphics+1PE" ]]
1635             then
1636                PPOPTS="$PPOPTS -D$package=$package"
1637             else
1638                PPOPTS="$PPOPTS -Ddvrp_graphics"
1639                export use_seperate_pe_for_dvrp_output=true
1640             fi
1641          else
1642             if [[ $package != "dvrp_graphics+1PE" ]]
1643             then
1644                PPOPTS="$PPOPTS -D$package"
1645             else
1646                PPOPTS="$PPOPTS -Ddvrp_graphics"
1647                export use_seperate_pe_for_dvrp_output=true
1648             fi
1649          fi
1650       done
1651    fi
1652    if [[ -n $cpp_opts ]]
1653    then
1654       for  popts  in  $cpp_opts
1655       do
1656          PPOPTS="$PPOPTS -D$popts"
1657       done
1658    fi
1659
1660       # -D ARGUMENTEN EINEN DOPPELTEN UNTERSTRICH VORANSTELLEN
1661    PPOPTS=`echo " $PPOPTS" | sed 's/ -D/ -D__/g'`
1662
1663       # OPTION ZUM EINSCHALTEN DES PRAEPROZESSORS HINZUFUEGEN
1664    if [[ $host = decalpha ]]
1665    then
1666       C_PPOPTS="-cpp  -DMPI_REAL=MPI_DOUBLE_PRECISION -DMPI_2REAL=MPI_2DOUBLE_PRECISION $PPOPTS"
1667    elif [[ $(echo $host | cut -c1-3) = ibm ]]
1668    then
1669          # blanks in PPOPTS muessen durch "," ersetzt werden
1670       PPOPTS=`echo $PPOPTS | sed 's/ -/,-/g'`
1671       C_PPOPTS="-qsuffix=cpp=f90 -WF,-DMPI_REAL=MPI_DOUBLE_PRECISION,$PPOPTS"
1672    elif [[ $host = lcmuk ]]
1673    then
1674       C_PPOPTS="$PPOPTS -DMPI_REAL=MPI_DOUBLE_PRECISION -DMPI_2REAL=MPI_2DOUBLE_PRECISION"
1675    elif [[ $host = lctit ]]
1676    then
1677       C_PPOPTS="$PPOPTS -Mpreprocess -DMPI_REAL=MPI_DOUBLE_PRECISION -DMPI_2REAL=MPI_2DOUBLE_PRECISION"
1678    elif [[ $(echo $host | cut -c1-3) = nec ]]
1679    then
1680       C_PPOPTS="-Ep -DMPI_REAL=MPI_REAL8 -DMPI_2REAL=MPI_2REAL8 -DSCFFT=dzfft -DCSFFT=zdfft $PPOPTS"
1681    else
1682       C_PPOPTS="$PPOPTS"
1683    fi
1684
1685 else
1686
1687
1688       # BEI LOKALEN RECHNUNGEN PRUEFEN, OB EXECUTABLE VORHANDEN
1689    if [[ $do_remote = false ]]
1690    then
1691       if [[ ! -f $executable ]]
1692       then
1693          printf "\n  +++ executable file:  $executable"
1694          printf "\n      does not exist"
1695          locat=executable; exit
1696       fi
1697    fi
1698 fi
1699
1700
1701    # JOBMODUS FESTSTELLEN
1702 if [[ "$ENVIRONMENT" = BATCH  &&  $localhost != lctit  ||  "$QUEUE" != interactive  &&  $localhost = lctit ]]
1703 then
1704    jobmo=BATCH
1705 else
1706    jobmo=INTERACTIVE
1707 fi
1708
1709
1710    # HOSTSPEZIFISCHE DEFAULT-COMPILER SETZEN, FALLS NICHT BEREITS
1711    # DURCH BENUTZER ANDERWEITIG VEREINBART
1712 if [[ "$compiler_name" = "" ]]
1713 then
1714    case  $localhost  in
1715        (unics)                                 compiler_name=f77;;
1716        (lcmuk)                                 if [[ "$cond1" = parallel  ||  "$cond2" = parallel ]]
1717                                                then
1718                                                   compiler_name=mpif90
1719                                                else
1720                                                   compiler_name=ifc
1721                                                fi;;
1722        (lctit)                                 if [[ "$cond1" = parallel  ||  "$cond2" = parallel ]]
1723                                                then
1724                                                   compiler_name=mpif90
1725                                                   echo ">>> compiler=mpif90"
1726                                                else
1727                                                   compiler_name=pgf95
1728                                                   echo ">>> compiler=pgf95"
1729                                                fi;;
1730        (nech)                                  compiler_name=sxmpif90;;
1731        (decalpha)                              compiler_name=f95;;
1732        (ibm|ibmb|ibmh|ibms|ibmy)               compiler_name=mpxlf95_r;;
1733        (*)      printf "\n  +++ unknown host name: $localhost \n";
1734                 locat=localhost; exit;;
1735    esac
1736 fi
1737
1738
1739    # COMPILER AUF NECK UEBERSCHREIBEN
1740 [[ $localhost = neck ]]  &&  compiler_name=mpif90
1741
1742
1743
1744    # PRAEPROZESSOR-PFAD BESTIMMEN
1745 case  $localhost  in
1746     (decalpha|ibm|ibmb|ibmh|ibms|ibmy|unics)  praeproc=cpp;;
1747 esac
1748
1749
1750    # TEMPORAEREN KATALOGNAMEN BESTIMMEN
1751 kennung=$RANDOM
1752 if [[ "$tmp_user_catalog" = "" ]]
1753 then
1754    if [[ $localhost = ibmb  ||  $localhost = ibmh ]]
1755    then
1756       tmp_user_catalog=$TMPDIR
1757    elif [[ $localhost = nech ]]
1758    then
1759       tmp_user_catalog=$WRKSHR
1760    else
1761       tmp_user_catalog=/tmp
1762    fi
1763 fi
1764 TEMPDIR=$tmp_user_catalog/${usern}.$kennung
1765
1766
1767    # KATALOGNAMEN FUER ZWISCHENSPEICHERUNG VON FORTSETZUNGSLAUFDATEIEN
1768    # BESTIMMEN
1769 if [[ "$tmp_data_catalog" = "" ]]
1770 then
1771    if [[ $localhost = ibmb  ||  $localhost = ibmh ]]
1772    then
1773       tmp_data_catalog=$WORK/mrun_restart_data
1774    elif [[ $localhost = nech ]]
1775    then
1776       tmp_data_catalog=$WRKSHR/mrun_restart_data
1777    else
1778       tmp_data_catalog=/tmp/mrun_restart_data
1779    fi
1780 fi
1781
1782
1783    # EVENTUELL BEI LOKALEN RECHNUNGEN $-ZEICHEN IN ENVIRONMENT-VARIABLEN
1784    # ERSETZEN
1785 if [[ $do_remote = false  &&  $do_compile = true ]]
1786 then
1787    eval  fopts=\"$fopts\"
1788    eval  lopts=\"$lopts\"
1789 fi
1790
1791
1792
1793    # COMPILE- UND LINK-OPTIONEN BESTIMMEN
1794 FOPTS="$fopts"
1795 LOPTS="$lopts"
1796 ROPTS="$ropts"
1797 if [[ ( $(echo $host | cut -c1-3) = nec  ||  $(echo $host | cut -c1-3) = ibm  ||  $host = lctit )  &&  -n $numprocs ]]
1798 then
1799    XOPT="-X $numprocs"
1800 fi
1801
1802
1803    # BEI VERWENDUNG VON DVRP-SOFTWARE MUSS ENTSPECHENDE GRAFIK-BIBLIOTHEK
1804    # MIT EINGEBUNDEN WERDEN
1805 if [[ -n $package_list ]]
1806 then
1807    if [[ $(echo $package_list | grep -c dvrp_graphics) != 0 ]]
1808    then
1809
1810          # DVRP-GRAFIK GIBT ES NUR AUF DER IBM AM HLRN, AUF NECH/NECK UND
1811          # DEM NOTEBOOK SCIROCCO
1812       if [[ $host != ibmh  &&  $host != nech  &&  $host != neck  &&  $host != lcmuk  &&  "$local_compile" != true ]]
1813       then
1814          printf "\n"
1815          printf "\n  +++ option -p with package \"dvrp_graphics\" only allowed on nech and ibmh"
1816          locat=parameter; exit
1817       fi
1818       if [[ $host = ibmh ]]
1819       then
1820          if [[ $cond1 = debug  ||  $cond2 = debug ]]
1821          then
1822             FOPTS="-I/home/h/hzazchmi/lib/debug  $FOPTS"
1823             LOPTS="$LOPTS -L/home/h/hzazchmi/lib/debug -lDVRP2 -lftp"
1824          else
1825             FOPTS="-I/home/h/nikevita/lib_stable/optimize  $FOPTS"
1826             LOPTS="$LOPTS -L/home/h/nikevita/lib_stable/optimize -lDVRP2 -lftp"
1827          fi
1828       elif [[ $host = nech ]]
1829       then
1830          FOPTS="-I/import/ds9b/ipf2/b/b323014/lib/optimize  $FOPTS"
1831          LOPTS="$LOPTS -L/import/ds9b/ipf2/b/b323014/lib/optimize -lDVRP2 -lftp"
1832       elif [[ $host = neck ]]
1833       then
1834          FOPTS="-I/home/DSRC/NC/tatuyama/pub/dvrp  $FOPTS"
1835          LOPTS="$LOPTS -L/home/DSRC/NC/tatuyama/pub/dvrp -lDVRP2 -lftp"
1836       elif [[ $host = lcmuk ]]
1837       then
1838          FOPTS="-I/usr/local/lib/dvrp/optimize  $FOPTS"
1839          LOPTS="$LOPTS -L/usr/local/lib/dvrp/optimize -lDVRP2 -lftp"
1840       fi
1841    fi
1842 fi
1843
1844
1845    # EVTL. EINBINDEN DER NETCDF-BIBLIOTHEK
1846 if [[ $netcdf_support = true ]]
1847 then
1848    case  $host  in
1849       (decalpha)         FOPTS="-I${netcdf_path}/include  $FOPTS"
1850                          LOPTS="$LOPTS -L${netcdf_path}/lib -lnetcdf";;
1851       (ibmb|ibmh)        FOPTS="-I ${netcdf_path}/include-64  $FOPTS"
1852                          LOPTS="$LOPTS -L${netcdf_path}/lib -lnetcdf";;
1853       (ibms)             FOPTS="-I /applic/netcdf64/src/f90  $FOPTS"
1854                          LOPTS="$LOPTS -L${netcdf_path} -lnetcdf";;
1855       (ibmy)             FOPTS="-I ${netcdf_path}/include  $FOPTS"
1856                          LOPTS="$LOPTS -L${netcdf_path}/lib -lnetcdf";;
1857       (lcmuk|nech|neck)  FOPTS="-I ${netcdf_path}/include  $FOPTS"
1858                          LOPTS="$LOPTS -L${netcdf_path}/lib -lnetcdf";;
1859       (lctit)            FOPTS="-I ${netcdf_path}/src/f90  $FOPTS"
1860                          LOPTS="$LOPTS -L${netcdf_path}/src/libsrc -lnetcdf";;
1861
1862    esac
1863 fi
1864
1865    # PRUEFEN DER CPU-ZEIT. (CPUMAX WIRD ALS ENV-VARIABLE VOM HAUTPRO-
1866    # GRAMM BENOETIGT
1867 done=false
1868 while [[ $done = false ]]
1869 do
1870    cputime=$cpumax
1871    if (( $cputime == 0 ))
1872    then
1873       printf "\n  +++ cpu-time is undefined"
1874       printf "\n  >>> Please type CPU-time in seconds as INTEGER:"
1875       printf "\n  >>> "
1876       read  cputime  1>/dev/null  2>&1
1877    else
1878       done=true
1879    fi
1880    cpumax=$cputime
1881 done
1882
1883 (( minuten = cputime / 60 ))
1884 (( sekunden = cputime - minuten * 60 ))
1885
1886
1887    # PRUEFEN DER KERNSPEICHERANFORDERUNG
1888 if [[ $do_batch = true ]]
1889 then
1890    done=false
1891    while [[ $done = false ]]
1892    do
1893       if (( memory == 0 ))
1894       then
1895          printf "\n  +++ memory demand is undefined"
1896          printf "\n  >>> Please type memory in  MByte per process  as INTEGER:"
1897          printf "\n  >>> "
1898          read  memory  1>/dev/null  2>&1
1899       else
1900          done=true
1901       fi
1902    done
1903 fi
1904
1905
1906    # PRUEFEN, OB FUER REMOTE-RECHNUNGEN EIN BENUTZERNAME ANGEGEBEN WURDE
1907 if [[ $do_remote = true  &&  -z $remote_username ]]
1908 then
1909    while [[ -z $remote_username ]]
1910    do
1911       printf "\n  +++ username on remote host \"$host\" is undefined"
1912       printf "\n  >>> Please type username:"
1913       printf "\n  >>> "
1914       read  remote_username
1915    done
1916    mc="$mc -u$remote_username"
1917 fi
1918
1919###########################################################################
1920# HEADER-AUSGABE
1921###########################################################################
1922
1923
1924 calltime=$(date)
1925 printf "\n"
1926# [[ $silent = false ]]  &&  clear
1927 printf "#--------------------------------------------------------------# \n"
1928 printf "| $version$calltime | \n"
1929 printf "|                                                              | \n"
1930 spalte1="called on:"; spalte2=$localhost_realname
1931 printf "| $spalte1$spalte2 | \n"
1932 if [[ $local_compile = false ]]
1933 then
1934    if [[ $do_remote = true ]]
1935    then
1936       spalte1="execution on:"; spalte2="$host (username: $remote_username)"
1937    else
1938       spalte1="execution on:"; spalte2="$host ($localhost_realname)"
1939    fi
1940 else
1941    spalte1="compiling test only!"; spalte2=""
1942 fi
1943 printf "| $spalte1$spalte2 | \n"
1944 if [[ -n $numprocs ]]
1945 then
1946    spalte1="number of PEs:"; spalte2=$numprocs
1947    printf "| $spalte1$spalte2 | \n"
1948 fi
1949 if [[ -n $tasks_per_node ]]
1950 then
1951    spalte1="tasks per node:"; spalte2="$tasks_per_node (number of nodes: $nodes)"
1952    printf "| $spalte1$spalte2 | \n"
1953 fi
1954 if [[ $threads_per_task != 1 ]]
1955 then
1956    spalte1="threads per task:"; spalte2="$threads_per_task"
1957    printf "| $spalte1$spalte2 | \n"
1958 fi
1959 printf "|                                                              | \n"
1960 if [[ $do_compile = true ]]
1961 then
1962    spalte1=cpp-directives:; spalte2=$C_PPOPTS
1963    printf "| $spalte1$spalte2 | \n"
1964    zeile=$(echo "$C_PPOPTS" | cut -c41-)
1965    while [[ "$zeile" != "" ]]
1966    do
1967       spalte1=""
1968       spalte2=$zeile
1969       printf "| $spalte1$spalte2 | \n"
1970       zeile=$(echo "$zeile" | cut -c41-)
1971    done
1972
1973    spalte1=compiler-options:; spalte2="$FOPTS $MODULE_OPTIONS"
1974    printf "| $spalte1$spalte2 | \n"
1975    zeile=$(echo "$FOPTS $MODULE_OPTIONS" | cut -c41-)
1976    while [[ "$zeile" != "" ]]
1977    do
1978       spalte1=""
1979       spalte2=$zeile
1980       printf "| $spalte1$spalte2 | \n"
1981       zeile=$(echo "$zeile" | cut -c41-)
1982    done
1983
1984    spalte1=linker-options:; spalte2=$LOPTS
1985    printf "| $spalte1$spalte2 | \n"
1986    zeile=$(echo "$LOPTS" | cut -c41-)
1987    while [[ "$zeile" != "" ]]
1988    do
1989       spalte1=""
1990       spalte2=$zeile
1991       printf "| $spalte1$spalte2 | \n"
1992       zeile=$(echo "$zeile" | cut -c41-)
1993    done
1994
1995    spalte1="main program":; spalte2=$mainprog
1996    printf "| $spalte1$spalte2 | \n"
1997    if [[ "$use_makefile" = true ]]
1998    then
1999       spalte1="using \"make\" for com"; spalte2="piling and linking"
2000       printf "| $spalte1$spalte2 | \n"
2001    fi
2002#    if [[ $vtk_graphics = true ]]
2003#    then
2004#       spalte1=""; spalte2="wird in C++ - Programm eingebunden (vtk)"
2005#       printf "| $spalte1$spalte2 | \n"
2006#    fi
2007 else
2008    spalte1=executable:; spalte2=$executable
2009    printf "| $spalte1$spalte2 | \n"
2010 fi
2011 printf "|                                                              | \n"
2012 spalte1="base name of files":; spalte2=$fname
2013 printf "| $spalte1$spalte2 | \n"
2014 if [[ $fname != $afname ]]
2015 then
2016    spalte1="base name of input files":; spalte2=$afname
2017    printf "| $spalte1$spalte2 | \n"
2018 fi
2019 spalte1="INPUT control list":; spalte2=$input_list
2020 printf "| $spalte1$spalte2 | \n"
2021 spalte1="OUTPUT control list":; spalte2=$output_list
2022 printf "| $spalte1$spalte2 | \n"
2023
2024 if [[ $do_batch = true  ||  "$LOADLBATCH" = yes ]]
2025 then
2026    spalte1="memory demand / PE":; spalte2="$memory MB"
2027    printf "| $spalte1$spalte2 | \n"
2028    spalte1=CPU-time:; spalte2="$minuten:$sekunden"
2029    printf "| $spalte1$spalte2 | \n"
2030 fi
2031
2032 if [[ $do_compile = true ]]
2033 then
2034    printf "|                                                              | \n"
2035    printf "| Files to be compiled:                                        | \n"
2036    zeile=$source_list
2037    while [[ "$zeile" != "" ]]
2038    do
2039       spalte3=$zeile
2040       printf "| $spalte3 | \n"
2041       zeile=$(echo "$zeile" | cut -c61-)
2042    done
2043 fi
2044 printf "#--------------------------------------------------------------#"
2045
2046
2047
2048    # BEDINGTE AUSGABE DER DATEIVERBINDUNGEN
2049 if [[ $do_trace = true ]]
2050 then
2051    (( i = 0 ))
2052    while (( i < iin ))
2053    do
2054       (( i = i + 1 ))
2055       if (( i == 1 ))
2056       then
2057          printf "\n\n >>> INPUT-file assignments:\n"
2058       fi
2059       printf "\n     ${localin[$i]} :  ${absnamein[$i]}"
2060    done
2061    (( i = 0 ))
2062    while (( i < iout ))
2063    do
2064       (( i = i + 1 ))
2065       if (( i == 1 ))
2066       then
2067          printf "\n\n >>> OUTPUT-file assignments:\n"
2068       fi
2069       printf "\n     ${localout[$i]} :  ${pathout[$i]}"
2070    done
2071    (( i = 0 ))
2072    while (( i < iic ))
2073    do
2074       (( i = i + 1 ))
2075       if (( i == 1 ))
2076       then
2077          printf "\n\n >>> INPUT-commands:\n"
2078       fi
2079       printf "\n     ${in_command[$i]}" 
2080    done
2081    (( i = 0 ))
2082    while (( i < ioc ))
2083    do
2084       (( i = i + 1 ))
2085       if (( i == 1 ))
2086       then
2087          printf "\n\n >>> OUTPUT-commands:\n"
2088       fi
2089       printf "\n     ${out_command[$i]}" 
2090    done
2091 fi
2092
2093
2094    # ABFRAGEN BEI AUFRUF AUF LOKALER MASCHINE
2095 if [[ $remotecall = false  &&  $silent = false  &&  $jobmo != BATCH ]]
2096 then
2097    antwort=dummy
2098    printf "\n\n"
2099    while [[ "$antwort" != y  &&  "$antwort" != Y  &&  "$antwort" != n  &&  "$antwort" != N ]]
2100    do
2101       printf " >>> everything o.k. (y/n) ?  "
2102       read  antwort
2103    done
2104    if [[ $antwort = n  ||  $antwort = N ]]
2105    then
2106       locat=user_abort; (( iec = 0 )); exit
2107    fi
2108    if [[ $do_batch = true ]]
2109    then
2110       printf " >>> batch-job will be created and submitted"
2111    else
2112       if [[ $local_compile = false ]]
2113       then
2114          printf " >>> MRUN will now continue to execute on this machine"
2115       else
2116          printf " >>> a test compilation will now be carried out on this machine"
2117       fi
2118    fi
2119 fi
2120 
2121
2122
2123
2124     # FALLS AUF DIESER MASCHINE GERECHNET WERDEN SOLL, WERDEN JETZT ENTSPRE-
2125     # CHENDE AKTIONEN DURCHGEFUEHRT
2126 if [[ $do_batch = false ]]
2127 then
2128
2129
2130       # TEMPORAEREN KATALOG ERZEUGEN
2131    mkdir -p  $TEMPDIR
2132    chmod  go+rx  $TEMPDIR
2133    tmpcreate=true
2134
2135
2136       # SAEMTLICHE QUELLTEXT-DATEIEN BZW. AUSFUEHRBARES PROGRAMM IN
2137       # TEMPORAERES VERZEICHNIS KOPIEREN
2138    if [[ $do_compile = true ]]
2139    then
2140
2141          # ON NEC, COMPILATION IS DONE ON HOST CROSS VIA CROSS COMPILING
2142          # CREATE A TEMPORARY DIRECTORY ON THAT MACHINE (HOME MOUNTED VIA NFS)
2143       if [[ $localhost = nech ]]
2144       then
2145          TEMPDIR_COMPILE=$HOME/work/${usern}.$kennung
2146          if  mkdir -p  $TEMPDIR_COMPILE
2147          then
2148             printf "\n  *** \"$TEMPDIR_COMPILE\" "
2149             printf "\n      is generated as temporary directory for cross compiling\n"
2150          else
2151             printf "\n  +++ creating directory \"$TEMPDIR_COMPILE\" "
2152             printf "\n      needed for cross compilation failed"
2153             locat=compile
2154             exit
2155          fi
2156       else
2157          TEMPDIR_COMPILE=$TEMPDIR
2158       fi
2159
2160       if [[ "$use_makefile" = true ]]
2161       then
2162
2163             # PFADNAMEN FUER DAS MAKE-DEPOSITORY ERMITTELN
2164          line=""
2165          grep "%depository_path" $config_file  |  while read line
2166          do
2167             if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
2168             then
2169                if [[ "$(echo $line | cut -d" " -s -f3)" = "" ]]
2170                then
2171                   global_depository_path=`echo $line | cut -d" " -s -f2`
2172                fi
2173             fi
2174          done
2175
2176          line=""
2177          grep  " $localhost" $config_file | grep "%depository_path"  |  while read line
2178          do
2179             if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
2180             then
2181                local_depository_path=`echo $line | cut -d" " -s -f2`
2182             fi
2183          done
2184
2185          if [[ "$local_depository_path" = "" ]]
2186          then
2187             if [[ "$global_depository_path" != "" ]]
2188             then
2189                local_depository_path=$global_depository_path
2190             else
2191                printf "\n\n  +++ no depository path found in configuration file"
2192                printf "\n      for local host \"$localhost\" "
2193                printf "\n      please set \"\%depository_path\" in configuration file\n"
2194                locat=config_file; exit
2195             fi
2196          fi
2197          eval local_depository_path=$local_depository_path
2198
2199          basename=`print $mainprog | cut -f1 -d"."`
2200          eval make_depository=${local_depository_path}/${basename}_current_version.tar
2201          if [[ ! -f $make_depository ]]
2202          then
2203             printf "\n"
2204             printf "\n  *** WARNING: make depository \"$make_depository\" not found"
2205             printf "\n               \"make\" will fail, if the Makefile or other source files are missing\n"
2206          else
2207             cp  $make_depository  $TEMPDIR_COMPILE
2208             cd  $TEMPDIR_COMPILE
2209             tar -xf  $make_depository  >  /dev/null  2>&1
2210             cd -  > /dev/null
2211          fi
2212
2213          cp  SOURCES_FOR_RUN_$fname/*  $TEMPDIR_COMPILE
2214
2215             # FALLS USER-INTERFACE VORHANDEN UND AUF DATEI MIT ANDEREM NAMEN
2216             # ALS user_interface.f90 LIEGT, DIESEN GEAENDERTEN NAMEN INS
2217             # MAKEFILE EINTRAGEN
2218          cd  $TEMPDIR_COMPILE
2219          interface_file=`grep -l "END SUBROUTINE user_parin" $source_list`
2220          if [[ "$interface_file" != "" ]]
2221          then
2222             interface_file=`echo $interface_file | cut -d"." -f1`
2223             mv  Makefile  Makefile_old
2224             sed "s/user_interface/$interface_file/g"  Makefile_old  >  Makefile
2225          fi
2226          cd -  > /dev/null
2227       fi
2228    else
2229       cp  $executable   ${TEMPDIR}/a.out
2230    fi
2231
2232
2233       # WECHSEL IN TEMPORAEREN KATALOG
2234    cd $TEMPDIR
2235    printf "\n  *** changed to temporary directory: $TEMPDIR"
2236
2237
2238       # OUTPUT-DATEI-VERBINDUNGEN AUF TEMPORAERER DATEI ABLEGEN
2239       # DIESE DATEI KANN VON SPAETER AUFZURUFENDEN BENUTZERPROZEDUREN GELESEN
2240       # WERDEN, UM ZU LOKALEN DATEINAMEN GEHOERENDE PERMANENTE NAMEN ZU
2241       # ERMITTELN
2242    (( i = 0 ))
2243    while (( i < iout ))
2244    do
2245       (( i = i + 1 ))
2246       if [[ "${actionout[$i]}" = tr  ||  "${actionout[$i]}" = tra  ||  "${actionout[$i]}" = trpe ]]
2247       then
2248          printf "${localout[$i]} ${actionout[$i]}\n${pathout[$i]}\n${localhost}_${fname}${endout[$i]}\n" >> OUTPUT_FILE_CONNECTIONS
2249       else
2250          printf "${localout[$i]} ${actionout[$i]}\n${pathout[$i]}\n${frelout[$i]}\n" >> OUTPUT_FILE_CONNECTIONS
2251       fi
2252    done
2253
2254
2255       # EVTL. UEBERSETZUNGSAKTIONEN STARTEN
2256    if [[ $do_compile = true ]]
2257    then
2258
2259
2260          # COMPILING WITH MAKE (ON NEC COMPILER IS CALLED ON HOST CROSS)
2261       if [[ "$use_makefile" = true ]]
2262       then
2263          printf "\n\n\n  *** compilation starts \n$striche\n"
2264          printf "  *** compilation with make using following options:\n"
2265          printf "      compilername:             $compiler_name\n"
2266          printf "      options:                  $FOPTS\n"
2267          printf "      preprocessor-directives:  $C_PPOPTS \n"
2268          printf "      linker-options:           $LOPTS \n"
2269          printf "      source code files:        $source_list \n"
2270
2271          if [[ $localhost = nech ]]
2272          then
2273             ssh  136.172.44.192 -l $usern ". /SX/opt/etc/initsx.sh; cd \$HOME/work/${usern}.$kennung; sxmake -f Makefile PROG=a.out  F90=$compiler_name  COPT=\"$C_PPOPTS\"  F90FLAGS=\"$FOPTS\"  LDFLAGS=\"$LOPTS\" "
2274             cp  $TEMPDIR_COMPILE/a.out  .
2275             [[ $? != 0 ]]  &&  compile_error=true
2276             rm -rf  $TEMPDIR_COMPILE
2277          else
2278             make -f Makefile PROG=a.out  F90=$compiler_name  COPT="$C_PPOPTS"  F90FLAGS="$FOPTS"  LDFLAGS="$LOPTS"
2279          fi
2280
2281          # UEBERSETZUNG "VON HAND" (OHNE MAKE)
2282       else
2283
2284
2285             # UEBERSETZUNG DER QUELLTEXT-DATEIEN UND DES HAUPTPROGRAMMS
2286             # $CPPOPTS FUER CPP-PRAEPROZESSOR WURDEN OBEN BESTIMMT
2287          printf "\n\n\n  *** compilation starts \n$striche\n"
2288
2289
2290             # VORWEG EVTL. UEBERSETZUNG VON PROGRAMMTEILEN MIT SPEZIELLEN
2291             # COMPILERN UND/ODER COMPILEROPTIONEN. DIESE WERDEN BEI DER SPAETEREN
2292             # EIGENTLICHEN UEBERSETZUNG ALS OBJECT-FILES EINGEBUNDEN
2293          new_source_list=""
2294          for  filename  in  $source_list
2295          do
2296
2297             basename=`print $filename | cut -f1 -d"."`
2298
2299                # EVTL. SPEZIELLEN COMPILER FUER UP BESTIMMEN
2300             comp_var=$(eval echo \$comp_$basename)  # \$ liefert evtl. fuer source alternativ vereinbarten Compiler
2301             comp_opt_var=$(eval echo \$$basename)  # \$$ liefert evtl. fuer source vereinbarte Compiler-Environment-Variable
2302
2303             if [[ "$comp_var" = ""  &&  "$comp_opt_var" = "" ]]
2304             then
2305                new_source_list="$new_source_list "$filename
2306             else
2307
2308                if [[ "$comp_var" = "" ]]
2309                then
2310                   SPECIAL_COMPILER=$compiler_name
2311                else
2312                   SPECIAL_COMPILER=$comp_var
2313                fi
2314
2315                if [[ "$comp_opt_var" = "" ]]
2316                then
2317                   SPECIAL_FOPTS=$FOPTS
2318                else
2319                   SPECIAL_FOPTS="$parallel_options $(eval echo \$$comp_opt_var)"
2320                fi
2321
2322                printf "  *** compiling of $filename with special compiler call: $SPECIAL_COMPILER  $CPPOPTS  -c $SPECIAL_FOPTS \n"
2323                $SPECIAL_COMPILER  $C_PPOPTS  -c $SPECIAL_FOPTS  $MODULE_OPTIONS  $filename 
2324                if [[ $? != 0 ]]
2325                then
2326                   printf "\n  +++ compiling error occured"
2327                   locat=compile
2328                   exit
2329                fi
2330                new_source_list="$new_source_list "${basename}.o
2331             fi
2332          done
2333          source_list="$new_source_list"
2334
2335
2336             # EIGENTLICHE UEBERSETZUNG MIT DEN NORMALEN OPTIONEN
2337          printf "  *** compilation with standard options: $compiler_name $FOPTS $MODULE_OPTIONS \n"
2338          printf "      preprocessor-directives:           $C_PPOPTS \n"
2339          printf "      linker-options:                    $LOPTS \n"
2340          printf "      source code files:                 $source_list \n"
2341
2342          $compiler_name  $C_PPOPTS  $FOPTS  $MODULE_OPTIONS  $LOPTS  $source_list 
2343
2344       fi
2345       if [[ $? != 0  ||  "$compile_error" = true  ||  "$module_compile_error" = true ]]
2346       then
2347          printf "\n  +++ error occured while compiling or linking"
2348          locat=compile
2349          exit
2350       else
2351          printf "$striche\n  *** compilation finished \n"
2352       fi
2353    fi
2354
2355
2356       # FALLS NUR TESTWEISE KOMPILIERT WERDEN SOLLTE, IST MRUN JETZT FERTIG
2357    if [[ $local_compile = true ]]
2358    then
2359       cd  $HOME
2360       rm -rf $TEMPDIR
2361       locat=local_compile; exit
2362    fi
2363
2364
2365       # BEREITSTELLEN DER INPUT-DATEIEN
2366       # SCHLEIFE UEBER ALLE VOM BENUTZER ANGEGEBENEN DATEIEN
2367    (( i = 0 ))
2368    while (( i < iin ))
2369    do
2370       (( i = i + 1 ))
2371       if (( i == 1 ))
2372       then
2373          printf "\n\n  *** providing INPUT-files:\n$striche"
2374       fi
2375
2376
2377          # OPTIONALE DATEIEN BEI NICHTVORHANDENSEIN UEBERGEHEN
2378       if [[ "${transin[$i]}" = unavailable ]]
2379       then
2380          if [[ "${extin[$i]}" = ""  ||  "${extin[$i]}" = " " ]]
2381          then
2382             printf "\n  +++ WARNING: input file \"${pathin[$i]}/${afname}${endin[$i]}\" "
2383             printf "\n               is not available!"
2384          else
2385             printf "\n  +++ WARNING: input file \"${pathin[$i]}/${afname}${endin[$i]}.${extin[$i]}\" "
2386             printf "\n               is not available!"
2387          fi
2388          continue
2389       fi
2390
2391          # PRUEFEN, OB EINZELDATEI ODER DATEI PRO PROZESSOR
2392       files_for_pes=false; datentyp=file
2393       if [[ "${actionin[$i]}" = pe  &&  -n $numprocs ]]
2394       then
2395          files_for_pes=true; datentyp=directory
2396          actionin[$i]=""
2397       elif [[ "${actionin[$i]}" = pe  &&  ! -n $numprocs ]]
2398       then
2399          actionin[$i]=""
2400       elif [[ "${actionin[$i]}" = arpe  &&  -n $numprocs ]]
2401       then
2402          files_for_pes=true; datentyp=directory
2403          actionin[$i]="ar"
2404       elif [[ "${actionin[$i]}" = arpe  &&  ! -n $numprocs ]]
2405       then
2406          actionin[$i]="ar"
2407       elif [[ "${actionin[$i]}" = flpe  &&  -n $numprocs ]]
2408       then
2409          files_for_pes=true; datentyp=directory
2410          actionin[$i]="fl"
2411       elif [[ "${actionin[$i]}" = flpe  &&  ! -n $numprocs ]]
2412       then
2413          actionin[$i]="fl"
2414       fi
2415
2416       if [[ $files_for_pes = true ]]
2417       then
2418          printf "\n  >>> INPUT: ${absnamein[$i]}/....  to  ${localin[$i]}"
2419       else
2420          printf "\n  >>> INPUT: ${absnamein[$i]}  to  ${localin[$i]}"
2421       fi
2422
2423          # INPUT-DATEI FUER EINEN FORTSETZUNGSLAUF. ES WIRD GEPRUEFT,
2424          # OB DIESE DATEI NOCH AUF DEM TEMPORAEREN DATENKATALOG VORHANDEN
2425          # IST. FALLS NICHT, WIRD VERSUCHT, SIE ANSCHLIESSEND VOM ARCHIV-
2426          # SERVER ZU HOLEN
2427       if [[ "${actionin[$i]}" = fl ]]
2428       then
2429          printf "\n      $datentyp will be fetched from temporary directory \"${tmp_data_catalog}\" !"
2430          if [[ $files_for_pes = false ]]
2431          then
2432             if [[ -f "$tmp_data_catalog/${frelin[$i]}" ]]
2433             then
2434                ln  $tmp_data_catalog/${frelin[$i]}  ${localin[$i]}
2435                got_tmp[$i]=true
2436             elif [[ -f "$WORK/${frelin[$i]}"  &&  $ignore_archive_error = true ]]
2437             then
2438                printf "\n  +++ $datentyp not found in \"$tmp_data_catalog\" !"
2439                printf "\n  *** trying to use backup copy in \"$WORK\" "
2440                cp  $WORK/${frelin[$i]}  ${localin[$i]}
2441             else
2442                printf "\n  +++ $datentyp not found in \"$tmp_data_catalog\" "
2443                printf "\n      or \"$tmp_data_catalog\" does not exist!"
2444                printf "\n  *** trying to get copy from archive"
2445                actionin[$i]=ar
2446             fi
2447          else
2448             if [[ -d "$tmp_data_catalog/${frelin[$i]}" ]]
2449             then
2450                mkdir  ${localin[$i]}
2451                ln  $tmp_data_catalog/${frelin[$i]}/*  ${localin[$i]}
2452                got_tmp[$i]=true
2453             elif [[ -d "$WORK/${frelin[$i]}"  &&  $ignore_archive_error = true ]]
2454             then
2455                printf "\n  +++ $datentyp not found in \"$tmp_data_catalog\" !"
2456                printf "\n  *** trying to use backup copy in \"$WORK\" "
2457                cp -r  $WORK/${frelin[$i]}  ${localin[$i]}
2458             else
2459                printf "\n  +++ $datentyp not found in \"$tmp_data_catalog\" "
2460                printf "\n      or \"$tmp_data_catalog\" does not exist!"
2461                printf "\n  *** trying to get copy from archive"
2462                actionin[$i]=ar
2463             fi
2464          fi
2465       fi
2466
2467
2468          # DATEI LIEGT AUF ARCHIV-SERVER
2469       if [[ "${actionin[$i]}" = ar ]]
2470       then
2471
2472          if [[ $files_for_pes = false ]]
2473          then
2474             printf "\n      file will be restored from archive-system ($archive_system)!"
2475          else
2476             printf "\n      directory will be restored from archive-system ($archive_system)!"
2477          fi
2478
2479          file_restored=false
2480
2481          if [[ $archive_system = asterix ]]
2482          then
2483             do_stagein=true
2484             (( stagein_anz = 0 ))
2485             while [[ $do_stagein = true ]]
2486             do
2487                if [[ $files_for_pes = false ]]
2488                then
2489                   stagein  -O  ${frelin[$i]}  >  STAGEIN_OUTPUT
2490                else
2491                   stagein  -t  -O  ${frelin[$i]}  >  STAGEIN_OUTPUT
2492                fi
2493                cat  STAGEIN_OUTPUT
2494                if [[ $(grep -c "st.msg:i24"  STAGEIN_OUTPUT) != 0 ]]
2495                then
2496                   file_restored=true
2497                   do_stagein=false
2498                else
2499                   (( stagein_anz = stagein_anz + 1 ))
2500                   if (( stagein_anz == 10 ))
2501                   then
2502                      printf "\n  +++ stagein stoped after 10 tries"
2503                      locat=stage
2504                      exit
2505                   fi
2506                   printf "\n  +++ restoring from archive failed, trying again:"
2507                   sleep 900
2508                fi
2509             done
2510          elif [[ $archive_system = DMF ]]
2511          then
2512             if [[ $files_for_pes = false ]]
2513             then
2514                printf "\n  +++ restoring of single files impossible with $archive_system !\n"
2515                locat=DMF
2516                exit
2517             else
2518                find  $ARCHIVE/${frelin[$i]}  -type m  -print  |  dmget
2519                cp  -r $ARCHIVE/${frelin[$i]}  $PWD
2520                file_restored=true
2521             fi
2522          elif [[ $archive_system = tivoli ]]
2523          then
2524             if [[ $files_for_pes = false ]]
2525             then
2526                if [[ $localhost = ibmh ]]
2527                then
2528                   ssh  $usern@hdata.hlrn.de  "cp  $PERM/${frelin[$i]}  $PWD"
2529                else
2530                   ssh  $usern@bdata.hlrn.de  "cp  $PERM/${frelin[$i]}  $PWD"
2531                fi
2532             else
2533                (( inode = 0 ))
2534                while (( inode < nodes ))
2535                do
2536                   if [[ $localhost = ibmh ]]
2537                   then
2538                      ssh  $usern@hdata.hlrn.de  "cd $PWD; tar  xf  $PERM/${frelin[$i]}/${frelin[$i]}.node_$inode.tar"
2539                   else
2540                      ssh  $usern@bdata.hlrn.de  "cd $PWD; tar  xf  $PERM/${frelin[$i]}/${frelin[$i]}.node_$inode.tar"
2541                   fi
2542                   (( inode = inode + 1 ))
2543                done
2544             fi
2545             file_restored=true
2546          elif [[ $archive_system = ut ]]
2547          then
2548             if [[ $files_for_pes = false ]]
2549             then
2550                cp  $UT/${frelin[$i]}  .
2551             else
2552                (( inode = 0 ))
2553                while (( inode < nodes ))
2554                do
2555                   tar  xf  $UT/${frelin[$i]}/${frelin[$i]}.node_$inode.tar
2556                   (( inode = inode + 1 ))
2557                done
2558             fi
2559             file_restored=true
2560          else
2561             printf "\n  +++ archive_system=\"$archive_system\"   restore impossible!"
2562             locat=rearchive
2563             exit
2564          fi
2565
2566          if [[ $file_restored = true ]]
2567          then
2568
2569                # DATEI AUCH AUF TEMPORAERES DATENVERZEICHNIS LEGEN, DAMIT
2570                # SIE BEI WEITEREN ZUGRIFFEN NOCH VORHANDEN IST
2571             [[ ! -d $tmp_data_catalog ]]  &&  mkdir -p  $tmp_data_catalog; chmod  g+rx  $tmp_data_catalog
2572             if [[ $files_for_pes = false ]]
2573             then
2574                ln  -f  ${frelin[$i]}  $tmp_data_catalog/${frelin[$i]}
2575             else
2576                mkdir  $tmp_data_catalog/${frelin[$i]}
2577                ln  -f  ${frelin[$i]}/*  $tmp_data_catalog/${frelin[$i]}
2578             fi
2579             got_tmp[$i]=true
2580
2581                # DATEI UNTER LOKALEM NAMEN ZUR VERFUEGUNG STELLEN
2582             mv  ${frelin[$i]}  ${localin[$i]}
2583
2584          fi
2585       fi
2586
2587
2588          # DATEI LIEGT IM VOM BENUTZER ANGEGEBENEN VERZEICHNIS
2589       if [[ "${actionin[$i]}" = ""  ||  "${actionin[$i]}" = "di"  ||  "${actionin[$i]}" = "npe" ]]
2590       then
2591
2592          if [[ "${actionin[$i]}" = "npe"  &&  -n $numprocs ]]
2593          then
2594
2595                # DATEI WIRD FUER DIE PROZESSOREN EINES PARALLERECHNERS BEREITGESTELLT
2596             printf "\n      file will be provided for $numprocs processors"
2597             mkdir  ${localin[$i]}
2598             ival=$numprocs
2599             (( ii = 0 ))
2600             while (( ii <= ival-1 ))
2601             do
2602                if (( ii < 10 ))
2603                then
2604                   cp  ${absnamein[$i]}  ${localin[$i]}/_000$ii
2605                elif (( ii < 100 ))
2606                then
2607                   cp  ${absnamein[$i]}  ${localin[$i]}/_00$ii
2608                elif (( ii < 1000 ))
2609                then
2610                   cp  ${absnamein[$i]}  ${localin[$i]}/_0$ii
2611                else
2612                   cp  ${absnamein[$i]}  ${localin[$i]}/_$ii
2613                fi
2614                (( ii = ii + 1 ))
2615             done
2616
2617          else
2618
2619             if [[ $files_for_pes = true ]]
2620             then
2621
2622                   # DIE DEN PROZESSOREN EINES PARALLELRECHNERS ZUGEHOERIGEN
2623                   # DATEIEN WERDEN BEREITGESTELLT, INDEM ZUERST DER GESAMTE
2624                   # KATALOGINHALT KOPIERT UND DANN DIE EINZELNEN DATEIEN
2625                   # PER MOVE UMBENANNT WERDEN
2626                printf "\n      providing $numprocs files for the respective processors"
2627                mkdir  ${localin[$i]}
2628                cp -r  ${absnamein[$i]}/*  ${localin[$i]}
2629
2630             else
2631                   # BEREITSTELLUNG AUF EINPROZESSORRECHNERN
2632                cp  ${absnamein[$i]}  ${localin[$i]}
2633             fi
2634          fi
2635       fi
2636
2637    done
2638    if (( i != 0 ))
2639    then
2640       printf "\n$striche\n  *** all INPUT-files provided \n"
2641    fi
2642
2643
2644       # NAMELIST-DATEI MIT WERTEN VON ENVIRONMENT-VARIABLEN ERZEUGEN (ZU
2645       # LESEN VON PALM)
2646    cat  >  ENVPAR  <<  %%END%%
2647 &envpar  run_identifier = '$fname', host = '$localhost',
2648          write_binary = '$write_binary', tasks_per_node = $tasks_per_node,
2649          maximum_cpu_time_allowed = ${cpumax}. /
2650
2651%%END%%
2652
2653
2654       # EVENTUELLE INPUT-KOMMANDOS ABARBEITEN
2655    (( i = 0 ))
2656    while (( i < iic ))
2657    do
2658       (( i = i + 1 ))
2659       if (( i == 1 ))
2660       then
2661          printf "\n\n  *** execution of INPUT-commands:\n$striche"
2662       fi
2663       printf "\n  >>> ${in_command[$i]}"
2664       eval  ${in_command[$i]}
2665       if (( i == iic ))
2666       then
2667          printf "\n$striche\n"
2668       fi
2669    done
2670
2671
2672       # VERBLEIBENDE CPU-ZEIT BERECHNEN
2673    cpurest=${cpumax}.
2674
2675
2676       # PROGRAMMSTART
2677    printf "\n\n  *** execution starts in directory\n      \"`pwd`\"\n$striche\n"
2678    PATH=$PATH:$TEMPDIR
2679
2680    if [[ "$cond1" = debug  ||  "$cond2" = debug ]]
2681    then
2682       if [[ "$ENVIRONMENT" = BATCH ]]
2683       then
2684          printf "\n  +++ debug is allowed in interactive mode only"
2685          locat=debug
2686          exit
2687       fi
2688       if [[ $localhost = decalpha ]]
2689       then
2690          dxladebug  a.out
2691       elif [[ $localhost = ibmb  ||  $localhost = ibmh ]]
2692       then
2693
2694             # SETUP THE IBM MPI ENVIRONMENT
2695          export MP_SHARED_MEMORY=yes
2696          export AIXTHREADS_SCOPE=S
2697          export OMP_NUM_THREADS=$threads_per_task
2698          export AUTHSTATE=files
2699          export XLFRTEOPTS="nlwidth=132:err_recovery=no"    # RECORD-LENGTH OF NAMELIST-OUTPUT
2700
2701             # FOLLOWING OPTIONS ARE MANDATORY FOR TOTALVIEW
2702          export MP_ADAPTER_USE=shared
2703          export MP_CPU_USE=multiple
2704          export MP_TIMEOUT=1200
2705
2706          unset  MP_TASK_AFFINITY
2707
2708             # SO FAR, TOTALVIEW NEEDS HOSTFILE MECHANISM FOR EXECUTION
2709          #(( ii = 1 ))
2710          #while (( ii <= $numprocs ))
2711          #do
2712          #   echo  $localhost_realname  >>  hostfile
2713          #   (( ii = ii + 1 ))
2714          #done
2715          #export MP_HOSTFILE=hostfile
2716
2717          if [[ "$LOADLBATCH" = yes ]]
2718          then
2719             totalview   poe  a.out  $ROPTS
2720          else
2721             echo totalview   poe  -a a.out  -procs $numprocs  -rmpool 0  -nodes 1   $ROPTS
2722             export TVDSVRLAUNCHCMD=ssh
2723             totalview   poe  -a a.out  -procs $numprocs  -rmpool 0  -nodes 1   $ROPTS
2724          fi
2725       else
2726          printf "\n  +++ no debug available on \"$localhost\" "
2727          printf "\n      or not implemented in mrun so far"
2728          locat=debug
2729          exit
2730       fi
2731    else
2732       if [[ -n $numprocs ]]
2733       then
2734
2735             # RUNNING THE PROGRAM ON PARALLEL MACHINES
2736          if [[ $(echo $host | cut -c1-3) = ibm ]]
2737          then
2738                # SETUP THE IBM MPI ENVIRONMENT
2739             export MP_SHARED_MEMORY=yes
2740             export AIXTHREAD_SCOPE=S
2741             export OMP_NUM_THREADS=$threads_per_task
2742             export XLSMPOPTS="spins=0:yields=0:stack=20000000"
2743             export AUTHSTATE=files
2744             export XLFRTEOPTS="nlwidth=132:err_recovery=no"    # RECORD-LENGTH OF NAMELIST-OUTPUT
2745             #  export MP_PRINTENV=yes
2746
2747                # TUNING-VARIABLEN ZUR VERBESSERUNG DER KOMMUNIKATION
2748                # ZEIGEN ABER DERZEIT (SEP 04, FEDERATION) KAUM WIRKUNG
2749             export MP_WAIT_MODE=poll
2750             [[ $node_usage = not_shared ]]  &&  export MP_SINGLE_THREAD=yes
2751#             export MP_EAGER_LIMIT=65535
2752
2753#                # TESTWEISE FUER TURBOMPI (JAN 05)
2754#             export MPJ_MTAB=128
2755#             export MPJ_ALLTOALL=1
2756#             export MPJ_ALLTOALLV=1
2757
2758             if [[ "$LOADLBATCH" = yes ]]
2759             then
2760                printf "\n--- Control: OMP_NUM_THREADS = \"$OMP_NUM_THREADS\" \n"
2761                if [[ "$cond1" = hpmcount  ||  "$cond2" = hpmcount ]]
2762                then
2763                   /opt/optibm/HPM_2_4_1/bin/hpmcount  a.out  $ROPTS  >  aout_output  2>&1
2764                else
2765                   poe ./a.out  $ROPTS  >  aout_output  2>&1
2766                fi
2767             else
2768                if [[ $localhost = ibmb  ||  $localhost = ibmh  ||  $localhost = ibms ]]
2769                then
2770                   poe  a.out  -procs $numprocs  -nodes 1  -rmpool 0  $ROPTS  >  aout_output  2>&1
2771                elif [[ $localhost = ibmy ]]
2772                then
2773                   if [[ -f $hostfile ]]
2774                   then
2775                      cp  $hostfile  hostfile
2776                   else
2777                      (( ii = 1 ))
2778                      while (( ii <= $numprocs ))
2779                      do
2780                         echo  $localhost_realname  >>  hostfile
2781                         (( ii = ii + 1 ))
2782                      done
2783                   fi
2784                   export MP_HOSTFILE=hostfile
2785                   ./a.out  -procs $tasks_per_node  $ROPTS  >  aout_output  2>&1
2786                else
2787                   if [[ "$host_file" = "" ]]
2788                   then
2789                      printf "\n  +++ no hostfile given in configuration file"
2790                      locat=config_file
2791                      exit
2792                   else
2793                      eval host_file=$host_file
2794                   fi
2795                   export MP_HOSTFILE=$host_file
2796                   poe  a.out  -procs $numprocs  -tasks_per_node $numprocs  $ROPTS  >  aout_output  2>&1
2797                fi
2798             fi
2799          elif [[ $host = nech  ||  $host = neck ]]
2800          then
2801             (( ii = nodes ))
2802             if [[ $ii = 1 ]]
2803             then
2804                export F_ERRCNT=0        # acceptable number of errors before program is stopped
2805                export MPIPROGINF=YES
2806                echo "*** execution on single node with mpirun"
2807                mpirun  -np $numprocs  ./a.out  $ROPTS  >  aout_output  2>&1
2808             else
2809                (( i = 0 ))
2810                while (( i < ii ))
2811                do
2812                   echo "-h $i  -p $tasks_per_node  -e ./mpi_exec_shell"  >>  multinode_config
2813                   (( i = i + 1 ))
2814                done
2815
2816                echo "#!/bin/sh"                         >   mpi_exec_shell
2817                echo " "                                 >>  mpi_exec_shell
2818                echo "set -u"                            >>  mpi_exec_shell
2819                echo "F_ERRCNT=0"                        >>  mpi_exec_shell
2820                echo "MPIPROGINV=YES"                    >>  mpi_exec_shell
2821                echo "OMP_NUM_THREADS=$threads_per_task" >>  mpi_exec_shell
2822                echo "cpurest=$cpurest"                  >>  mpi_exec_shell
2823                echo "fname=$fname"                      >>  mpi_exec_shell
2824                echo "localhost=$localhost"              >>  mpi_exec_shell
2825                echo "return_addres=$return_addres"      >>  mpi_exec_shell
2826                echo "return_username=$return_username"  >>  mpi_exec_shell
2827                echo "tasks_per_node=$tasks_per_node"    >>  mpi_exec_shell
2828                echo "write_binary=$write_binary"        >>  mpi_exec_shell
2829                echo "use_seperate_pe_for_dvrp_output=$use_seperate_pe_for_dvrp_output"  >>  mpi_exec_shell
2830                echo "  "                                >>  mpi_exec_shell
2831                echo "export F_ERRCNT"                   >>  mpi_exec_shell
2832                echo "export MPIPROGINV"                 >>  mpi_exec_shell
2833                echo "export OMP_NUM_THREADS"            >>  mpi_exec_shell
2834                echo "export cpurest"                    >>  mpi_exec_shell
2835                echo "export fname"                      >>  mpi_exec_shell
2836                echo "export localhost"                  >>  mpi_exec_shell
2837                echo "export return_addres"              >>  mpi_exec_shell
2838                echo "export return_username"            >>  mpi_exec_shell
2839                echo "export tasks_per_node"             >>  mpi_exec_shell
2840                echo "export write_binary"               >>  mpi_exec_shell
2841                echo "export use_seperate_pe_for_dvrp_output"  >>  mpi_exec_shell
2842                echo " "                                 >>  mpi_exec_shell
2843                echo "exec  ./a.out > aout_output  2>&1" >>  mpi_exec_shell
2844
2845                chmod u+x  mpi_exec_shell
2846                export MPIPROGINF=YES
2847                mpirun  -f multinode_config  &
2848                wait
2849
2850             fi
2851          elif [[ $host = lcmuk ]]
2852          then
2853
2854                # COPY HOSTFILE FROM SOURCE DIRECTORY OR CREATE IT, IF IT
2855                # DOES NOT EXIST
2856             if [[ -f $hostfile ]]
2857             then
2858                cp  $hostfile  hostfile
2859             else
2860                (( ii = 1 ))
2861                while (( ii <= $numprocs / $threads_per_task ))
2862                do
2863                   echo  $localhost_realname  >>  hostfile
2864                   (( ii = ii + 1 ))
2865                done
2866             fi
2867             (( ii = $numprocs / $threads_per_task ))
2868             eval zeile=\"`head -n $ii  hostfile`\"
2869             printf "\n  *** running on: $zeile"
2870             export OMP_NUM_THREADS=$threads_per_task
2871             if [[ $threads_per_task != 1 ]]
2872             then
2873                printf "\n      threads per task: $threads_per_task"
2874             fi
2875             printf "\n\n"
2876             if [[ $scirocco = true ]]
2877             then
2878                mpiexec  -machinefile hostfile  -n $ii  a.out  $ROPTS   >  aout_output  2>&1
2879             else
2880                mpirun  -machinefile hostfile  -np $ii  a.out  $ROPTS   >  aout_output  2>&1
2881             fi
2882          elif [[ $host = decalpha ]]
2883          then
2884             dmpirun  -np $numprocs  a.out  $ROPTS  >  aout_output  2>&1
2885          elif [[ $host = lctit ]]
2886          then
2887             export runfile=runfile.$kennung
2888
2889             echo "cd $PWD"                                  >   $runfile
2890             echo "export OMP_NUM_THREADS=$OMP_NUM_THREADS"  >>  $runfile
2891             echo "export cpurest=$cpurest"                  >>  $runfile
2892             echo "export fname=$fname"                      >>  $runfile
2893             echo "export localhost=$localhost"              >>  $runfile
2894             echo "export return_addres=$return_addres"      >>  $runfile
2895             echo "export return_username=$return_username"  >>  $runfile
2896             echo "export tasks_per_node=$tasks_per_node"    >>  $runfile
2897             echo "export write_binary=$write_binary"        >>  $runfile
2898             echo "export use_seperate_pe_for_dvrp_output=$use_seperate_pe_for_dvrp_output"  >>  $runfile
2899             echo "./a.out"                                  >>  $runfile
2900             chmod  u+x  $runfile
2901
2902             if [[ "$QUEUE" = interactive ]]
2903             then
2904                mpirun  -np $numprocs  $runfile  $ROPTS  >  aout_output  2>&1
2905             else
2906                n1ge  -fore  -mpi $numprocs  -q $queue  $runfile  $ROPTS  >  aout_output  2>&1
2907             fi
2908
2909             rm  $runfile
2910          else
2911             mpprun  -n $numprocs  a.out  $ROPTS  >  aout_output  2>&1
2912          fi
2913          [[ $? != 0 ]]  &&  execution_error=true
2914
2915
2916             # PERFORMANCE-AUSWERTUNG MIT APPRENTICE
2917          if [[ "$cond1" = apprentice  ||  "$cond2" = apprentice ]]
2918          then
2919             apprentice
2920          fi
2921       else
2922          a.out  $ROPTS  >  aout_output  2>&1
2923       fi
2924    fi
2925    if [[ $? != 0  ||  $execution_error = true ]]
2926    then
2927
2928          # ABBRUCH BEI LAUFZEITFEHLER
2929       [[ ! ( "$cond1" = debug  ||  "$cond2" = debug ) ]]  &&  cat  aout_output
2930       printf "\n  +++ runtime error occured"
2931       locat=execution
2932       exit
2933    else
2934       [[ ! ( "$cond1" = debug  ||  "$cond2" = debug ) ]]  &&  cat  aout_output
2935       printf "\n$striche\n  *** execution finished \n"
2936    fi
2937
2938
2939
2940       # EVENTUELLE OUTPUT-KOMMANDOS ABARBEITEN
2941    (( i = 0 ))
2942    while (( i < ioc ))
2943    do
2944       (( i = i + 1 ))
2945       if (( i == 1 ))
2946       then
2947          printf "\n\n  *** execution of OUTPUT-commands:\n$striche"
2948       fi
2949       printf "\n  >>> ${out_command[$i]}"
2950       eval  ${out_command[$i]}
2951       if (( i == ioc ))
2952       then
2953          printf "\n$striche\n"
2954       fi
2955    done
2956
2957
2958       # EVTL. INHALT DES AKTUELLEN VERZEICHNISSES AUSGEBEN
2959    if [[ $do_trace = true ]]
2960    then
2961       printf "\n\n"
2962       ls -al
2963    fi
2964
2965
2966
2967       # OUTPUT-DATEIEN AN IHRE ZIELORTE KOPIEREN
2968    (( i = 0 ))
2969    while (( i < iout ))
2970    do
2971       (( i = i + 1 ))
2972       if (( i == 1 ))
2973       then
2974          printf "\n\n  *** saving OUTPUT-files:\n$striche"
2975       fi
2976
2977          # PRUEFEN, OB EINZELDATEI ODER DATEI PRO PROZESSOR
2978       files_for_pes=false; filetyp=file
2979       if [[ "${actionout[$i]}" = pe  &&  -n $numprocs ]]
2980       then
2981          files_for_pes=true; filetyp=directory
2982          actionout[$i]=""
2983       elif [[ "${actionout[$i]}" = pe  &&  ! -n $numprocs ]]
2984       then
2985          actionout[$i]=""
2986       elif [[ "${actionout[$i]}" = arpe  &&  -n $numprocs ]]
2987       then
2988          files_for_pes=true; filetyp=directory
2989          actionout[$i]="ar"
2990       elif [[ "${actionout[$i]}" = arpe  &&  ! -n $numprocs ]]
2991       then
2992          actionout[$i]="ar"
2993       elif [[ "${actionout[$i]}" = flpe  &&  -n $numprocs ]]
2994       then
2995          files_for_pes=true; filetyp=directory
2996          actionout[$i]="fl"
2997       elif [[ "${actionout[$i]}" = flpe  &&  ! -n $numprocs ]]
2998       then
2999          actionout[$i]="fl"
3000       elif [[ "${actionout[$i]}" = trpe  &&  -n $numprocs ]]
3001       then
3002          files_for_pes=true; filetyp=directory
3003          actionout[$i]="tr"
3004       elif [[ "${actionout[$i]}" = trpe  &&  ! -n $numprocs ]]
3005       then
3006          actionout[$i]="tr"
3007       fi
3008
3009       if [[ ! -f ${localout[$i]}  &&  $files_for_pes = false ]]
3010       then
3011          printf "\n  +++ temporary OUTPUT-file  ${localout[$i]}  does not exist\n"
3012       elif [[ ! -f ${localout[$i]}/_0000  &&  $files_for_pes = true ]]
3013       then
3014          printf "\n  +++ temporary OUTPUT-file  ${localout[$i]}/....  does not exist\n"
3015       else
3016
3017
3018             # KOPIEREN PER FTP/SCP (IMMER IM BINAERMODUS, -M: FALLS ZIELKATALOG
3019             # NICHT VORHANDEN, WIRD VERSUCHT, IHN ANZULEGEN), ABER NUR BEI
3020             # REMOTE-RECHNUNGEN
3021          if [[ "${actionout[$i]}" = tr ]]
3022          then
3023             if [[ $localhost != $fromhost ]]
3024             then
3025                if [[ $files_for_pes = false ]]
3026                then
3027                   cps=""
3028                   cst=""
3029                else
3030                   cps=-c
3031                   cst="/"
3032                fi
3033                if [[ $localhost = ibmh  ||  $localhost = ibmb  ||  $localhost = nech ]]
3034                then
3035
3036                      # TRANSFER IN EIGENSTAENDIGEM JOB
3037                      # ZUERST KOPIE DER DATEI INS TEMPORAERE DATENVERZEICHNIS
3038                   [[ ! -d $tmp_data_catalog/TRANSFER ]]  &&  mkdir -p  $tmp_data_catalog/TRANSFER
3039                   file_to_transfer=${fname}_${localout[$i]}_to_transfer_$kennung
3040                   if [[ $files_for_pes = false ]]
3041                   then
3042                      ln -f  ${localout[$i]}  $tmp_data_catalog/TRANSFER/$file_to_transfer
3043                   else
3044                      mkdir  $tmp_data_catalog/TRANSFER/$file_to_transfer
3045                      ln  ${localout[$i]}/*  $tmp_data_catalog/TRANSFER/$file_to_transfer
3046                   fi
3047
3048                   echo "set -x"                                    >    transfer_${localout[$i]}
3049                   echo "cd  $tmp_data_catalog/TRANSFER"            >>   transfer_${localout[$i]}
3050                   if [[ $filetransfer_protocol = ftp ]]
3051                   then
3052                      if [[ $files_for_pes = true ]]
3053                      then
3054                         printf "\n  +++ WARNING: no transfer of catalogs via ftpcopy\n"
3055                      fi
3056                      printf "\n  >>> OUTPUT: ${localout[$i]}  by FTP in seperate job to"
3057                      printf "\n              ${pathout[$i]}/${localhost}_${fname}${endout[$i]}"
3058                      printf "\n              or higher cycle\n"
3059                      echo "ftpcopy -b -m $return_addres $file_to_transfer \"${pathout[$i]}\" ${localhost}_${fname}${endout[$i]}  ${extout[$i]}"  >>  transfer_${localout[$i]}
3060                   else
3061                      printf "\n  >>> OUTPUT: ${localout[$i]}$cst  by SCP in seperate job to"
3062                      printf "\n              ${pathout[$i]}/${localhost}_${fname}${endout[$i]}$cst"
3063                      printf "\n              or higher cycle\n"
3064                      echo "batch_scp $cps -b -m -u $return_username $return_addres  $file_to_transfer \"${pathout[$i]}\" ${localhost}_${fname}${endout[$i]}  ${extout[$i]}"  >>  transfer_${localout[$i]}
3065                   fi
3066                   echo "[[ \$? = 0 ]]  &&  rm  $file_to_transfer"  >>  transfer_${localout[$i]}
3067
3068                   if [[ $localhost = nech ]]
3069                   then
3070                      subjob  -d  -c /pf/b/$usern/job_queue  -v  -q pp  -X 0  -m 1000  -t 900  -f $filetransfer_protocol  transfer_${localout[$i]}
3071                   else
3072                      if [[ "$LOGNAME" = b323013 ]]
3073                      then
3074                         subjob  -v  -q c1  -X 0  -m 1000  -t 900  -f $filetransfer_protocol  transfer_${localout[$i]}
3075                      else
3076                         subjob  -d  -v  -q c1  -X 0  -m 1000  -t 900  -f $filetransfer_protocol  transfer_${localout[$i]}
3077                      fi
3078                   fi
3079
3080                else
3081
3082                      # TRANSFER INNERHALB DIESES JOBS
3083                   transfer_failed=false
3084                   if [[ $filetransfer_protocol = ftp ]]
3085                   then
3086                      if [[ $files_for_pes = true ]]
3087                      then
3088                         printf "\n  +++ WARNING: no transfer of catalogs via ftpcopy\n"
3089                      fi
3090                      printf "\n  >>> OUTPUT: ${localout[$i]}  by FTP to"
3091                      printf "\n              ${pathout[$i]}/${localhost}_${fname}${endout[$i]}\n"
3092                      ftpcopy -b -m $return_addres ${localout[$i]} "${pathout[$i]}" ${localhost}_${fname}${endout[$i]}  ${extout[$i]}
3093                      [[ $? != 0 ]]  &&  transfer_failed=true
3094                   else
3095                      printf "\n  >>> OUTPUT: ${localout[$i]}$cst  by SCP to"
3096                      printf "\n              ${pathout[$i]}/${localhost}_${fname}${endout[$i]}$cst\n"
3097                      batch_scp $cps -b -m -u $return_username $return_addres  ${localout[$i]} "${pathout[$i]}" ${localhost}_${fname}${endout[$i]}  ${extout[$i]}
3098                      [[ $? != 0 ]]  &&  transfer_failed=true
3099                   fi
3100
3101                      # BEI FEHLGESCHLAGENEM TRANSFER SICHERUNGSKOPIE AUF
3102                      # LOKALER MASCHINE ANLEGEN
3103                   if [[ $transfer_failed = true ]]
3104                   then
3105                      printf "  +++ transfer failed. Trying to save a copy on the local host under:\n"
3106                      printf "      ${pathout[$i]}/${localhost}_${fname}${endout[$i]}_$kennung\n"
3107
3108                         # ERSTMAL PRUEFEN, OB VERZEICHNIS EXISTIERT. GEGEBENENFALLS
3109                         # ANLEGEN.
3110                      eval  local_catalog=${pathout[$i]}
3111                      if [[ ! -d $local_catalog ]]
3112                      then
3113                         printf "  *** local directory does not exist. Trying to create:\n"
3114                         printf "      $local_catalog \n"
3115                         mkdir -p  $local_catalog
3116                      fi
3117                      eval  cp  ${localout[$i]}  ${pathout[$i]}/${localhost}_${fname}${endout[$i]}_$kennung
3118                      transfer_problems=true
3119                   fi
3120                fi
3121             else
3122
3123                   # WERTZUWEISUNG, SO DASS WEITER UNTEN NUR KOPIERT WIRD
3124                actionout[$i]=""
3125             fi
3126          fi
3127
3128
3129             # APPEND PER FTP/SCP (IMMER IM BINAERMODUS, -M: FALLS ZIELKATALOG
3130             # NICHT VORHANDEN, WIRD VERSUCHT, IHN ANZULEGEN), ABER NUR BEI
3131             # REMOTE-RECHNUNGEN
3132          if [[ "${actionout[$i]}" = tra ]]
3133          then
3134             if [[ $localhost != $fromhost ]]
3135             then
3136                if [[ $localhost = ibmh  ||  $localhost = ibmb  ||  $localhost = nech ]]
3137                then
3138
3139                      # TRANSFER IN EIGENSTAENDIGEM JOB
3140                      # ZUERST KOPIE DER DATEI INS TEMPORAERE DATENVERZEICHNIS
3141                   [[ ! -d $tmp_data_catalog/TRANSFER ]]  &&  mkdir -p  $tmp_data_catalog/TRANSFER
3142                   file_to_transfer=${fname}_${localout[$i]}_to_transfer_$kennung
3143                   ln -f  ${localout[$i]}  $tmp_data_catalog/TRANSFER/$file_to_transfer
3144
3145                   echo "set -x"                                    >    transfer_${localout[$i]}
3146                   echo "cd  $tmp_data_catalog/TRANSFER"            >>   transfer_${localout[$i]}
3147                   if [[ $filetransfer_protocol = ftp ]]
3148                   then
3149                      printf "\n  >>> OUTPUT: ${localout[$i]}  append by FTP in seperate job to"
3150                      printf "\n              ${pathout[$i]}/${localhost}_${fname}${endout[$i]}"
3151                      printf "\n              or higher cycle\n"
3152                      echo "ftpcopy -A -b -m $return_addres $file_to_transfer \"${pathout[$i]}\" ${localhost}_${fname}${endout[$i]}  ${extout[$i]}"  >>  transfer_${localout[$i]}
3153                   else
3154                      printf "\n  >>> OUTPUT: ${localout[$i]}  append by SCP in seperate job to"
3155                      printf "\n              ${pathout[$i]}/${localhost}_${fname}${endout[$i]}"
3156                      printf "\n              or higher cycle\n"
3157                      echo "batch_scp -A -b -m -u $return_username $return_addres  $file_to_transfer \"${pathout[$i]}\" ${localhost}_${fname}${endout[$i]}  ${extout[$i]}"  >>  transfer_${localout[$i]}
3158                   fi
3159                   echo "[[ \$? = 0 ]]  &&  rm  $file_to_transfer"  >>  transfer_${localout[$i]}
3160
3161                   if [[ $localhost = nech ]]
3162                   then
3163                      subjob  -d  -c /pf/b/$usern/job_queue  -v  -q pp  -X 0  -m 1000  -t 900  -f $filetransfer_protocol  transfer_${localout[$i]}
3164                   else
3165                      if [[ $LOGNAME = b323013 ]]
3166                      then
3167                         subjob  -v  -q c1  -X 0  -m 1000  -t 900  -f $filetransfer_protocol  transfer_${localout[$i]}
3168                      else
3169                         subjob  -d  -v  -q c1  -X 0  -m 1000  -t 900  -f $filetransfer_protocol  transfer_${localout[$i]}
3170                      fi
3171                   fi
3172
3173                else
3174
3175                      # TRANSFER INNERHALB DIESES JOBS
3176                   transfer_failed=false
3177                   if [[ $filetransfer_protocol = ftp ]]
3178                   then
3179                      printf "\n  >>> OUTPUT: ${localout[$i]}  append by FTP to"
3180                      printf "\n              ${pathout[$i]}/${localhost}_${fname}${endout[$i]}\n"
3181                      ftpcopy -A -b -m $return_addres ${localout[$i]} "${pathout[$i]}" ${localhost}_${fname}${endout[$i]}  ${extout[$i]}
3182                      [[ $? != 0 ]]  &&  transfer_failed=true
3183                   else
3184                      printf "\n  >>> OUTPUT: ${localout[$i]}  append by SCP to"
3185                      printf "\n              ${pathout[$i]}/${localhost}_${fname}${endout[$i]}\n"
3186                      batch_scp -A -b -m -u $return_username  $return_addres ${localout[$i]} "${pathout[$i]}" ${localhost}_${fname}${endout[$i]}  ${extout[$i]}
3187                      [[ $? != 0 ]]  &&  transfer_failed=true
3188                   fi
3189
3190                      # BEI FEHLGESCHLAGENEM TRANSFER SICHERUNGSKOPIE AUF
3191                      # LOKALER MASCHINE ANLEGEN
3192                   if [[ $transfer_failed = true ]]
3193                   then
3194                      printf "  +++ transfer failed. Trying to save a copy on the local host under:\n"
3195                      printf "      ${pathout[$i]}/${localhost}_${fname}${endout[$i]}_$kennung\n"
3196
3197                         # ERSTMAL PRUEFEN, OB VERZEICHNIS EXISTIERT. GEGEBENENFALLS
3198                         # ANLEGEN
3199                      eval  local_catalog=${pathout[$i]}
3200                      if [[ ! -d $local_catalog ]]
3201                      then
3202                         printf "  *** local directory does not exist. Trying to create:\n"
3203                         printf "      $local_catalog \n"
3204                         mkdir -p  $local_catalog
3205                      fi
3206
3207                      eval  cp  ${localout[$i]}  ${pathout[$i]}/${localhost}_${fname}${endout[$i]}_$kennung
3208                      transfer_problems=true
3209                   fi
3210                fi
3211             else
3212
3213                   # WERTZUWEISUNG, SO DASS WEITER UNTEN NUR APPEND AUF
3214                   # LOKALER MASCHINE DURCHGEFUEHRT WIRD
3215                actionout[$i]=a
3216             fi
3217          fi
3218
3219
3220             # OUTPUT-DATEI FUER EINEN FORTSETZUNGSLAUF. DATEI WIRD PER
3221             # LINK AUF DEN TEMPORAEREN DATENKATALOG GELEGT. OPTION -f WIRD
3222             # VERWENDET, FALLS DORT NOCH EINE DATEI GLEICHEN NAMENS VORHANDEN
3223             # SEIN SOLLTE. ANSCHLIESSEND WIRD SEINE ARCHIVIERUNG ANGESTOSSEN
3224          if [[ "${actionout[$i]}" = fl ]]
3225          then
3226             [[ ! -d $tmp_data_catalog ]]  &&  mkdir -p  $tmp_data_catalog
3227             chmod  g+rx  $tmp_data_catalog
3228             if [[ $files_for_pes = false ]]
3229             then
3230                printf "\n  >>> OUTPUT: ${localout[$i]}  to"
3231                printf "\n              $tmp_data_catalog/${frelout[$i]} (temporary data catalog)\n"
3232                ln -f  ${localout[$i]}  $tmp_data_catalog/${frelout[$i]}
3233             else
3234                printf "\n  >>> OUTPUT: ${localout[$i]}/....  to"
3235                printf "\n              $tmp_data_catalog/${frelout[$i]} (temporary data catalog)\n"
3236                mkdir  $tmp_data_catalog/${frelout[$i]}
3237                ln -f  ${localout[$i]}/*  $tmp_data_catalog/${frelout[$i]}
3238             fi
3239
3240
3241                # ARCHIVIERUNGSJOB WIRD ERZEUGT UND ABGESCHICKT
3242             if [[ $store_on_archive_system = true ]]
3243             then
3244
3245                if [[ $archive_system = asterix ]]
3246                then
3247                   echo "cd  $tmp_data_catalog"                      >> archive_${frelout[$i]}
3248                   if [[ $files_for_pes = false ]]
3249                   then
3250                      echo "stageout  ${frelout[$i]}  > STAGE_OUTPUT${i}_$kennung" >> archive_${frelout[$i]}
3251                   else
3252                      echo "stageout -t  ${frelout[$i]}  > STAGE_OUTPUT${i}_$kennung" >> archive_${frelout[$i]}
3253                   fi
3254                   echo "cat  STAGE_OUTPUT${i}_$kennung"               >> archive_${frelout[$i]}
3255                   echo "if [[ \$(grep -c \"st.msg:150\"  STAGE_OUTPUT${i}_$kennung) != 0 ]]" >> archive_${frelout[$i]}
3256                   echo "then"                                       >> archive_${frelout[$i]}
3257                   echo "   do_stageout=false"                       >> archive_${frelout[$i]}
3258                   echo "else"                                       >> archive_${frelout[$i]}
3259                   echo "   echo \"  +++ $filetyp ${frelout[$i]}  could not be stored on archive-system\" " >> archive_${frelout[$i]}
3260                   echo "   cat  /dev/null  >  ~/job_queue/ARCHIVE_ERROR_$fname" >> archive_${frelout[$i]}
3261                   echo "   cat  STAGE_OUTPUT${i}_$kennung  >  ~/job_queue/archive_${frelout[$i]}_error" >> archive_${frelout[$i]}
3262                   echo "   echo \"  *** $filetyp ${frelout[$i]} will be copied to \$WORK as backup\" " >> archive_${frelout[$i]}
3263                   if [[ $files_for_pes = false ]]
3264                   then
3265                      echo "   cp   ${frelout[$i]}  \$WORK"                    >> archive_${frelout[$i]}
3266                   else
3267                      echo "   cp -r  ${frelout[$i]}  \$WORK/${frelout[$i]}"   >> archive_${frelout[$i]}
3268                   fi
3269                   echo "   echo \"  *** $filetyp ${frelout[$i]} saved\" " >> archive_${frelout[$i]}
3270                   echo "fi"                                         >> archive_${frelout[$i]}
3271                   echo "rm  STAGE_OUTPUT${i}_$kennung"              >> archive_${frelout[$i]}
3272                elif [[ $archive_system = DMF ]]
3273                then
3274                   echo "cd  $tmp_data_catalog"                      >> archive_${frelout[$i]}
3275                   if [[ $files_for_pes = false ]]
3276                   then
3277                      printf "\n  +++ archiving of single files impossible with $archive_system !\n"
3278                      locat=DMF
3279                      exit
3280                   else
3281                         # FUER RECHNER IN JUELICH. DORT KOENNTEN AUCH
3282                         # EINZELNE DATEIEN GESICHERT WERDEN (SPAETER KORR.)
3283                      echo "rm -rf  \$ARCHIVE/${frelout[$i]}"     >> archive_${frelout[$i]}
3284                      echo "cp -r  ${frelout[$i]}  \$ARCHIVE"     >> archive_${frelout[$i]}
3285                   fi
3286                elif [[ $archive_system = tivoli ]]
3287                then
3288                   echo "cd  $tmp_data_catalog"                       >> archive_${frelout[$i]}
3289                   if [[ $files_for_pes = false ]]
3290                   then
3291                         # EVENTUELL NOCH VORHANDENE DATEI IM ARCHIV LOSCHEN
3292                      echo "set -x"                                   >> archive_${frelout[$i]}
3293                      echo "rm  -rf  \$PERM/${frelout[$i]}"           >> archive_${frelout[$i]}
3294                      echo "cp  ${frelout[$i]} \$PERM/${frelout[$i]}" >> archive_${frelout[$i]}
3295                   else
3296
3297                      echo "set -x"                                   >> archive_${frelout[$i]}
3298                      echo "rm  -rf  \$PERM/${frelout[$i]}/*"         >> archive_${frelout[$i]}
3299                      echo "[[ ! -d \$PERM/${frelout[$i]} ]] && mkdir $PERM/${frelout[$i]}" >> archive_${frelout[$i]}
3300                      cd  $tmp_data_catalog
3301                      all_files=`ls -1 ${frelout[$i]}/*`
3302                      cd -  > /dev/null
3303                      (( inode = 0 ))
3304                      (( tp1   = tasks_per_node + 1 ))
3305                      while (( inode < nodes ))
3306                      do
3307#                         echo "*** all_files = \"$all_files\" "
3308                         files=`echo $all_files | cut -d" " -f1-$tasks_per_node`
3309                         all_files=`echo $all_files | cut -d" " -f$tp1-`
3310#                         echo "*** tasks_per_node = \"$tasks_per_node\" "
3311#                         echo "*** files = \"$files\" "
3312#                         echo "*** all_files = \"$all_files\" "
3313                         echo "tar  cvf \$PERM/${frelout[$i]}/${frelout[$i]}.node_$inode.tar $files"   >> archive_${frelout[$i]}
3314                         echo "dsmc incremental  \$PERM/${frelout[$i]}/${frelout[$i]}.node_$inode.tar" >> archive_${frelout[$i]}
3315                         echo "dsmmigrate \$PERM/${frelout[$i]}/${frelout[$i]}.node_$inode.tar"        >> archive_${frelout[$i]}
3316                         (( inode = inode + 1 ))
3317                      done
3318#                      echo "rm  -rf  \$PERM/${frelout[$i]}.tar"       >> archive_${frelout[$i]}
3319#                      echo "tar  cvf \$PERM/${frelout[$i]}.tar ${frelout[$i]}" >> archive_${frelout[$i]}
3320                   fi
3321                elif [[ $archive_system = ut ]]
3322                then
3323                   echo "cd  $tmp_data_catalog"                       >> archive_${frelout[$i]}
3324                   if [[ $files_for_pes = false ]]
3325                   then
3326                         # EVENTUELL NOCH VORHANDENE DATEI IM ARCHIV LOSCHEN
3327                      echo "set -x"                                 >> archive_${frelout[$i]}
3328                      echo "rm  -rf  \$UT/${frelout[$i]}"           >> archive_${frelout[$i]}
3329                      echo "cp  ${frelout[$i]} \$UT/${frelout[$i]}" >> archive_${frelout[$i]}
3330                   else
3331
3332                      echo "set -x"                                 >> archive_${frelout[$i]}
3333                      echo "rm  -rf  \$UT/${frelout[$i]}/*"         >> archive_${frelout[$i]}
3334                      echo "[[ ! -d \$UT/${frelout[$i]} ]] && mkdir $UT/${frelout[$i]}" >> archive_${frelout[$i]}
3335                      cd  $tmp_data_catalog
3336                      all_files=`ls -1 ${frelout[$i]}/*`
3337                      cd -  > /dev/null
3338                      (( inode = 0 ))
3339                      (( tp1   = tasks_per_node + 1 ))
3340                      while (( inode < nodes ))
3341                      do
3342                         files=`echo $all_files | cut -d" " -f1-$tasks_per_node`
3343                         all_files=`echo $all_files | cut -d" " -f$tp1-`
3344                         echo "tar  cvf \$UT/${frelout[$i]}/${frelout[$i]}.node_$inode.tar $files"   >> archive_${frelout[$i]}
3345                         (( inode = inode + 1 ))
3346                      done
3347                   fi
3348                elif [[ $archive_system = none ]]
3349                then
3350                   printf "              +++ archiving on $localhost not available!\n"
3351                fi
3352
3353                if [[ $archive_system != none ]]
3354                then
3355                   if [[ $localhost = ibmh  ||  $localhost = ibmb ]]
3356                   then
3357                      subjob  -d  -v  -q cdata  -X 0  -m 1000  -t 7200  -f $filetransfer_protocol  archive_${frelout[$i]}
3358                   elif [[ $localhost = nech ]]
3359                   then
3360                      subjob  -d  -c /pf/b/$usern/job_queue  -v  -q pp  -X 0  -m 1000  -t 7200  -f $filetransfer_protocol  archive_${frelout[$i]}
3361                   fi
3362                   printf "              Archiving of $tmp_data_catalog/${frelout[$i]} initiated (batch job submitted)\n"
3363                fi
3364             else
3365                printf "              +++ caution: option -A is switched on. No archiving on $archive_system!\n"
3366             fi
3367
3368
3369                # LEERDATEI IM BENUTZERVERZEICHNIS ANLEGEN, DAMIT BEKANNT IST,
3370                # WIE DIE HOECHSTE ZYKLUSNUMMER AUF DEM ARCHIV-SYSTEM LAUTET
3371             if [[ $files_for_pes = false ]]
3372             then
3373                cat  /dev/null  >  ${pathout[$i]}
3374             else
3375                mkdir -p  ${pathout[$i]}
3376             fi
3377
3378          fi
3379
3380
3381             # KOPIEREN AUF LOKALER MASCHINE ZUM ARCHIV-SYSTEM
3382             # AUSSERDEM MUSS LEERDATEI ANGELEGT WERDEN, DAMIT BEKANNT IST,
3383             # WIE DIE HOECHSTE ZYKLUSNUMMER AUF DEM ARCHIV-SYSTEM LAUTET
3384             # FALLS IRGENDEINE (VON MEHREREN) ARCHIVIERUNGEN SCHIEF GEHT,
3385             # WIRD FLAG GESETZT UND BLEIBT AUCH BEI WEITEREN ORDNUNGS-
3386             # GEMAESSEN ARCHIVIERUNGEN GESETZT
3387          if [[ "${actionout[$i]}" = ar ]]
3388          then
3389             if [[ $files_for_pes = false ]]
3390             then
3391                printf "\n  >>> OUTPUT: ${localout[$i]}  to"
3392                printf "\n              ${pathout[$i]}"
3393                printf "\n              File will be copied to archive-system ($archive_system) !\n"
3394             else
3395                printf "\n  >>> OUTPUT: ${localout[$i]}/_....  to"
3396                printf "\n              ${pathout[$i]}"
3397                printf "\n              Directory will be copied to archive-system ($archive_system) !\n"
3398             fi
3399             mv  ${localout[$i]}  ${frelout[$i]}
3400
3401             file_saved=false
3402
3403             if [[ $archive_system = asterix ]]
3404             then
3405                do_stageout=true
3406                (( stageout_anz = 0 ))
3407                while [[ $do_stageout = true ]]
3408                do
3409                   if [[ $files_for_pes = false ]]
3410                   then
3411                      stageout  ${frelout[$i]}  > STAGE_OUTPUT
3412                   else
3413                      stageout  -t  ${frelout[$i]}  > STAGE_OUTPUT
3414                   fi
3415                   cat  STAGE_OUTPUT
3416                   if [[ $(grep -c "st.msg:150"  STAGE_OUTPUT) != 0 ]]
3417                   then
3418                      file_saved=true
3419                      do_stageout=false
3420                   else
3421                      if [[ $files_for_pes = false ]]
3422                      then
3423                         printf "\n  +++ file ${frelout[$i]}  could not be saved on archive-system"
3424                      else
3425                         printf "\n  +++ directory ${frelout[$i]} could not be saved on archive-system"
3426                      fi
3427                      (( stageout_anz = stageout_anz + 1 ))
3428                      if (( stageout_anz == 10 ))
3429                      then
3430                         printf "\n  +++ stoped after 10 unsuccessful tries!"
3431                         archive_save=false
3432                         do_stageout=false
3433                      else
3434                         printf "\n  *** new try to store on archive after 15 min:"
3435                         sleep 900
3436                      fi
3437                   fi
3438                done
3439             elif [[ $archive_system = DMF ]]
3440             then
3441                if [[ $files_for_pes = false ]]
3442                then
3443                   printf "\n  +++ archiving of single files impossible on $archive_system!\n"
3444                   locat=DMF
3445                   exit
3446                else
3447                   rm -rf  $ARCHIVE/${frelout[$i]}
3448                   cp -r  ${frelout[$i]}  $ARCHIVE
3449                fi
3450                file_saved=true
3451             elif [[ $archive_system = tivoli ]]
3452             then
3453                   # ARCHIVIERUNG NUR PER BATCH-JOB MOEGLICH
3454                   # DATEI MUSS ZWISCHENZEITLICH INS TEMPORAERE DATENVERZEICHNIS
3455                   # GELEGT WERDEN
3456                [[ ! -d $tmp_data_catalog ]]  &&  mkdir -p  $tmp_data_catalog
3457                chmod  g+rx  $tmp_data_catalog
3458                if [[ $files_for_pes = false ]]
3459                then
3460                   ln -f  ${frelout[$i]}  $tmp_data_catalog/${frelout[$i]}
3461                else
3462                   mkdir  $tmp_data_catalog/${frelout[$i]}
3463                   ln -f  ${frelout[$i]}/*  $tmp_data_catalog/${frelout[$i]}
3464                fi
3465
3466                   # BATCH JOB GENERIEREN UND ABSCHICKEN; DATEI MUSS WIEDER
3467                   # AUS TEMPORAEREM DATENVERZEICHNIS ENTFERNT WERDEN
3468                echo "cd  $tmp_data_catalog"                       >  archive_${frelout[$i]}
3469                if [[ $files_for_pes = false ]]
3470                then
3471                      # EVENTUELL NOCH VORHANDENE DATEI IM ARCHIV LOSCHEN
3472                   echo "rm  -rf  \$PERM/${frelout[$i]}"           >> archive_${frelout[$i]}
3473                   echo "cp  ${frelout[$i]} \$PERM/${frelout[$i]}" >> archive_${frelout[$i]}
3474                   echo "rm  -rf  ${frelout[$i]}"                  >> archive_${frelout[$i]}
3475                else
3476                   echo "rm  -rf  \$PERM/${frelout[$i]}.tar"       >> archive_${frelout[$i]}
3477                   echo "tar  cvf \$PERM/${frelout[$i]}.tar ${frelout[$i]}" >> archive_${frelout[$i]}
3478                   echo "rm  -rf  ${frelout[$i]}"                  >> archive_${frelout[$i]}
3479                fi
3480
3481                subjob  -v  -d  -q cdata  -X 0  -m 1000  -t 7200  -f $filetransfer_protocol  archive_${frelout[$i]}
3482                printf "              Archiving of $tmp_data_catalog/${frelout[$i]} initiated (batch job submitted)\n"
3483                file_saved=true
3484
3485             elif [[ $archive_system = ut ]]
3486             then
3487                   # ARCHIVIERUNG NUR PER BATCH-JOB MOEGLICH
3488                   # DATEI MUSS ZWISCHENZEITLICH INS TEMPORAERE DATENVERZEICHNIS
3489                   # GELEGT WERDEN
3490                [[ ! -d $tmp_data_catalog ]]  &&  mkdir -p  $tmp_data_catalog
3491                chmod  g+rx  $tmp_data_catalog
3492                if [[ $files_for_pes = false ]]
3493                then
3494                   ln -f  ${frelout[$i]}  $tmp_data_catalog/${frelout[$i]}
3495                else
3496                   mkdir  $tmp_data_catalog/${frelout[$i]}
3497                   ln -f  ${frelout[$i]}/*  $tmp_data_catalog/${frelout[$i]}
3498                fi
3499
3500                   # BATCH JOB GENERIEREN UND ABSCHICKEN; DATEI MUSS WIEDER
3501                   # AUS TEMPORAEREM DATENVERZEICHNIS ENTFERNT WERDEN
3502                echo "cd  $tmp_data_catalog"                       >  archive_${frelout[$i]}
3503                if [[ $files_for_pes = false ]]
3504                then
3505                      # EVENTUELL NOCH VORHANDENE DATEI IM ARCHIV LOSCHEN
3506                   echo "rm  -rf  \$UT/${frelout[$i]}"           >> archive_${frelout[$i]}
3507                   echo "cp  ${frelout[$i]} \$UT/${frelout[$i]}" >> archive_${frelout[$i]}
3508                   echo "rm  -rf  ${frelout[$i]}"                >> archive_${frelout[$i]}
3509                else
3510                   echo "rm  -rf  \$UT/${frelout[$i]}.tar"       >> archive_${frelout[$i]}
3511                   echo "tar  cvf \$UT/${frelout[$i]}.tar ${frelout[$i]}" >> archive_${frelout[$i]}
3512                   echo "rm  -rf  ${frelout[$i]}"                >> archive_${frelout[$i]}
3513                fi
3514
3515                subjob  -v  -c /pf/b/$usern/job_queue  -d  -q pp  -X 0  -m 1000  -t 7200  -f $filetransfer_protocol  archive_${frelout[$i]}
3516                printf "              Archiving of $tmp_data_catalog/${frelout[$i]} initiated (batch job submitted)\n"
3517                file_saved=true
3518
3519             else
3520                printf "\n  +++ archive_system=\"$archive_system\"  archiving impossible!"
3521                archive_save=false
3522             fi
3523             if [[ $file_saved = true ]]
3524             then
3525                if [[ $files_for_pes = false ]]
3526                then
3527                   cat  /dev/null  >  ${pathout[$i]}
3528                else
3529                   mkdir -p  ${pathout[$i]}
3530                fi
3531             fi
3532          fi
3533
3534             # APPEND AUF LOKALER MASCHINE
3535          if [[ "${actionout[$i]}" = "a" ]]
3536          then
3537             printf "\n  >>> OUTPUT: ${localout[$i]}  append to  ${pathout[$i]}\n"
3538             cat  ${localout[$i]}  >>  ${pathout[$i]}
3539          fi
3540
3541             # KOPIEREN AUF LOKALER MASCHINE
3542             # ES MUSS KOPIERT WERDEN, DA MOVE NICHT UEBER FILESYSTEM HINAUS MOEGLICH
3543          if [[ "${actionout[$i]}" = ""  &&  $files_for_pes = false ]]
3544          then
3545
3546                # KOPIEREN AUF EINPROZESSORMASCHINE
3547             if [[ "${extout[$i]}" != " "  &&  "${extout[$i]}" != "" ]]
3548             then
3549                printf "\n  >>> OUTPUT: ${localout[$i]}  to  ${pathout[$i]}.${extout[$i]}\n"
3550                cp  ${localout[$i]}  ${pathout[$i]}.${extout[$i]}
3551             else
3552                printf "\n  >>> OUTPUT: ${localout[$i]}  to  ${pathout[$i]}\n"
3553                cp  ${localout[$i]}  ${pathout[$i]}
3554             fi
3555
3556          elif [[ "${actionout[$i]}" = ""  &&  $files_for_pes = true ]]
3557          then
3558
3559                # DIE DEN PROZESSOREN EINES PARALLELRECHNERS ZUGEHOERIGEN
3560                # DATEIEN WERDEN ERST IN EINEM KATALOG GESAMMELT UND DIESER
3561                # WIRD DANN KOPIERT
3562                # PER MOVE UMBENANNT WERDEN
3563             printf "\n  >>> OUTPUT: ${localout[$i]}/_....  to  ${pathout[$i]}\n"
3564             cp -r  ${localout[$i]}  ${pathout[$i]}
3565
3566          fi
3567       fi
3568    done
3569    if (( i != 0 ))
3570    then
3571       if [[ $transfer_problems = true ]]
3572       then
3573          printf "\n$striche\n  *** OUTPUT-files saved"
3574          printf "\n  +++ WARNING: some data transfers failed! \n"
3575       else
3576          printf "\n$striche\n  *** all OUTPUT-files saved \n"
3577       fi
3578    fi
3579
3580
3581       # EVENTUELL FOLGEJOB STARTEN
3582       # DATEI CONTINUE_RUN MUSS VOM BENUTZERPROGRAMM AUS ERZEUGT WERDEN
3583    if [[ -f CONTINUE_RUN ]]
3584    then
3585
3586       if [[ $archive_save = true ]]
3587       then
3588
3589             # ZUERST IN MRUN-AUFRUF OPTIONEN FUER FORTSETZUNGSLAUF, FUER
3590             # STILLES ABARBEITEN (OHNE INTERAKTIVE RUECKFAGEN) UND FUER
3591             # BATCH-BETRIEB (NUR WICHTIG, FALLS BATCH AUF LOKALER MASCHINE
3592             # DURCHGEFUEHRT WERDEN SOLL) EINFUEGEN, FALLS NICHT BEREITS VOR-
3593             # HANDEN
3594          [[ $(echo $mc | grep -c "\-C") = 0 ]]  &&  mc="$mc -C"
3595          [[ $(echo $mc | grep -c "\-v") = 0 ]]  &&  mc="$mc -v"
3596          [[ $(echo $mc | grep -c "\-b") = 0 ]]  &&  mc="$mc -b"
3597          if [[ $(echo $mc | grep -c "#") != 0 ]]
3598          then
3599             mc=`echo $mc | sed 's/#/f/g'`
3600          fi
3601
3602
3603             # JOB STARTEN
3604          printf "\n\n  *** initiating restart-run on \"$return_addres\" using command:\n"
3605          echo "      $mc"
3606          printf "\n$striche\n"
3607          if [[ $localhost != $fromhost ]]
3608          then
3609
3610             if [[ $localhost = nech  ||  $localhost = ibmb  ||  $localhost = ibmh  ||  $localhost = ibms  ||  $localhost = lctit ]]
3611             then
3612                echo "*** ssh will be used to initiate restart-runs!"
3613                echo "    return_addres=\"$return_addres\" "
3614                echo "    return_username=\"$return_username\" "
3615                if [[ $return_addres = 172.20.25.41 ]]
3616                then
3617                      # WORKAROUND AUF SCIROCCO AM TIT
3618                   print  "PATH=\$PATH:$LOCAL_MRUN_PATH;cd $LOCAL_PWD; $mc "  |  ssh $return_addres -l $return_username 
3619                else
3620                   ssh $return_addres -l $return_username "PATH=\$PATH:$LOCAL_MRUN_PATH;cd $LOCAL_PWD; $mc "
3621                fi
3622             else
3623                printf "\n  +++ no restart mechanism available for host \"$localhost\" "
3624                locat=restart; exit
3625             fi
3626
3627                # WARTEN, DAMIT SICH RESTART JOB IN QUEUE EINREIHEN KANN, BEVOR
3628                # DER AKTUELLE JOB ENDET
3629             sleep 30
3630
3631          else
3632
3633                # BEI RECHNUNGEN AUF LOKALER MASCHINE KANN MRUN DIREKT AUFGE-
3634                # RUFEN WERDEN
3635             cd $LOCAL_PWD
3636             eval  $mc                # ' MUESSEN AUSGEWERTET WERDEN
3637             cd -  > /dev/null
3638          fi
3639          printf "\n$striche\n  *** restart-run initiated \n"
3640
3641
3642             # EVENTUELL INPUT-DATEIEN, DIE VON TEMPORAEREM DATENVERZEICHNIS
3643             # GEHOLT WORDEN SIND, LOESCHEN
3644          (( i = 0 ))
3645          while (( i < iin ))
3646          do
3647             (( i = i + 1 ))
3648             if [[ "${got_tmp[$i]}" = true   &&  $keep_data_from_previous_run = false ]]
3649             then
3650                rm -r  $tmp_data_catalog/${frelin[$i]}
3651             fi
3652          done
3653
3654       else
3655
3656          printf "\n  +++ no restart-run possible, since errors occured"
3657          printf "\n      during the archive process"
3658       fi
3659
3660    fi
3661
3662
3663   
3664       # EVTL. EMAIL-BENACHRICHTIGUNG UEBER ABGESCHLOSSENEN LAUF
3665    if [[ "$email_notification" != "" ]]
3666    then
3667
3668       if [[ $localhost != $fromhost ]]
3669       then
3670          if [[ -f CONTINUE_RUN ]]
3671          then
3672             echo "PALM restart run necessary"        >   email_text
3673             echo "description header of actual run:" >>  email_text
3674             cat  CONTINUE_RUN                        >>  email_text
3675             echo "mrun-command to restart:"          >>  email_text
3676             echo "$mc"                               >>  email_text
3677          else
3678             echo "PALM run with base filename \"$fname\" on host \"$localhost\" finished"  >  email_text
3679          fi
3680          mail  $email_notification  <  email_text
3681          printf "\n  *** email notification sent to \"$email_notification\" "
3682       fi
3683    fi
3684
3685
3686
3687       # ALLE ARBEITEN BEENDET. TEMPORAERER KATALOG KANN GELOESCHT WERDEN
3688    cd  $HOME
3689    [[ $delete_temporary_catalog = true ]]  &&  rm -rf $TEMPDIR
3690
3691 else
3692
3693
3694       # FALLS AUF REMOTE-MASCHINE GERECHNET WERDEN SOLL, WERDEN JETZT ENTSPRE-
3695       # CHENDE AKTIONEN DURCHGEFUEHRT
3696
3697       # MRUN-BEFEHL FUER REMOTE-MASCHINE ZUSAMMENSTELLEN
3698    mrun_com="$mrun_script_name -a $afname -c $config_file -d $fname -f $filetransfer_protocol -h $host -H $fromhost -m $memory -t $cpumax -q $queue -R $return_addres -U $return_username -u $remote_username"
3699    [[ "$cpp_opts" != "" ]]       &&  mrun_com=${mrun_com}" -D \"$cpp_opts\""
3700    [[ $do_compile = true ]]      &&  mrun_com=${mrun_com}" -s \"$source_list\""
3701    [[ "$input_list" != "" ]]     &&  mrun_com=${mrun_com}" -i \"$input_list\""
3702    [[ $ignore_archive_error = true ]]  &&  mrun_com=${mrun_com}" -I"
3703    [[ $keep_data_from_previous_run = true ]]  &&  mrun_com=${mrun_com}" -k"
3704    [[ "$additional_conditions" != "" ]]  &&  mrun_com=${mrun_com}" -K \"$additional_conditions\""
3705#    [[ "$makefile" != "$source_path/Makefile" ]]  &&  mrun_com=${mrun_com}" -M \"$makefile\""
3706    [[ "$output_list" != "" ]]    &&  mrun_com=${mrun_com}" -o \"$output_list\""
3707    [[ "$read_from_config" = false ]]  &&  mrun_com=${mrun_com}" -S"
3708    [[ $do_trace = true ]]        &&  mrun_com=${mrun_com}" -x"
3709    [[ "$numprocs" != "" ]]       &&  mrun_com=${mrun_com}" -X $numprocs"
3710    if [[ $use_openmp = true ]]
3711    then
3712       mrun_com=${mrun_com}" -O"
3713       [[ "$tasks_per_node" != "" ]] &&  mrun_com=${mrun_com}" -T $threads_per_task"
3714    else
3715       [[ "$tasks_per_node" != "" ]] &&  mrun_com=${mrun_com}" -T $tasks_per_node"
3716    fi
3717    [[ $store_on_archive_system = false ]]  &&  mrun_com=${mrun_com}" -A"
3718    [[ $package_list != "" ]]     &&  mrun_com=${mrun_com}" -p \"$package_list\""
3719    [[ $return_password != "" ]]  &&  mrun_com=${mrun_com}" -P $return_password"
3720    [[ $delete_temporary_catalog = false ]]  &&  mrun_com=${mrun_com}" -B"
3721    [[ $node_usage != default ]]  &&  mrun_com=${mrun_com}" -n $node_usage"
3722    if [[ $do_remote = true ]]
3723    then
3724       printf "\n>>>> MRUN-command on execution host:\n>>>> $mrun_com \n"
3725    fi
3726
3727
3728       # ZUSAMMENSTELLUNG DES JOBSCRIPTS AUF DATEI jobfile
3729    jobfile=jobfile.$RANDOM
3730
3731
3732       # TEMPORAERES VERZEICHNIS GENERIEREN UND NACH DORT WECHSELN
3733    echo  "mkdir  $TEMPDIR"      >>  $jobfile
3734    echo  "cd  $TEMPDIR"         >>  $jobfile
3735
3736
3737       # EVENTUELL FEHLERVERFOLGUNG AKTIVIEREN
3738    if [[ $do_trace = true ]]
3739    then
3740       echo  "set -x"                                    >>  $jobfile
3741    else
3742       echo  "set +vx"                                   >>  $jobfile
3743    fi
3744
3745
3746       # ABSPEICHERN DER QUELLTEXTE (NUR FALLS UEBERSETZT WERDEN SOLL)
3747       # SOWIE GEGEBENENFALLS DES MAKEFILES
3748    if [[ $do_compile = true ]]
3749    then
3750
3751       source_catalog=SOURCES_FOR_RUN_$fname
3752
3753           # UNTERVERZEICHNIS FUER QUELLTEXTE UND MAKEFILE ANLEGEN
3754           # MRUN WIRD DIESES VRZEICHNIS UEBER ENVIRONMENT VARIABLE
3755           # MITGETEILT (UEBERSTEUERT ANGABE IN KONFIGURATIONSDATEI)
3756       echo  "mkdir  SOURCES_FOR_RUN_$fname"                >>  $jobfile
3757       echo  "export SOURCES_COMPLETE=true"                 >>  $jobfile
3758       echo  "cd     SOURCES_FOR_RUN_$fname"                >>  $jobfile
3759
3760       for  filename  in  $source_list
3761       do
3762             # ABDECKZEICHEN VERHINDERN, DASS ERSETZUNGEN ERFOLGEN
3763          echo  "cat > $filename << \"%END%\""              >>  $jobfile
3764          cat   $source_catalog/$filename                   >>  $jobfile
3765          echo  " "                                         >>  $jobfile
3766          echo  "%END%"                                     >>  $jobfile
3767          echo  " "                                         >>  $jobfile
3768       done
3769
3770       if [[ "$use_makefile" = true ]]
3771       then
3772             # ABDECKZEICHEN VERHINDERN, DASS ERSETZUNGEN ERFOLGEN
3773          echo  "cat > Makefile << \"%END%\""               >>  $jobfile
3774          cat   $source_catalog/Makefile                    >>  $jobfile
3775          echo  " "                                         >>  $jobfile
3776          echo  "%END%"                                     >>  $jobfile
3777          echo  " "                                         >>  $jobfile
3778       fi
3779
3780       echo  "cd -  > /dev/null"                         >>  $jobfile
3781
3782    fi
3783
3784
3785       # ABSPEICHERN DER KONFIGURATIONSDATEI
3786       # ABDECKZEICHEN VERHINDERN, DASS ERSETZUNGEN ERFOLGEN
3787    echo  "cat > $config_file << \"%END%\""      >>  $jobfile
3788    cat   $config_file                           >>  $jobfile
3789    echo  "%END%"                                >>  $jobfile
3790    echo  " "                                    >>  $jobfile
3791
3792
3793       # ABSPEICHERN DER AKTUELLEN MRUN-VERSION
3794       # ABDECKZEICHEN VERHINDERN, DASS ERSETZUNGEN ERFOLGEN
3795    echo  "cat > $mrun_script_name <<\"%END%\""  >>  $jobfile
3796    cat   ${mrun_path}/$mrun_script_name         >>  $jobfile
3797    echo  "%END%"                                >>  $jobfile
3798    if [[ $host = lctit ]]
3799    then
3800       echo "sed 's/bin\/ksh/home2\/usr5\/mkanda\/pub\/ksh/' < $mrun_script_name > mrun_new" >>  $jobfile
3801       echo "mv  mrun_new  $mrun_script_name"    >>  $jobfile
3802    fi
3803    echo  "chmod u+x $mrun_script_name"          >>  $jobfile
3804    echo  "execute_mrun=true"                    >>  $jobfile
3805    echo  " "                                    >>  $jobfile
3806
3807       # EVTL. BENOETIGTE INPUT-DATEIEN PER FTP HOLEN ODER DEM JOB DIREKT
3808       # MITGEBEN UND AUF DEM REMOTE-RECHNER IM BENUTZERVERZEICHNIS ABLEGEN
3809       # FALLS DIESES NICHT EXISTIERT, WIRD VERSUCHT, DAS JEWEILS LETZTE
3810       # UNTERVERZEICHNIS DES PFADNAMENS ANZULEGEN
3811    if [[ $do_remote = true ]]
3812    then
3813       (( i = 0 ))
3814       while (( i < iin ))
3815       do
3816          (( i = i + 1 ))
3817          echo  "[[ ! -d ${pathin[$i]} ]]  &&  mkdir -p  ${pathin[$i]}"  >>  $jobfile
3818          if [[ "${transin[$i]}" = job ]]
3819          then
3820             echo  "cat > ${remotepathin[$i]} <<\"%END%\""    >>  $jobfile
3821             eval cat   ${pathin[$i]}/${frelin[$i]}           >>  $jobfile
3822             echo  " "                                        >>  $jobfile
3823             echo  "%END%"                                    >>  $jobfile
3824          else
3825             if [[ $filetransfer_protocol = ftp ]]
3826             then
3827                echo  "ftpcopy -b -o -g -s $return_addres ${remotepathin[$i]} \"${pathin[$i]}\" ${frelin[$i]}" >>  $jobfile
3828             else
3829                echo  "batch_scp -b -o -g -s -u $return_username $return_addres ${remotepathin[$i]} \"${pathin[$i]}\" ${frelin[$i]}" >>  $jobfile
3830             fi
3831          fi
3832
3833             # UEBERPRUEFEN, OB DATEI ANGELEGT WERDEN KONNTE
3834          echo  "if [[ \$? = 1 ]]"                    >>  $jobfile
3835          echo  "then"                                >>  $jobfile
3836          echo  "   echo \" \" "                      >>  $jobfile
3837          echo  "   echo \"+++ file ${remotepathin[$i]} could not be created\" "   >>  $jobfile
3838          echo  "   echo \"    please check, if directory exists on $host!\" "  >>  $jobfile
3839          echo  "   echo \"+++ MRUN will not be continued\" "  >>  $jobfile
3840          echo  "   execute_mrun=false"               >>  $jobfile
3841          echo  "fi"                                  >>  $jobfile
3842       done
3843    fi
3844
3845       # ARBEITSKATALOG AUF DER LOKALEN MASCHINE FUER EVENTUELLE
3846       # FORTSETZUNGSLAUEFE PER ENV-VARIABLE UEBERGEBEN
3847    echo  "LOCAL_PWD=$working_directory"                >>  $jobfile
3848    echo  "export LOCAL_PWD"                            >>  $jobfile
3849
3850       # EBENSO LOKALEN MRUN-KATALOG UEBERGEBEN
3851    echo  "LOCAL_MRUN_PATH=$mrun_path"                  >>  $jobfile
3852    echo  "export LOCAL_MRUN_PATH"                      >>  $jobfile
3853
3854#    echo  "for_subjob_to_do=\"rm -rf  $TEMPDIR\" "      >>  $jobfile
3855
3856       # MRUN AUF ZIELRECHNER AUFRUFEN
3857    echo  "set -x"                                      >>  $jobfile
3858    echo  "[[ \$execute_mrun = true ]]  &&  ./$mrun_com"  >>  $jobfile
3859
3860    echo  'ls -al; echo `pwd`'                          >>  $jobfile
3861    echo  "cd \$HOME"                                   >>  $jobfile
3862    echo  "rm -rf  $TEMPDIR"                            >>  $jobfile
3863
3864
3865
3866
3867       # JOB PER SUBJOB STARTEN
3868    if [[ $silent = false ]]
3869    then
3870       printf "\n     "
3871    else
3872       printf "\n\n"
3873    fi
3874
3875    subjob  $job_on_file  -h $host  -u $remote_username  -q $queue  -m $memory  -N $node_usage -t $cpumax  $XOPT  $TOPT  $OOPT  -n $fname  -f $filetransfer_protocol  -v   $jobfile
3876    rm -rf  $jobfile
3877
3878
3879 fi  # ENDE REMOTE-TEIL
3880
3881
3882
3883     # ENDE DER PROZEDUR
Note: See TracBrowser for help on using the repository browser.