source: palm/trunk/SCRIPTS/mrun @ 556

Last change on this file since 556 was 555, checked in by raasch, 14 years ago

New:
---

Changed:


Documentation for surface_heatflux in case of prandtl_layer = .F. improved.

bugfix for wrong netcdf/3.6.3 module on lcsgi (mbuild, mrun)

Errors:


Bugfix in if statement (disturb_heatflux)

Bugfix: in 2201 statement: closing " was missing (interpret_config)

Bugfix: default setting of nzb_local for flat topography (init_grid)

Bugfix: wrong dimension used for ts_value_l (user_statistics)

disturb_heatflux, init_grid, interpret_config, user_statistics

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