source: palm/trunk/SCRIPTS/mrun @ 812

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

new utility check_namelist_files implemented

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