source: palm/trunk/SCRIPTS/mrun @ 818

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

bugfix: namelist file check now possible for topography and re-enabled. mrungui update (-z option)

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