source: palm/trunk/SCRIPTS/mrun @ 858

Last change on this file since 858 was 858, checked in by suehring, 12 years ago

default compiler on ibmh changed

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