source: palm/trunk/SCRIPTS/mrun @ 354

Last change on this file since 354 was 352, checked in by raasch, 15 years ago

+option -e in subjob

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