source: palm/trunk/SCRIPTS/mrun @ 669

Last change on this file since 669 was 669, checked in by gryschka, 13 years ago

last commit documented

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