source: palm/trunk/SCRIPTS/mrun @ 1058

Last change on this file since 1058 was 1058, checked in by raasch, 11 years ago

Intel inspector (inspxe) is given the number of PEs instead of the number of nodes

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