source: palm/trunk/SCRIPTS/mrun_new @ 19

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

dvrp library path adjusted for nech

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