source: palm/trunk/SCRIPTS/mrun @ 823

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

bugfix for namelist file check (mrun)

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