source: palm/trunk/SCRIPTS/mrun @ 837

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

info for mrun-option -s updated

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