source: palm/trunk/SCRIPTS/mrun @ 1045

Last change on this file since 1045 was 1045, checked in by maronga, 11 years ago

parameter file check adapted for batch jobs on local machine

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