source: palm/trunk/SCRIPTS/mrun @ 829

Last change on this file since 829 was 824, checked in by raasch, 12 years ago

preliminary checkin of new curvature/solution effects on droplet growth

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