source: palm/trunk/SCRIPTS/mrun @ 336

Last change on this file since 336 was 331, checked in by raasch, 15 years ago

mrun adjustment for coupled runs on ibmy

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