source: palm/trunk/SCRIPTS/mrun @ 310

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