source: palm/trunk/SCRIPTS/mrun @ 1040

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

script adjustments for lckiaps

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