source: palm/trunk/SCRIPTS/mrun @ 674

Last change on this file since 674 was 670, checked in by gryschka, 13 years ago

last commit documented

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