source: palm/trunk/SCRIPTS/mrun @ 1046

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

put scripts and utilities under GPL

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