source: palm/trunk/SCRIPTS/mrun @ 847

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

mrun -T option not obligatory for lcflow

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