source: palm/trunk/SCRIPTS/mrun @ 678

Last change on this file since 678 was 678, checked in by raasch, 13 years ago

New:
---

further adjustments on Tsubame and concerning openMP usage
(mrun, mbuild, subjob)

Changed:


Errors:


Bugfix in calculation of divergence of vertical flux of resolved scale
energy, pressure fluctuations, and flux of pressure fluctuation itself
(flow statistics)

Bugfix: module pegrid was missing. (user_statistics)

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