source: palm/trunk/SCRIPTS/mrun @ 850

Last change on this file since 850 was 848, checked in by raasch, 12 years ago

mrun tasks_per_node divisor check not for lcflow

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