source: palm/trunk/SCRIPTS/mrun @ 915

Last change on this file since 915 was 892, checked in by maronga, 12 years ago

bugfixes in parameter file check, adapted for lcxe6 (was lcxt4), new mrun.config parameter %login_init_cmd introduced

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