source: palm/trunk/SCRIPTS/mrun @ 274

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