source: palm/tags/release-3.5/SCRIPTS/mrun @ 3890

Last change on this file since 3890 was 201, checked in by raasch, 16 years ago

property Rev set for mrun, build and subjob

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